]> Dogcows Code - chaz/yoink/blob - data/scenes/Classic.lua
mesh and other random adjustments
[chaz/yoink] / data / scenes / Classic.lua
1
2 LogInfo("-----",
3 "Scene: Classic",
4 "Created by Neil Carter",
5 "Converted to Lua by Charles McGarvey",
6 "-----")
7
8 -- Scene API:
9 --
10 -- Functions:
11 -- SetBounds(point1, point2)
12 -- ResetTransform()
13 -- Translate(x, y, z)
14 -- Scale(x, y, z) or Scale(xyz)
15 -- Rotate(axis, degree) or Rotate(x, y, z)
16 -- SetTexture(name)
17 -- DrawTilemap({width = $num, [surface = TOP | LEFT | RIGHT], tiles})
18 -- DrawTile(tile, [u_scale])
19 --
20 -- Globals:
21 -- detail - level of detail of the scene (HIGH, MEDIUM, or LOW)
22
23
24 SetBounds({-5, 0, -6}, {45, 15, 4})
25
26
27 --geometry = yoink.mesh("classic.ac")
28 --geometry:draw()
29 --geometry = yoink.mesh.fromstring([[
30 --AC3Db
31 --OBJECT poly
32 --name "Hello World"
33 --...
34 --]]
35
36
37 -- Functions:
38 -- DisplayText(text, seconds)
39 -- Yield(seconds)
40 -- SpawnItem(what, coords, timeout)
41 -- SpawnRandomItem(coords, timeout)
42 -- SpawnCharacter(what, coords, ai level)
43 -- SpawnHeroine(coords)
44 -- PlaySound(name)
45 -- PlayMusic(name)
46 -- BeginNewWave()
47
48 -- Events:
49 -- Think() is called periodically
50 -- BadGuyDied(enemy)
51 -- HeroineDied(player)
52
53 -- Globals:
54 -- numberOfBadGuys
55
56
57 --do
58 --SpawnHeroine({5, 5})
59 --local waveNum = BeginNewWave()
60 --PopulateScene(waveNum)
61 --end
62
63
64 -- Events
65 ---------
66
67 Event = {}
68
69 do
70 local mysound = yoink.sound("Explosion")
71 local count = 0
72 function Event.Think()
73 if count % 300 == 0 then
74 --mysound:play()
75 end
76 count = count + 1
77 end
78 end
79
80
81 classic_mesh = yoink.mesh("classic")
82
83 --drawme = {}
84
85 --world = classic_mesh:object(1)
86 --for i = 1, 19 do
87 --local object = world:kid(i)
88 --if object then table.insert(drawme, object) end
89 --end
90
91 --lawn = classic_mesh:object(1):kid("M-Lawn")
92
93 --Event.Draw = function() tower:draw(false) end
94 Event.Draw = function()
95 --for i,object in ipairs(drawme) do
96 --object:draw()
97 --end
98 --lawn:draw()
99 classic_mesh:draw()
100 end
101
102 function Event:BadGuyDied(enemy)
103 if numberOfBadGuys == 0 then
104 local waveNum = BeginNewWave()
105 PopulateScene(waveNum)
106 end
107 if math.random() <= 0.2 then
108 SpawnRandomItem(enemy.position)
109 end
110 end
111
112
113 -- Helper functions
114 -------------------
115
116 function PopulateScene(waveNum)
117 -- spawn some robot troopers
118 local numBadGuys = math.random(3, 2 * waveNum)
119 for i = 0, numBadGuys do
120 SpawnCharacter("RobotTrooper", RandomSpawnPlace(), RandomSkillLevel())
121 end
122
123 -- spawn some alien warriors
124 if waveNum >= 10 then
125 numBadGuys = math.random(3, 2 * waveNum)
126 for i = 0, numBadGuys do
127 SpawnCharacter("AlienWarrior", RandomSpawnPlace(), RandomSkillLevel())
128 end
129 end
130
131 -- spawn some jetbots
132 if waveNum >= 20 then
133 numBadGuys = math.random(3, 2 * waveNum)
134 for i = 0, numBadGuys do
135 SpawnCharacter("Jetbot", RandomSpawnPlace(), RandomSkillLevel())
136 end
137 end
138 end
139
140 function RandomSpawnPlace()
141 return {5, 5}
142 end
143
144 function RandomSkillLevel()
145 return "dumb"
146 end
147
148
149 -- vim: ts=4 sw=4 tw=80
150
This page took 0.040238 seconds and 4 git commands to generate.