000000
SPACETIME

Rendering

←/→ turn · ↑ thrust · space fire
V view · P pause · M mute · wheel zoom

◀
▶
▲
●

RELATIVISTIC ASTEROIDS

Asteroids has always been played on a torus, with a speed of light that is effectively infinite. Here the speed of light is slow enough to matter: by default light takes 2.5 seconds to cross the screen. Everything else follows from taking that seriously.

Every pixel is an event

Each frame, a shader asks for every pixel which point in spacetime am I looking at? It then looks up what was there, then. The game records a snapshot of the universe every 1/120 s of torus time, which is about 17 seconds of history. In the default view the pixel at distance r from the ship lies on the ship's past light cone, at ship-frame time −r/c. A Lorentz boost carries that event into the torus frame, where the history lives. Aberration, light delay and the apparent shapes of moving things all come out of that one transformation. None of it is special-cased.

That default view is called Seen. The other two views are not about light at all. Each asks where is everything right now? and gets a different answer, because "now" depends on who is asking. Ship's now is the ship's plane of simultaneity, which is what the ship would measure with rulers and synchronized clocks rather than see. The torus is contracted along your motion, and parts of the world that are "now" for the ship are still in the torus's future, so they are extrapolated. Torus's now is the classic screen, sliced by the clocks of the torus itself, with every body contracted along its own motion. The effect is small for asteroids at a few tenths of c but obvious for the ship at full speed. Flipping between the two "nows" shows the relativity of simultaneity directly.

The torus has a preferred frame

Special relativity says no inertial frame is special, but a compact space quietly picks one out. That frame is the one in which the left/right and top/bottom edges are glued together at the same instant. This is how the twin paradox resolves on a torus. The history is stored in this frame. Because a pixel's event is reduced modulo the torus after the boost, wrapping costs nothing: light that has gone around the universe shows you older images of the asteroids, and of yourself.

Lorentz contraction in 2D

A body is drawn by testing whether the pixel's event lies inside its world-tube. The offset from the body's center is stretched by γ along its velocity, which undoes the contraction and returns it to the body's rest frame, and is then tested against the rest-frame outline. In the torus frame this gives contraction. In the other views the boost adds the shear from simultaneity and light delay. Your own ship is always drawn at its true rest shape, as it should be.

Motion

Bodies carry proper velocity w = γv, so nothing can reach c. Thrust is a constant proper acceleration of 0.6c per second of ship time. The engine limit slider cuts the engine off at the chosen speed, but you can still steer. Bullets leave at 0.8c relative to the ship using relativistic velocity addition, and they live 1.1 s of their own proper time. By default the game runs on your ship's clock, so at γ = 7 the universe runs seven times faster around you.

Color

Everything glows like a 6500 K blackbody, which gives the white vectors of the original. A Doppler shifted blackbody is exactly another blackbody at D·T, in any number of dimensions, so color shift and relativistic beaming come from a single lookup of a Planck spectrum through the CIE color matching functions. Brightness is tone-mapped like an HDR camera spanning 2.5 decades, otherwise anything behind you at high speed would simply vanish into the infrared. D combines the observer's motion, the emitter's motion, and the gravitational redshift √(g₀₀(emitter)/g₀₀(observer)).

One consequence caught out the first version. Your bolts always leave at 0.8c relative to you, however fast you are going, so you always see them receding with D = 1/3. An ordinary 9000 K bolt looked like a dim 3000 K ember and effectively vanished. They are now 20,000 K plasma. That looks blue in their own frame and white by the time the light gets back to you.

Gravity in two dimensions

With one fewer spatial dimension, Gauss's law gives g = GM/r, a logarithmic potential with ∇²Φ = 2πGρ. On a closed surface the total flux through the whole space has to be zero, so a net mass has nowhere to send its field lines. Only ρ − ⟨ρ⟩ can gravitate. The torus enforces the "Jeans swindle" as a matter of topology. The potential lives on a 64×64 grid. By default it obeys a damped wave equation, so changes to the field spread outward at c. The alternative is an instantaneous FFT solve, which is instantaneous only in the torus frame.

A logarithmic potential never levels off, so on an infinite plane the escape velocity from any mass would be infinite and everything would be bound. The torus caps the depth of every well, but fragments of a shattered rock often stay bound to each other anyway. They orbit and pass through one another.

The field is used in a weak-field, general-relativity-flavored way: clocks run slow in wells (dτ/dt = √(1+2Φ/c²)/γ), light is redshifted climbing out, and each pixel's photon is marched back through the field. It bends by twice the Newtonian amount and picks up a Shapiro delay. Moving bodies bend with a factor of (1+β²), which matches light as β → 1. One curiosity: in 2D the bending angle of a point mass does not depend on the impact parameter, which is essentially a conical deficit.

That points at a caveat. True 2+1 dimensional general relativity has no local gravity at all. Point masses do not attract. They cut a wedge out of space and leave a cone. The gravity here is therefore a toy: 2D Newtonian dynamics dressed in the weak-field metric. A conical-spacetime mode would be the honest next step.

Other approximations

Before t = 0 there is nothing, only the dim glow of the game's own big bang. Early in the game you can watch the observable universe grow at c.

← Topological Asteroids