Physics for Stupid People like me

Blitz3D Forums/Blitz3D Beginners Area/Physics for Stupid People like me

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.

due to numerical instabilities
You talk about the bouncing ball right? Going higher and higher for no obvious reason. Normal flawy code is like this:
position=position+velocity
velocity=velocity+acceleration
If [ball hit floor] Then velocity=-velocity
The ball will gain more and more height, because when the ball hit the floor, first acceleration due to gravity is added, then velocity is inverted, resulting in the ball launching upwards with greater speed than it came down with, the fix however is simple:
position=position+velocity
velocity=velocity+½acceleration
If [ball hit floor] Then velocity=-velocity
velocity=velocity+½acceleration
This can be made a bit smoother:
position=position+velocity+½acceleration
velocity=velocity+acceleration
If [ball hit floor] Then velocity=-velocity