Skip to content

ti84plusprograms/Planetary-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Planetary Simulation ๐ŸŒŒ

An interactive solar system simulation built with Processing that displays all planets orbiting the sun with real-time data integration, realistic physics, and engaging visual effects.

Solar System Demo Status License

โšก Quick Start

  1. Download Processing from processing.org
  2. Clone this repo: git clone https://github.com/ti84plusprograms/Planetary-Simulation.git
  3. Open Solar_System_PlanetAPI/Solar_System_PlanetAPI.pde in Processing
  4. Install Sound Library: Tools โ†’ Add Tool โ†’ Libraries โ†’ Search "Sound" โ†’ Install
  5. Click Play โ–ถ๏ธ and explore the solar system!

๐Ÿ’ก Tip: Hover over planets to see detailed information, use the control buttons to pause or speed up!

๐Ÿš€ Features

Interactive Solar System

  • 9 Planets: All planets including Pluto with realistic orbital mechanics
  • Dynamic Orbits: Elliptical orbits with accurate relative speeds and distances
  • Real-time Animation: Smooth 60 FPS animation with planetary rotation

Live Data Integration

  • API Integration: Fetches real planetary data from API Ninjas
  • Real-time Updates: Mass, radius, orbital period, and temperature data
  • Accurate Information: Scientific data for educational purposes

Interactive Controls

  • โธ๏ธ Pause/Play: Stop and resume planetary motion
  • โฉ Fast Forward: Speed up the simulation for faster observation
  • ๐Ÿ–ฑ๏ธ Hover Information: Click on any planet to view detailed facts

Visual Effects

  • โœจ Starfield: Animated background stars
  • ๐Ÿชจ Asteroid Belt: Realistic asteroid belt between Mars and Jupiter
  • ๐ŸŽต Audio: Immersive background music
  • ๐Ÿ–ผ๏ธ Planet Textures: High-quality planet images

๐Ÿ“‹ Requirements

Software Requirements

  • Processing 3.x or later (Download here)
  • Java 8 or later
  • Internet connection for API data fetching
  • Screen Resolution: Minimum 1400x800 pixels (window size)
  • RAM: 512MB+ available memory recommended

Processing Libraries

  • Sound Library: Required for background audio
    • Install via: Tools โ†’ Add Tool โ†’ Libraries โ†’ Search "Sound" โ†’ Install
  • JSON Library: Included (uses org.json from included jar file)

๐Ÿ› ๏ธ Installation & Setup

1. Install Processing

Download and install Processing from processing.org

2. Clone the Repository

git clone https://github.com/ti84plusprograms/Planetary-Simulation.git
cd Planetary-Simulation

3. API Setup

The simulation uses API Ninjas for planetary data.

โš ๏ธ Security Note: The current code includes an API key. For production or public deployment, you should use your own API key.

To set up your own API key:

  1. Sign up at API Ninjas
  2. Get your free API key (1000 requests/month free)
  3. Replace the API key in Solar_System_PlanetAPI.pde:
String apiKey = "YOUR_API_KEY_HERE";

4. Install Required Libraries

  1. Open Processing IDE
  2. Go to Tools โ†’ Add Tool โ†’ Libraries
  3. Search for "Sound" and install the Sound library
  4. The JSON library (json-20210307.jar) is already included in the code/ folder

5. Run the Simulation

  1. File โ†’ Open โ†’ Navigate to Solar_System_PlanetAPI/Solar_System_PlanetAPI.pde
  2. Click the Play button (โ–ถ๏ธ) to run the simulation
  3. Enjoy exploring the solar system!

๐ŸŽฎ How to Use

Application Window

When you run the simulation, you'll see:

  • Central Sun: Bright yellow sun at the center
  • Orbiting Planets: All 9 planets following elliptical paths
  • Starry Background: Animated stars creating a space atmosphere
  • Asteroid Belt: Animated asteroids between Mars and Jupiter
  • Control Buttons: Two circular buttons (Pause/Play and Fast Forward)

Controls

Action Description
Mouse Hover Hover over any planet to see detailed information
Left Button (Pause/Play) Click to pause/resume planetary motion
Right Button (Fast Forward) Click to toggle 2x speed mode

Information Display

When hovering over a planet, a green information panel appears showing:

  • ๐ŸŒ Planet Mass: Mass relative to Earth
  • ๐Ÿ“ Planet Radius: Radius relative to Earth
  • ๐Ÿ”„ Revolution Time: Orbital period in days
  • ๐ŸŒก๏ธ Temperature: Surface temperature in Kelvin
  • ๐Ÿ“ Distance: Distance from the Sun

