![]() |
Ricochet (under construction)Newtonian Collision Simulator - and - Calculated Frame Rate DemoWritten in Dark Basic Professional - Version 1.054 |
![]() |
|
Newton's laws and 2D collisions
|
Ricochet is a program that applies Newton's laws
of motion to simulate collisions between spheres, and to calculate their
resulting trajectories. The program assumes perfectly elastic
spheres, and so the simulations will run indefinitely since there is no
loss of energy during the collisions. The varying mass of the spheres is
taken into account in the calculation, which means that a small sphere
will travel faster than a large sphere with the same kinetic energy. Ricochet is written in DarkBASIC, a programming language designed specifically for producing interactive computer games. One of the problems with games programming is that a program often runs at different speeds on different computers due to the varying maximum frame rate of the equipment/program. If the program is designed to run at a high frame rate then it will look slow on a weaker platform. Conversely, setting the frame rate lower means that a high-end platform is under utilised and looks jerky. In Ricochet,the fixed frame rate problem is avoided by letting the computer run flat out, then using a calculated frame rate to determine how far the objects have moved since the last time the screen was updated.This means that the simulation should run at a similar speed on different computers. It is possible to display the current frame rate and the milli-seconds per frame. When the simulations has more spheres on the screen then it runs at a slower frame rate. Also, by toggling the graphics between sprites and circles, it is clear that sprites run faster as they use the processing capacity of the graphics card, while circles have to be drawn by the computer which pushes the frame rate down. However, changing the "speed" of the simulation does not affect the frame rate. |
Copyright © 2005 - David Greenwood