Chapter 5 Collision Theory and Logic 125
Objectives
After completing this chapter, you will be able to:
game design software to create a
playable video game.
animated objects into a
video game.
sound and music effects in a
video game.
a video
game.
basic computer
logic.
applied mathematics
logic statements.
features of object
oriented programming.
Logic
The fi rst concept of designing and programming a video game is an
action-reaction relationship. To create a game environment that the player
can control, the player’s actions must cause something to change or react.
This is the action-reaction relationship. Often, obstacles and challenges
are placed within a game to force the player to
take action.
Programmers use logic statements to break
down these action-reaction relationships. For
example, if the action is colliding your go-
cart into a banana peel, the reaction will be the
go-cart spinning out, Figure 5-1. To begin this
programming process, you will need to under-
stand the fi ve basic operators of a programming
language: IF, THEN, AND, OR, and ELSE.
Basic Logic Statement
Two of the basic operators fi t together to make a logic statement. A
logic statement tests a condition and determines an action based on the
result. An IF…THEN statement is the most basic example of a logic state-
ment. The operator
IF
is used with the basic statement to test a condition.
This is the action side of the logic statement. In the go-cart example, the
action side of the logic statement is written as:
Use
Integrate
Create
Debug
Describe
Build
List
CHEAT CODE: COLLISION
Collision is the most-used action command in
game programming. Often substituted with hit
or touch, a collision occurs when an object
contacts something. This may be a player
contacting an obstacle or other player.
In may also be two obstacles
contacting each other.
Previous Page Next Page