Core Game Mechanics

As you might have guessed from the title of this chapter, you are about to implement a variation of Space Invaders, a 2D game in its original form (illustrated in Figure 12–1).

images

Figure 12–1. The original Space Invaders arcade game

Here's a little surprise: you'll continue to stay in 2D, for the most part. All of your objects will have 3D bounds in the form of bounding spheres and positions in 3D space. However, movement will only happen in the x/z plane, which makes certain things a little easier. Figure 12–2 shows the adapted 3D Space Invaders world. The mock-up was created with Wings3D.

images

Figure 12–2. The 3D game field mock-up

Now to define the game mechanics:

  • A ship is flying at the bottom of the playfield, capable of navigating only on the x-axis.
  • The movement is limited to the boundaries of the playfield. When the ship reaches the left or right boundary of the game field, it simply stops moving.
  • You want to give the player the option of using either the accelerometer to navigate the ship, or the on-screen buttons, for left and right movement.
  • The ship can fire one shot per second. The player shoots by pressing an on-screen button.
  • At the bottom of the game field, there are three shields, each composed of five cubes.
  • Invaders start off with the configuration shown in Figure 12–2, and then they move to the left for some distance, and then they move some distance in the positive z-direction, and then to the right for some distance. There will be 32 invaders in total, making up four rows of eight invaders.
  • Invaders will shoot randomly.
  • When a shot hits the ship, the ship explodes and loses one life.
  • When a shot hits a shield, the shield disappears permanently.
  • When a shot hits an invader, the invader explodes and the score is increased by 10 points.
  • When all invaders are destroyed, a new wave of invaders appears, moving slightly faster than the last wave.
  • When an invader collides directly with a ship, the game is over.
  • When the ship has lost all of its lives, the game is over.

That's not an overwhelming list, is it? All operations can essentially be performed in 2D (in the x/z plane instead of the x/y plane). You'll still use 3D bounding spheres, however. And maybe you'll want to extend the game to real 3D after you are done with the first iteration. And now? You can move on to the backstory.

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

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