singe/testScripts/author/pool.game
2026-09-14 14:20:17 -05:00

42 lines
2.3 KiB
Text

-- The long tail, in 3D: water a body floats in, a boat pushed by its propeller, and a soft
-- body -- the pieces a boat game or a physics toy needs.
return {
title = "Author test: the pool",
size = { w = 720, h = 480 },
layers = { { kind = "scene3d", ambient = { r = 90, g = 100, b = 120 }, fov = 55 }, { kind = "overlay" } },
vars = { score = 0 },
kinds = {
floor = { look = { kind = "mesh", shape = "box", w = 40, h = 0.4, d = 40, r = 90, g = 90, b = 80 }, behaviours = { { kind = "solid" } } },
pool = { look = { kind = "mesh", shape = "box", w = 20, h = 3, d = 20, r = 60, g = 120, b = 200 }, behaviours = { { kind = "water", density = 1 } } },
ball = { look = { kind = "mesh", shape = "sphere", w = 0.8, r = 220, g = 80, b = 80 }, behaviours = { { kind = "body", shape = "sphere", mass = 2, buoyancy = 2 } } },
boat = { look = { kind = "mesh", shape = "box", w = 1.6, h = 0.4, d = 2.6, r = 200, g = 170, b = 90 },
behaviours = { { kind = "body", mass = 120, buoyancy = 3 }, { kind = "vehicle", type = "boat", mass = 120, thrust = 600 } } },
balloon = { look = { kind = "mesh", shape = "sphere", w = 1, r = 240, g = 220, b = 80 }, behaviours = { { kind = "soft", type = "body", pressure = 2, mass = 0.6 } } },
camera = { look = { kind = "none" }, behaviours = { { kind = "camera", mode = "fixed", lookX = 0, lookY = 1, lookZ = 0 } } },
readout = { look = { kind = "text", text = "", r = 235, g = 235, b = 245 } }
},
rooms = {
{ name = "pool",
entities = {
{ kind = "floor", id = "floor", x = 0, y = -3.2, z = 0 },
{ kind = "pool", id = "pool", x = 0, y = -1.5, z = 0 },
{ kind = "ball", id = "ball", x = 3, y = 3, z = 2 },
{ kind = "boat", id = "boat", x = -4, y = 0.4, z = 6 },
{ kind = "balloon", id = "balloon", x = 6, y = 4, z = -6 },
{ kind = "camera", id = "camera", x = 0, y = 10, z = 16 },
{ kind = "readout", id = "readout", x = 12, y = 12, z = 0 }
} }
},
rules = {
{ note = "The boat runs its propeller",
on = "frame", each = "boat",
act = { { "setVar", entity = "self", name = "dy", value = -1 } } },
{ note = "The readout, every frame",
on = "frame",
act = { { "setText", entity = "readout", text = '"ball y " .. floor(ball.y * 10) / 10 .. " boat z " .. floor(boat.z * 10) / 10' } } }
}
}