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

Status: Built: detection, dispatch and execution apart; swept touches; pixel tests; riding and carrying; unless=; deflect; side, checks and triggers in rules; contacts and <knock>; solid inks and hitboxes; bounce by the normal. Reference: collisions, commands.

Structure

The algorithm

Fewer checks

Donkey Kong lagged: about 50,000 pairs compared each frame. Kept every touch and its order exactly, and:

  1. which pairs a rule answers for is found once per game (FrameRules::partners);
  2. each pair first checks whether the boxes they cover over the frame meet;
  3. a pair too far apart sleeps until a reaction moves one of them;
  4. being in play is cached until the stage changes.

A screen grid was rejected: it needs a cell size per game, and what is left after pruning is a few hundred cheap tests. Open: a grid if a game has thousands of movers; nearest searches still look at everything.

Riding, carrying, unless

Pixel collisions

Filters and checks in rules

Deflect

Pong’s rule: the paddle’s middle sends the ball straight back, its ends at 45 degrees. <deflect>45</deflect> measures from the side’s middle and keeps the speed. Rejected: <bounce>45</bounce> (bounce also runs on edges).

Contacts and knocks

Bounce by the normal