XMLGameEngine

XMLGameEngine is a VGDL (video game description language) and an engine for running games completely contained within an XML file.

View the Project on GitHub beefviper/XMLGameEngine

Collisions

<collisions> says how an object touches, then its rules:

<collisions>
  <type>pixel</type>                      <!-- optional: box (default) or pixel -->
  <solid char="*" />                      <!-- optional, pixel only: which bitmap characters touch -->
  <collision edge="vertical"><bounce /></collision>
  <collision class="bricks"><deflect>30</deflect></collision>
  <collision object="paddle" side="bottom"> ... </collision>
</collisions>

In order: <enabled> (false turns it off), <lockstep>, <type>, <solid>s, a <hitbox>, then the rules. Only objects in play with collisions on take part.

Rules

Rule filters

Filter Runs only
side="top" (bottom, left, right, horizontal, vertical) when touched on that side of its own object: a ball falling onto a block is touched on its bottom
sprite="cracked" (edges too) while its object shows that look, as the touch happened
unless="logs" (edges too) when not also touching something of that class right now. Frogger’s river: <collision class="water" unless="logs">
through="floor" for a touch felt through something of that class; without it, only a direct touch
<slower>N</slower>, <faster>N</faster> (first in the rule) while its speed is under N, or N or more, as the touch happened: a landing and a crash on one pad. Not on edges
<condition>s, <all>, <any> (after those) while every one holds, written as a condition. One with no class= or object= is about the object itself. Not on edges yet

How a touch is found

<hitbox>
  <rectangle><width>12</width><height>6</height></rectangle>
  <position><x>6</x><y>18</y></position>
</hitbox>

Lockstep

<lockstep>true</lockstep> in a group’s <collisions> makes each innermost group one block: its members never touch each other, a rule’s <move> moves them all, and one hitting a side with <bounce /> turns the whole block. Each cell is still swept on its own, so a bullet meets only the cells alive. This is the invaders’ march.

Knocks

<knock /> in a rule about another object makes the two meet as things with weight:

<collision class="ball"><knock>0.3</knock></collision>    <!-- on a flipper -->