Sunday, November 18, 2012

Nokia's Snake - Part I: Preparation - Making a Quick Game

Here our journey starts! And why not start it with something legendary! Something so simple yet addictive that a whole generation of traveling people would play it in subways all around the world!? Snake!

Even though this game was created in 1970s and Nokia had nothing to do with this, it became a world-wide hit after it became standard game on Nokia phones! So please allow me to call it Nokia's Snake!


About importance of preparation!

Most probably at this stage you think that you only have a problem of HOW to develop a game and there is no issue of WHAT game to develop! You might think it's the easy part! I know I did! 

But once you start developing you come to realize that there are some things you didn't think were to be done. In the best case scenario you will simply add the functionality/content and it will slightly affect your deadline. But in the worst case (like I had) you're gonna have to rebuild the whole code and redo some graphical assets.You need to have a good map before you start your trip, because you need to know what to put in the backpack and which shortcuts are actual shortcuts!) So...

Let's break down the game before we try to build it!

In this game we control this creature which is kind of (surprise, surprise!) a snake! But we do control only it's head with a d-pad, the rest of the body is just following the same route.
The snake lives in this weird rectangular world and it can't leave it! The only thing it can do is eat! There is always just one "food"-thing on the screen and once the snake eats it, another one appears! But this unhealthy nutrition makes snake grow! With every meal our snake is longer!
Speed
Oh and did I tell you the most awful thing about the snake's life!? It has this SandraBullock-KeanuReevs medical condition where she just can't stop! If it stops it dies! Hit a wall - DEATH! Hit your own body - DEATH!

The point of this game is simply high score! No bosses, no story lines :) Just play as long as you can!

So let's write our understanding of what functions this game needs to have in my favorite bullet list style.
  • As the game loads we see menu with two buttons: StartGame and Score.
  • Score will show us other menu with list of previous game records if there are any.
  • StartGame will start the game, duh.
  • As the game starts we see the world space, pause button, current score and current top record.
  • The world space consists of floor and walls. We'll call walls TheWalls :)
  • Player is represented by an object we'll call SnakeHead.
  • The SnakeHead constantly moves in the direction it is looking.
  • Player can change direction of the Snake movement, by pressing keys: up,down,left,right.
  • Object that we'll call BodyParts follow the route of the head!
  • There is a concrete number of BodyParts.
  • An object we'll call SnakeFood should be randomly created within the world space.
  • Every time SnakeHead touches SnakeFood, it is disappears. Number of BodyParts is increased by one and a new SnakeFood is randomly created within the world space. 
  • If SnakeHead touches a BodyPart or one of TheWalls the game is over!
  • Once the game is over we create a record of number of BodyParts the Snake head at the moment of death into a list. We compare the record to the existent ones (if any) and put it after the record that is heigher, but before the one that is lower, thus creating an aligned chart of records.
 PS: Before we start with the game itself let's make sure we are on the same page and you have all of the tools tuned and ready! Meaning you should have your UDK and IDE installed, folder(s) for your code created, .ini files edited and so on. If you haven't coded a game in UDK yet, you need to do that! This post will help you out:
Set-up UDK for Programming with UnrealScript


2 comments:

  1. Replies
    1. Submitting it to Apple within one week! It took more time then I thought to achieve production quality with the project, so I couldn't find time to write about it. But I will do a series of posts describing the development process... Some interesting issues were solved while programming it :)

      Delete