50 lines
2.1 KiB
Text
50 lines
2.1 KiB
Text
-- A rhythm game, from the catalogue: a track plays, notes are windows in time, and a press inside
|
|
-- one scores while one outside is a miss. The notes are a track of points keyed by time, so the
|
|
-- editor's timeline lays them out.
|
|
return {
|
|
title = "Author test: rhythm",
|
|
size = { w = 720, h = 480 },
|
|
layers = { { kind = "overlay" }, { kind = "music", file = "testScripts/tune.mp3", volume = 60 } },
|
|
vars = { score = 0, hits = 0, misses = 0, early = 0 },
|
|
|
|
types = {
|
|
lane = { look = { kind = "box", w = 60, h = 400, r = 40, g = 40, b = 60 } },
|
|
marker = { look = { kind = "box", w = 80, h = 6, r = 200, g = 200, b = 220 } },
|
|
note = { look = { kind = "box", w = 50, h = 16, r = 255, g = 200, b = 60 },
|
|
behaviours = { { kind = "drift", vx = 0, vy = 200 } } },
|
|
readout = { look = { kind = "text", text = "", r = 235, g = 235, b = 245 } }
|
|
},
|
|
|
|
rooms = {
|
|
{ name = "stage",
|
|
entities = {
|
|
{ type = "lane", id = "lane", x = 360, y = 240 },
|
|
{ type = "marker", id = "marker", x = 360, y = 400 },
|
|
{ type = "readout", id = "readout", x = 12, y = 12 }
|
|
},
|
|
tracks = {
|
|
{ name = "notes", key = "time", points = { { at = 1.0 }, { at = 2.0 }, { at = 2.5 }, { at = 3.5 } } }
|
|
} }
|
|
},
|
|
|
|
rules = {
|
|
{ note = "A note falls two seconds before its time",
|
|
on = "frame", each = "lane",
|
|
when = { { "every", seconds = 0.5, tag = "spawn" }, { "test", expr = "time < 2" } },
|
|
act = { { "spawn", type = "note", x = 360, y = 0 } } },
|
|
|
|
{ note = "A press on a note at the marker",
|
|
on = "pressed", key = "SPACE", each = "note",
|
|
when = { { "test", expr = "abs(self.y - 400) < 24" } },
|
|
act = { { "destroy", entity = "self" }, { "addScore", amount = 100 }, { "addVar", name = "hits", amount = 1 } } },
|
|
|
|
{ note = "A note that falls past the marker is a miss",
|
|
on = "frame", each = "note",
|
|
when = { { "test", expr = "self.y > 440" } },
|
|
act = { { "destroy", entity = "self" }, { "addVar", name = "misses", amount = 1 } } },
|
|
|
|
{ note = "The readout, every frame",
|
|
on = "frame",
|
|
act = { { "setText", entity = "readout", text = '"score " .. score .. " hits " .. hits .. " misses " .. misses' } } }
|
|
}
|
|
}
|