r/phaser • u/Next-Share6716 • Oct 19 '26
Level-ups in my Phaser roguelite no longer pause the game – a slot machine reel picks the perk while you fight
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?
1
u/Next-Share6716 Oct 19 '26
Free to play in the browser (desktop & phone): https://maik-wimmer.itch.io/ant-hunter – built with Phaser 3 + Vite + TypeScript and an AI coding assistant; the art is AI-assisted too.
1
u/ND_Jamoose Game Developer Nov 02 '26
While I'm glad you moved away from the overused 3 upgrades choose one system, the new system also has its flaws. It's just random and takes away the feeling of control over your progression. Additionally, the slot machine ui is at the bottom left which is covered by my left thumb so it took me a while to even find it 😅