Expand description
What a game on the short path names (ADR-0036): shuyi-platform’s
prelude, and run_game, which runs it from a
plain main.
Structs§
- AppInfo
- Who a game is. Build it with
AppInfo::newand thewith_setters: a struct literal doesn’t compile outside this crate, so a new field never breaks a game (ADR-0039). - Basic
Data - A game’s data on the short path: what the engine reads from the
standard files, the files themselves and the game’s own part
T. Its actions areA(most simplyUiAction), its colours the engine’s. - Basic
Game - A game on the short path: its data is a
BasicDataof actionsAand its own partT, read from one layer of files. - Bundle
- The layers a game reads its files from.
- Cell
- One console cell: a glyph with foreground and background colours.
- Console
Spec - A console’s size:
cols × rowscells ofcell_w × cell_hlogical pixels. The frame (GlyphBuffer) keeps the spec it was made with; the game picks one when it starts (game ADR-0070 §6). - Content
Error - One problem found while loading or validating an asset. Build it with
ContentError::newand its methods (ADR-0039). - Ctx
- Resources shared by every screen: the engine’s, and the game’s in
game. - Frame
Input - One frame’s input as a screen sees it.
- Game
- Owns the screens, input state, shared context and the console buffer.
- Game
Hooks - Where the game has a say in the frame loop.
Defaulthas none. - Glyph
Buffer - A grid of
Cells, row-major. - Install
- What
Module::installdeclares with. - Layer
- One layer of the bundle.
- Look
- What a game’s frame is painted with: the font atlas and the pictures in
the game’s data. A backend makes its textures from them the first time
it sees them. Build it with
Look::new(ADR-0039); a game that runs on a one-bit display addsLook::with_one_bit(ADR-0062). - Rect
- A rectangle of cells. A non-positive
worhmeans empty. - Rgb
- A 24-bit RGB colour. Ordered red, then green, then blue: an order for maps, not a look.
- Screen
Result - A value a screen pops with (
Transition::PopWith) for the screen below, which reads it back as its type inScreen::uncovered. Any'statictype will do; the two screens agree on which. - Setup
- What the platform gives a game as it loads: what goes into its context
(
ctx). A backend with more to give (the voice manifest it read) adds it withStart::before_load. - Start
- How a game starts: the card shown while it loads, the load, where its
look is and its hook for the system’s events. Built with
Start::new, its optional parts set by the methods named for them (ADR-0039).
Enums§
- BoxStyle
- Border style for
GlyphBuffer::draw_box(game ADR-0012: single for panels, double for focus/modal). - Card
- What the screen shows while the game’s data loads, from the first frame (a slow device takes seconds to load a game, and shows nothing until a frame is drawn). Drawn by the backend with what it has of its own, since the game’s font isn’t loaded yet.
- Engine
Color - The colors the engine’s own widgets ask for. A game’s
ColorSetsays which of its palette’s names each one is (engine_name). - Hook
- A place in the frame loop where the game calls a module.
- Transition
- What a screen asks the stack to do after an update.
- UiAction
- What the generic widgets (a menu), the Key bindings screen and the debug
hook react to. A game maps some of its actions onto these with
ActionSet::ui; the rest are its own business.
Traits§
- Action
Set - Everything a player can ask for in one game: the game’s action enum. The keymap file, the keymap, held keys and repeat, the player’s saved bindings and help text are all built on it, never on one game’s actions.
- Game
Data - The game’s part of the
Ctx, and what the engine reads from the game’s data through it: its actions, colors, text, keys, audio manifest and palettes, and the hooks where the game has a say. - Module
- A piece that joins a running game: the game installs it with
Game::with_module, and calls only the hooks itsinstalldeclares, in install order. - Screen
- One screen of a game: a title, a map, a menu overlay, …
Functions§
- print_
centred - Prints
textcentred on rowy. A text wider thanbufstarts at column 0,cutto the buffer’s width. - run_
game - Runs a game on the short path until it quits, in a window of its
console at twice its size: its files become the process’s bundle, and
runstarts it asBasicGame::startsays, with no sounds, no voices and no system keyboard. Called from a plainfn main. Undercargo shuyi run --watchthe game’s files on disk are laid over the embedded ones (watched_layer).