How Gravity Wars works
Gravity Wars is a free game that plays in your browser. Two ships take turns firing missiles across a universe of planets, stars and black holes, and gravity bends every shot. The physics is real enough to learn from: orbits precess near black holes, light bends around them, and a missile's clock runs slow as it falls in. This page explains what the game simulates and gives you universes to try.
PLAY FREE WATCH THE TRAILER
How to play
- Aim. Drag from anywhere: the direction from your ship sets the angle θ, the distance sets the speed v₀. You can also type exact numbers, as in the 1989 original.
- Fire with the FIRE button, Space or Enter. The missile flies until it hits something, falls into a black hole or escapes.
- Correct. Your last shot stays on screen as a trail. Read how it bent, adjust, and fire again. The first pilot to hit the other ship wins the round.
Play against a friend on the same device, or against a CPU pilot at three skill levels (cadet, navigator, astrophysicist) that plans its shots with the same physics you're fighting. On a phone, hold it sideways; Add to Home Screen installs it as an app that also plays offline.
Planets: Newton's gravity
Planets pull with Newton's inverse-square law. Each one's mass grows with its density and size, and, as in the original game, colour tells you density: red planets are the lightest (ρ = 1), green heavier (ρ = 1.5), blue the heaviest (ρ = 2). A small blue planet can bend a shot more than a big red one.
a = −GM / r²A missile doesn't stop at the edge of the screen. It keeps flying until it hits something or reaches escape velocity, so a shot can leave, swing round and come back. Press O during a flight to see its osculating orbit: the ellipse or hyperbola it would follow if only the nearest body existed, with its eccentricity and the velocity and acceleration vectors.
Black holes: Einstein's correction
Near a black hole, Newton isn't enough. The game adds the leading correction from general relativity for an orbit around a non-rotating (Schwarzschild) black hole:
a = −GM/r² · (1 + 3L²/c²r²)Here L is the missile's angular momentum per unit mass. The extra term is tiny far away and grows fast close in, and it changes how orbits behave:
- Orbits precess. Instead of closing into an ellipse, an orbit swings round a little further each lap and traces a rosette. Mercury does the same around the Sun, very slowly; here you can watch it in a few seconds.
- The photon sphere at 1.5 Schwarzschild radii (rs) is where even light can circle the hole. A missile skimming it can loop round several times before flying off.
- The ISCO (innermost stable circular orbit) is at 3 rs. Inside it no orbit is stable, and a missile that drifts in spirals down.
- The horizon is at rs. Cross it and the missile is gone.
To make relativity visible, light is slow in this universe: c is only 900 units per second, and missiles launch at up to 0.67c. So the corrections show up in every match, not only in physics textbooks.
Ray-traced lensing
Every pixel near a black hole is traced along a bent light path. That's why you see the far side of the accretion disk lifted over the black shadow, a thin photon ring at the shadow's edge, and an Einstein ring of whatever is behind the hole, including stars, planets and your own missile trails.
The disk glows with the colour of its temperature, hotter towards the middle (T ∝ r−3/4). Its gas orbits at up to about 0.7c, so the side moving towards you is Doppler-boosted and blazes, while the side moving away dims.
Time dilation
The flight readout (I) shows two clocks: coordinate time t, measured far away, and the missile's proper time τ, its own clock. Deep in a gravity well or at high speed, τ runs slow:
dτ/dt ≈ √(1 − 2Φ/c² − v²/c²)The soundtrack hears it too: the missile's voice drops as its clock slows near a horizon, and the whole score sinks with it.
Open universe 95, start a two-pilot match and give AURORA θ = 42°, v₀ = 3. The missile drops toward the black hole, loops it several times near the photon sphere, then flies out into a lava world. Press O and I first to watch its orbit and its clock.
Stars: five kinds, five kinds of physics
- Main-sequence stars
- From 3,300 K red dwarfs to 9,500 K blue-white stars, each glowing with the black-body colour of its temperature and lighting the planets around it. Their light pushes on the missile (radiation pressure), so a star pulls with only part of its mass, and hotter stars push harder.
- White dwarfs
- A star's mass crushed to the size of a small moon: blinding, with enormous surface gravity. They bend light a little and make close orbits precess, but unlike a black hole they have a surface to hit.
- Red giants
- Huge and thin. The outer envelope drags on the missile, more strongly deeper in, so a shot can pass through, slow down or spiral in. Only the dense core destroys it.
- Pulsars
- Spinning neutron stars that sweep two lighthouse beams around. A beam shoves the missile outward, and since the beams keep turning during the flight, the same aim lands differently depending on when you fire. Listen for the tick of each sweep.
- Binary stars
- Two stars orbiting their shared centre of mass, by Kepler's law ω = √(G(M₁+M₂)/a³), slowed to stay playable. The gravity field moves while the missile flies, so timing matters as much as aim.
A pulsar, a binary, a red giant and a white dwarf, each alone at the centre of its universe. On the title screen, Stars: chaos mixes them all.
The spacetime sheet (3D lite)
Press V and flat space tilts up into a sheet, with every body sitting in a well as deep as its gravitational potential (Φ = GM/r, compressed to fit on screen). It's the textbook picture of gravity, and it makes a universe readable at a glance: deep wells are where shots bend most.
It's a picture, not the cause. Missiles fly by the same equations in both views, and a marble rolling on a real rubber sheet wouldn't quite follow them. A black hole's well shows gravitational time dilation, which matches GM/r far away but plunges straight down at the horizon.
Under the hood
- Integrator. Flights are stepped with an adaptive leapfrog (kick-drift-kick). It's symplectic, so orbits don't slowly spiral in or out from numerical error; energy is conserved to about one part in 1014 in the game's own checks.
- Overlays. G draws the spacetime grid, P the equipotentials (contours of Φ), O the osculating orbit and T a short or full trajectory preview for practice.
- Destroyed ships send out a gravitational-wave ripple (a quadrupole pattern, cos 2φ) and a rising chirp, f ∝ (tc − t)−3/8, like the black hole mergers LIGO hears.
- The music is math. Each planet hums a note of the harmonic series, heavier bodies lower, with a tremolo at its orbital frequency √(GM/R³). The melody is the Fibonacci sequence mod 7, which repeats every 16 notes (its Pisano period), over Euclidean rhythms. Every equipotential the missile falls through rings a note.
- Plain web code. JavaScript and WebGL, no frameworks and no build step. It runs in Chrome, Edge and Firefox on computers and phones.
For teachers and students
Gravity Wars can make orbital mechanics something you can poke at. Some things to try in a lesson:
- Turn on the full trajectory preview (T) and change v₀ in small steps: watch a shot go from crashing, to orbiting, to escaping.
- Compare a red and a blue planet of the same size: same radius, different density, different pull.
- Put a missile in orbit around a black hole and watch the rosette form. Then try the same near a planet, where the orbit nearly closes.
- Watch t and τ in the flight readout as a missile dives toward a horizon.
The game is free and needs no account or install; it runs from a link.
The 1989 original
Gravity Wars is a remake of Gravity Wars (1989) by Sohrab Ismail-Beigi, a DOS game he released to the public domain, itself a port of an Amiga original. This version keeps its rules: aim by angle and speed, planet colour is density, missiles fly off screen until they escape, and the original victory tune plays when you win. Everything else, from the black holes to the relativity, is new.
Questions
- Is it free?
- Yes. It plays free at gravwars.com and on itch.io, with no ads and no account.
- Does it work on phones?
- Yes, held sideways. Android phones in Chrome and Firefox are tested; iPhones and Safari aren't yet, so tell us how it goes.
- Can I play against a friend?
- Yes, taking turns on the same device. Online play isn't available yet.
- Found a bug, or have an idea?
- Press ! (bug or feedback) in the game, on the title screen or during a match.