Skip to content

This repository hosts a fun Python Project which uses Pygame module to create beautiful visuals of orbital motion of planets.

License

Notifications You must be signed in to change notification settings

tvnisxq/Planetary-Orbits-using-Pygame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Planetary Orbits Using Pygame

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.

Features

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

Requirements

  • Python 3.10+
  • Pygame 2.6.1
  • Math module (built-in)

Installation

  1. Clone this repository
  2. 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
  1. Install required packages:
pip install pygame

Usage

Run the simulation using:

python src/main.py

Controls

  • Left Mouse Click: Create new celestial bodies
  • Zoom: Toggle between normal and zoomed view

How It Works

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.

Contributing

Feel free to fork this repository and submit pull requests for any improvements.

License

This project is licensed under the included license file.

Acknowledgments

  • Pygame community for the excellent graphics library
  • Physics equations based on Newton's laws of motion and gravitation

About

This repository hosts a fun Python Project which uses Pygame module to create beautiful visuals of orbital motion of planets.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages