Greetings!

The main purpose of this website is to support Android indie game developers with tutorials, reviews and promotion of their games. The main difficulty for the developers is not to make the game, but to get exposure. To get it out there. If you find anything useful here, please spread the word. Like my page on Facebook, follow me on Google+ or Twitter. Thank you!

Google+ Facebook Twitter

× close

Wednesday 16 October 2013

Android Game Development Tutorial in AndEngine - Part 2 - Concept

Before you start coding, you have to already know how is your game going to look like. Not in all details, but at least a high level view - a concept. It sounds like an obvious fact, but a lot of people will start making a game only to find later that their idea won't work.

You don't need any special tools to create a concept. For a simple game, you can simply think it through. But at least put your thoughts on paper or create a short document.

Creating a concept will help you figure out the basic requirements for your game and having requirements can help you estimate the time and resources needed to finish your game. To be less theoretical, let's look at example.

Squong Game Concept

First, I had an idea to create a pong game for this tutorial. But then I wanted to make the game a bit more complex and I was thinking what can I add or change. First I just thought of making the pong game with more freedom of movement - like a pong where you can move you paddle not just left/right but also up/down. I already thought of using Box2D physics - it is not really neccessary, but good for the purpose of the tutorial. And there was the idea - paddles could collide if they are both on one side of the court. Like in Squash.

If you can figure a name for your game at this stage, good. But don't spend too much time thinking about a cool title. Simply call your game "First Game".

Second, I came up with basic entities in the game. Entity is any object that you will add to the game.
  • A paddle - one player, one opponent
  • Ball
  • Court - and the court consists of
    • Walls

Next I tried to think of all possible situations that can happen in Squong. Players must change possession of the ball. That can happen when the ball hits the top wall. But then player could go close to the wall, hit the ball and disallow the opponent to play. So I had to change the possession a little bit further from the top wall. Also the bottom wall should actually be the same as in pong - when the ball exits the court there, player loses:

  • Court - and the court consists of
    • Walls - top, left and right
    • Center line
    • Bottom line

And that's it. There's not going to be anything else in the game. Few more thoughts:

  • When ball stops, player in possession loses
  • When paddle crosses the center line, the owner of the paddle loses

Now I have pretty much what I need to make a game.

Squong Game Requirements

I've already decided that I will use AndEngine. Now let's give a quick thought to the architecture of the game. We are going to need:

  • Graphics - paddles, ball - this should be pretty straightforward
  • Sounds - ball hits paddle, wall, sound for score or foul. Maybe for change of possession.
  • Music - not really needed, but could be nice to have background music in menu (at least for the purpose of a tutorial)
  • Physics - paddle, ball, line and wall collisions
  •  
This gives us basic idea of what are we going to use from AndEngine.

At this point you can start drawing your entities or thinking where you get them. But don't get stuck. If you don't have them, simply use some mock pictures. A paddle can simply be a rectangle, ball is a circle. You can start looking for sounds and music, but that is a very low priority now.

Scenes

A scene is exactly what the words means. If you look at games, they usually consist of some initial loading scene, that we call Splash. Then you go to Menu scene (a Tap-To-ontinue scene is sometimes present). There can be a Settings scene if you can't fit everything in Menu scene. Then a one of more Game Scenes. Maybe a Credits Scene, Achievments Scene etc. In Squong we are going to use the following. See the flow diagram to understand how the scenes change.


The Info scene will simply be a link to this tutorial. Note that concept of "Exit Game" is a bit complicated in Android, we will get to it later.

This all might seem like a waste of time. You want to be coding already! But trust me. Having these will be very useful later especially in bigger games.

Next part

In the next chapter, we finally start coding!

Further reading

Here's my book about AndEngine and you can see the list of books about Android Game Development for further reading, not just about AndEngine but game development in general.

Note: I had to take a break from writing this tutorial. The game is published in Google Play store now. You can still get the full source code of the final game for 99¢. Available on Sellfy, pay by PayPal:
buy

Also here's one Box2D physics problem that is directly related to the Squong game. If you find a solution, let me know! 
Martin Varga is a Czech software developer who likes pygmy owls (hence Kulíš), running, ramen, travelling and living in foreign countries. He is also known as smartus or sm4 on the internet (read as smartass, but there are too many of them). He currently tries to make games in AndEngine like Mr. Dandelion's Adventures and hangs around a lot at the AndEngine forums.