demo.mp4
A beautiful simulation of planetary orbital motion built with Python and Pygame. This project demonstrates gravitational interactions between celestial bodies using real physics principles.
- Realistic gravitational physics simulation
- Interactive celestial body creation
- Zoom functionality to observe orbital details
- Accurate position updates based on gravitational forces
- Customizable planetary properties (mass, radius, velocity, color)
- Python 3.10+
- Pygame 2.6.1
- Math module (built-in)
- Clone this repository
- Set up a virtual environment (optional but recommended):
python -m venv planetary_pygame_venv
source planetary_pygame_venv/Scripts/activate # On Windows use: planetary_pygame_venv\Scripts\activate- Install required packages:
pip install pygameRun the simulation using:
python src/main.py- Left Mouse Click: Create new celestial bodies
- Zoom: Toggle between normal and zoomed view
The simulation uses Newton's law of universal gravitation to calculate the forces between celestial bodies. Each body's position is updated based on:
- Gravitational constant (G = 6.67430e-11)
- Mass of interacting bodies
- Distance between bodies
- Current velocity vectors
The Body class handles all celestial body properties and physics calculations.
Feel free to fork this repository and submit pull requests for any improvements.
This project is licensed under the included license file.
- Pygame community for the excellent graphics library
- Physics equations based on Newton's laws of motion and gravitation