-- Scene API:
--
-- Functions:
--- SetPlayfieldBounds(point1, point2)
--- SetMaximumBounds(point1, point2)
+-- SetBounds(point1, point2)
-- ResetTransform()
-- Translate(x, y, z)
-- Scale(x, y, z) or Scale(xyz)
-- Rotate(axis, degree) or Rotate(x, y, z)
-- SetTexture(name)
--- MakeTilemap({width = ..., surface_type = ..., tiles = {}})
--- MakeBillboard({tile = ..., u_scale = ...})
+-- DrawTilemap({width = $num, [surface = TOP | LEFT | RIGHT], tiles})
+-- DrawTile(tile, [u_scale])
--
-- Globals:
--- detail - level of detail of the scene
+-- detail - level of detail of the scene (HIGH, MEDIUM, or LOW)
-SetPlayfieldBounds({0, 0, -100}, {1280, 500, 100})
-SetMaximumBounds({-160, 0, -192}, {1440, 480, 224})
+SetBounds({-5, 0, -6}, {45, 15, 7})
-- Left end tower block
ResetTransform()
Translate(-5, 0, 5)
-Scale(32)
SetTexture("TowerBlock1")
-MakeTilemap({
+DrawTilemap({
width = 5,
- tiles = {
- 2, 2, 2, 2, 2,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 1, 0, 0, 1, 0,
- 4, 4, 4, 4, 4
- }
-})
+ 2, 2, 2, 2, 2,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 1, 0, 0, 1, 0,
+ 4, 4, 4, 4, 4})
-- Right side
ResetTransform()
Rotate(Y, 90)
Translate(0, 0, 5)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 5,
- surface_type = RIGHT,
- tiles = {
- 2, 2, 2, 2, 2,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 6,
- 4, 5, 5, 5, 4
- }
-})
+ surface = RIGHT,
+ 2, 2, 2, 2, 2,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 6,
+ 4, 5, 5, 5, 4})
-- Top
ResetTransform()
Rotate(X, 90)
Translate(-5, 15, 0)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 5,
- surface_type = TOP,
- tiles = {
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3
- }
-})
+ surface = TOP,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3})
-- Leftmost background tower block
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Front
-if detail > 1 then
+if detail > LOW then
ResetTransform()
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 7,
- tiles = {
- 2, 2, 2, 2, 2, 2, 2,
- 0, 1, 0, 0, 0, 1, 0,
- 0, 1, 0, 0, 0, 1, 0,
- 0, 1, 0, 0, 6, 1, 0,
- 0, 1, 0, 0, 0, 1, 0,
- 0, 1, 0, 0, 0, 1, 0,
- 0, 1, 0, 0, 0, 1, 0,
- 4, 4, 5, 5, 5, 4, 4
- }
- })
+ 2, 2, 2, 2, 2, 2, 2,
+ 0, 1, 0, 0, 0, 1, 0,
+ 0, 1, 0, 0, 0, 1, 0,
+ 0, 1, 0, 0, 6, 1, 0,
+ 0, 1, 0, 0, 0, 1, 0,
+ 0, 1, 0, 0, 0, 1, 0,
+ 0, 1, 0, 0, 0, 1, 0,
+ 4, 4, 5, 5, 5, 4, 4})
-- Right side
ResetTransform()
Rotate(Y, 90)
Translate(7, 0, 0)
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 6,
- tiles = {
- 2, 2, 2, 2, 2, 2,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 4, 4, 4, 4, 4, 4
- }
- })
+ 2, 2, 2, 2, 2, 2,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 4, 4, 4, 4, 4, 4})
-- Top
ResetTransform()
Rotate(X, 90)
Translate(-2, 8, -6)
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 9,
- tiles = {
- 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3
- }
- })
+ 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3})
end
-- Foreground building with pitched roof
ResetTransform()
Rotate(Y, -90)
Translate(10, 0, 1)
-Scale(32)
SetTexture("Building")
-MakeTilemap({
+DrawTilemap({
width = 4,
- surface_type = LEFT,
- tiles = {
- -1, 9, 11, -1,
- 9, 10, 12, 11,
- 15, 7, 7, 16,
- 3, 5, 6, 4,
- 3, 6, 5, 4
- }
-})
+ surface = LEFT,
+ -1, 9, 11, -1,
+ 9, 10, 12, 11,
+ 15, 7, 7, 16,
+ 3, 5, 6, 4,
+ 3, 6, 5, 4})
-- Right wall
ResetTransform()
Rotate(Y, -90)
Translate(13, 0, 1)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 4,
- surface_type = RIGHT,
- tiles = {
- -1, 9, 11, -1,
- 9, 10, 12, 11,
- 15, 7, 7, 16,
- 3, 5, 6, 4,
- 3, 8, 5, 4
- }
-})
+ surface = RIGHT,
+ -1, 9, 11, -1,
+ 9, 10, 12, 11,
+ 15, 7, 7, 16,
+ 3, 5, 6, 4,
+ 3, 8, 5, 4})
-- Front wall
ResetTransform()
Translate(10, 0, 5)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 3,
- tiles = {
- 15, 7, 16,
- 3, 5, 4,
- 3, 6, 4
- }
-})
+ 15, 7, 16,
+ 3, 5, 4,
+ 3, 6, 4})
-- Pitched roof
Rotate(X, 135)
Scale(1, 1.5, 1.5)
Translate(10, 5, 3)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 3,
- tiles = {
- 13, 13, 13,
- 13, 13, 13
- }
-})
+ 13, 13, 13,
+ 13, 13, 13})
-- Finial
ResetTransform()
Translate(10, 5, 3)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 3,
- tiles = {
- 18, 18, 18
- }
-})
+ 18, 18, 18})
-- Cheaty invisible platform
ResetTransform()
Translate(10, 4, 3)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 3,
- surface_type = TOP,
- tiles = {
- -1, -1, -1
- }
-})
+ surface = TOP,
+ -1, -1, -1})
-- The ground
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ResetTransform()
Rotate(X, 90)
Translate(-3, 0, 0)
-Scale(32)
SetTexture("Scenery")
-MakeTilemap({
+DrawTilemap({
width = 13,
- surface_type = TOP,
- tiles = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
- }
-})
+ surface = TOP,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ -1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
-- Front grass
-if detail > 2 then
+if detail > MEDIUM then
ResetTransform()
Scale(8, 1, 1)
Translate(1, -0.5, 5)
- Scale(32)
- MakeBillboard({
- tile = 2,
- u_scale = 8
- })
+ DrawTile({
+ 2,
+ u_scale = 8})
-- Back grass
ResetTransform()
Scale(8, 1, 1)
Translate(1, -0.5, 1)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 8
})
Scale(4, 1, 1)
Rotate(Y, -90)
Translate(1, -0.5, 1)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 4
})
Scale(4, 1, 1)
Rotate(Y, -90)
Translate(9, -0.5, 1)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 4
})
ResetTransform()
Scale(11, 1, 1)
Translate(7, 0, 0)
- Scale(32)
- MakeBillboard({
- tile = 4,
+ DrawTile({
+ 4,
u_scale = 11
})
end
-- Front wall
-if detail > 1 then
+if detail > LOW then
ResetTransform()
Translate(19, 0, 0)
- Scale(32)
SetTexture("Building")
- MakeTilemap({
+ DrawTilemap({
width = 4,
- tiles = {
- -1, 9, 11, -1,
- 9, 10, 12, 11,
- 15, 7, 7, 16,
- 3, 6, 5, 4,
- 3, 5, 6, 4,
- 3, 8, 5, 4
- }
- })
+ -1, 9, 11, -1,
+ 9, 10, 12, 11,
+ 15, 7, 7, 16,
+ 3, 6, 5, 4,
+ 3, 5, 6, 4,
+ 3, 8, 5, 4})
-- Left wall
ResetTransform()
Rotate(Y, -90)
Translate(19, 0, -3)
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 3,
- tiles = {
- 15, 1, 16,
- 3, 7, 4,
- 3, 5, 4,
- 3, 0, 4
- }
- })
+ 15, 1, 16,
+ 3, 7, 4,
+ 3, 5, 4,
+ 3, 0, 4})
-- Right wall
ResetTransform()
Rotate(Y, -90)
Translate(23, 0, -3)
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 3,
- tiles = {
- 15, 0, 16,
- 3, 7, 4,
- 3, 6, 4,
- 3, 2, 4
- }
- })
+ 15, 0, 16,
+ 3, 7, 4,
+ 3, 6, 4,
+ 3, 2, 4})
-- Left pitched roof
Scale(1, 1.5, 1.5)
Rotate(Y, -90)
Translate(21, 6, -3)
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 3,
- tiles = {
- 13, 13, 13,
- 13, 13, 13
- }
- })
+ 13, 13, 13,
+ 13, 13, 13})
-- Right pitched roof
Scale(1, 1.5, 1.5)
Rotate(Y, -90)
Translate(21, 6, -3)
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 3,
- tiles = {
- 13, 13, 13,
- 13, 13, 13
- }
- })
+ 13, 13, 13,
+ 13, 13, 13})
-- Finial
ResetTransform()
Rotate(Y, -90)
Translate(21, 6, -3)
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 3,
- tiles = {
- 18, 18, 18
- }
- })
+ 18, 18, 18})
end
-- More ground to the right
ResetTransform()
Rotate(X, 90)
Translate(10, 0, 0)
-Scale(32)
SetTexture("Scenery")
-MakeTilemap({
+DrawTilemap({
width = 3,
- surface_type = TOP,
- tiles = {
- 1, 1, 1,
- 1, 1, 1,
- -1, -1, -1,
- -1, -1, -1,
- -1, -1, -1,
- -1, -1, -1,
- 1, 1, 1
- }
-})
+ surface = TOP,
+ 1, 1, 1,
+ 1, 1, 1,
+ -1, -1, -1,
+ -1, -1, -1,
+ -1, -1, -1,
+ -1, -1, -1,
+ 1, 1, 1})
-- Left part of center courtyard
ResetTransform()
Rotate(X, 90)
Translate(13, 0, 0)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 8,
- surface_type = TOP,
- tiles = {
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 0, 0, 0, 0, 0, 0, 0,
- 1, 0, 0, 0, 0, 0, 1, 1,
- 0, 0, 0, 0, 0, 0, 1, 1,
- 1, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 0, 0, 0
- }
-})
+ surface = TOP,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 1, 1,
+ 0, 0, 0, 0, 0, 0, 1, 1,
+ 1, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 0, 0, 0})
-- Front grass
-if detail > 2 then
+if detail > MEDIUM then
ResetTransform()
Scale(12, 1, 1)
Translate(14, -0.5, 5)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 12
})
ResetTransform()
Scale(4, 1, 1)
Translate(14, -0.5, 1)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 4
})
ResetTransform()
Translate(13, -0.5, 3)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 1
})
ResetTransform()
Translate(13, -0.5, 2)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 1
})
ResetTransform()
Rotate(Y, -90)
Translate(14, -0.5, 1)
- Scale(32)
- MakeTilemap({
+ DrawTilemap({
width = 4,
- tiles = {
- 2, -1, 2, 2
- }
- })
+ 2, -1, 2, 2})
-- Grass left of house
ResetTransform()
Rotate(Y, -90)
Translate(18, -0.5, 0)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 1
})
ResetTransform()
Rotate(Y, -90)
Translate(24, -0.5, 0)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 1
})
ResetTransform()
Scale(4, 1, 1)
Translate(19, -0.5, 4)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 4
})
ResetTransform()
Scale(4, 1, 1)
Translate(19, -0.5, 2)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 4
})
Scale(2, 1, 1)
Rotate(Y, -90)
Translate(19, -0.5, 2)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 2
})
Scale(2, 1, 1)
Rotate(Y, -90)
Translate(23, -0.5, 2)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 2
})
end
ResetTransform()
Rotate(X, 90)
Translate(21, 0, 0)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 7,
- surface_type = TOP,
- tiles = {
- 1, 1, 1, 1, 1, 0, 0,
- 1, 1, 1, 1, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 0, 0, 0, 0, 0,
- 1, 1, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 1
- }
-})
+ surface = TOP,
+ 1, 1, 1, 1, 1, 0, 0,
+ 1, 1, 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 0, 0, 0, 0, 0,
+ 1, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1})
-- Fence to right of back house
-if detail > 2 then
+if detail > MEDIUM then
ResetTransform()
Scale(4, 1, 1)
Translate(24, 0, 0)
- Scale(32)
- MakeBillboard({
- tile = 4,
+ DrawTile({
+ 4,
u_scale = 4
})
ResetTransform()
Scale(4, 1, 1)
Translate(24, -0.5, 1)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 4
})
Scale(2, 1, 1)
Rotate(Y, -90)
Translate(26, -0.5, 5)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 2
})
Scale(2, 1, 1)
Rotate(Y, -90)
Translate(35, -0.5, 5)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 2
})
ResetTransform()
Scale(5, 1, 1)
Translate(35, -0.5, 5)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 5
})
ResetTransform()
Scale(6, 1, 1)
Translate(34, -0.5, 1)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 6
})
ResetTransform()
Rotate(Y, -90)
Translate(34, -0.5, 0)
- Scale(32)
- MakeBillboard({
- tile = 2,
+ DrawTile({
+ 2,
u_scale = 1
})
end
ResetTransform()
Rotate(X, 90)
Translate(28, 0, 4)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 5,
- surface_type = TOP,
- tiles = {
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0
- }
-})
+ surface = TOP,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0})
-- Rightmost ground
ResetTransform()
Rotate(X, 90)
Translate(33, 0, 0)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 10,
- surface_type = TOP,
- tiles = {
- 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
- 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
- 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
- 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
- 0, 1, 1, 1, 1, 1, 1, -1, -1, -1
- }
-})
+ surface = TOP,
+ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
+ 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
+ 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
+ 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
+ 0, 1, 1, 1, 1, 1, 1, -1, -1, -1})
-- Right foreground tower block
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ResetTransform()
Translate(28, 0, 4)
-Scale(32)
SetTexture("TowerBlock1")
-MakeTilemap({
+DrawTilemap({
width = 5,
- tiles = {
- 2, 2, 2, 2, 2,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 6,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 6, 0,
- 4, 4, 4, 4, 4
- }
-})
+ 2, 2, 2, 2, 2,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 6,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 6, 0,
+ 4, 4, 4, 4, 4})
-- Right side
ResetTransform()
Rotate(Y, 90)
Translate(33, 0, 4)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 6,
- surface_type = RIGHT,
- tiles = {
- 2, 2, 2, 2, 2, 2,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 5, 4, 5, 5, 4, 5
- }
-})
+ surface = RIGHT,
+ 2, 2, 2, 2, 2, 2,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 5, 4, 5, 5, 4, 5})
-- Left side
ResetTransform()
Rotate(Y, 90)
Translate(28, 0, 4)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 6,
- surface_type = LEFT,
- tiles = {
- 2, 2, 2, 2, 2, 2,
- 0, 1, 6, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 0, 1, 0, 0, 1, 0,
- 5, 4, 5, 5, 4, 5
- }
-})
+ surface = LEFT,
+ 2, 2, 2, 2, 2, 2,
+ 0, 1, 6, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 0, 1, 0, 0, 1, 0,
+ 5, 4, 5, 5, 4, 5})
-- Top
ResetTransform()
Rotate(X, 90)
Translate(28, 7, -2)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 5,
- surface_type = TOP,
- tiles = {
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3
- }
-})
+ surface = TOP,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3})
-- Right end tower block
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ResetTransform()
Translate(40, 0, 5)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 5,
- tiles = {
- 2, 2, 2, 2, 2,
- 0, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 6, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 6, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 0, 1, 0, 0, 1,
- 4, 4, 4, 4, 4
- }
-})
+ 2, 2, 2, 2, 2,
+ 0, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 6, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 6, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 0, 1, 0, 0, 1,
+ 4, 4, 4, 4, 4})
-- Left side
ResetTransform()
Rotate(Y, 90)
Translate(40, 0, 5)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 5,
- surface_type = LEFT,
- tiles = {
- 2, 2, 2, 2, 2,
- 6, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 6, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 6, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 5, 5, 5, 4
- }
-})
+ surface = LEFT,
+ 2, 2, 2, 2, 2,
+ 6, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 6, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 6, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 4, 5, 5, 5, 4})
-- Top
ResetTransform()
Rotate(X, 90)
Translate(40, 15, 0)
-Scale(32)
-MakeTilemap({
+DrawTilemap({
width = 5,
- surface_type = TOP,
- tiles = {
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3
- }
-})
+ surface = TOP,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3})
-- Background
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ResetTransform()
-Translate(-0.3, -0.17, -900)
-Scale(3200, 1600, 1)
+Translate(-0.3, -0.17, -28)
+Scale(100, 50, 1)
SetTexture("BackgroundFar")
-MakeBillboard()
+DrawTile()
-Translate(0, 0, 300)
+Translate(0, 0, 5)
SetTexture("BackgroundNear")
-MakeBillboard({
- blend = detail > 1 and true or false
+DrawTile({
+ blend = detail > LOW and true or false
})
-- Trees
-- Left courtyard
-if detail > 1 then
+if detail > LOW then
ResetTransform()
- Scale(96)
- Translate(250, -2.5, 16)
- MakeBillboard({
- tile = 1
- })
+ Scale(3)
+ Translate(7.75, -0.1, 0.5)
+ DrawTile(1)
end
-- Center courtyard
ResetTransform()
-Scale(96)
-Translate(610, -2.5, 85)
-MakeBillboard({
- tile = 0
-})
+--Translate(610, -2.5, 85)
+Scale(3)
+Translate(19, -0.1, 2.5)
+DrawTile(0)
ResetTransform()
-Scale(96)
-Translate(650, -2.5, 115)
-MakeBillboard({
- tile = 1
-})
+Scale(3)
+Translate(20.25, -0.1, 3.5)
+DrawTile(1)
-- Right courtyard
-if detail > 1 then
+if detail > LOW then
ResetTransform()
- Scale(96)
- Translate(1080, -2.5, 10)
- MakeBillboard({
- tile = 1
- })
+ Scale(3)
+ Translate(34, -0.1, 0.25)
+ DrawTile(1)
ResetTransform()
- Scale(96)
- Translate(1120, -2.5, -15)
- MakeBillboard({
- tile = 0
- })
+ Scale(3)
+ Translate(36, -0.1, -0.5)
+ DrawTile(0)
ResetTransform()
- Scale(96)
- Translate(1220, -2.5, -30)
- MakeBillboard({
- tile = 1
- })
+ Scale(3)
+ Translate(37, -0.1, 0.75)
+ DrawTile(1)
+end
+
+
+
+function GetZCoord(x, y)
+ return 3
+end
+
+
+-- Functions:
+-- DisplayText(text, seconds)
+-- Yield(seconds)
+-- SpawnItem(what, coords, timeout)
+-- SpawnRandomItem(coords, timeout)
+-- SpawnCharacter(what, coords, ai level)
+-- SpawnHeroine(coords)
+-- PlaySound(name)
+-- PlayMusic(name)
+-- BeginNewWave()
+
+-- Events:
+-- BadGuyDied(enemy)
+-- PlayedDied(player)
+-- SceneLoaded()
+
+-- Globals:
+-- numberOfBadGuys
+
+
+-- Events
+---------
+
+Event = {}
+
+function Event:SceneLoaded()
+ SpawnHeroine({500, 500})
+ local waveNum = BeginNewWave()
+ PopulateScene(waveNum)
+end
+
+function Event:BadGuyDied(enemy)
+ if numberOfBadGuys == 0 then
+ local waveNum = BeginNewWave()
+ PopulateScene(waveNum)
+ end
+ if math.random() <= 0.2 then
+ SpawnRandomItem(enemy.position)
+ end
+end
+
+
+-- Helper functions
+-------------------
+
+function PopulateScene(waveNum)
+ -- spawn some robot troopers
+ local numBadGuys = math.random(3, 2 * waveNum)
+ for i = 0, numBadGuys do
+ SpawnCharacter("RobotTrooper", RandomSpawnPlace(), RandomSkillLevel())
+ end
+
+ -- spawn some alien warriors
+ if waveNum >= 10 then
+ numBadGuys = math.random(3, 2 * waveNum)
+ for i = 0, numBadGuys do
+ SpawnCharacter("AlienWarrior", RandomSpawnPlace(), RandomSkillLevel())
+ end
+ end
+
+ -- spawn some jetbots
+ if waveNum >= 20 then
+ numBadGuys = math.random(3, 2 * waveNum)
+ for i = 0, numBadGuys do
+ SpawnCharacter("Jetbot", RandomSpawnPlace(), RandomSkillLevel())
+ end
+ end
+end
+
+function RandomSpawnPlace()
+ return {500, 500}
+end
+
+function RandomSkillLevel()
+ return "dumb"
end