An engine for describing games built around Xerces, exprtk, and SFML.
Status: built (games/asteroids.xml, tests/test_asteroids.cpp); new verbs and tags: <heading>, <drag>, <hidden>, <turn>, <thrust>, <release>; <fire> now takes a group and follows the heading; <inc>/<dec> take an amount
Asteroids (Atari, 1979) needs what Lunar Lander (34) left out: a ship that turns and is pushed along the way it faces, shots that leave its nose, a ship that coasts and slowly loses speed, a screen with no edges, and rocks that break into smaller rocks. Pixel collisions and <wrap /> already existed; everything else about facing and breaking is new.
An 800 by 600 window. The ship is a triangle of four lines. Left and right turn it, up thrusts along the way it faces, space fires. Four big rocks drift in; a shot breaks a big rock into two medium ones, a medium into two small ones, a small one into nothing. A big rock is worth 2, a medium one 5 and a small one 10, each one <inc variable="ship.score">N</inc>. Three ships; a rock touching the ship costs one and the ship starts again in the middle. All rocks gone is a win.
<heading> (degrees clockwise from straight up) and a picture that follows it.<turn> and a held <thrust> in an object’s <action>.<drag>: a fraction of the speed lost each frame, so thrust has a top speed.<fire> aimed along the heading, from a pool of shots, several in flight.<release> verb that brings some of them into play where another object was.<heading> is unchanged.rasterizeTurned) into a picture of the same square size at every heading. The object shows that picture, so every backend, which already redraws from the object’s bitmap, needed no change, and pixel collisions use the picture that is shown. The first version made 72 pictures (every 5 degrees) when the game loaded; 42 replaced that with turning on demand, to the whole degree, so the object keeps only the original and the picture it shows.<turn> and <thrust> are held like <move> and <accelerate>; <thrust> can burn a variable. Using either on an object with no <heading> is an error when the game loads.<drag> is a fraction from 0 up to (not including) 1, applied to the velocity once a frame after thrust.<group> of rocks is built at load and hidden (<hidden>true</hidden>). <release object="group">N</release> in a collision rule puts the first N out-of-play members back, centered on the object running the rule, at their own starting velocity. The same idea gives shots: <fire object="shots" /> picks the first member whose collisions are off.<inc> and <dec> take an amount (<inc variable="ship.score">5</inc>; a bare one is still 1). Scoring first repeated <inc />, which showed the need.remaining, so “no rocks left” is a plain condition.<reset /> restores the heading as well as the position; <stop /> also clears turn and thrust.The ship comes back at the middle straight away, with no wait for a safe spot. A pool member has the same velocity every time it is released. One wave only, no flying saucer, no sound. Headings are rounded to a whole degree.