Asteroid Style Movement

Blitz3D Forums/Blitz3D Beginners Area/Asteroid Style Movement

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Use separate variables (vx# and vy#) for keeping track of the player's velocity. While the player accellerates, add a small amount to them (vx=vx+sin(dir)*speed:vy=vy+cos(dir)*speed). Every update, add the velocity to the position (x=x+vx:y=y+vy). Thusly, the player has control over his accelleration, but not his position (unless he engages his emergency random teleport device, which I believe all asteroids ships are equipped with during factory assembly.)

If you decide that there's air in space, you can multiply the velocity by a number close to 1 (try .9) to decay the velocity and achieve drag.

Happy hunting!