-- A space shooter, from the catalogue: a ship on a body pushed by thrust and turned by the keys, -- bolts it fires, rocks that come at it, and a camera behind. No gravity. return { title = "Author test: space", size = { w = 720, h = 480 }, layers = { { kind = "scene3d", gravity = 0, ambient = { r = 40, g = 40, b = 70 }, fov = 65 }, { kind = "overlay" } }, vars = { score = 0, rocks = 0 }, types = { ship = { look = { kind = "mesh", shape = "box", w = 1.2, h = 0.4, d = 2.4, r = 200, g = 210, b = 240 }, behaviours = { { kind = "body", mass = 50, friction = 0 }, { kind = "thrust", force = 400, turn = 1.2 }, { kind = "keys", player = 1, left = "LEFT", right = "RIGHT", up = "UP", down = "DOWN", fire = "SPACE" }, { kind = "shooter", spawns = "bolt", rate = 0.2, offsetY = 0 } } }, bolt = { look = { kind = "mesh", shape = "sphere", w = 0.3, r = 255, g = 240, b = 120 }, behaviours = { { kind = "projectile", vx = 0, vy = 0, vz = -30, life = 3 } } }, rock = { look = { kind = "mesh", shape = "sphere", w = 2, r = 130, g = 110, b = 90 }, vars = { health = 1 }, behaviours = { { kind = "projectile", vx = 0, vy = 0, vz = 6, life = 20 }, { kind = "health", max = 1 } } }, belt = { look = { kind = "none" }, behaviours = { { kind = "spawner", spawns = "rock", every = 0.8, max = 8, total = 12, points = { { x = -4, y = 0, z = -60 }, { x = 0, y = 0, z = -60 }, { x = 4, y = 0, z = -60 }, { x = 2, y = 1, z = -60 } } } } }, camera = { look = { kind = "none" }, behaviours = { { kind = "camera", mode = "follow", target = "ship", x = 0, y = 3, z = 8, lookY = 0, lag = 0.2 } } }, readout = { look = { kind = "text", text = "", r = 235, g = 235, b = 245 } } }, rooms = { { name = "belt", entities = { { type = "ship", id = "ship", x = 0, y = 0, z = 0 }, { type = "belt", id = "belt", x = 0, y = 0, z = -60 }, { type = "camera", id = "camera", x = 0, y = 3, z = 8 }, { type = "readout", id = "readout", x = 12, y = 12, z = 0 } } } }, rules = { { note = "A bolt meets a rock", on = "collision", a = "bolt", b = "rock", act = { { "destroy", entity = "self" }, { "damage", entity = "other", amount = 1 } } }, { note = "A rock is broken", on = "death", type = "rock", act = { { "addScore", amount = 25 }, { "addVar", name = "rocks", amount = 1 } } }, { note = "The readout, every frame", on = "frame", act = { { "setText", entity = "readout", text = '"score " .. score .. " rocks " .. rocks' } } } } }