Game Development Reference
In-Depth Information
56.
}
57.
}
Listing 6: The Script that implements the platformer input system
The first note regarding this script is its relative length and complexity, compared with
what we have been dealing with so far. This is reasonable, since this is our first script that
does some real game stuff, and there is much more yet to come! You might now have had
an idea about amount of work required to make a real game, regardless of how small and
simple it might be.
Let's now dive into the details of the script and discuss them. We have three speed variables
that control the speed of the character movement. The first speed is jumpSpeed , by jump
speed we mean the vertical speed upwards at the moment the character leaves the ground.
This speed starts to decrease with time until it reaches zero. After that, it starts to degrade
below zero, so the object begins to fall down again because of the gravity. The second
speed is gravity , which represents how fast the vertical speed of the character decreases
when it is in the air. We are going to discuss the relation between these two speeds in a
moment.
Search WWH ::




Custom Search