Saturday, May 5, 2012

Gravity


When a sprite move around with the arrow keys and you jump with the up arrow key, it is necessary to put "gravitation" in the program, otherwise the sprite stays in the air after jumping.


I simple forever if loop can check constantly whether the sprite is still touching the "ground", which is a certain colour in this example.  If it is not touching the ground, the sprite will keep moving a little lower until it does.






No comments:

Post a Comment