Welcome to Edge of Code’s series of tutorials showing you how to create a 2D Infinite Roller game using free software. We’ll be using the Unity game engine to program the game, Inkscape to create artwork and Audacity for sound effects. If you’d prefer to watch a YouTube video, go here. If you’d like to try playing the game, go to this page.
Throughout these tutorials, as well as coding (using C#), I’ll show you how to make simple coder art and sound effects. If you don’t want to make your own or you’d like the source code, you can download it all on the Downloads page.
In this first tutorial, I’ll give you a quick introduction to the game and then to Unity. This game is an Infinite Roller game which is similar to an Infinite Runner game, but the character will roll instead of run. In later tutorials, we’ll learn random, infinite terrain generation. We’ll also go over object pooling (re-use), how to create the menu system and how to code a controller for the character.
The first version of the game places pieces of ground randomly but according to certain rules. The further the character rolls, the higher your score, and the game will keep track of your highscore. The second version of the game has images of blocks again randomly placed but with a different set of rules. You could also add to these games by introducing objects to avoid or objects to pick up. If you’d like a tutorial on this or anything else, let me know by leaving a comment below or email firstname.lastname@example.org.
First of all, if you haven’t already, you’ll need to download Unity 5. Unity is a free game engine used by people to create some awesome games. Once you’ve downloaded and installed it, open Unity and create a new project. To do this click ‘New Project’, give it a name (Infinite Roller in this case), select a location to save it in, and click 2D since our game is two dimensional. You don’t need to include any asset packages, so just click on ‘Create Project’.
To rearrange the window like I have in the image below, you just need to drag and drop the different components.
The scene view (see the image for each) shows the objects that make up your game; objects in the scene are called game objects. At the moment, there’s only one game object in the scene, a camera. You can see it in the scene and also in the hierarchy.
The hierarchy shows a list of the game objects in the scene. If you click on one, Unity shows you information about that object in the inspector.
The inspector shows all the different components that make up the game object. All game objects have a transform which holds information about its placement in the scene and its scale. This object is a camera, so it has a camera component, and there are variables in here that you can change if you need to.
When you want to preview the game you’re making, you press the play button at the top of the screen, and the game will appear below. The project window is where all of your game assets live, and by assets, I mean all of your scripts, artwork and audio. In preparation for the next tutorial, make a folder here by right clicking and selecting Create -> Folder. Name it Sprites. Now save the project by going to File -> Save Project.
In this tutorial, we’ve looked at the game we’re going to create and have had a quick look at Unity. In the next tutorial, I’ll show you how to create a simple character and a piece of ground using Inkscape, which is a vector graphics editor. Then I’ll show you how to import your images into Unity and how to add physics to them.
Remember you can download the files for this tutorial on the Downloads page. See you next time!