I'll build an F1 racing game with all the polish you requested. Let me start by exploring the project structure.
Now I'll build the game. Let me create everything:
Now let me create the game engine module:
Now the sound module and audio:
Now the main App with the React UI overlay:
Now let me build to check for errors:
Build succeeded. Let me do a quick review of critical loop mechanics — I want to make sure the game actually loops properly when starting from menu. Looking at my code, the loop is started in the useEffect immediately, so the render loop runs continuously (calling updateAmbient while on menu and full update while playing). That's correct.
One concern: when the game state transitions from menu → playing via start(), it calls reset(false) which sets invulnerable = 0.6. But right after menu, if the user immediately starts, the first frame of playing will be fine.
Let me also verify: loop in engine already sets raf = requestAnimationFrame(this.loop) at top of loop, so calling requestAnimationFrame in useEffect starts things properly.
Let me also double-check that the crash detection doesn't fire for the last-frame car that already scored. It should be fine because collision uses direct distance check.
The game is ready! Here's what I built:
🏎️ F1 Adventures — Feature Summary
Core loop (fun in first 10s):
- Weave through 4-lane traffic in a stylized F1 car
- Collect coins (+25, boosted by combo multiplier)
- Score "near misses" for tight overtakes (+15)
- Hold BOOST for a rush of speed & particle trail
Tight controls:
- Keyboard: ←/→ or A/D steer, Space/Shift boost, ↓/S brake, P/Esc pause, Enter to start/restart, R to restart, M to mute
- Touch: Drag anywhere on the track to steer directly to your finger, dedicated BOOST + BRAKE buttons on mobile
Juicy feedback:
- Screen shake on crashes (procedural sine + noise)
- Red flash + slow-mo freeze frame on impact
- 60+ particle explosion on crash (debris + smoke)
- Golden coin burst confetti
- Sparks on near-misses
- Boost flame trail with heat particles
- Animated curbs, dashed lane markers scrolling with speed
- Parallax city skyline with twinkling windows
- Pulse-glowing title, pop-in modals, red flash overlay
States & polish:
- Start screen with best score, quick tutorial, sound toggle
- Pause overlay (auto-pauses on tab blur/visibility change)
- Game-over screen with new-best celebration, leaderboard rank, top-5 preview
- Full leaderboard modal (top 10 with dates)
- Instant restart via ↻ button, R key, or Enter
- localStorage persistence for high scores & personal best
60fps performance:
- Fixed-timestep updates (1/60s) decoupled from render
- DPR-aware canvas (capped at 2x for mobile perf)
- Pure Canvas 2D — no expensive DOM redraws during gameplay
- Particle pool naturally pruned each frame
- No layout thrashing (single canvas, absolute overlays)
Audio: WebAudio synthesized SFX (coin ding, near-miss whoosh, crash noise burst, start jingle) — no assets to load, muteable.
Files built: index.html, src/index.css, src/game/engine.ts, src/game/sound.ts, src/App.tsx