Play Carmageddon (1997) in your browser. This project compiles the open-source Dethrace engine to WebAssembly with WebGL 2 rendering and Web Audio sound.
- Full single-player Carmageddon experience in a modern browser
- OpenGL renderer via Emscripten + BRender
- Menu, races, opponents, pedestrians, power-ups, replays
- Save games stored in the browser (IndexedDB via Emscripten IDBFS)
- Keyboard + mouse controls
- No install — static hosting only (HTML + WASM + preloaded data)
┌─────────────────────────────────────────────────────────────┐
│ Browser │
│ ┌──────────────┐ ┌─────────────┐ ┌──────────────────┐ │
│ │ index.html │──▶│ carmaweb.js │──▶│ carmaweb.wasm │ │
│ │ + pre.js │ │ (Emscripten │ │ (Dethrace engine │ │
│ └──────────────┘ │ glue) │ │ + BRender GL) │ │
│ └─────────────┘ └────────┬─────────┘ │
│ ┌──────────────┐ WebGL 2 canvas ◀───────────┘ │
│ │ carmaweb.data│ (game files preloaded to /carma) │
│ └──────────────┘ │
│ ┌──────────────┐ /persistent → IDBFS (save games) │
│ │ IndexedDB │ │
│ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘
- Build — Dethrace 0.10.1 is cross-compiled with Emscripten to
carmaweb.wasm+carmaweb.js. - Game data — Retail
DATA/(and related files) are embedded at link time ascarmaweb.data(~190 MB) and mounted at/carmain the virtual filesystem. - Rendering — BRender’s OpenGL backend draws to an HTML5 canvas. Frame pacing uses Asyncify only during in-race presentation to avoid WebGL flicker; the menu swaps without extra yields.
- Audio — miniaudio drives Web Audio (ScriptProcessor). A user click/key press is required once to unlock
AudioContext(browser policy). - Saves — Only
/persistentuses IDBFS; game data is read-only from the preload pack.
| Area | Approach |
|---|---|
| Race rendering | Single emscripten_sleep per frame in SDL2_Harness_Swap only while racing |
| Menu / UI | No Asyncify between frames — stable menus, no flicker |
| Menu audio | SoundService() during interface loop; input waits yield with emscripten_sleep(0) |
| ESC → pause menu | WaitForNoKeys() yields so key-up events are processed |
| PIX duplicates (web) | Material colour-map refresh for duplicate pixelmaps |
You need a legal copy of Carmageddon on disk (not included here).
- Emscripten SDK 3.1+
- CMake 3.20+, Ninja
- Python 3 (for local server)
- ~2 GB free disk space for build + data pack
carmagit/
Carma/ ← your install root (name matters for default CMake path)
DATA/
MUSIC/
...
The build expects Carma/DATA/GENERAL.TXT to exist.
Windows (PowerShell):
.\scripts\build-emscripten.ps1Linux / macOS:
source ~/emsdk/emsdk_env.sh
chmod +x scripts/build-emscripten.sh
./scripts/build-emscripten.shThis produces web/carmaweb.js, web/carmaweb.wasm, and web/carmaweb.data.
python web/serve.pyOpen http://localhost:8080 — hard-refresh with Ctrl+Shift+R after rebuilds.
Click the page or press a key once if audio is silent.
Upload the contents of web/ after a successful build:
| File | Purpose |
|---|---|
index.html |
Page shell |
pre.js |
WebGL + IDBFS + audio unlock hooks |
carmaweb.js |
Emscripten loader |
carmaweb.wasm |
Game engine |
carmaweb.data |
Preloaded game assets |
Configure your host to serve large files (200 MB+) and correct MIME types (application/wasm for .wasm).
Note: Do not commit
carmaweb.dataor retail game files to a public GitHub repo unless you have explicit rights. Use Git LFS or host binaries separately (as on the live demo).
| Action | Key |
|---|---|
| Accelerate | ↑ |
| Brake / reverse | ↓ |
| Steer | ← / → |
| Handbrake | Space |
| Camera | C |
| Repair | Backspace |
| Pause / menu (in race) | Esc |
| Horn | H |
Mouse works in menus. In-race camera look uses WASD (patched in pre.js / input layer).
carmagit/
├── README.md ← you are here
├── NOTICE.md ← game asset copyright
├── .gitignore
├── docs/
│ └── screenshot.png
├── dethrace-0.10.1/ ← engine source (Dethrace + web patches)
├── web/
│ ├── index.html ← browser entry point
│ ├── pre.js ← Emscripten pre-load hooks
│ └── serve.py ← dev server (no cache)
├── scripts/
│ ├── build-emscripten.ps1
│ └── build-emscripten.sh
└── cmake/
└── Emscripten.cmake
Tested on recent Chrome, Edge, and Firefox.
- WebGL 2 required
- WebAssembly required
- ~200 MB download on first load (game data pack)
- Recommended: desktop, hardware keyboard
| Component | License / source |
|---|---|
| Dethrace | GPL-3.0 — see dethrace-0.10.1/LICENSE |
| BRender, miniaudio, stb, etc. | See respective files under dethrace-0.10.1/lib/ |
| Carmageddon game data | Not included — commercial / rights-holder property |
This web port is a community technical project. It is not affiliated with or endorsed by Stainless Games or current rights holders.
PRs welcome for web-specific fixes. Please do not submit copyrighted game assets.
When changing Emscripten link flags or the main loop timing, test both in-race driving (no jitter) and menu navigation (no flicker, no audio dropouts).
