This is a 2D physics simulation game built using Python and Pygame. The simulation features multiple entities that move and interact with each other based on realistic physics, including inelastic collisions, friction, gravity, acceleration, and user-controlled movement.
-
Entity Physics: Each entity has mass, size, position, and velocity.
-
Inelastic Collisions: Entities collide realistically with adjustable elasticity.
-
Gravity and Friction: Entities experience gravity and friction effects, making the simulation closer to real-world physics.
-
Acceleration and Speed Change Switch: Entities can accelerate or decelerate, and users can adjust speed dynamically.
-
User Interaction:
- Click to select/deselect entities.
- Arrow keys to control the selected entity.
- Multiple entities can be added and controlled sequentially.
-
Collision Handling: All entity pairs are checked for collisions every frame.
-
Visual Feedback: The currently selected entity is highlighted with a yellow border.
-
Clone the repository:
git clone <repository_url> cd <repository_folder>
-
Install Pygame if not already installed:
pip install pygame
Run the main demo script:
python renderer_demo.py- Mouse Click: Select or deselect an entity.
- Arrow Keys: Move the selected entity.
- Number Keys (1-9): Quickly select an entity by index.
engine/
│ entity.py # Entity class with physics properties
│ physics.py # Physics engine for collisions, gravity, friction
│ renderer.py # Renderer class for display and user input
renderer_demo.py # Demo script to run the simulation
- Add more complex physics like rotational inertia.
- Expand to multi-axis movement.
- Integrate particle effects and visual enhancements.
- Transition to a roguelike dungeon game with procedural generation.
This project is licensed under the MIT License – see the LICENSE file for details.
Teja Sai Eswar Reddy
Student, IIT Kharagpur – ECE Department (3rd Year)
Project: 2D Physics Simulation Game