Author Archives: Patrick

Unity from Zero to Proficiency (Proficient) is out today for $3.99 (promotional offer)

If you are struggling with RPG creation in Unity, this book should help. It includes 432 pages that painlessly take you through all the necessary steps to create your 3D RPG in Unity including a dialogue system, an inventory, a shop system, real-time combat, randomly-generated procedural levels, a quest system, along with intelligent NPCs. Along the way, you will also learn how to create systems that you can reuse in other games and that will speed up the development process.
Unity from Zero to Proficiency (Proficient) is available today on Amazon for $3.99 (promotional offer until Friday).
Hope this helps
https://www.amazon.com/dp/B07Z45N6J1

Books and Video Courses on Learning to Code through Video Game Creation

Hi there,

In the past years, I have been liaising with teachers  who wanted to introduce programming to their students through the creation of games; several teachers have been using some of my resources (books and video courses) and found that it had helped their students to get started with programming while enjoying the journey and using a free game engine called Unity.
Last November, I gave access to these resources to several teachers for free, so that they could use it for their classes, if they found these to be a good fit.
So, I am renewing this offer for those who did not see it then, and also for those who have developped an interest in teh use of games for learning recently.
The books include:
  • Unity From Zero to Proficiency Series: a series of 4 books through which students learn to create and export 3D worlds and 3D games, and learn to code in C# in the process.
  • Beginner’s Guides: a series of 4 books through which students learn to create and export 2D games, and learn to code in C# in the process. They will be creating platformers, card games, puzzles, word games, shooter games, and infinite runners.
  • Quick Guides: a series of 6 books where students avail of a quick and easy tutorial (60 minutes) to get started on a specific topic (C#, Artificial Intelligence,etc.)
  • JavaScript from Zero to Proficiency (Beginner): A book that introduces Javascript programming to students with no prior knowledge of programming.
  • C# from Zero to Proficiency (Beginner): A book that introduces C#  programming to students with no prior knowledge of programming;
The video courses include:
All the books and video courses include a practical approach with many hands-on activities (students will spend most of their time coding and building their game), checklists (so that the students can check their progress), quizzes (to check their knowledge), challenges (to put their skills into practice), FAQs, and lots of explanations (e.g., many screenshots for the books).
So I am giving away these books and video courses for free to 100 teachers throughout Europe on a first-come-first-served basis.
If you are interested in receiving these, please email me: learntocreategames@gmail.com or pfelicia@gmail.com
Also, I am aware that Unity may be quite demanding in terms of computer requirements for some schools, and I am planning on a series of books that introduce coding through the creation of games with JavaScript or Java so that itcan be used on less up-to-date computers; if this is a topic that you are interested in, please email me to let me know the topics that you’d like to see covered in this book; I will also send you a free copy of same when it is released.

Hope this helps,- Patrick

Starting to Code in Java – Part 1

In this section, we will go through an introduction to Java programming and look at key aspects of this programming language, including:

  • It’s syntax.
  • Variable types and scope.
  • Methods

 

So, after completing this chapter, you will be able to:

  • Understand key concepts related to Java programming.
  • Understand how to use variables and methods.
  • Create and use your own methods.

The code solutions for this chapter are included in the resource pack that you can download by following the instructions included in the section entitled “Support and Resources for this Book“.

What is Java

Java is a high level object-oriented language developed by Sun. It is a multiplatform language which means that once it has been written and compiled, a Java application can run on most platforms.

The fact that it is an object-oriented programming language means that a Java programme consists of a collection of objects that interact with each other.

Java is used for many purposes, including the creation desktop or mobile applications or even games.

Choosing a code editor

In the next sections, you will start to write your own Java code. For this purpose, you will need to use a code editor, and more specifically, an Integrated Development Environment (IDE). These IDEs include all the necessary tools to compile and execute your code, in addition to other options that will speed-up your development and also help you to keep it free from bugs.

Using an IDE will provide you with an easier way to create, organize and check your code, with some of the following features:

  • Text highlighting: so that you code is clearer to read and to modify.
  • Auto-completion: so that you don’t have to remember the name of all the variables in your code, or the name of some common methods.
  • Error highlighting: so that some obvious errors are highlighted before you even test your code.

 

There are many free IDEs available with their advantages and drawbacks, including:

  • BlueJ
  • IntelliJ IDEA.
  • NetBeans

All these IDEs considered, we will be using BlueJ for this book, although you could use any of the other IDEs if you wish. BlueJ is an IDE specially developed for beginners. It won’t overwhelm you with too many features, but instead, help you to get started with Java and provide some very useful features along the way that will make your coding clearer, such as class diagrams, or code split into color-coded blocks.

You can download BlueJ from the following site: https://www.bluej.org/

 

Installing Java

Before you start working with Java, you will need to install the most recent version of the Java Development Kit (JDK). The JDK includes all the libraries that you need to be able to write, compile and run code in Java.

To do so, please do the following:

  • Open the following page:

https://www.oracle.com/technetwork/Java/Javase/downloads/index.html

  • Look for the latest version of Java SE Development Kit.
  • Download the most recent Java SE DK: as this book is being written, the latest version of Java is Java SE 11.0.2.

Figure 1‑1: Downloading the SDK(Part 1)

  • Once you click on the Download button, a new set of options will appear from which you can chose the version that you would like to download, after accepting the license agreement.

Figure 1‑2: Downloading the SDK(Part 2)

  • Once you have downloaded the software please launch it and follow the instructions.

 

Installing BlueJ

Once the Java SDK has been installed, it is time to install BlueJ, which is an IDE that you will use to write your code in this book. BlueJ was designed with Java beginners in mind and includes many features that make it easy to create Java applications. So let’s install this software:

  • Please open the following link: https://www.bluej.org/.
  • Download the BlueJ version that corresponds to your operating system (i.e., for Mac OS, Windows, or Linux).

Figure 1‑3: Installing BlueJ

If you are using a Windows computer:

  • Double-click the install file that you have downloaded.
  • This will run a standard installation. Follow the instructions on screen. The installer will install the executable bluej.exe.
  • If when executing BlueJ you see a dialog box asking you whether you want to block or unblock BlueJ, you may choose not to block BlueJ so that it can be launched seamlessly.
  • The first time you launch BlueJ, and if you have more than one Java version installed on your computer, you will be asked to select your preferred version.

If you are using a Mac:

  • Download the installer for Mac (this is a zip file).
  • Decompress the zip file; this will create a folder called BlueJ.
  • Move the resulting folder to your Applications folder for example.
  • You can then click on the icon called BlueJ, to launch this application.

Figure 1‑4: Installing BlueJ on a Mac

 

Creating your first application

After this brief introduction, it is now your turn to code.

So that you get to experiment with your Java code, please do the following after installing BlueJ:

  • Please launch BlueJ.
  • Once BlueJ has been launched, select: Project | New Project from the top menu to create a new project.
  • In the new window, please select a name and a location for your project and click “OK“.

Figure 1‑5: Selecting a location for the project

  • Once this is done, a new window will appear that will make it possible for you to create your first programme.

Figure 1‑6: Creating your first programme in Java (part 1)

  • Click on the button called “New Class” that is located on the left-hand side of the window, as per the previous figure. This will open a new window.
  • Enter a name of your choice in the text field for the attribute “Class Name“, leave all the other options as default, and press “OK“.

Figure 1‑7: Creating your first programme in Java (part 2)

  • You should see that a new class called MyClass has been created within your project.

Figure 1‑8: Creating your first programme in Java (part 3)

  • You can now double-click on the icon labelled “MyClass“, as per the previous figure.
  • This will open a new window that displays the code that has been created by default for your new class, as follows.

/**

* Write a description of class MyClass here.

*

* @author (your name)

* @version (a version number or a date)

*/

public class MyClass

{

// instance variables – replace the example below with your own

private int x;

 

/**

* Constructor for objects of class MyClass

*/

public MyClass()

{

// initialise instance variables

x = 0;

}

 

/**

* An example of a method – replace this comment with your own

*

* @param  y  a sample parameter for a method

* @return    the sum of x and y

*/

public int sampleMethod(int y)

{

// put your code here

return x + y;

}

}

Since we will not be using all this code, please do the following:

  • Select all the code (CTRL + A).
  • Press delete to delete all the code.
  • Type the following code instead:

public class MyClass

{

public static void main (String [] parameters)

{

System.out.println(“Hello World”);

}

 

}

In the previous code:

  • We declare a class called MyClass. As we will see later, your application will be made of a collection of classes. One of these classes will be the class MyClass which the starting point for your application.
  • We also declare a method called main. This method will be the starting point for our application.
  • In this method, and this is the most important part for now, we write the text “Hello World” in the console window. This window will be displayed as you execute your code.

You can now do the following:

  • Compile and execute this code by pressing the button labelled “Compile” from the top of the window.

Figure 1‑9: Compiling your code

  • Check that your code has been compiled properly by ensuring that the message “Class Compiled – no syntax errors” is displayed at the bottom of the window.

Figure 1‑10: Checking for errors

  • Run your programme: switch to the “Project” window, right-click on the icon labelled “MyClass“, and select the option void main(String [] parameters) from the contextual menu, as illustrated in the next figure.

Figure 1‑11: Running your first lines of code (part 1)

  • A new window will appear asking you whether you want to enter parameters: just press “OK” for now.

Figure 1‑12: Running your first lines of code (part 2)

  • Once this is done, the terminal window should appear as follows.

Figure 1‑13: Your first console application

As illustrated in the previous figure, the text “Hello World” was written and displayed in the terminal window, based on your code.

We could now change our code to display a different message:

  • Please close the console window.
  • Edit your code and modify it as follows (new code in bold). To edit your code, you can double click on the icon called MyClass in the main window.

public static void main(String[] args)

{

System.out.println(“Hello, this is my first line of code”);

}

In the previous code, we just modified the message displayed in the console window to add the text “this is my first line of code”.

  • You can then compile and run your code and see the new message: “Hello, this is my first line of code” in the console window.

 

About compiling and Java bytecode

When you write your Java source code, it is usually saved as .Java file. Once your file is compiled, it is converted (i.e., compiled) into bytecode as a .class file. This code, in turn, is interpreted by the Java Virtual Machine (JVM) that is installed on your computer and directly executed or translated into a code that the computer can understand (i.e., machine code) and execute. So, the JVM acts as a translator between your bytecode and the computer. The advantage of this approach is that given that a Java Virtual Machine can be installed on most computers, your code after being compiled into bytecode, can be executed on any computer where the Java Virtual Machine has been installed. You can therefore compile your code once and run the code virtually anywhere.

You may wonder how the JVM is installed. Well, when you installed the Java SDK at the very start of this book, it installed, amongst other things, a JVA Runtime Environment (JRE) that includes the Java Virtual Machine, as well as the Java compiler.

You can see both the .Java and .class that have been created and compiled in your project, if you navigate to the folder that you have chosen for your project initially. For example, in the next figure, you can see that several files, including MyClass.Java and MyClass.class, that belong to the current project.

Figure 1‑14: Locating the .class and .Java files

Christmas Sale 2018!

As a way to say thanks for being part of this list, and to help you kick start the Christmas Season  in style, I am offering 50% discount on all my books and online courses until midnight this Friday 21st December.

motionmailapp.com

So here is how you can get your discount for the books:

  • Open this page: http://learntocreategames/books/
  • Click on the book (s) that you’d like to buy. This will open the book’s page.
  • Select the option “Buy pdf” at the top of the page for each book, this will add the book to your cart.
  • Repeat the above steps for all the books that you’d like to add to your cart.
  • When you have selected all the books that you need, enter the discount code HOHOHO2018 click on the button “Update Cart” and you should see that a 50% discount has been applied to your cart.
  • Check-out and enjoy!

You can get any my Udemy courses at $9.99 (i.e., that’s more than 50% of their original price) by using these links:

motionmailapp.com

This is offer will end in less than 48 hours.

All the best,

– Pat

PS: I don’t do this often, so take advantage of this great deal right now before it’s too late.

New Book on 3D Animation in Unity

Being able to animate your 3D character and to control it through C# is quite important because it makes it possible to make your game more engaging, to include characters that look believable, and to build games that are more fun to play; so knowing how to animate 3D characters can certainly boost the appeal of your game.

Now, there are many books and resources on 3D animation; however, it is difficult to find a book that doesn’t overwhelm you with too much information at a time, and that guides you step-by-step in the process of becoming proficient in 3D Animation in Unity.

So this is the reason why I created “Getting Started with 3D animation in Unity“, a new book that will get you started smoothly with 3D Character Animation in Unity.

>> Getting Started with 3D Animation in Unity is out today at $1.99: Grab your Copy today before the price goes up tomorrow . <<

If you need to get started with 3D Character Animation, and to understand the different aspects involved (e.g., Mecanim, Finite-State Machine, transition, Animator Controllers, etc.) in a very clear and understandable way, then this book is for you.

In this book, you will not only learn 3D Animation in Unity but also enjoy the journey, without the frustration. It includes five chapters that painlessly guide you through the necessary skills to animate and control 3D Characters in Unity. It assumes no prior knowledge on your part and ensures that you have all the information and explanations that you need every step of the way. All the information is introduced progressively.

After completing this book, you will be able to:

  • Control 3D animated characters in Unity.
  • Understand how to create and use a Finite-State Machine (FSM) in Unity through Mecanim.
  • Create parameters, states, and transitions for this FSM.
  • Create blend trees in Mecanim to include smooth transitions between animations.
  • Control your character through a C# script.
  • Combine Character Controllers and Finite State Machines for more realistic movements.

 

Getting started with 3D Animation in Unity is available today for $1.99 (before the price goes up to 2.99 tomorrow)!

=>> Don’t wait: Grab Your copy today!

Talk soon,

– Pat

7 steps to find and design your next game idea

As you build-up your game development skills, you may often be on the look-out for your next game idea; often, this happens to be a difficult process; you may feel stuck first, wondering, how you will be able to find an idea that is both original and challenging for the players; so, in this post, I will cover a few principles that you can start to use to draft and start to design the key mechanics and goals for your game. Continue reading

Creating a Timer and Pausing The Game in Unity

In most of the games that you will create, you will, more than likely, include the concept of time. This may mean a timer indicating how much time remains before the player loses, or simply, the ability to pause the game.

Implementing a Timer

So first, let’s look at the following snippet example that implements a timer:

float time;

void Update()

{

     time += Time.deltaTime;

     float seconds, minutes, hours;

     seconds = time % 60;

     minutes = time / 60;

     hours = time / 3600;

     print ((int)hours + “:” + (int)minutes + “:” + (int)seconds);

}

In the previous code:

  • We use the Update
  • We calculate the time since the game started and save it in the variable called time.
  • We then calculate the current seconds, minutes, and hours based on the variable time.

If you were to create a countdown, the principle would remain the same, except that the variable time would be initialized to a value that is greater than zero and then decreased every seconds until it reaches zero. 

 

Pausing the Game

In Unity, it is very simple to pause or resume your game, using the following code:

Time.timeScale = 0;//time is paused

Time.timeScale = 1;//time is back to normal

So, you could for example, create two buttons and functions: one button (and its associated function) for pausing the game as well as one button (and its associated function) for resuming the game. You could then call one of these functions based on the button that the player has pressed.