Defining the Game World

One of the joys of working in 3D is that you are free from the shackle of pixels. You can define your world in whatever units you want. The game mechanics that were outlined dictate a limited playing field, so start by defining that field. Figure 12–5 shows you the area of the playing field in the game's world.

images

Figure 12–5. The playing field

Everything in the world will happen inside this boundary in the x/z plane. Coordinates will be limited on the x-axis from −14 to 14 and on the z-axis from 0 to −15. The ship will be able to move along the bottom edge of the playing field, from (−14,0,0) to (14,0,0).

Next, define the sizes of the objects in the world:

  • The ship will have a radius of 0.5 units.
  • The invaders will have a slightly larger radius of 0.75 units. This makes them easier to hit.
  • The shield blocks each have a radius of 0.5 units.
  • The shots each have a radius of 0.1 units.

How do you arrive at these values? Simply divide the game world up in cells of 1 unit by 1 unit and think about how big each game element has to be in relation to the size of the playing field. Usually, you arrive at these measurements through a little experimentation, or by using real-world units like meters. In Droid Invaders, don't use meters, use nameless units.

The radii just defined can be directly translated to bounding spheres, of course. In the case of the shield blocks and the ship, you can cheat a little, as those are clearly not spherical. Thanks to the 2D properties of the world, you can get away with this little trick. In the case of the invaders, the sphere is actually a pretty good approximation.

You also have to define the velocities of the moving objects:

  • The ship can move with a maximum velocity of 20 units per second. As in Super Jumper, you'll usually have a lower velocity, as it is dependent on the device's tilt.
  • The invaders initially move 1 unit per second. Each wave will slightly increase this speed.
  • The shots move at 10 units per second.

With these definitions, you can start implementing the logic of the game world. It turns out, however, that creating the assets is directly related to the defined units.

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

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