188
Video Game Design Foundations
The
LOOP
command allows the subroutine to be active for a specific
number of iterations. To program a sound effect to repeat three times, a
program would include
LOOP (3)
code. This specifies that the activity will only
cycle three times and then stop until activated again.
The
FOR
command allows
the subroutine to be active for
a specific number of times.
To program an avatar to have
limited super speed when it
collides with a speed fruit object,
a programmer would include
FOR (90)
code. The loop will be
repeated 90 times. If the program
operates at 30
steps
per second,
then the super speed would last
for three seconds.
The
DO WHILE
command
allows the subroutine to be active
only when another condition is active. To program calculating a bonus when
using super speed, a
DO WHILE
command would be appropriate. A programmer
might write code to have points double when using super speed.
DO WHILE (Animation = SuperSpeed)
Bonus = (Points * 2)
Note that an asterisk (*) is used for the multiplication symbol. When the super
speed animation is over, the bonus stops being calculated.
The
DO UNTIL
command allows the subroutine to be active until another specific
interaction takes place. If a programmer wanted to have the avatar in super-size
animation until it collided with a minion, then the code might look similar to:
DO UNTIL (minion_class, collision)
Animation = Super_Size
Different loop commands allow programmers to have limits to special
conditions within the program. When the loop ends, the condition would need
to be reactivated to start over.
Naming Convention
Here comes the tricky part! You get to create all of the names for the
objects, actions, methods, variables, and more. You can use common words
like
JUMP
when creating the programming to make something leap in the
air, but you can also make up a crazy word like
APPLE
to do the same thing.
Remember, you are creating the definitions for the computer to understand.
If you make the word
APPLE
have the same definition that most of us use for
JUMP, the computer will remember
APPLE
means to leap in the air. Doing
this “junk” programming makes it very difficult for you to remember what a
method is trying to do and impossible for other programmers to figure out the
programming. If you program
Character APPLE
5, then other programmers think
your character will find five apples. Instead your character jumps five feet. This
can cause confusion because people have memory and definition persistence.
CHEAT CODE: STEPS
When programming, steps refers
to how many iterations occur per
second. If the steps are set to 20,
then the computer will check for
interactions every 1/20th of a second. The higher the
steps setting, the smoother the game will run. If the steps
setting is too high, the program will lag as it tries to test
each conditional statement in a fraction of a second.