Game Development Reference
In-Depth Information
more speed available to us, so using a vetted, powerful physics
package makes the most sense.
Box2D is widely used for Flash game development. It is popular
because it works well, is free, and is open source. It is
continually improved by the community, and because it is
supported on so many different platforms, it allows you to
switch between Flash and, say, native iOS development, and
maintain almost identical syntax.
There are a couple of things to note about Box2D. First is that I
will only be scratching the surface of its capabilities in this chapter.
I encourage you to explore it further on your own; it has a very
active community around it. The second is that the library has its
roots in the C language, so some of the ways in which you interact
with it are decidedly less
Everything about it is
engineered to run as fast and efficiently as possible. Luckily, it is
pretty well documented, so it is relatively easy to figure out how to
perform a specific task with it. The final note is that, like any robust
physics solution, Box2D operates abstracted away from the ele-
ments of the display list. What this means is that most of the work
ActionScript like.
ll be doing will be to bind the objects in the physics simulation
with DisplayObjects on the Stage to achieve the look we want.
ll dig into this further when we explore the air hockey engine.
The Game: Two-Player Air Hockey
The concept of air hockey, if you
re unfamiliar with it, is extremely
simple. The game is played on a table, usually designed to look
like a traditional hockey rink, with two openings on either end act-
ing as the goals. Two players are each given a round plastic instru-
ment, usually called a paddle (shown on the right in Fig. 16.1 ),
with which they must hit the puck (the disc shown on the left) into
their opponent
s goal. For the record, if you haven
game and my description just now was your first
exposure to it, put down this topic right now and
go find a place to play it. It
s very fun!
For the virtual simulation of this game, we
define some quick rules.
In real air hockey, the puck and the paddles are
not too different in size from each other, radius
wise. In this version, the paddles will be enlarged
somewhat in proportion to the puck so as to
provide a usable target to hit with one
s finger.
In the live game, players can feasibly reach
across the table to their opponent
s side to hit
the puck (though that is usually against the
rules). This will be very rigidly disallowed here
Figure 16.1 The puck (left) and paddle (right)
used in a typical air hockey game.
Search Nedrilad ::

Custom Search