# Turbo Loop — 3D Kart Racer

A browser kart racer built with Three.js. You race 3 AI karts for 3 laps around one closed track with banked turns. Everything is generated in code (track, karts, scenery, textures, and sound), so there are no image, model, or audio files.

## Running it

There's no build step. Serve the folder with any static server and open `index.html`:

```sh
python3 -m http.server 8000
# then open http://localhost:8000/
```

Files:
- `index.html`: the page, HUD, and menus
- `js/game.js`: the game
- `js/three.min.js`: a local copy of Three.js r158

## Controls

| Key | Action |
|---|---|
| **↑** / **W** | Accelerate |
| **↓** / **S** | Brake, or reverse when stopped |
| **←** **→** / **A** **D** | Steer |
| **Space** (or Shift) | Drift. Hold it while steering through a corner, then let go for a mini-turbo (blue sparks = small boost, orange sparks = big boost) |
| **R** | Put your kart back on the track |
| **C** | Switch camera (chase, far chase, bumper) |
| **P** / **Esc** | Pause (press **Q** while paused to go back to the title screen) |
| **M** | Mute or unmute sound |
| **Enter** | Start the race, or race again from the finish screen |

## How a race works

- There's a 3-2-1-GO countdown (with start lights on the gantry), then 3 laps. You start at the back of the grid.
- The HUD shows your lap, your position, the race time with each lap's time, live standings with gaps, your speed, a drift/boost meter, and a minimap. Banked sections are highlighted in yellow on the minimap.
- Banked turns (up to about 22°) give extra grip, so you can take them faster. The tarmac edges and gravel run-off are walled in. Driving on the gravel slows you down.
- When you cross the line after lap 3, a finish screen shows your place, total time, each lap's time (best lap highlighted), and the full results. AI karts still racing get an estimated finish time.

## Developer URL flags (for testing)

`?auto` skips the title screen. `?autopilot` lets the AI drive your kart. `?ff=<seconds>` fast-forwards the simulation. `?cam=0|1|2` picks the camera. `?kbdbot` drives your kart with synthetic keyboard events.

Example: `index.html?autopilot&ff=160` jumps straight to the finish screen.
