Skip to content

AkiRusProd/python-2d-physics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 

Repository files navigation

2D Physics Engine

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.

Features

  • 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.

Structure

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, and Circle 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.

Acknowledgments

This project was inspired by various resources on game development and physics simulations, including:

Releases

No releases published

Packages

No packages published

Languages