Philip J. Uren

Simulating Physics in PyGame

This script is an effort to apply some simple physics simulation in PyGame. Please credit the source if you make use of this code.


Version 0.1 (15th July 2009)

An object (a square sprite) is created and placed into a running PyGame environment. The object behaves as if it is under the influence of gravity (somewhat like a tennis ball).

Download this script.


Version 0.2 (25th July, 2009)

Proper collision detection is added, including path based collisions. You can use the mouse to pick the object up and move it around the environment. The simulated object moves in both the vertical and horizontal axes. Collisions are completely elastic in this version. There is a known bug with lost velocity on a small number of collisions

Download this script.

Version 0.3 (2nd October 2009)

This version represents a major redesign of code, with several major bugs rectified. Multiple dynamic sprites are now modeled with proper collisions between them. The Internal code documentation has been improved and code has been seperated into library code and application code. There is a known major bug with dragging sprites with the left mouse button (to be corrected in the next release)

Download this library and sample application

 

Creative Commons License
All work on this page by Philip Uren is licensed under a
Creative Commons Attribution-Non-Commercial-Share Alike 3.0 United States License.
www.philipuren.com.
Site last updated 17th May 2014