Core Game Mechanics

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

Figure 12-1. The original Space Invaders arcade game

Here's a little surprise: we'll stay in 2D as well for the most part. All our 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 some things a little easier. Figure 12-2 shows you our adapted 3D Space Invaders world. The mock-up was created with Wings3D.

W «ti»'

tfr? -«*« Ty« ^J'

© ©

& O ^

& ®

© ^


z □

Figure 12-2. Our 3D game field mock-up

Figure 12-2. Our 3D game field mock-up

Let's define the game mechanics:

■ We have a ship flying in the bottom of the playfield capable of navigating on the x-axis only.

■ 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.

■ We want to give the player the option of either using the accelerometer to navigate the ship or 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 move to the left for some distance, then 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, it explodes. 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 directly collides with a ship the game is over.

■ When the ship has lost all 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 instead of the x/y plane). We'll still use 3D bounding spheres though. Maybe you want to extend the game to real 3D after we are done with its first iteration. Let's move on to the back story.

Was this article helpful?

0 0

Post a comment