Vspeed
A vspeed variable (or v_speed, vSpeed) is a common variable used to keep track of the vertical speed of a game object. This is done with a minimum of game programming.
First, the vspeed variable has to have a value. This value will be how fast the game object is moving up or down in pixels per game loop. If the game object is moving upwards, it's vspeed will be negative. If it is moving down, it's vspeed will be positive. If it is moving neither up nor down, it's vspeed will be 0.
Setting the variable alone is not enough to make a game object move up or down. Somewhere in your game code you must add the value of vspeed to the the game object's y variable, used to keep track of it's vertical location.
The code looks like this :
y = y + vspeed
Related Pages
- gravity - simulating gravity in a 2D game.
| This article is a stub. You can help improve Game Design Novice by expanding it. |
page_revision: 1, last_edited: 1204174063|%e %b %Y, %H:%M %Z (%O ago)