-- Arcade physics, from the catalogue: a ball that bounces, bricks that break, a paddle the keys -- move, and a life lost when the ball is missed. world2d with no gravity. return { title = "Author test: breakout", size = { w = 720, h = 480 }, layers = { { kind = "world2d", gravity = 0 } }, vars = { score = 0, lives = 3, broken = 0 }, kinds = { wall = { look = { kind = "box", w = 20, h = 480, r = 90, g = 90, b = 110 }, behaviours = { { kind = "solid" } } }, roof = { look = { kind = "box", w = 720, h = 20, r = 90, g = 90, b = 110 }, behaviours = { { kind = "solid" } } }, paddle = { look = { kind = "box", w = 100, h = 14, r = 230, g = 230, b = 240 }, behaviours = { { kind = "keys", player = 1, left = "LEFT", right = "RIGHT" }, { kind = "mover", speed = 400, clamp = true }, { kind = "solid", moving = true } } }, ball = { look = { kind = "box", w = 14, h = 14, r = 255, g = 220, b = 80 }, behaviours = { { kind = "body", shape = "sphere", mass = 1, bounce = 1, friction = 0 } } }, brick = { look = { kind = "box", w = 60, h = 20, r = 220, g = 90, b = 90 }, behaviours = { { kind = "solid" } } }, readout = { look = { kind = "text", text = "", r = 235, g = 235, b = 245 } } }, rooms = { { name = "court", entities = { { kind = "wall", id = "wallL", x = 10, y = 240 }, { kind = "wall", id = "wallR", x = 710, y = 240 }, { kind = "roof", id = "roof", x = 360, y = 10 }, { kind = "brick", id = "brick1", x = 200, y = 100 }, { kind = "brick", id = "brick2", x = 280, y = 100 }, { kind = "brick", id = "brick3", x = 360, y = 100 }, { kind = "brick", id = "brick4", x = 440, y = 100 }, { kind = "brick", id = "brick5", x = 520, y = 100 }, { kind = "paddle", id = "paddle", x = 360, y = 440 }, { kind = "ball", id = "ball", x = 360, y = 380 }, { kind = "readout", id = "readout", x = 30, y = 30 } } } }, rules = { { note = "Serve", on = "roomStart", act = { { "push", entity = "ball", x = 120, y = -380 } } }, { note = "A brick breaks", on = "collision", a = "ball", b = "brick", act = { { "destroy", entity = "other" }, { "addScore", amount = 10 }, { "addVar", name = "broken", amount = 1 } } }, { note = "The ball is missed", on = "frame", when = { { "test", expr = "ball.y > 500" } }, act = { { "addVar", name = "lives", amount = -1 }, { "moveTo", entity = "ball", x = 360, y = 380 }, { "push", entity = "ball", x = -100, y = -380 } } }, { note = "The readout, every frame", on = "frame", act = { { "setText", entity = "readout", text = '"score " .. score .. " lives " .. lives' } } } } }