This project is a simple 2D physics simulation implemented in Python using the Pygame library for objects visualization. It is designed to simulate basic physical phenomena such as collisions, gravity, and friction for various shapes like rectangles, circles, and convex polygons.
- Collision Detection: Implements Separating Axis Theorem (SAT) for polygon collision detection and handles circle collisions.
- Collision Response: Includes impulse-based collision response with support for both linear and rotational kinematics.
- Friction: Simulates both static and dynamic friction.
- Gravity: Applies gravitational forces to objects.
The project is structured into several modules:
- main.py: The entry point of the application, which sets up the Pygame window and contains the main game loop.
- body.py: Defines the
Polygon
,Rectangle
, andCircle
classes, which represent physical objects in the simulation. - space.py: Contains the
Space
class, which manages all bodies and simulates physics steps. - vector.py: Implements the
Vector2D
class for vector operations. - collision.py: Contains functions for collision detection and response.
This project was inspired by various resources on game development and physics simulations, including: