Trevin-Small / Python-Physics-Engine

A simple 2D Physics Engine Made with Python and Pygame.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NOTICE: This project is old and no longer being worked on!

Much of the code is poorly written, optimized, and generally messy (😅 I was learning a LOT at this point...)

I may return to this project at some point (and start over lol) but for now, the project is archived.




Python Physics Engine (2D)

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 Comes Next?

The collision system needs to be completely rewritten. Overtime it has become spaghetti-code that is increasinlgy hard to debug, and the way it is structured could be improved. Currently, collisions are a method of the bodies themselves, which was a poor choice. Instead, body interactions/collisions should be its own class, taking in two bodies as parameters and dealing with both of them at synchronously in an organized fashion.

Possible Future Features

Body Linking

Rotational Motion

Ramps

Circular Collision Masks

About

A simple 2D Physics Engine Made with Python and Pygame.

License:MIT License


Languages

Language:Python 100.0%