65 lines
3.2 KiB
Text
65 lines
3.2 KiB
Text
-- Genre two of milestone 2: a 3D platformer. A character on the engine's controller, a camera
|
|
-- that follows, floors and ledges, a prize that is a trigger, and a fall that puts the hero back.
|
|
-- Nothing in it is shared with the rail shooter but the scene itself.
|
|
return {
|
|
title = "Author test: 3D platformer",
|
|
size = { w = 720, h = 480 },
|
|
layers = { { kind = "scene3d", ambient = { r = 80, g = 80, b = 100 }, fov = 55 }, { kind = "overlay" } },
|
|
vars = { score = 0 },
|
|
|
|
types = {
|
|
floor = { look = { kind = "mesh", shape = "box", w = 30, h = 0.4, d = 12, r = 90, g = 110, b = 90 }, behaviours = { { kind = "solid" } } },
|
|
ledge = { look = { kind = "mesh", shape = "box", w = 4, h = 0.4, d = 4, r = 110, g = 90, b = 70 }, behaviours = { { kind = "solid" } } },
|
|
prize = { look = { kind = "mesh", shape = "sphere", w = 0.6, r = 255, g = 200, b = 60 }, behaviours = { { kind = "trigger" } } },
|
|
hero = { look = { kind = "model", file = "testScripts/Models/Fox.glb", scale = 0.008, w = 0.6, h = 0.9, d = 0.6 },
|
|
behaviours = { { kind = "keys", player = 1, left = "LEFT", right = "RIGHT", up = "UP", down = "DOWN" },
|
|
{ kind = "character", speed = 4, jump = 6.5, radius = 0.3, height = 0.9 },
|
|
{ kind = "animator", idle = "Survey", walk = "Walk" } } },
|
|
camera = { look = { kind = "none" }, behaviours = { { kind = "camera", mode = "follow", target = "hero", x = 0, y = 3, z = 7, lookY = 0.6, lag = 0.2 } } },
|
|
readout = { look = { kind = "text", text = "", r = 235, g = 235, b = 245 } }
|
|
},
|
|
|
|
rooms = {
|
|
{ name = "field",
|
|
entities = {
|
|
{ type = "floor", id = "floor", x = 0, y = -0.2, z = 0 },
|
|
{ type = "ledge", id = "ledge", x = 6, y = 1.2, z = 0 },
|
|
{ type = "prize", id = "prize", x = 6, y = 2.0, z = 0 },
|
|
{ type = "hero", id = "hero", x = -4, y = 0.5, z = 0 },
|
|
{ type = "camera", id = "camera", x = -4, y = 3, z = 7 },
|
|
{ type = "readout", id = "readout", x = 12, y = 12, z = 0 }
|
|
} }
|
|
},
|
|
|
|
rules = {
|
|
{ note = "Walking sets the state the animator plays",
|
|
on = "frame", each = "hero",
|
|
when = { { "test", expr = "self.dx != 0 or self.dy != 0" } },
|
|
act = { { "setState", entity = "self", state = "walk" } } },
|
|
|
|
{ note = "Standing still",
|
|
on = "frame", each = "hero",
|
|
when = { { "test", expr = "self.dx == 0 and self.dy == 0" } },
|
|
act = { { "setState", entity = "self", state = "idle" } } },
|
|
|
|
{ note = "Jump, with ground underfoot",
|
|
on = "frame",
|
|
when = { { "keyHeld", key = "SPACE" }, { "onGround", entity = "hero" } },
|
|
act = { { "jump", entity = "hero" } } },
|
|
|
|
{ note = "The prize is taken",
|
|
on = "enter", a = "prize", b = "hero",
|
|
act = { { "destroy", entity = "self" },
|
|
{ "addScore", amount = 100 },
|
|
{ "setVar", name = "won", value = true } } },
|
|
|
|
{ note = "Fallen off the world: back to the start",
|
|
on = "frame",
|
|
when = { { "test", expr = "hero.y < -5" } },
|
|
act = { { "moveTo", entity = "hero", x = -4, y = 0.5, z = 0 } } },
|
|
|
|
{ note = "The readout, every frame",
|
|
on = "frame",
|
|
act = { { "setText", entity = "readout", text = '"score " .. score' } } }
|
|
}
|
|
}
|