126 Video Game Design Foundations
IF
the go-cart collides with the banana peel…
The reaction side of the logic statement describes what should happen when
the condition is met. The reaction side of the logic statement for the go-cart is:
THEN
the go-cart spins out.
Together, the action and reaction sides of the statement form a complete
logic statement. The interaction between the go-cart and the banana peel is
completely stated as:
IF
the go-cart collides with the banana peel,
THEN
the go-cart spins out.
You see that
IF
an action occurs,
THEN
a reaction takes place. From
this basic statement, more complex statements can be created.
Conditions and Events
The action-reaction relationship is everywhere and not just in games. You
have several interactions every day. Looking at everyday interactions, they are
defi ned in terms of cause and effect. Since cause and effect are exactly
the same as action and reaction, the go-cart example can be rewritten in
cause-effect language. Here, the cause is a banana peel in the road and the
effect is slipping on the peel. Cause-effect relationships can be written in the
same IF…THEN logic format. This looks exactly the same:
IF
the go-cart collides with the banana peel,
THEN
the go-cart spins out.
The table in Figure 5-2 shows some everyday cause and effect relationship
you might encounter.
Figure 5-1. The go-cart spins out when it hits the banana peel. This can be written as an IF…THEN statement: IF the
go-cart hits the banana peel, THEN it spins out.