Skip to content

Simple 2D Physics Engine Made with Python and Pygame.

License

Notifications You must be signed in to change notification settings

thentername/Python-Physics-Engine

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python 2D Physics Engine

This project is a simple 2D Physics Engine made with Python and Pygame.

It may be used to build a game later on, but for now the engine itself is still under development.

Physics Engine Running

Bodies

The engine is based off of bodies, shapes with a position and size that can be collided with.

Static Body VS Kinematic Body

The Static Body is the base class for all bodies. These bodies cannot move - they are in a fixed position. They have a material type, coefficient of friction and elastic collision energy return value.

The Kinematic Body inherits from the Static Body. These bodies can move - They have mass, velocity, acceleration, force, coefficient of friction, gravitational acceleration, air resistance and momentum transfer (with each other)

What Needs Work?

Currently, the momentum transfer is the feature that needs the most work. I can't seem to get it just right, fixing one issue usually causes another. Currently there is an issue with momentum being transferred to the object with lower energy. The applied force is in the opposite direction it should be. The magnitude is OK and the energy of the system is constant (besides friction), so the issue is purely directional.

Possible Future Features

Body Linking - Connect Kinematic Bodies together, share all kinematics. Treated as one body although may be made of several.

Rotational Motion - Center of Gravities of objects will allow for objects to rotate about them. Forces exerted on objects could cause some energy to be converted into rotational intertia of a kinematic body.

Ramps - Angled Static Bodies could interact with Kinematic bodies in interesting ways. Would require Kinematic bodies to be able to rotate. Force would be redirected upon impact with ramps, and frictional forces, normal forces and gravity would allow objects to accelerate down ramps.

Circular Collision Masks - Currently, collision masks of bodies are strictly rectangular. Circular masks would allow for more shapes to collide naturally.

About

Simple 2D Physics Engine Made with Python and Pygame.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%