What it does
This pack is the player for an rpg-world document. load cleans the world and builds every map from its seeds;
start shows the title, while newGame and resume skip it for a game with a title screen of its own. From there the
player walks a top-down overworld with roads between towns and random encounters, enters towns with wandering villagers,
conversations, a shop and an inn, and goes down into dungeons with fog of war, a torch, doors, chests, roaming monsters
that give chase and a boss. A dungeon can be walked top-down or in first person.
Battles are pushed over the current scene, side-on, and play on the turn-battle rules. Foes telegraph their attacks,
elements beat one another round a wheel, weakness hits empty a Break gauge so a foe loses its next turn, and heroes
attack, use skills and items, defend or flee. A party menu manages gear, items and the quest log. The party, with its
levels, gear, bag and gold, comes from party, and the quest log from quests, so the rules are the same ones a game
built by hand would use.
Everything beyond the document is an option, in two halves. Plain data in the manifest covers scene names, keys and
gamepad buttons, fonts, colours, encounter rates, the look of the panels, the cover between maps and the starting
gold. Code passed through host covers the map rules, the battle's rules and skill effects, how foes choose, the
party's equipment slots and level curve, and quest step kinds of your own. onEvent reports scenes, conversations,
quests, battles, levels, items and the ending, and fight starts a scripted battle.
Features
- The whole loop — title, overworld, town, dungeon, battle, shop, inn, menu, ending and game over, as scenes you can rename.
- Generated maps — the overworld, every town and every dungeon floor, the same every time from the world's seeds.
- Dungeons two ways — top-down with fog of war and a torch, or first person down straight corridors.
- Turn-based battles — telegraphs, the element wheel, the Break gauge, criticals, skills, items, defending and fleeing.
- Towns — wandering villagers who talk, a shop to buy and sell, and an inn to rest at.
- Party and quests — gear in slots, a shared bag and gold, levels and experience, and a quest log in acts.
- Autosave — on every scene change, resumed from the title;
savehands you the run to keep. - Keyboard, gamepad and touch — arrows or WASD with confirm and cancel keys, a gamepad's d-pad and buttons, and on-screen controls on a phone.
- Two looks — its own dark-and-gold panels, or your game's
uitheme. - Screens that fit — every screen laid out from the screen's size, with a detail column moving below its list on a phone held upright.
- Events and scripting —
onEventfor the story's moments andfightfor a scripted battle.
Good for
- Small JRPGs that are all data, with towns, dungeons, a party and turn-based battles.
- Previews in a design tool, where a world being written can be played at once.
- Story prototypes, to try acts, quests and characters before any art is made.
- Role-playing games whose rules differ only in options: other classes, a wheel of your own, a fifth act, more equipment slots, a harsher battle formula, a skill that drains life.
- Dungeon crawls with first-person floors, fog of war and a boss at the bottom.
Make it yours
The manifest takes scenes, keys and padButtons, fonts, colours per element, class, role, biome and dungeon
theme, encounters (group sizes, a cooldown, a safe radius round entrances and the most foes in one battle), look
('rpg' or 'theme'), styles, speech, transition, startGold, hint and world, the document's caps and
vocabularies. host adds the rules that are code: maps, battle, skillEffects, foeChoice, party (slots, level
curve, growth, consumables, selling) and questRules.
Two different uses: the sample world played as written, in three acts with three heroes and four regions; and a world
of its own with a moon biome on its own terrain, a bard class, a light-and-dark element wheel, a fourth equipment slot
for charms, triple criticals and a skill that drains life, all set through host. A game that wants its own screens
composes the rules packs itself and borrows the maps from rpg-world.
A quick look
The game handed over, a world loaded and started, a scripted battle and a save:
game.rpg.host(game, { battle: { critFactor: 3 } }); // once: the game it drives, and the rules that are code
game.rpg.load(worldJson, { save: null }); // clean, build the maps, go to the title
game.rpg.newGame(); // or start(), or resume()
game.rpg.fight(['root-warden'], result => onWardenFight(result)); // over the current map
const off = game.rpg.onEvent(e => log(e)); // scene, talk, quest, battle, level, item, ending
const json = game.rpg.save(); // the run, to keep; give it back as `save`
Works with
rpg-world— the world document and the map generators it plays.turn-battle,partyandquests— the rules underneath, for a game that builds its own screens.ui,bars,dialogueandtransition— its panels, meters, speech box and the cover between maps.lighting-2d— lights the dungeons when present, on WebGPU.vector-2d— draws the first-person view, on WebGPU; without it every dungeon is walked top-down.controls-touch— on-screen buttons so a phone can play.
Good to know
- Maps are generated from seeds, not drawn by hand, and a save made inside a dungeon resumes on the overworld beside its entrance.
- The battle party is the first heroes up to the world's party size; the first-person view draws straight corridors and the cells beside them, not a full 3D view.
- Menus are its own cursor lists driven by its keys and pad; they do not take the
uipack's pointer or Tab focus. - Fonts do not scale: a very small screen shows fewer rows rather than smaller text.
- There is no music.






