I'll build a tilt marble labyrinth game with HTML5 Canvas, physics, and a nicely designed wooden board. Let me start by updating the title and creating the game.
Now I'll build the main game. I'll create a src/labyrinth/ directory with the maze data and physics separated for clarity, then wire it all together in App.tsx.
Now the main App component with rendering, tilt controls, and game loop:
Now let me build the project to check for errors:
Build succeeded. Let me quickly verify my checkpoint sequence makes sense with the maze layout by tracing the intended path once more:
Let me tweak the maze slightly – the final corridor combo of two holes + a stub wall + goal is too brutal for a "sample maze". I'll remove one hole for better playability:
Build succeeds. Here's what I built:
🪵 Tilt Labyrinth
Architecture
src/labyrinth/maze.ts — Sample maze data: 9×9 grid, snaking corridors with border walls, interior walls, short stub-wall chicanes, 10 holes, and 4 checkpoints leading to a checkered goal.
src/labyrinth/physics.ts — Circle-vs-rectangle collision resolution (closest-point projection + normal reflection with bounce), hole "suck-in" detection, checkpoint & goal checks.
src/App.tsx — Canvas renderer + game loop + pointer/touch input + React HUD.
Physics & controls
- Cursor/finger position relative to the board's center becomes the tilt vector (dead-zone in the middle for a "flat" rest). Full tilt at the edges.
- Tilt applies acceleration to the marble; velocity is dampened each frame (rolling friction) and capped at a max speed.
- Sub-stepped integration (3 sub-steps per frame) keeps the marble from tunneling through thin walls at high speed.
- Wall collisions push the marble out along the shortest axis and reflect velocity with a bounce coefficient (0.35).
Game rules
- Collect checkpoints in order (they pulse gold; collected ones turn green with a ✓).
- Fall in a hole → marble is sucked in with a shrinking animation, deaths counter increments, marble respawns at the start (but collected checkpoints stay collected — no need to redo the whole thing).
- Reach the checkered goal after all checkpoints → win overlay with time + deaths.
Visual polish
- Procedurally generated wooden board with grain lines and darker knots baked into an offscreen canvas for perf.
- Walls rendered as beveled brown planks with cast shadows offset by tilt for a 3D feel.
- The whole board tilts with CSS
perspective + rotateX/Y (smoothed with easing) so tilting is visible physically, not just in physics.
- Steel-marble radial gradient with a highlight, inset recessed frame around the play area, vignette, and a win overlay.
HUD
- Checkpoints collected, deaths, elapsed time, and current tilt %.
- Restart button resets everything.
Files built: index.html, src/labyrinth/maze.ts, src/labyrinth/physics.ts, src/App.tsx