Visual Feedback

  • Green Highlight: Planets highlight when hovered
  • Button States: Buttons change color when activated
  • Smooth Animation: 60 FPS for fluid motion
  • Dynamic Text: Helpful instructions appear at the bottom

๐Ÿ—๏ธ Project Structure

Solar_System_PlanetAPI/
โ”œโ”€โ”€ Solar_System_PlanetAPI.pde  # Main sketch file
โ”œโ”€โ”€ planet.pde                  # Planet class definition
โ”œโ”€โ”€ asteroid.pde               # Asteroid belt implementation
โ”œโ”€โ”€ button.pde                 # UI controls
โ”œโ”€โ”€ star.pde                   # Background stars
โ”œโ”€โ”€ sound.mp3                  # Background audio
โ”œโ”€โ”€ code/
โ”‚   โ””โ”€โ”€ json-20210307.jar     # JSON parsing library
โ””โ”€โ”€ data/
    โ”œโ”€โ”€ mercury.png           # Planet textures
    โ”œโ”€โ”€ venus.png
    โ”œโ”€โ”€ earth.png
    โ”œโ”€โ”€ mars.png
    โ”œโ”€โ”€ jupiter.png
    โ”œโ”€โ”€ saturn.png
    โ”œโ”€โ”€ uranus.png
    โ”œโ”€โ”€ neptune.png
    โ”œโ”€โ”€ pluto.png
    โ”œโ”€โ”€ sun.png
    โ”œโ”€โ”€ asteroid.png
    โ”œโ”€โ”€ asteroid2.png
    โ””โ”€โ”€ sound.mp3            # Audio file

๐Ÿ”ง Technical Details

Planet Class

  • Orbital Mechanics: Elliptical orbits using trigonometric calculations
  • Visual Rendering: Image-based planets with scaling
  • Data Display: Dynamic fact rendering on hover

API Integration

  • HTTP Requests: RESTful API calls to fetch planetary data
  • JSON Parsing: Processes real-time astronomical data
  • Error Handling: Graceful fallbacks for network issues

Performance

  • 60 FPS: Smooth animation with optimized rendering
  • Memory Efficient: Smart resource management
  • Scalable: Easy to add more celestial bodies

๐Ÿ› Troubleshooting

Common Issues

๐Ÿ”‡ Audio Not Playing

  • Ensure sound.mp3 is in the sketch folder
  • Install Processing Sound library: Tools โ†’ Add Tool โ†’ Libraries โ†’ Search "Sound"
  • Check computer audio/volume settings
  • Try commenting out sound-related lines if issues persist

๐ŸŒ Planets Not Loading/Displaying

  • Check internet connection for API calls
  • Verify all image files are in the data/ folder
  • Ensure API key is valid (check console for error messages)
  • Try running without internet to use fallback data

๐ŸŒ Performance Issues

  • Close other applications to free up memory
  • Reduce frame rate: change frameRate(60); to frameRate(30);
  • Ensure Java has sufficient heap memory
  • Try running on a computer with better graphics capabilities

โŒ Compilation Errors

  • Verify Processing Sound library is installed
  • Check that json-20210307.jar is in the code/ folder
  • Ensure all .pde files are in the same folder
  • Try restarting Processing IDE

๐ŸŒ API Errors (Check console output)

  • HTTP 401: Invalid API key - get a new one from API Ninjas
  • HTTP 429: Rate limit exceeded - wait or upgrade API plan
  • HTTP timeout: Check internet connection
  • JSON parsing errors: API response format may have changed

๐Ÿ–ฑ๏ธ Controls Not Working

  • Ensure mouse is over the application window
  • Check that button coordinates are correct for your screen size
  • Try clicking directly on the pause/play buttons (circular areas)

๐ŸŽ“ Educational Value

This simulation is perfect for:

  • Astronomy Education: Learn about planetary characteristics
  • Physics Concepts: Understand orbital mechanics
  • Programming Skills: Study object-oriented design in Processing
  • API Integration: Learn how to work with external data sources

๐Ÿค Contributing

Contributions are welcome! Areas for improvement:

  • Add more celestial bodies (moons, comets)
  • Implement zoom and pan functionality
  • Add more detailed planetary information
  • Improve visual effects and animations
  • Add keyboard shortcuts
  • Implement save/load simulation states

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ™ Credits

๐Ÿ“ž Support

For questions or issues:

  1. Check the troubleshooting section above
  2. Open an issue on GitHub
  3. Review the Processing documentation

Made with โค๏ธ and Processing

Explore the cosmos from your computer! ๐Ÿš€

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors