A dungeon crawler in the spirit of the early-1980s cartridge era, built around one idea: the same space, seen more than one way. You draw a dungeon as a floor plan, then walk through it in first person or look down on it from above, and switch between the two whenever you like.
Live: https://dragonkeep.mathaiproject.org/
Single file, no build step, no dependencies. Open index.html in a browser.
Creator. An 11×11 grid — the original's maze footprint. Carve floor out of solid rock, place arms, treasure, monsters and puzzles, and set the mist, the dragon's wake radius and the party size. The plan is the third view of the same space: the one you draw.
Play. Corridors render as nested rectangles with flat sprites centred in them — the way the original did it, not raycast. Two parallel health tracks, War and Spiritual, with two matching weapon classes: swords and bows hit War, books and fireballs hit Spiritual.
While you play, one thin strip across the top carries what you check on every step — your bricks, and whether the dragon is sealed — and one line at the bottom says what just happened. Nothing marks how near the dragon is except its breathing, which grows louder as you close in along the corridors; come within its wake radius, or strike it, and it wakes, burns you and drives you back to where you came in. Everything else — health, helpers, treasure, the full map, the quest, and what the dungeon still holds — is in the status panel (I, Start, or the button on the strip), and the game waits while it is open.
Two views of one dungeon. Press V (or Overhead under the picture, or the status panel's VIEW button) to look down on the dungeon from above instead of walking through it, the way the 1982 Advanced Dungeons & Dragons cartridge showed its caves under Cloudy Mountain. Only what you have explored is drawn: bright where you can see from where you stand, dimmed under the mist where you have been. You keep your cell, your facing and everything you have uncovered when you switch, so you can flip back and forth mid-step. Overhead always steers by compass, since up is north on the screen. The corner map hides there, because the whole screen is the map. The game remembers which view you used last.
Skill and pace, in Battle. Four skill levels, named after the 1982 cartridge's: Sightseer, Weekend Adventurer, Soldier of Fortune and Hero. Each step up adds more monsters to every dungeon and makes them faster, and from Soldier up they come looking for you. Pace decides when they move. With you: they move when you move, so the dungeon waits while you think. Real time: they move on a clock, as on the cartridge, and the clock stops whenever a panel, riddle or scroll is open. The dragon never moves, because walling it in depends on it staying put. Both settings are under the game, beside Riddles, and only show in Battle.
Saved games. The status panel (I, or Start on the pad) has three save slots, kept in this browser. A save holds the whole game in progress: where you stand, what you carry, every brick you have moved, and how far through a world you are. Load puts you back exactly there, and Begin again still restarts that dungeon as you first walked in. Loading never touches your own drawing in Creator.
Masonry is a wall someone built rather than rock: it shows as brick, and B lifts a brick out of it as readily as it lays one. Every brick you lay is masonry, so any brick can be taken back.
Dungeons also hold scrolls, which tell the story of the place and stay in the status panel once read; riddles on the way out, answered in one word; and things that want something — a windlass with no handle, a statue with an empty hand — that open once you bring what they need. A world's guide greets you on arrival, speaks up as you reach each new part of the cave, and travels as your first helper. Riddles: Easy lets you through after three wrong answers and shows you the answer; Answer never does. Wrong answers cost nothing in Adventure.
Beside the game sits a list of cards: the worlds, ready to play, under Battle / Adventure and the other choices. In Adventure nothing fights back — walk into a creature to collect it. Playing a card never touches your own drawing; it is waiting in Creator when you go back.
Measurements went in v0.38 (Todd: "I'm much more interested in geometric views than measurements here. Multiple representations of the same space is more interesting to me."). What the game teaches now is moving between representations:
The dragon cannot be fought. Strike it, or come within its wake radius (counted along the corridors, not in a straight line), and it wakes, burns you and drives you back to where you came in.
You win by walling it in with the bricks your party carries, then walking out while it still breathes. Look for the narrow places: a brick there closes more than a brick in a hall. No number tells you how many you need; you read it off the shape. Every shipped dungeon was checked before release to be winnable with the bricks the party carries (the check, sealCost(), stays in the file for tools/worldgen and is never shown).
Bricks come from the party: 2 base plus 2 per helper. Helpers also step in front of one monster blow each, and then they are gone.
Because bricking only ever removes floor, path distances can only grow — so laying a brick can push a previously fatal cell out of the wake radius. You build your way to safety.
Sealing the dragon does not end the run. It opens the ladder, and "you walked out alive" happens when you actually climb one. A level with no ladder still ends on the seal, which is why the older adventures play exactly as they did.
A ladder lives in exits{}, a parallel map keyed by cell — a way out is a property of a floor cell, not a replacement for one. Paint it from the Brush panel under Structure, or write it as = in ASCII art. Standalone, it is barred while a dragon is loose and open when there is none, so a lesson can be finished on foot while a dragon level has to be earned.
Since v0.43 a world is one big cave (Todd, 2026-10-14: "delete the worlds we currently have and rewrite with the 'extended map' in mind"), after the caves of the 1982 Intellivision Advanced Dungeons & Dragons cartridge: rooms in its octagon and diamond shapes, joined by winding one-cell passages, and only a window of it on screen at a time. The overhead view shows about 21 cells top to bottom and scrolls with you (Settings, View, Zoom changes that); the first-person view never needed to change.
A cave is cut into regions, each with its own look, music and name on the status strip, and joined only through gates: a thing that wants something, or a riddle. The world's guide speaks the first time you step into each region.
One world ships while the rest are rewritten, one at a time, each read by Todd before it ships:
Caves are generated by tools/worldgen/cave.py and checked in the page with the game's own functions: connected, every gate a true gate, the handle on the near side of the windlass, the ring well clear of the dragon, and no monster standing where it would force a fight.
The warden shows four small maps of the ground around you, north up, and asks which one is where you stand. The wrong three are the true one turned or mirrored. The maps are cut from the live dungeon, so redrawing it changes the question.
Authored puzzles are records, with the board holding references to them. Several cells can point at one puzzle. Only the lock role is wired today; clue and mechanism exist in the data shape as groundwork for distributing one puzzle across several locations.
The Creator panel reports what references cost you: which puzzles are unplaced and so can never be met, which have no answer and so can never be solved. Keep authored content for riddles and story — anything asserting a fact about the geometry should stay generated, or it will quietly start lying the first time the floor plan is redrawn.
The gear opens Settings, where the Controller tab draws an eight-button pad — the d-pad, Select, Start, B and A. Click a button, then press the key you want for it; pressing the button on a plugged-in controller works too. A key replaces only keys and a pad button only pad buttons, so setting one never unplugs the other.
| Button | Does |
|---|---|
| D-pad | move |
| A | attack, and begin again once a run is over |
| B | lay a brick, or lift one out of masonry |
| Select | switch weapon, through everything you carry |
| Start | pause: the status panel, which is also the options window. D-pad moves, A presses, B or Start closes |
Fullscreen (F), sound (M), the map (N), the keys card (?), the two arm keys and begin-again (0) stay on the keyboard. The Controls tab lists every binding. Two presets ship.
8 is forward and 2 is back.1 2 3 across the top — vertically mirrored against a numpad.. lays a brick. The controller picture is drawn from the live bindings, so it cannot drift out of sync.
Pressing Play goes straight to full screen, because pressing Play means playing. Esc steps back one level at a time: full screen first, then out of Play to Creator. F toggles full screen directly. While playing, the masthead is hidden either way; in Creator, Hide title does the same thing and is remembered.
The chip modelled here is an AY-3-8914: three square-wave channels and one noise generator. No samples, no filters, no envelopes beyond a 4-bit volume you wrote yourself. The synth is built from exactly those parts, which is why it sounds right rather than merely retro.
Two details are emulated rather than approximated. Tone frequency was the 1.79 MHz clock divided by 16 and by a 12-bit divider, so the available pitches were quantised — ayFreq() rounds to a real divider. And the noise came from a 17-bit shift register tapped at bits 0 and 3, which has a coarser grain than white noise; ayNoiseBuffer() runs the actual register.
The one concession is a lowpass at 7 kHz, standing in for the television speaker the chip was heard through. Without it the squares are harsh in a way no 1981 living room ever was.
The dragon's breathing is information, not atmosphere. It is the noise generator with a slow swell, and its volume tracks path distance through open air — audible from about eight steps, loud when it is near enough to wake. You hear it through mist that hides it. When the seal closes it goes silent, so you know you have won before the message says so.
M mutes, and the choice is remembered. Browsers hold the audio clock suspended until the page is interacted with, so it starts silent and wakes on your first key or click. That is unavoidable, not a design decision.
Save & share exports a level as JSON — floor plan, contents, settings and every puzzle — and imports one back. Import validates before touching live state and refuses a malformed bundle outright rather than half-applying it.
The working level also autosaves to localStorage, which is per-browser and per-machine. Use the JSON bundle to move a level anywhere that matters.
The Levels panel in Creator holds the lessons, each built to show one idea: walk it, then look down on it. The finished dungeons and worlds live on the Play side, under the game.
launcher/make-icon.py generates the icon at nine sizes from a 16×16 grid that lives in the script. The dragon is the data; edit GRID and re-run. No dependencies — the PNG encoder is thirty lines of zlib and struct, so it runs on Mint and on a Mac that has never seen pip. Scaling is nearest-neighbour, because a pixel dragon smoothed with interpolation stops being a pixel dragon.
Linux / Cinnamon — launcher/linux/install.sh, no sudo, everything under $HOME. Lands in the menu under Education.
Three things a bare chromium --app= gets wrong, and what fixes each:
| Problem | Fix |
|---|---|
| The window shows Chromium's icon | --class=Dragonkeep plus StartupWMClass=Dragonkeep in the .desktop. Both halves, or you still get the browser icon. |
| A second launch opens a second copy | flock on fd 9, held across exec for the life of the browser. A second launch raises the first with wmctrl. |
| The window joins the running browser session | Its own --user-data-dir, which also keeps the game's localStorage separate. |
Confirmed with xprop rather than assumed:
WM_CLASS = "home_todd_Repos_dragons-keep_index.html", "Dragonkeep"
--class sets the second field. --name is silently ignored — Chromium derives the instance name from the file path, so StartupWMClass must match the class, which is the half that stays stable across machines.
macOS — launcher/macos/make-app.sh, run on the Mac since it needs iconutil. It builds a Dragonkeep.app with the dragon icon, its own profile and one-instance-only.
It cannot fix the Dock icon, and says so when it finishes. A Mac app's identity comes from the bundle owning the running executable, and that executable is inside Chrome.app. There is no --class equivalent. For the dragon on the live window, use Chrome's Install page as app, then paste the icon in Get Info — the script prints the steps.
All art is original. The rendering palette is restricted to a sixteen-colour set, defined in IV at the top of the script.
The name is a pun, and it is also the whole design. A keep is a fortress, but to keep something is to look after it. You never kill the dragon. You keep it — away from the townspeople, and the townspeople away from its teeth.