Under the hood
How Bottom Time works
No framework, no build step, no image or audio files. Four small ES modules you can read
with View Source. Built in one session by Zack Robinson, a TDI/SDI Divemaster, at Keystone
Analytics.
Deterministic fixed-step simulation
Physics runs at a fixed 60 Hz, separate from the display. Rendering interpolates between
the last two ticks, so a 120 Hz phone stays smooth without changing the physics. The
simulation module has no DOM access and never calls Math.random or
Math.sin during a tick, so the same seed and the same inputs replay
bit-for-bit.
Ghost replays in a few hundred bytes
Your input is stored only as the ticks where you pressed or released, base-36 delta
encoded. Because the simulation is deterministic, replaying that list against the same
seed rebuilds your best dive exactly. That ghost is what you race. The same property would
let a server verify a leaderboard score by re-simulating it rather than trusting the
client.
Boyle's law buoyancy
-
BCD volume is
gas / P, where P = 1 + depth / 10 atm. The
inflator adds gas at a fixed rate and the dump valve releases a fraction of what's
there.
-
The same input is sluggish at 30 m and twitchy at 3 m, just like real diving. The
runaway ascent near the surface is real too.
-
Wetsuit neoprene compresses with depth, so you get heavier the deeper you go. Each
breath shifts your lift by about half a litre.
A real decompression model
Nitrogen loading uses the first four compartments of the Buhlmann ZHL-16C model
(half-times of 5 to 18.5 minutes, compressed so a real minute passes in 1.5 seconds of
play), with a gradient factor of 70. The red line is the resulting ceiling: the shallowest
depth your tissues can tolerate right now. Gas use scales with ambient pressure, and so
does your score.
Light that behaves like water
Colour is attenuated per channel with Beer-Lambert absorption, so reds disappear first as
you descend. The camera strobe restores true colour for a moment when you photograph
something. Because depth maps to screen height, each material's tint is a single vertical
gradient per frame rather than per-pixel work.
Procedural reef, daily seed
The reef is generated in 40 m chunks from a hash of the seed and the chunk index, so any
chunk can be built in any order and dropped once it's behind you. Everyone who plays on
the same day gets the same Daily Dive.
Try it
-
Press
` (or tap with three fingers) for the debug overlay: frame times,
tick counts, a live state hash, and the tissue compartments filling up.
-
M mutes, P or Esc pauses. All sound is
synthesised in WebAudio.