-- Genre one of milestone 1: a shoot-em-up. Kinds spawned by the dozen, bullets that collide, -- health, a spawner, a HUD document, sound, and a game over -- none of which the first slice could -- say. Everything is a box, so the description needs no art. return { title = "Author test: shoot-em-up", layers = { { kind = "overlay" }, { kind = "hud", document = "testScripts/author/hud.rml", bind = { score = "score", lives = "lives" } } }, vars = { score = 0, lives = 3 }, kinds = { ship = { look = { kind = "box", w = 28, h = 20, r = 120, g = 220, b = 255 }, vars = { health = 1 }, behaviours = { { kind = "keys", player = 1, left = "LEFT", right = "RIGHT", up = "UP", down = "DOWN", fire = "SPACE" }, { kind = "mover", speed = 260, clamp = true }, { kind = "shooter", spawns = "shot", rate = 0.15, offsetY = -14 }, { kind = "health", max = 1, keep = true }, { kind = "sound", hit = "testScripts/crackle.wav" } } }, shot = { look = { kind = "box", w = 4, h = 10, r = 255, g = 255, b = 160 }, behaviours = { { kind = "projectile", vx = 0, vy = -520, life = 3 } } }, raider = { look = { kind = "box", w = 26, h = 18, r = 240, g = 80, b = 80 }, vars = { health = 2 }, behaviours = { { kind = "drift", vx = 0, vy = 90 }, { kind = "health", max = 2 }, { kind = "sound", death = "testScripts/crackle.wav" } } }, hive = { look = { kind = "none" }, behaviours = { { kind = "spawner", spawns = "raider", every = 0.6, max = 6, total = 12, points = { { x = 100, y = -20 }, { x = 300, y = -20 }, { x = 500, y = -20 }, { x = 640, y = -20 } } } } } }, rooms = { { name = "space", entities = { { kind = "ship", id = "ship", x = 360, y = 420 }, { kind = "hive", id = "hive", x = 360, y = -20 } } } }, rules = { { note = "A shot lands on a raider", on = "collision", a = "shot", b = "raider", act = { { "destroy", entity = "self" }, { "damage", entity = "other", amount = 1 }, { "addScore", amount = 10 } } }, { note = "A raider dies", on = "death", kind = "raider", act = { { "emit", entity = "self", count = 24, r = 255, g = 120, b = 60 }, { "addScore", amount = 50 } } }, { note = "A raider rams the ship", on = "collision", a = "raider", b = "ship", act = { { "destroy", entity = "self" }, { "damage", entity = "other", amount = 1 } } }, { note = "The ship is lost", on = "death", kind = "ship", act = { { "addVar", name = "lives", amount = -1 }, { "flash", r = 255, g = 60, b = 60, seconds = 0.3 }, { "setVar", entity = "self", name = "health", value = 1 }, { "moveTo", entity = "self", x = 360, y = 420 } } }, { note = "Out of lives", on = "frame", when = { { "test", expr = "lives <= 0" } }, act = { { "gameOver" } } }, { note = "A raider slips past the bottom", on = "frame", each = "raider", when = { { "test", expr = "self.y > 500" } }, act = { { "destroy", entity = "self" } } }, { note = "The wave is done", on = "frame", when = { { "test", expr = 'count("raider") == 0 and hive.made >= 12' }, { "once", tag = "wave", scope = "game" } }, act = { { "setVar", name = "cleared", value = true }, { "say", text = '"WAVE CLEAR"', seconds = 2 } } } } }