Planning Battle Tank

Before you just jump in and start coding you need to plan out how you want your game to look and work. Since you want to create a Scorched Earth remake, you will need two tank graphics. You will need some sort of playing field. You will need to be able to input an angle and velocity so you can attempt to kill your opponent. All of that is just what the user will see. It has nothing to do with the logic of the game.

So what will you need for the logic of the game? Well, you will need some sort of calculation for your bullets. You will need to detect if the opponent has been hit. If the opponent has been hit you need to tell the user if he won or lost. You will also need to be able to control the computer. If the computer has not been hit then the computer gets to calculate a move and fire at the opponent.

You will also need to determine what game states you will have. A good start is assuming that you will need three game states. The three default game states you should have are:

  • Game Starting

  • Game Running

  • Game Over

If you need more game states you can add them later, but for now let’s assume those are the only three you will need. This seems like a good start.

Now you must determine what graphics you will need. Before you get to creating dynamic terrain you should create the game with all static images. You will want to define an image for your tanks, an image for your terrain, and an image for the explosion that will occur when a shot detonates. Just to make sure this is clear, you will need to define the following:

  • Image for Tank #1

  • Image for Tank #2

  • Image for the Terrain

  • Image for the explosion

When you create the explosion you will want to create an animated .gif. That way you have a pseudo effect of real-time animation. You will learn how to do this in the next section of this chapter, “Creating the Graphics.”

Since you will be doing calculations that deal with angle and velocity you will need some sort of constant to pull down the bullet. That’s right, dust off all those old physics books—you will need to define gravity. If you need any other constants you can add them later just like with the game states.

So what are the objectives of the game? You want to generate a turn-based game that takes angle and velocity as the user input. Once you have the angle and velocity you calculate where the explosion will occur. If you hit the opponent, you win; if the opponent hits you, then you lose. After you have a working version of the game you’ll want to go back and add dynamic terrain with all of your newfound graphics knowledge. Based on this description you will need six game states. You will use the three that you have already determined plus three more.

  • Game Starting

  • Game Menu

  • Game Init

  • Game Play

  • Game Win

  • Game Over

The game starting state tells the game to start the session then go to the menu. While you are on the menu you are in the game menu state. Once you click to start a new game, that takes you to the game init state. This isn’t a big deal for the first version of the game, but it will come in handy when you start generating the terrain. Once you leave the game init state you enter the game play state. This is where you are physically playing that game. If you hit the opponent, then you enter the game win state, where you can display a cool “you win” graphic. If you get hit by the opponent, then you enter the game over state where you will put up a graphic telling the player that he has lost. Pretty simple, huh? Take a look at Figure 9.1 to see a screen shot of what the final product should look like when you are all through.

Figure 9.1. A screen shot of Battle Tank.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset