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