179
Chapter 5 Collision Theory and Logic
then the player cannot interact with it. Take the example of a player flying an
airplane. There is no collision statement for the sky or the clouds. This allows
the airplane to fly through these objects without any reaction. However, if the
airplane collides with a bird, then the engine would sputter and the plane would
lose altitude. Therefore, birds are programmed to trigger interaction events when
touched. In other words, the bird objects have a collision statement.
Remember, just because an object looks like a dart does not mean a balloon
will pop if the dart touches it. In the balloon pop game, if an event is not
associated with the condition:
IF
the dart object collides with the balloon object
then nothing will happen when the dart hits the balloon. No events will occur at all,
no balloon pop, no explosion, and no increase in score. The computer has no way of
knowing the proper event unless you tell it exactly what to do and how to do it.
This can be a difficult topic to understand. It is easy to think that if an
object looks like grass, then it should act like grass. That is true in real life. A
real grassy surface stops you from falling to the center of the earth. But, this
real-world logic does not apply in a video game. In a video game, the grass is
just an image of a grass. The object will only act like real grass if the designer
programs it to do so. Every interaction with the grass object needs to be
programmed to react as though it came in contact with real grass.
Of course, you do not have to program objects to act the way they do in
the real world. Some surreal and fantasy games program unusual properties for
objects that appear as real-world objects. For example, you may program a road
to act as a river. On the other hand, you may have a waterfall act like an elevator.
Figure 5-11.
In this platform game,
Spiko the Hedgehog,
the main character
must walk on the
grassy platforms
to reach the gold.
However, notice the
glitch in this game.
Spiko can walk on
the water hole, when
he should sink. The
collision with the
water was incorrectly
programmed to act
as solid platform.
Goodheart-Willcox Publisher
Previous Page Next Page