Game Development Reference
[fqilBkn_a is the force with which the object will jump. It needs to project upward toward the top
of the stage, so it has a negative value. The actual value that you give it is again a matter of trial and
error. You'll need to make sure that its value is enough to counteract gravity and any other forces that
might be acting on the object.
How does the object know whether it's on the ground? This is something that could become quite com-
plex, depending on the game you're designing, so you'll need to think about this carefully when you start
any project that uses jumping. In this simple example, the _]p object is on the ground when it's at the
bottom of the stage. So all you need to do is set [eoKjCnkqj` to pnqa in the same section of code that
checks for the bottom stage boundary:
That's pretty straightforward. In most games that use jumping, game characters also need to know
when they're standing on platforms. That makes detecting the ground a little more complex, but you'll
be looking at a solution in the Bug Catcher game that you'll build later in the chapter.
Making the object actually jump happens in the kjGau@ksj event handler: