README
¶
Hollowbrook, a top-down RPG template
A small, complete top-down RPG built with NSGo and github.com/nsgo-dev/game: the town of Hollowbrook and the meadow beyond its gate, three people to talk to, a pack of items and equipment, one quest, turn-based battles and three save slots.
The shrine lamp of Hollowbrook has gone out. Mira the healer needs three glowcaps from Whisper Meadow to light it again, and Thornhide, an old bramble boar, keeps the gatherers away. The starting stick will not beat Thornhide: earn the coins for Bram's iron sword from the moss slimes, find the leather vest in the meadow, drive Thornhide off and bring the glowcaps back to win. Fall in battle and you can load a save or start again.
Running and testing
go tool nsgo dev # this machine, rebuilt on save
go tool nsgo dev -target web # the browser
go tool nsgo dev -target ios_simulator
go tool nsgo dev -target android
go tool nsgo test ./... # the rules, the data files and full playthroughs
go tool game playtest # automated bot playtest and report
go tool nsgo check -target macos,windows,linux,android,web
The tests play the game through to the victory screen with the keyboard and to the defeat screen with a gamepad and with the touch pad, so a change that breaks the quest, the balance or a control fails them.
Controls
Every control is in game.yaml's input map, so rebinding one is an edit there.
| Action | Keyboard | Gamepad | Touch and mouse |
|---|---|---|---|
| Walk, move through menus | Arrows or WASD | D-pad or left stick | The arrows of the on-screen pad |
| Talk, go on, pick | Enter, Space or E | South (A) | The A button, or a tap on the conversation |
| Back, open the pack | Escape or Backspace | East (B) | The B button |
| Open and close the pack | Tab | Start | The Pack button |
The on-screen pad is drawn on phones and tablets, and on other devices once the map is touched or clicked. Menus are buttons, so a tap or a click picks an entry too.
How it is organised
| File | What it holds |
|---|---|
game.yaml |
The project file: name, window, the 480×270 virtual resolution, the input map and the export presets. |
data/world.yaml |
The maps, drawn as rows of characters, with their exits, people, foes, patrols and items, and the foes' stats. Its format is defined in world.go. |
data/items.yaml |
The items, read by inventory: coins, potions, glowcaps and equipment. |
data/stats.yaml |
The player's stats and each piece of equipment's bonuses, read by stats. |
data/quests.yaml |
The quest and its objectives and rewards, read by quest. |
data/cast.yaml, data/dialogue.yarn |
Who speaks and what they say: a vn cast and a Yarn Spinner script with branching options and commands that give items, start the quest and heal. |
data.go |
Loads every data file and checks that they agree with each other. |
game.go |
The rules: walking, patrols, conversations, the quest, equipment and battles. |
menu.go, save.go |
The title, pack, battle, defeat and victory menus, and the save slots. |
input.go |
Turns the input map's actions into what the player asked for in one step. |
art.go, draw.go |
The pixel art, written as text and painted at start-up, and the drawing of each screen. |
ui.go |
The app: the fixed-step loop, the scenes and the native HUD and menus. |
playtest.yaml, playtest_test.go |
The topdown-explorer playtest configuration and TestPlaytest adapter driven by go tool game playtest. |
*_test.go |
Format and rules tests, and the playthroughs. |
Where to change it
- A new map: add it to
mapsindata/world.yamlwith an exit to it from another map. A new kind of tile or foe goes intilesorfoes, with its picture inart.go. - A new person: add them to a map's
people, todata/cast.yaml, and a node todata/dialogue.yarn. - A new item or piece of equipment: add it to
data/items.yaml; equipment also needs an effect of the same name indata/stats.yaml. - A new quest: add it to
data/quests.yamland start it from a conversation with<<start id>>.mainQuestindata.gonames the quest that wins the game. - Balance: the foes' stats are in
data/world.yamland the player's indata/stats.yaml;TestThornhideNeedsTheIronSwordchecks the fight the game is built around. - Real art: replace
newAtlasinart.gowithsprite.LoadAtlas, keeping the frame names.
The game's settings live in game.yaml. Edit its name and identifier before shipping, then write them into nsgo.yaml and check the project:
go run github.com/nsgo-dev/game/cmd/game project sync
go run github.com/nsgo-dev/game/cmd/game project check
Git setup
Each clone enables the object-by-object scene merge driver once (.gitattributes names it, while Git keeps driver config local to .git/config):
go tool game merge -setup