]> Dogcows Code - chaz/yoink/blob - data/scenes/Classic.lua
b1364b02a64cadca5823868697c2dac5cc111605
[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 mysound = yoink.sound()
72 --mysound:sample("Explosion")
73 local count = 0
74 function Event.Think()
75 if count % 300 == 0 then
76 --mysound:play()
77 end
78 count = count + 1
79 end
80 end
81
82
83 classic_mesh = yoink.mesh("classic")
84
85 --drawme = {}
86
87 --world = classic_mesh:object(1)
88 --for i = 1, 19 do
89 --local object = world:kid(i)
90 --if object then table.insert(drawme, object) end
91 --end
92
93 --lawn = classic_mesh:object(1):kid("M-Lawn")
94
95 --Event.Draw = function() tower:draw(false) end
96 Event.Draw = function()
97 --for i,object in ipairs(drawme) do
98 --object:draw()
99 --end
100 --lawn:draw()
101 classic_mesh:draw()
102 end
103
104 function Event:BadGuyDied(enemy)
105 if numberOfBadGuys == 0 then
106 local waveNum = BeginNewWave()
107 PopulateScene(waveNum)
108 end
109 if math.random() <= 0.2 then
110 SpawnRandomItem(enemy.position)
111 end
112 end
113
114
115 -- Helper functions
116 -------------------
117
118 function PopulateScene(waveNum)
119 -- spawn some robot troopers
120 local numBadGuys = math.random(3, 2 * waveNum)
121 for i = 0, numBadGuys do
122 SpawnCharacter("RobotTrooper", RandomSpawnPlace(), RandomSkillLevel())
123 end
124
125 -- spawn some alien warriors
126 if waveNum >= 10 then
127 numBadGuys = math.random(3, 2 * waveNum)
128 for i = 0, numBadGuys do
129 SpawnCharacter("AlienWarrior", RandomSpawnPlace(), RandomSkillLevel())
130 end
131 end
132
133 -- spawn some jetbots
134 if waveNum >= 20 then
135 numBadGuys = math.random(3, 2 * waveNum)
136 for i = 0, numBadGuys do
137 SpawnCharacter("Jetbot", RandomSpawnPlace(), RandomSkillLevel())
138 end
139 end
140 end
141
142 function RandomSpawnPlace()
143 return {5, 5}
144 end
145
146 function RandomSkillLevel()
147 return "dumb"
148 end
149
150
151 -- vim: ts=4 sw=4 tw=80
152
This page took 0.038178 seconds and 3 git commands to generate.