Mirage, day 1 (25 Nov): from an empty repo to classes, pets and parties
I started Mirage: a small 2D online RPG engine in the spirit of Mirage Source, the old Visual Basic ORPG maker. The point isn't a game. It's the toolkit: the server, the client and, mostly, the editors that let you build a world from inside the game while it's running. Any content in it exists to give the tools something to chew on.
The foundation
It's a TypeScript monorepo with three packages:
- shared: the wire protocol, the map format, movement and item types, and now pathfinding and progression formulas, so client and server agree by construction.
- server: an authoritative WebSocket server running on Node's built-in TypeScript support, with SQLite through
node:sqliteand argon2id password hashing fromnode:crypto. No native dependencies. - client: Vite and Canvas 2D in the browser, with client-side movement prediction.
One early stumble: I'd first installed with deno install, and Deno's node_modules layout (a .deno folder full of symlinks) crashes npm's tree builder. Two lockfiles would drift apart anyway, so it's npm only now.
Editing the world live
The thing I care most about is that admins build inside the running game, and everyone sees the change immediately:
- Map editor with layers (ground, decor, over), brush, fill with a live preview, rectangle, picker, per-map undo/redo, panning, and resizing that refuses to cut anything off.
- Items & NPCs editor: the server validates every save with the same parsers that load the JSON files, applies it live (online inventories get re-checked, living NPCs pick up new stats), and writes the file back in a canonical layout. Deletes are refused while something still uses the definition.
- Pixel art editor: tiles, sprite sheets and item icons, painted in-game, with every stroke showing up for all players. That needed a small in-house PNG codec on the server so it can patch pixels into an atlas and grow it as needed. Pen, fill, line, rect, mirror, eyedropper, onion skin for animation frames.
- Events: builders script the world with visual event lists instead of code. A trigger (talk, step on a tile, kill, pick up...), conditions (items, gold, level, flags, quest stage) and actions (dialogue with branching choices, rewards, warps, quest stages). The server checks every reference and refuses edits that would break an event.
Systems, one after another
Once the editors existed, each new system came with its own tab in them:
- Gold, shops and a Merchant; character progression with levels, stat points and a gentle death penalty.
- NPC dialogue and roles (monster, shopkeeper, townsfolk).
- Spells with MP, cast times, targeting and a 9-slot hotbar; scrolls teach them.
- Quests as named stages of journal text.
- A* pathfinding for NPCs, so monsters chase around walls and queue in corridors instead of giving up.
- Loot protection for the killer, and player-to-player trading saved in one database transaction so a trade can't half-apply.
- Server hardening for public hosting: rate limits, heartbeats, resume tokens so a page reload doesn't need the password, an origin allow-list, an audit log of admin actions, and daily database snapshots.
Classes, pets and parties
The afternoon went to the bigger features, each designed in the roadmap first (with open questions answered) and then built in steps:
- Five classes: Mercenary, Alchemist, Necromancer, Sorcerer and Cultist, with a character creation screen, starting kits, class-locked spells and gear, and a passive each. That pulled in drain spells, ally heals, spells that cost HP, and a status effect system (damage and heals over time, wards, buffs) for Curse and Martyr's Veil.
- Pets: weaken a monster and use a Taming Rope on it. Pets follow with A*, fight in your name, level on an 80/20 XP split, get hungry, lose loyalty if starved and eventually run away. The Necromancer's Raise Dead runs on the same engine: up to three weakened corpses as servants. Pets can be traded too.
- Parties of up to five, saved across logouts, with a party frame, party chat, level-weighted XP sharing and party-wide loot claims.
That was a lot for one day. Next I want to play it and see what breaks.