CodeBase - sprite jumping code, timer based

Return to the CodeBase listing

Category: Sprite

Version: 1.0

0
0

Information

Uploaded: 26th Nov 2008 02:23

Modified: 26th Nov 2008 02:46

Author:  Visigoth

Summary

I've been playing with sprites, and needed a way to make a sprite jump, and just came up with this tonight. It is a function that allows a sprite to jump using the spacekey(), and allows for height and speed(or gravity), if you prefer.

Full Description

basically, the function moves the sprite after a certain time has elapsed, set by the interval# value, and uses the sin() function to calculate what the y position is going to be. At 60 fps, a setting of around 30 to 40 for the interval seems pretty good. The higher the interval, the slower the jump. The height parameter is just how many pixels high to jump. Also, you could tweak the jump_angle incrementer to change the speed as well.

Comments

No comments yet.