Introduction to Mobile Game Development
Written July, 2015, by Rachel J. Morris
Introduction to Mobile Game Development by Rachel J. Morris is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at http://www.moosader.com/learn/ccckc/introduction-to-mobile-game-development/.
This course is really built to be a jump-right-in, let’s learn as we go, fast-paced but simple lesson in basic programming, and working with mobile devices. Sounds impossible, doesn’t it?
Well, we’re going to keep it simple in a few regards:
- We aren’t going to animate our sprites, or make complex maps to load into our games.
- We’re going to stick to simple tapping controls.
It definitely helps that Gideros is pretty easy to use, both from getting the software running and also coding simple programs quickly.
At the end of this three-week course, you might not write beautiful code, but you’ll be acquainted with some basic concepts of game development, mobile development, and programming. We’ll learn programming concepts as we go, so make sure to ask questions if anything isn’t clear. I will also edit these course files if any good questions are brought up, since it can be hard to combat the Curse of Knowledge.
This glossary will be used to define some concepts and terms that might come up in the course, or in example code, or in documentation otherwise. You may not need to completely understand these terms right off the bat, but they will be introduced later on.
Variables are containers that you can store information in. For example, this could be something like characterName, enemyLevel, timePlayed, or anything else – it’s up to you. One thing that we may use frequently are x and y variables, which will symbolize where an image is on the screen, with x being the horizontal position, and y being the vertical position.
Just like we can give a name to a variable to help us remember what information that variable stores, we can give a name to a Function as well. Instead of simply holding data, a Function can process data. For example, MovePlayerLeft, SetGameOver, IsEnemyTouchingPlayer.
Functions can return information (IsEnemyTouchingPlayer? true or false?), or it might not need to (for example, MovePlayerLeft could simply do this action).
A class is another step up – It is an object that contains Functions and Variables. A Player class might have functions like AddScore, GetHurt, BeginJump, and it might have variables like x, y, width, height, and more.
At the time of writing, I am not planning on introducing the concept of writing our own class objects in this course. However, Gideros has objects too, like Bitmap and Sound. Sound has functions like play or stop. So, it is good to know what a class is, generally.
With the Lua programming language, as soon as the program begins, it is in the code. It will continue going down the page of code, executing anything that isn’t inside of a Function.
This can make it easy to get up-and-running quickly, but it can also make code become ugly very quickly.
We can detect input from the user via Gideros Event Handlers. These handlers wait and listen for a specific event to happen, and when it does it will call a Function that we’ve written. For example, if the player taps the game board, we might move the player image to that location via the MovePlayer function.