singe/testScripts/author/platformer.game
2026-09-13 22:06:39 -05:00

52 lines
2.3 KiB
Text

-- A game description: data, not code. Singe/AuthorCompile.singe turns it into a Singe game.
--
-- Genre one of two. This one uses a single world2d layer and shares nothing with the QTE beside
-- it -- no disc, no branching, no time windows -- which is the point: if the core can express
-- both, it is not secretly a platformer engine or secretly a laserdisc engine.
return {
title = "Author test: platformer",
layers = {
{ kind = "world2d", gravity = 1500 }
},
entities = {
{ id = "ground", x = 360, y = 440, look = { kind = "box", w = 720, h = 40, r = 60, g = 70, b = 90 },
behaviours = { { kind = "solid" } } },
{ id = "ledge", x = 520, y = 330, look = { kind = "box", w = 180, h = 20, r = 60, g = 70, b = 90 },
behaviours = { { kind = "solid" } } },
{ id = "prize", x = 520, y = 300, look = { kind = "box", w = 18, h = 18, r = 255, g = 200, b = 60 },
behaviours = { { kind = "drift", vx = 0, vy = 0 } } },
{ id = "hero", x = 120, y = 380, look = { kind = "box", w = 24, h = 44, r = 230, g = 90, b = 170 },
behaviours = { { kind = "platformer", speed = 210, jump = 620 } } },
{ id = "readout", x = 12, y = 12, look = { kind = "text", text = "score 0", r = 235, g = 235, b = 245 } }
},
rules = {
{ note = "Run left",
when = { { "keyHeld", key = "LEFT" } },
act = { { "run", entity = "hero", direction = -1 } } },
{ note = "Run right",
when = { { "keyHeld", key = "RIGHT" } },
act = { { "run", entity = "hero", direction = 1 } } },
{ note = "Jump, but only with ground underfoot",
when = { { "keyHeld", key = "SPACE" }, { "onGround", entity = "hero" } },
act = { { "jump", entity = "hero" } } },
{ note = "Take the prize once",
when = { { "touching", entity = "hero", other = "prize" }, { "once", tag = "prize" } },
act = { { "addScore", amount = 100 },
{ "show", entity = "prize", visible = false },
{ "setFlag", flag = "won", value = true } } },
{ note = "Fallen off the world: back to the start",
when = { { "below", entity = "hero", y = 520 } },
act = { { "moveTo", entity = "hero", x = 120, y = 380 } } },
{ note = "The readout, every frame",
when = {},
act = { { "setText", entity = "readout", text = '"score " .. AUTHOR_SCORE' } } }
}
}