One of the joys of working in 3D is that we are free from the shackles of pixels. We can define our world in whatever units we want. The game mechanics we outlined dictate a limited playing field, so let's start by defining that field. Figure 12-5 shows you the playing field area in our game's world.
Everything in our 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 we should define the sizes of all objects in our world:
■ The invaders have a slightly bigger radius of 0.75 units. This makes them easier to hit.
■ The shield blocks each have a radius of 0.5 units.
How did I arrive at those values? I simply divided the game world up in cells of 1 unit by 1 unit and thought about how big each game element has to be in relation to the size of the playing field. Usually you arrive at those measures through a little experimentation or by taking real-world units like meters. In Droid Invaders we don't use meters but nameless units.
The radii we just defined can be directly translated to bounding spheres of course. In case of the shield blocks and ship we cheat a little, as those are clearly not spherical. Thanks to the 2D properties of our world we get away with this little trick, though. In case of the invaders the sphere is actually a pretty good approximation.
We also have to define the velocities of our moving objects:
■ The ship can move with a maximum velocity of 20 units per second. As in Super Jumper, we'll usually have a lower velocity as it is dependent on the phone's tilt.
■ The invaders move with 1 unit per second initially. Each wave will increase this speed slightly.
■ The shots move with 10 units per second.
With these definitions we can already start implementing the logic of our game world. It turns out, however, that creating the assets is directly related to the units we defined here.
Was this article helpful?