XMLGameEngine

An engine for describing games built around Xerces, exprtk, and SFML.

View the Project on GitHub beefviper/XMLGameEngine

09. States and screens

Status: implemented (state stack, shows, inputs, conditions)

What a state is

A <state> is a specific screen: a menu, the playfield, a pause screen, a game-over screen. It defines what is shown, which buttons run which commands in that context, and which conditions to watch. States are loaded much like objects, and a group of them sits in a <states> block, mirroring <objects>.

A state is a declarative definition (a template), not a live thing. Which state is current at a given moment is separate run-time information.

Decision: a stack

<push state="playing" /> pushes a state and <pop /> pops to the previous one. Pause is then space in playing pushing paused, and space in paused popping back. A bare <reset /> from a state input or condition collapses the stack to the first state, so mainmenu -> playing -> gameover -> mainmenu -> ... does not grow forever.

Naming history (file layout)

During a July 2026 restructure the engine’s files were grouped by responsibility, with a compile_* group for the pipeline (parse, validate, evaluate, generate) and a second group for the data those steps produce. Names considered for the second group: model_, runtime_, world_, instance_, def_, schema_, live_, sim_.

The useful conclusion was that model_object and model_states are parallel: both are definitions parsed from XML, so they should share a prefix rather than one moving to runtime_. What is genuinely runtime is the current state and the live objects. The current code (object.h, states.h, game.cpp) has since been flattened and no longer uses these directory prefixes; see 16.

Design questions still open

Sources