A new physics simulation game on gravity!




Gravity Sandbox is a 2D real-time n-body gravitational simulation sandbox built using Java and Swing, focusing on minimal UI and high-precision motion physics.
The game allows users to create self-evolving systems of celestial bodies and observe stable or decaying orbital structures through emergent behavior.
Core Simulation
| System | Description |
|---|---|
| Gravity Model | Newtonian point-mass attraction using inverse square law |
| Integration | Continuous real-time step-based numerical integration |
| Interaction | Dynamic body creation, deletion, and repositioning |
| Stability | Self-stabilizing orbits emerge naturally based on velocity, mass, and radius |
| Rendering | Lightweight particle-based glow effects with motion trails |
Interaction & Modes
The simulation operates in multiple tool modes, toggleable by keyboard shortcuts:
| Mode | Function |
|---|---|
| 1 | Add stars/planets with mass & initial velocity |
| 2 | Add and drag existing bodies to modify orbits |
| 3 | Create white holes (negative mass / repulsive gravity) |
| 4 | Delete bodies from the scene |
These modes allow the user to repeatedly edit and reshape the gravitational system during runtime without resetting the simulation.
Performance & Architecture
| Aspect | Details |
|---|---|
| Language | Java |
| UI Framework | Swing (lightweight, custom rendering) |
| Assets | External raster glow-based sprites and trail rendering |
| Physics Tick | Fixed timestep loop tied to repaint cycle |
| Input | Mouse drag for placement and trajectory initialization |
| Memory Usage | Minimal (no heavy engines or GPU APIs) |
| JDK | Distributed with custom minimal runtime (jlink) |
Visual Rendering Pipeline
-
Bodies rendered with layered soft glow effect to simulate stellar luminosity
-
Motion trails generated by storing past path history (short-lived)
-
Black cosmic background for contrast and realism
-
No UI clutter — simulation is the visual focus
Design Philosophy
The game does not rely on predefined scripted systems.
Every orbital path, collision, decay, or ejection is a natural consequence of real-time gravitational math.
You design systems, not animations.
🗂 Planned / Extensible Systems (Future-ready)
-
Body-to-body collisions (merge / fragmentation)
-
Adjustable gravitational constants
-
Save/load system states
-
Procedural galaxy generation
-
UI sliders for live parameter tuning
Files
Get Gravity Sandbox
Gravity Sandbox
Experiment with gravity in a 2D sandbox. Add planets, stars, and white holes — launch them and collide them.
| Status | Released |
| Author | aNoobdev |
| Genre | Simulation, Strategy |
| Tags | 2D, Gravity, Sandbox, Visualization |
| Languages | English |
Leave a comment
Log in with itch.io to leave a comment.