singe/testScripts/author/maze.game
2026-09-14 14:20:17 -05:00

48 lines
2.3 KiB
Text

-- A maze, from the catalogue: corridors that are a walk area, a hero sent by clicks, dots that
-- are eaten on touch, and a ghost that follows the hero across the mesh.
return {
title = "Author test: maze",
size = { w = 720, h = 480 },
layers = { { kind = "overlay" } },
vars = { score = 0, eaten = 0 },
kinds = {
walls = { look = { kind = "grid", file = "testScripts/checker.png", tile = 32, columns = 2, map = "1 1 1 1 1 1 1 1 1 1 1; 1 0 0 0 0 0 0 0 0 0 1; 1 0 1 1 1 0 1 1 1 0 1; 1 0 0 0 0 0 0 0 0 0 1; 1 1 1 1 1 1 1 1 1 1 1" } },
hero = { look = { kind = "box", w = 24, h = 24, r = 255, g = 230, b = 60 }, behaviours = { { kind = "walker", speed = 140, radius = 6 } } },
ghost = { look = { kind = "box", w = 24, h = 24, r = 90, g = 120, b = 255 }, behaviours = { { kind = "walker", speed = 90, radius = 6, follow = "hero", every = 0.3, stopAt = 10 } } },
dot = { look = { kind = "box", w = 8, h = 8, r = 255, g = 255, b = 255 } },
readout = { look = { kind = "text", text = "", r = 235, g = 235, b = 245 } }
},
rooms = {
{ name = "maze",
walk = { { 40, 140, 360, 140, 360, 220, 40, 220 }, { 40, 220, 360, 220, 360, 300, 40, 300 } },
entities = {
{ kind = "walls", id = "walls", x = 8, y = 100 },
{ kind = "dot", id = "dot1", x = 150, y = 180 },
{ kind = "dot", id = "dot2", x = 250, y = 180 },
{ kind = "dot", id = "dot3", x = 250, y = 260 },
{ kind = "hero", id = "hero", x = 60, y = 180 },
{ kind = "ghost", id = "ghost", x = 340, y = 260 },
{ kind = "readout", id = "readout", x = 12, y = 12 }
} }
},
rules = {
{ note = "A click sends the hero",
on = "pressed", switch = "SWITCH_BUTTON3", interrupt = true,
act = { { "walkToPointer", entity = "hero", player = 1 } } },
{ note = "A dot is eaten",
on = "collision", a = "hero", b = "dot",
act = { { "destroy", entity = "other" }, { "addScore", amount = 10 }, { "addVar", name = "eaten", amount = 1 } } },
{ note = "Caught",
on = "collision", a = "ghost", b = "hero",
act = { { "setVar", name = "caught", value = true } } },
{ note = "The readout, every frame",
on = "frame",
act = { { "setText", entity = "readout", text = '"score " .. score .. " eaten " .. eaten' } } }
}
}