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.
- Download Processing from processing.org
- Clone this repo:
git clone https://github.com/ti84plusprograms/Planetary-Simulation.git - Open
Solar_System_PlanetAPI/Solar_System_PlanetAPI.pdein Processing - Install Sound Library: Tools โ Add Tool โ Libraries โ Search "Sound" โ Install
- Click Play
โถ๏ธ and explore the solar system!
๐ก Tip: Hover over planets to see detailed information, use the control buttons to pause or speed up!
- 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
- 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
- โธ๏ธ 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
- โจ Starfield: Animated background stars
- ๐ชจ Asteroid Belt: Realistic asteroid belt between Mars and Jupiter
- ๐ต Audio: Immersive background music
- ๐ผ๏ธ Planet Textures: High-quality planet images
- 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
- Sound Library: Required for background audio
- Install via: Tools โ Add Tool โ Libraries โ Search "Sound" โ Install
- JSON Library: Included (uses
org.jsonfrom included jar file)
Download and install Processing from processing.org
git clone https://github.com/ti84plusprograms/Planetary-Simulation.git
cd Planetary-SimulationThe 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:
- Sign up at API Ninjas
- Get your free API key (1000 requests/month free)
- Replace the API key in
Solar_System_PlanetAPI.pde:
String apiKey = "YOUR_API_KEY_HERE";- Open Processing IDE
- Go to Tools โ Add Tool โ Libraries
- Search for "Sound" and install the Sound library
- The JSON library (
json-20210307.jar) is already included in thecode/folder
- File โ Open โ Navigate to
Solar_System_PlanetAPI/Solar_System_PlanetAPI.pde - Click the Play button (
โถ๏ธ ) to run the simulation - Enjoy exploring the solar system!
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)
| 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 |
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
- 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
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
- Orbital Mechanics: Elliptical orbits using trigonometric calculations
- Visual Rendering: Image-based planets with scaling
- Data Display: Dynamic fact rendering on hover
- HTTP Requests: RESTful API calls to fetch planetary data
- JSON Parsing: Processes real-time astronomical data
- Error Handling: Graceful fallbacks for network issues
- 60 FPS: Smooth animation with optimized rendering
- Memory Efficient: Smart resource management
- Scalable: Easy to add more celestial bodies
๐ Audio Not Playing
- Ensure
sound.mp3is 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);toframeRate(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.jaris in thecode/folder - Ensure all
.pdefiles 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 NinjasHTTP 429: Rate limit exceeded - wait or upgrade API planHTTP 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)
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
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
This project is open source and available under the MIT License.
- Planet Data: API Ninjas Planets API
- Planet Images: NASA/Public Domain
- Background Music: Included audio track
- Processing Framework: Processing Foundation
For questions or issues:
- Check the troubleshooting section above
- Open an issue on GitHub
- Review the Processing documentation
Made with โค๏ธ and Processing
Explore the cosmos from your computer! ๐