The game language
A game the engine plays with no script, written as one JSON object. The engine checks it (and says what is wrong, in words), lays it out, writes tests for it and plays it before it is called ready. crates/ae_cli/src/gamespec.rs reads and plays it; 35 games are written in it in crates/ae_cli/assets/games/, and a connected model is told it to write games nobody wrote.
{"name": "Fruit Catch", "view": "side", "size": [22, 12.5], "background": "sky", "edges": "solid",
"things": {
"basket": {"role": "player", "look": "model:basket", "size": [2.0, 1.4], "move": "pointer-x", "speed": 12},
"apple": {"role": "item", "look": "model:apple", "size": [0.9, 0.9], "move": "fall", "gravity": 5},
"bomb": {"role": "hazard", "look": "model:bomb", "size": [1.0, 1.0], "move": "fall", "gravity": 5}},
"start": [{"what": "basket", "at": "bottom"}],
"spawn": [{"what": "apple", "at": "top", "every": 0.9, "faster": 0.99}, {"what": "bomb", "at": "top", "every": 3.0, "first": 4}],
"touch": [{"a": "basket", "b": "apple", "do": ["remove b", "score 1"]}, {"a": "basket", "b": "bomb", "do": ["remove b", "hurt"]},
{"a": "apple", "b": "edge", "do": ["remove a"]}],
"win": {"score": 30}, "lives": 3, "hint": "Move the mouse to catch the fruit"}
The parts
| Part | What it is |
|---|---|
view | top (seen from above: x across, y up the screen) or side (x across, y up) |
size, edges | the play area, about [20, 12]; its edges solid (things stay in), wrap (out one side, in the other) or open |
background | space, night, sky, grass, sand, water, road, snow, dungeon, neon |
things | each kind of thing: role (player, enemy, hazard, item, goal, shot, wall, box, other), look (Cube, Sphere, Cylinder, Cone, Capsule, Torus, Wedge, Dome, or model:<noun> fetched from the internet), colour, glow, size, tall (height seen from above), move, speed, gravity, jump, solid, push, hits, spin, lifetime, shoot {what, key: space, click or auto, every, aim: up, down, left, right, facing, player or pointer} |
move | the player: arrows, left-right, up-down, grid (a square at a time), platform (side: run and jump), flap, steer (turn and thrust), pointer, pointer-x, tilt (rolls the way the phone is tipped, like a marble; the arrows push it on a computer). Others: still, up, down, left, right, across (away from the side it came in), wander, chase, flee, hunt (through a maze), bounce, march (side to side, a step down at each edge), patrol, fall, drift, zigzag |
start | where things are at first: [x, y], bottom, top, left, right, middle, random, top-row, bottom-row, {points}, {lanes}, {columns} or {block: [cols, rows]}, with a count (edges is for spawn: what comes in from outside as the game goes) |
map, legend, cell | a level drawn in letters instead (row 0 at the top) |
spawn | what appears as it goes: what, at (a place as in start), every, first, most, faster |
touch | what happens when a meets b (or a is "click": the player clicked on b; or b is "edge": a left the area): remove a, remove b, score N, hurt, lives N, lose, win, bounce, stop, spawn KIND, turn a into KIND, turn b into KIND, time +N, say WORDS |
win, lose | {score: N}, {cleared: KIND}, {survive: seconds}, {all_on: [KIND, KIND]}, "time_up" |
lives, time, hud, hint | lives, a time limit, the line at the top ({score} {lives} {time}), how to play (and hint_ar) |
tilt | true: tipping the phone steers the player too, as the arrows do |
On a phone every game plays by fingers. A tap is a click where the finger was (it counts when the finger comes up, so a long press, which is a right click, flags instead), a quick flick is a press of the arrow that way (a grid player steps), a finger drags a pointer player, and a tap flaps. A player that is steered (arrows, left-right, up-down, platform, steer) gets a stick and, when it jumps or shoots with Space, one button. A test tips the phone with the step {"tilt": [x, y], "secs": n}.
"hurt" costs the player a life and sends it back to where it started, safe for a moment. A thing that starts a little inside a wall can move away from it. "cleared" counts once there has been something of that kind.