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

Input

Keys are bound in states, never in objects. An object names what it can do; a state binds a key to that name:

<object name="paddle1">
  <actions>
    <action name="up"><move direction="up">step</move></action>
  </actions>
</object>
...
<state name="playing">
  <inputs>
    <input><button>w</button><button>up</button><trigger object="paddle1" action="up" /></input>
  </inputs>
</state>

So remapping a key is one edit in one state, a key can do different things in different states, and one action name can mean different things on different objects.

Keys

A key’s three moments

on= picks which moment an <input> answers:

on= Runs its commands
press (or left out) as the key goes down; held verbs (<move>, <accelerate>, <thrust>, <turn>) stay on until it is let go
hold every frame while it is down, each time as one press
release once, as it is let go
<input button="space" on="hold"><trigger object="arrow" action="charge" from="ready" /></input>
<input button="space" on="release"><trigger object="arrow" action="putt" from="ready" /></input>

Pointing controls

<input axis="mouse.x"> (or mouse.y, pad1.x, pad1.y, pad2.x, pad2.y) runs its <trigger> whenever that control moves, and a <track /> in the action puts the object where it points: its middle at the mouse, or as far across as the stick is pushed, kept in the window. That is the Atari’s paddle controller.

<action name="steer"><track /></action>
...
<input axis="mouse.x"><trigger object="bucket" action="steer" /></input>

Held keys and state changes