Click anywhere to spawn a planet.
Watch them orbit and merge.
In our simulation, planets are attracted to a central star via gravitational force. In reality, gravity follows Newton's law: F = G(māmā)/r², where the force between two objects depends on their masses and the square of the distance between them.
Our simplified model only accounts for star-planet attraction (not planet-planet), making it more stable and predictable than real n-body physics.
In the early universe, planets formed through accretionāsmall particles colliding and sticking together. Our collision system mimics this: when two planets collide, the larger absorbs the smaller, growing in both size and mass.
The particle explosions you see represent ejected material during these cosmic impacts, similar to how Earth's moon likely formed from debris after a massive collision.
When you click "Reset," our central star collapses into a black holeāan ultra-dense region where gravity is so strong that not even light can escape. The "event horizon" (the point of no return) is represented by the dark sphere that grows.
After consuming nearby matter, the black hole implodes in our simulation, triggering a "rebirth" similar to how stellar nurseries form from the remnants of dead stars.
Canvas API: All rendering happens on an HTML5 canvas using 2D context drawing methods.
Physics Loop: Each frame calculates gravitational acceleration (a = F/m), updates velocities, and moves objects accordingly.
Collision Detection: Uses simple distance checks: if distance between centers < sum of radii, objects collide.
Particle Systems: Explosions spawn particles with random velocities that decay over time for visual flair.
The actual universe operates on scales both vastly larger and smaller than what we can simulate. From quantum foam at the Planck scale (10ā»Ā³āµ m) to the observable universe spanning 93 billion light-years, reality is far stranger and more wonderful than any simulation.
General relativity shows us that massive objects don't just exert forceāthey curve spacetime itself. Quantum mechanics reveals that at tiny scales, particles exist in superposition until observed. These phenomena are impossible to capture in a simple JavaScript canvas!