XMLGameEngine

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

View the Project on GitHub beefviper/XMLGameEngine

06. Names and classes

Status: implemented (name, class, filters, unique names for grid cells); class inheritance and compound selectors are ideas only

Decision

Objects have a name (their unique identifier) and an optional class (a group label). This is borrowed from HTML’s id and class, with the same purpose: target one specific thing, or all things of a kind.

<object name="paddle1" class="paddle"> ... </object>
<condition class="paddle" variable="score"><atleast>15</atleast><push state="gameover" /></condition>

A single condition on class="paddle" checks either paddle’s score, instead of writing one condition per paddle.

Where it is used today

Unique names for grid cells (built)

The author’s view was that every object block needs a unique name anyway. Every cell of a <grid> is now its own object, named after the grid with its column and row counted from 1 (aliens.3.2). The grid’s own name still works where the whole group is meant: <show object="aliens"/>, a rule or condition with object="aliens", <reset object="aliens" />, while a single cell can be named on its own. This is what lets each cell be swept and killed on its own (11) and lets a condition watch one alien. Names for formations (group1[x]) were not built. The members of a <group> are named the same way, the group’s name and a number (logrow3.2), and the group’s own name means all of them (29).

Ideas discussed, not built

Second batch: alternatives

Sources