Skip to content

muhammedaksam/opentui-doom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

39 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

DOOM for OpenTUI

๐ŸŽฎ Play DOOM in your terminal using OpenTUI's framebuffer rendering!

โœจ Features

  • Full DOOM gameplay in your terminal
  • High-resolution rendering using half-block characters (โ–€) for 2x vertical resolution
  • Mouse aiming - Turn and fire with your mouse (enabled by default)
  • Keyboard input support with WASD and arrow keys
  • Save/Load game support - saves persist to ~/.opentui-doom/
  • Sound effects and music via mpv
  • WebAssembly powered - DOOM compiled to WASM via Emscripten

๐Ÿ“‹ Requirements

  • Bun - JavaScript runtime
  • Emscripten SDK - For compiling DOOM to WebAssembly
  • DOOM WAD file - Game data (shareware doom1.wad is freely available)

โšก Quick Play (via npm)

If you have Bun installed, just download a doom1.wad and run:

bunx @muhammedaksam/opentui-doom --wad ./doom1.wad

๐Ÿš€ Quick Start (Development)

1. Clone the Repository

git clone https://github.com/muhammedaksam/opentui-doom.git
cd opentui-doom
bun install

2. Install Emscripten (if not already installed)

git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
cd ~/emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh

3. Build DOOM WASM Module

bun run build:doom

This clones doomgeneric and compiles it to WebAssembly.

4. Get a WAD File

Download the shareware DOOM WAD:

Place the WAD file in the project root.

5. Run DOOM

bun run dev -- --wad ./doom1.wad

To disable mouse aiming:

bun run dev -- --wad ./doom1.wad --mouse false

Debug Mode

To run with debug logging enabled (outputs to debug.log):

bun run dev:debug -- --wad ./doom1.wad

๐ŸŽฎ Controls

Action Keys
Move Forward/Back W / S or โ†‘ / โ†“
Turn Left/Right Mouse or โ† / โ†’
Strafe A / D
Fire Left Click or Ctrl
Use/Open Space
Run Shift
Weapons 1-7
Menu Escape
Map Tab
Quit Ctrl+C

๐Ÿ’พ Save Games

Save games are stored in ~/.opentui-doom/ with DOOM's standard naming:

  • Slot 1: doomsav0.dsg
  • Slot 2: doomsav1.dsg
  • ... up to Slot 6: doomsav5.dsg

Saves are automatically synced every 5 seconds and on exit.

๐Ÿ”Š Sound

Sound effects and music require mpv to be installed:

# Ubuntu/Debian
sudo apt install mpv

# macOS
brew install mpv

# Arch
sudo pacman -S mpv

Sound files should be placed in the sound/ directory.

๐Ÿ–ฅ๏ธ Recommended Terminal Configuration

For the best experience, we recommend:

  • Alacritty terminal emulator
  • Font size: 5 (for maximum resolution)
  • Maximize your terminal window

โš ๏ธ Known Limitations

  • Multi-key input: Terminals only send key repeat events for one key at a time. Holding W to move forward will stop when you press arrow keys to turn. This is a terminal limitation, not a bug.
  • No Kitty keyboard protocol: While OpenTUI supports the Kitty keyboard protocol for proper key release events, it didn't work as expected in my testing. Currently using timeout-based key release as a workaround.

๐Ÿ”ง How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  doomgeneric    โ”‚โ”€โ”€โ”€โ–ถโ”‚  OpenTUI         โ”‚โ”€โ”€โ”€โ–ถโ”‚   Terminal     โ”‚
โ”‚  (WASM)         โ”‚    โ”‚  FrameBuffer     โ”‚    โ”‚   Display      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ–ฒ                      โ”‚
         โ”‚                      โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              Key Events
  1. DOOM runs as a WebAssembly module (compiled from C via Emscripten)
  2. Each frame, DOOM renders to a 1280x800 framebuffer
  3. OpenTUI reads the framebuffer and converts it to terminal cells using half-block characters
  4. Terminal keyboard input is mapped back to DOOM key codes

๐Ÿ“ Project Structure

opentui-doom/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts          # Main entry point
โ”‚   โ”œโ”€โ”€ doom-engine.ts    # WASM module wrapper
โ”‚   โ”œโ”€โ”€ doom-input.ts     # Keyboard input mapping
โ”‚   โ””โ”€โ”€ doom-mouse.ts     # Mouse input handling
โ”œโ”€โ”€ doom/
โ”‚   โ”œโ”€โ”€ doomgeneric_opentui.c  # Platform implementation
โ”‚   โ”œโ”€โ”€ doomgeneric/           # doomgeneric source (cloned during build)
โ”‚   โ””โ”€โ”€ build/                 # Compiled WASM output
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ build-doom.sh     # Build script
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ README.md

๐Ÿ“ License

  • This project code: MIT
  • DOOM source code: GPL-2.0 (from id Software)
  • doomgeneric: GPL-2.0 (by ozkl)

๐Ÿ™ Credits

๐Ÿค Contributing

Contributions are welcome! Please submit pull requests to the develop branch.