Game Development Reference
In-Depth Information
indicating a catch (unless, of course, your player is all thumbs and fumbles the ball after
it hits his hands). You can find similar applications for other sports-based games as well.
What about a 3D “shoot 'em up” game? How could you use particle kinematics in this
genre aside from bullets, cannons, grenades, and the like? Well, you could use particle
kinematics to model your player when she jumps into the air, either from a run or from
a standing position. For example, your player reaches the middle of a catwalk only to
find a section missing, so you immediately back up a few paces to get a running head
start before leaping into the air, hoping to clear the gap. This long-jump scenario is
perfect for using particle kinematics. All you really need to do is define your player's
initial velocity, both speed and take-off angle, and then apply the vector formula for
displacement to calculate whether or not the player makes the jump. You can also use
the displacement formula to calculate the player's trajectory so that you can move the
player's viewpoint accordingly, giving the illusion of leaping into the air. You may in fact
already be using these principles to model this action in your games, or at least you've
seen it done if you play games of this genre. If your player happens to fall short on the
jump, you can use the formulas for velocity to calculate the player's impact velocity when
she hits the ground below. Based on this impact velocity, you can determine an appro‐
priate amount of damage to deduct from the player's health score, or if the velocity is
over a certain threshold, you can say goodbye to your would-be adventurer!
Another use for simple particle kinematics is for certain special effects like particle
explosions. This sort of effect is quite simple to implement and really adds a sense of
realism to explosion effects. The particles don't just fly off in random, straight-line tra‐
jectories. Instead, they rise and fall under the influence of their initial velocity, angle,
and the acceleration due to gravity, which gives the impression that the particles have
So, let's explore an example of a kinematic particle explosion. The code for this example
is taken from the cannon example discussed previously, so a lot of it should look familiar
to you. Figure 2-7 shows this example program's main window.
Search Nedrilad ::

Custom Search