Skip to content

humancto/rogue-ts

Repository files navigation

Rogue-TS

A faithful TypeScript port of the classic Rogue (1980) dungeon crawler, playable directly in your browser. Every monster stat, item property, dungeon generation algorithm, and game mechanic preserved from the original C source. The only change is the platform: curses replaced with HTML5 Canvas.

Gameplay

Features

Everything from the original Rogue, running natively in the browser:

  • 26 monster types (A-Z) with exact original stats, behaviors, and special attacks
  • 14 potions, 18 scrolls, 9 weapons, 8 armors, 14 rings, 14 wands — all with original effects
  • Procedural dungeon generation — 3x3 room grid with corridors, dark rooms, mazes, and treasure rooms
  • 8 trap types — teleport, arrow, sleep, bear, pit, dart, rust, mysterious
  • Full combat system — attack rolls, damage dice, armor class, strength bonuses, experience levels
  • Hunger system — find and eat food or starve
  • Item identification — colored potions, titled scrolls, gems on rings, wood/metal wands
  • Fog of war — rooms light up when entered, corridors reveal as you explore
  • Daemon/fuse system — timed effects for confusion, haste, blindness, hallucination
  • Amulet of Yendor — descend to level 26+, find it, and escape back to the surface to win
  • Seedable RNG — share runs via URL, compete on daily challenges

Shareable Seeds

Every run gets a unique seed displayed in the status bar. Share your exact dungeon with friends:

https://humancto.github.io/rogue-ts/#seed=12345

Daily Challenge — everyone gets the same dungeon for the day:

https://humancto.github.io/rogue-ts/#daily

Or pick a specific date:

https://humancto.github.io/rogue-ts/#daily=2026-02-12

Getting Started

Play Online

https://humancto.github.io/rogue-ts/

No install needed.

Run Locally

git clone https://github.com/humancto/rogue-ts.git
cd rogue-ts
npm install
npm run dev

Opens at http://localhost:3000.

Build for Production

npm run build

Run Tests

npm test

36 tests covering monster data tables, combat math, damage parsing, and RNG determinism.

Controls

Movement

Key Direction
h / a / Arrow Left Left
j / s / Arrow Down Down
k / w / Arrow Up Up
l / d / Arrow Right Right
y Up-Left
u Up-Right
b Down-Left
n Down-Right

Hold Shift + movement key (e.g., H, J, K, L) to run in that direction until something interesting happens.

Actions

Key Action
> Go down stairs
< Go up stairs
. Rest one turn
s Search for traps/secret doors
i Show inventory
e Eat food
q Quaff (drink) potion
r Read scroll
w Wield weapon
W Wear armor
T Take off armor
z Zap wand/staff
t Throw item
d Drop item
, Pick up item
? Help screen
Q Quit game

Credibility

Ported from Rogue 5.4.4 C source. This is not a "roguelike inspired by" — it is the actual game, re-implemented line-by-line.

C Source to TypeScript Module Mapping

Original C File(s) TypeScript Module Lines
rogue.h, extern.h, extern.c src/core/types.ts 1,301
rooms.c, passages.c, new_level.c src/dungeon/dungeon.ts 1,251
monsters.c, chase.c src/entities/monsters.ts 920
fight.c, hit.c src/entities/combat.ts 822
things.c, potions.c, scrolls.c, sticks.c, rings.c, pack.c, weapons.c, armor.c src/items/items.ts 1,722
command.c, move.c, io.c, save.c src/systems/commands.ts 2,889
daemon.c, daemons.c, rip.c src/systems/daemons.ts 924
curses library src/ui/renderer.ts 507
main.c src/main.ts 1,870
Total ~12,200

Architecture Mapping

Original C TypeScript Port
curses library HTML5 Canvas renderer (renderer.ts)
Global variables GameState interface (types.ts)
rogue.h structs TypeScript interfaces and enums (types.ts)
INDEX(x,y) macro ((x<<5)+y) index(x,y) function
Linked lists (_t_thing) Arrays of Creature / Item
daemon.c fuse/daemon system DelayedAction[] in daemons.ts
Damage strings "2d4" "2x4" format (parsed by parseDamage())
ncurses keyboard input Browser keydown events
srand()/rand() Seedable mulberry32 PRNG

Screenshots

Title Screen Gameplay Help
Title Game Help

Tech Stack

  • TypeScript — strict mode, fully typed
  • Vite — dev server and production bundler
  • Vitest — 36 unit tests for core game systems
  • HTML5 Canvas — pixel-perfect terminal rendering at 80x24 characters
  • GitHub Pages — auto-deployed on every push to main

Original Game

This is a port of the original Rogue by Michael Toy, Glenn Wichman, and Ken Arnold (1980).

Original C source: https://github.com/Davidslv/rogue

License

ISC

About

A faithful TypeScript port of the classic Rogue (1980) dungeon crawler, playable in your browser. Every monster, item, and mechanic preserved from the original C source.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors