Every level-up in ANT HUNTER (small browser roguelite, gecko knight vs. ant colony) used to pause the game and show three perk cards. In a horde that happened every few seconds and killed the flow, so now a slot machine reel spins on the left and picks a random perk while you keep fighting.
How it works:
- The reel is plain DOM over the canvas, not a Phaser object: a strip of 15 emoji cells (14 random, the last one is the winner), moved with a single Web Animations API call – translateY over 1.15 s, easing cubic-bezier(0.12, 0.8, 0.25, 1), fill: forwards
- The cell height is measured at runtime: CSS makes it 64 px on desktop and 52 px on phones, and a hard-coded value stopped the reel between two symbols on mobile
- Tick sounds are scheduled at t = 1 − ∛(1 − k/14) of the spin, so they slow down with the reel and rise in pitch
- The perk only applies when the reel lands. Several level-ups queue up and spin one after another, with a shorter hold while more are waiting
- With prefers-reduced-motion the reel just jumps to the result
Since nothing needs a click, it works the same with touch. Has anyone synced sounds to a CSS easing curve more precisely than with this cube-root shortcut?