Skip to content

sinemeister/cs50-final-solar-system-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solar System Simulation

Language Module

About

This project is developed as final project for Harvard University's CS50x Introduction to Computer Science Course, in August 2023.

It is a simple solar system simulation using Python's Pygame module, using Newton's second law of motion and Newton's law of universal gravitation with actual properties of the celestial bodies (only Sun and the planets).

Main idea of the project is inspired from Tech With Tim's Planet Simulation In Python - Tutorial video, which I have watched while I was trying to learn Pygame module before I enrolled in CS50x. I have added various features and applied it to the full scale of Solar System, using the same calculations, which are Newton's universal laws, as stated above.

You may find the video demo of the project here.

Features & Implementation

  • Distances are to scale, sizes are not to scale.
  • Calculations are done regarding Newton's laws with actual properties of the celestial bodies (Retrieved from NASA's fact sheets)
  • Dynamically shown celestial body information (by selecting desired celestial body with keyboard or hovering mouse at desired instance)
  • Dynamically colored indicators to show user that particular celestial body is selected
  • Dynamically updating orbital velocities and orbits (not to forget that orbital velocities and orbits are just fine approximations as moons and other celestial bodies are excluded in this simulation)
  • Ambient background music
  • Ability to pause/unpause the simulation
  • Ability to toggle on/off celestial body information (refer above)
  • Ability to mute/unmute the background music
  • Ability to quit the simulation any time by pressing Q as screen borders may be invisible depending user's display resolution
  • As Uranus' and Neptune's orbits may sometimes be out of the screen, an arrow indicating current position of the related planet is drawn for user to be able to keep track of the planet

Instructions on Usage

  • Make sure that all the files are in the same folder, e.g. project
  • Change your directory to the folder you keep the files, e.g. cd path\project
  • Install dependencies from the requirements.txt by executing pip install -r requirements.txt at your IDE's terminal (or command prompt). This will successfully install Pygame.
  • Start the program at your IDE's terminal (or command prompt) by executing python main.py

You may find the shortcuts useful:

Key Function
P Pause / Unpause simulation
M Mute / Unmute background music
I Toggle information off (when on)
Q Quit simulation
0-8 Display celestial body information (Sun to Neptune)
MOUSE 1 Toggle information off (when on)

Assets Used

All assets used in this project are copyright-free.

Misc

This project is developed solely by myself as a final project for Harvard University's CS50x Introduction to Computer Science Course. I have no commercial or monetary purposes. This is developed only for educational purposes.

Special thanks to Harvard University, Prof. David J. Malan, and the staff!

Contact

Many thanks for checking this project and trying the simulation. Your interest is very much appreciated.

Please do not hesitate to contact me if you have questions regarding the project or any other related subject. Mail me here.