-- Genre two of milestone 4: tower defence. Creeps that walk a lane on the navigation mesh in -- waves, turrets placed with a click on the floor that fire at the nearest creep in range, -- projectiles that collide, gold and lives. Nothing here is shared with the racing game but the -- scene. return { title = "Author test: tower defence", size = { w = 720, h = 480 }, layers = { { kind = "scene3d", ambient = { r = 80, g = 90, b = 80 }, fov = 55 }, { kind = "overlay" } }, vars = { score = 0, gold = 120, lives = 5, killed = 0 }, kinds = { floor = { look = { kind = "mesh", shape = "box", w = 30, h = 0.4, d = 24, r = 80, g = 110, b = 80 }, behaviours = { { kind = "solid" } } }, creep = { look = { kind = "mesh", shape = "box", w = 0.6, h = 0.8, d = 0.6, r = 120, g = 200, b = 90 }, vars = { health = 3 }, behaviours = { { kind = "walker", speed = 2.5, radius = 0.3 }, { kind = "patrol", points = { { x = -10, y = 0, z = -6 }, { x = 10, y = 0, z = -6 }, { x = 10, y = 0, z = 6 }, { x = -10, y = 0, z = 6 } } }, { kind = "health", max = 3 } } }, hive = { look = { kind = "none" }, behaviours = { { kind = "spawner", spawns = "creep", every = 1.2, max = 8, total = 10, points = { { x = -12, y = 0, z = -6 } } } } }, turret = { look = { kind = "mesh", shape = "cylinder", w = 0.8, h = 1.2, r = 70, g = 90, b = 220 }, behaviours = { { kind = "turret", targets = "creep", range = 6, rate = 0.5, spawns = "bolt", speed = 14 } } }, bolt = { look = { kind = "mesh", shape = "sphere", w = 0.25, r = 255, g = 230, b = 80 }, behaviours = { { kind = "projectile", life = 2 } } }, camera = { look = { kind = "none" }, behaviours = { { kind = "camera", mode = "fixed", lookX = 0, lookY = 0, lookZ = 0 } } }, readout = { look = { kind = "text", text = "", r = 235, g = 235, b = 245 } } }, rooms = { { name = "field", navFrom = { "floor" }, entities = { { kind = "floor", id = "floor", x = 0, y = -0.2, z = 0 }, { kind = "hive", id = "hive", x = -12, y = 0, z = -6 }, { kind = "camera", id = "camera", x = 0, y = 20, z = 14 }, { kind = "readout", id = "readout", x = 12, y = 12, z = 0 } } } }, rules = { { note = "A click on the floor builds a turret, for fifty gold", on = "pressed", switch = "SWITCH_BUTTON3", when = { { "test", expr = "gold >= 50" } }, act = { { "spawnAtPointer", kind = "turret", player = 1 }, { "addVar", name = "gold", amount = -50 } } }, { note = "A bolt lands", on = "collision", a = "bolt", b = "creep", act = { { "destroy", entity = "self" }, { "damage", entity = "other", amount = 1 } } }, { note = "A creep dies", on = "death", kind = "creep", act = { { "addVar", name = "gold", amount = 20 }, { "addScore", amount = 10 }, { "addVar", name = "killed", amount = 1 } } }, { note = "A creep reaches the end of the lane", on = "patrolEnd", kind = "creep", act = { { "destroy", entity = "self" }, { "addVar", name = "lives", amount = -1 } } }, { note = "Out of lives", on = "frame", when = { { "test", expr = "lives <= 0" }, { "once", tag = "over", scope = "game" } }, act = { { "gameOver" } } }, { note = "The readout, every frame", on = "frame", act = { { "setText", entity = "readout", text = '"gold " .. gold .. " lives " .. lives .. " killed " .. killed .. " creeps " .. count("creep")' } } } } }