Eclipse Hunter: Solar System Simulator

Inspiration

I've always been fascinated by space exploration and how planets move through the cosmos. I wanted to create something that brings the solar system to life and shows one of nature's most amazing events - a solar eclipse! I thought it would be cool to build a simulator where you can actually see when eclipses happen.

What It Does

Eclipse Hunter is an interactive solar system simulator that shows:

  • Four planets (Mercury, Venus, Earth, and Mars) orbiting the Sun
  • Earth's moon orbiting around Earth
  • Real-time eclipse detection - when the moon passes between the Sun and Earth, the program alerts you with a big "ECLIPSE!" message
  • Speed controls so you can fast-forward through time

How I Built It

I used Python and Pygame to create the graphics and animations. Here's what I did:

  1. Created Planet and Moon classes - These are like blueprints that define how celestial bodies behave
  2. Used trigonometry - I used sin() and cos() functions to calculate circular orbits. The math looks like this:
    • $x = distance \times \cos(\theta)$
    • $y = distance \times \sin(\theta)$

Where $\theta$ is the angle that increases over time to create smooth orbits.

  1. Built an eclipse detector - I calculated the distances between the Sun, Earth, and Moon to check if they align
  2. Added interactive controls - Users can pause, speed up, or slow down time

What I Learned

  • How to use object-oriented programming to organize my code
  • How trigonometry is used in real programming (not just math class!)
  • How to create game loops that run 60 times per second
  • How to detect collisions and alignments using distance calculations
  • How to make user interfaces with keyboard controls

Challenges I Faced

  • Getting the orbits smooth - At first, the planets were jumpy. I learned I needed to update their positions in small steps 60 times per second.
  • Eclipse detection - Figuring out the math to check if three objects are aligned in space was tricky. I had to calculate distances and compare them.
  • Making it interactive - Learning how Pygame handles keyboard input took some experimentation.

What's Next

I want to add more features like:

  • Saturn with its beautiful rings
  • More moons for other planets
  • A counter showing how many eclipses have occurred
  • Sound effects when eclipses happen ```

Built With

Share this project:

Updates

Submission history