Building a space survivor roguelite in the browser with custom HDR WebGL2 and orbiting planets

By Ant Games (@antgames.bsky.social)
Published:

STAR AGAINST THE DARK: a glowing star with worlds in orbit and a golden beam through it, in a dark starfield with small pink enemies around it

Most browser survivor-like games either draw flat 2D sprites on Canvas 2D or pull in a heavy 3D engine just to render glowing circles in space. When we built STAR AGAINST THE DARK — a free space survivor roguelite in the browser where you play as a newborn star and your orbiting worlds are your weapons — we wanted deep-space lighting, procedural spinning planets, gravitational lensing, and hundreds of enemies at 60 FPS with zero engine framework overhead.

This post walks through two halves of how the game actually works under the hood: the custom linear-HDR WebGL2 renderer we wrote in TypeScript, and the lagged orbital physics and alignment-beam math that make orbiting planets feel like active weapons instead of passive rings.

Watch the 16:9 gameplay trailer: STAR AGAINST THE DARK Official Trailer on YouTube

Why orbiting worlds need lagged physics to feel like weapons

In a classic survivor-like, rotating shields or orbitals spin at a fixed radius around the player. You walk near enemies and wait for the ring to clip them. That works for a secondary passive, but when orbiting planets are your primary weapon, a rigid ring feels sluggish.

In STAR AGAINST THE DARK, every world orbits a lagged center (cx, cy) that chases the star with exponential inertia rather than snapping to (player.x, player.y):

const k = 1 - Math.exp(-dt / Math.max(0.02, b.def.lag));
b.cx += (p.x - b.cx) * k;
b.cy += (p.y - b.cy) * k;

We clamp that lag distance to 190 world units so planets never get left behind off-screen. Every tick, the body computes its actual world velocity from its previous position and scales contact damage through a speed-based "whip" multiplier (clamped between 0.5× and 3.5× relative to a reference orbital speed).

That single change turns movement into melee combat:

Measuring alignments on a circle without wrap-around bugs

The game's signature payoff is lining worlds up through the star:

Because alignment is an undirected line through the star (a planet at 1° and a planet at 181° are collinear), naive angle averaging breaks at the 0° / 180° boundary. We reduce every planet's bearing from the star modulo π, then compute the mean direction on the doubled-angle circle:

sx += Math.cos(2 * phi[j]);
sy += Math.sin(2 * phi[j]);
// ...
return modPi(Math.atan2(sy, sx) * 0.5);

Because alignment is measured from the star's live position while the orbits lag behind, moving and surging deliberately pulls worlds into temporary collinear bands. A player running Sirius (the Binary Star, which starts with three worlds, zero star weapons, 40% wider alignment tolerance, and +30% alignment damage) plays almost entirely around baiting swarms into the beam lane and erasing bullet walls on cue.

A zero-framework linear-HDR WebGL2 pipeline

Space bullet-heaven games live or die on visual readability: you need glowing lasers, pulsing stars, and dense enemy waves without turning the screen into muddy white noise. We skipped third-party renderers and built a focused WebGL2 pipeline in src/render/gl/ with seven shader stages:

How the content scales across five epochs

A 20-to-30-minute run crosses five distinct epochs — First Light, The Gathering, The Long Night, The Devouring, and Heat Death — each shifting the nebula palette, dimming the background starfield as the Dark closes in, raising the spawn budget, and ending in a multi-phase boss (Maw, Arachne, Twins, Ouroboros, and Entropy).

Around that core loop sit:

Try it in your browser

If you want to see how lagged orbital physics, syzygy beams, and a custom HDR WebGL2 renderer feel in a real run, play STAR AGAINST THE DARK right in your browser. It is free, no pay to win, no sign-up, and plays in the browser with nothing to install.

A note on how it was made: the game was built with heavy AI assistance (including Claude Code), directed, tuned, and verified by our team at Ant Games, and this article was also drafted with AI assistance.