billv wrote:Thank God I'm not alone!. For several years I was obsessed with how to make a bouncing ball
in FS. I always failed, because you need to create some sort of physics engine.
A physics engine is my number one dream for FS, opening the door for some serious Game development.
I use software called "Fusion", is a perfect example of how a physics engine in FS should behave...with shitloads
of user control options. Right now I'm be happy with a box with a bouncing ball inside...any Guru's out there
looking for a challenge??
Thanks
I did this once, at it isn't very difficult to be honest. First you set up gravity. It means a direction where the circle is pulled to contantly. For example to the bottom. Let's just set our gravity to 4 pixels per second.
You loop-call a method that applies 4 pixels per second (via deltatime) to the direction "bottom".
-method gravity
dt = t - time
t = time
circleforcebottom += 4 * dt
end method
With this alone, when placing a circle at the top of the screen, it will gain velocity and move gradually faster and faster towards the bottom.
Combine this with a "ground": an immovable object that will decelerate motion to zero, if no bouncing force exists. If it exists, you add the bouncing force to the circle, and it will accelerate towards the top, until the gravity moves it down again. Friction is defining the material of the "ground". When the circle moves on the ground, this is the amount by which it will slow down - it loses momentum. And lastly: angle of incident = angle of emergence. If the circle hits the "ground" at 30°, it will leave it at mirrored 30°. The curve it will take builds automatically from the applied gravity force.
And so on. Really, it isn't very difficult, once you start it. It is just very time consuming.