181
Chapter 5 Collision Theory and Logic
CHEAT CODE: RELATIVE
The term relative is used when
placing or moving an object in a
game to describe from where the
position is determined. When you
place a duck three units to the left of a frog, you are
placing it relative to the position of the frog. If something
is placed at coordinates 0,0 relative to an original object,
it is in the exact same spot as the original.
Look at line 1 in the event frame. The
IF
side of the logic statement is in the
first column. The
THEN
side of the logic statement is shown in the remaining
columns. The condition on line 1 states “collision between dart object and
balloon object.” When that condition is met, the computer processes the events
in the
THEN
statement.
Notice the four check marks
in line 1 in the event frame.
The first check mark is in the
Create New Objects
column.
This event creates a new
explosion animation object at
coordinates 0,0
relative
to the
balloon object. The next check
mark is in the
Player 1
column.
This event adds 100 points to
player one’s score. The next
check mark is in the
Balloon
Object
column (the name of
this column matches the name
assigned to the object). This
event is set to destroy the balloon
object. The last check mark is
in the
Pops
column. This event
increases by one the counter
keeping track of the number of
pops. To see this type of object-
oriented programming as a logic
statement, add the word
IF
before
the condition and the word
THEN
before an event. See Figure 5-13.
Remember, collision theory
is more than just setting collision
events. To make objects appear
solid, the programmer needs to
add some realistic effects to the
collision. Think about what happens when someone walks into a glass door.
Do they just stop or do they bounce with their head whipping back and
Think about creating logic statements
for the interactions programmed in
Figure 5-12. Examine the conditions
programmed on lines 6 and 7. These lines
have AND/OR operators between the two
conditions on each line. Which conjunction
works best in each line?
UP!
5.4
Figure 5-13.
Goodheart-Willcox Publisher
Logical operators can be added to
help explain how a logic statement is
constructed in The Games Factory 2.