-
Notifications
You must be signed in to change notification settings - Fork 0
/
scene.lua
382 lines (338 loc) · 10.8 KB
/
scene.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
--scene.lua
scene = {}
scene.game = {}
scene.title = {}
scene.stage = {}
scene.ending = {}
function scene.ending.load()
scene.ending.seqani = 0
scene.ending.tmrani = 0
scene.ending.seq = 0
scene.ending.tmrseq = 0
game.scene = 4
end
function scene.ending.update(dt)
scene.ending.tmrani = scene.ending.tmrani + dt
if scene.ending.tmrani >= 0.2 then
scene.ending.tmrani = scene.ending.tmrani - 0.2
if scene.ending.seqani == 1 then
scene.ending.seqani = 0
else
scene.ending.seqani = scene.ending.seqani + 1
end
end
scene.ending.tmrseq = scene.ending.tmrseq + dt
if scene.ending.tmrseq >= 4 then
scene.ending.tmrseq = scene.ending.tmrseq - 4
scene.ending.seq = scene.ending.seq + 1
end
end
function scene.ending.draw()
love.graphics.setColor(255, 255, 255)
if scene.ending.seqani == 0 then
love.graphics.draw(imgbat, quadbat[7], 400 - 16, 70)
love.graphics.draw(imgbat, quadbat[7], 370 - 16, 100)
love.graphics.draw(imgbat, quadbat[5], 430 - 16, 100)
love.graphics.draw(imgbat, quadbat[5], 400 - 16, 130)
else
love.graphics.draw(imgbat, quadbat[5], 400 - 16, 70 + 1)
love.graphics.draw(imgbat, quadbat[5], 370 - 16, 100 - 1)
love.graphics.draw(imgbat, quadbat[7], 430 - 16, 100 + 1)
love.graphics.draw(imgbat, quadbat[7], 400 - 16, 130 - 1)
end
if scene.ending.seq == 1 then
love.graphics.printf("Credits", 0, 192, 800, "center")
elseif scene.ending.seq == 2 then
love.graphics.printf("Credits\n\nConcept by: Norubal", 0, 192, 800, "center")
elseif scene.ending.seq == 3 then
love.graphics.printf("Credits\n\nProgramming by: Norubal", 0, 192, 800, "center")
elseif scene.ending.seq == 4 then
love.graphics.printf("Credits\n\nGraphic Design by: Norubal", 0, 192, 800, "center")
elseif scene.ending.seq == 5 then
love.graphics.printf("Credits\n\nBGM: 4′33″ by John Cage", 0, 192, 800, "center")
elseif scene.ending.seq == 7 then
love.graphics.printf("Thanks for playing\nPress Esc to quit.", 0, 192, 800, "center")
elseif scene.ending.seq == 10 then
love.graphics.printf("I'm looking for people who can work together with me.", 0, 192, 800, "center")
elseif scene.ending.seq == 11 then
love.graphics.printf("I'm currently looking for pixel artists and musicians.", 0, 192, 800, "center")
elseif scene.ending.seq == 12 then
love.graphics.printf("If you want to join me,", 0, 192, 800, "center")
elseif scene.ending.seq == 13 then
love.graphics.printf("..or if you want to be my friend.", 0, 192, 800, "center")
elseif scene.ending.seq == 14 then
love.graphics.printf("Please contact me.", 0, 192, 800, "center")
elseif scene.ending.seq == 15 then
love.graphics.printf("E-mail: [email protected]\nSkype: viktor.norubal\nBlog:http://norubal.blogspot.com/", 0, 192, 800, "center")
elseif scene.ending.seq > 15 then
love.graphics.printf("E-mail: [email protected]\nSkype: viktor.norubal\nBlog:http://norubal.blogspot.com/\n\nThanks for reading!", 0, 192, 800, "center")
end
end
-----------------------------------------------------------------
function scene.game.load()
game.scene = 3
canvas = love.graphics.newCanvas(800, 600)
player.load()
game.load()
echo.load()
if (game.stage == 4) and (game.map == 5) then
boss.load()
end
end
function scene.game.draw()
echo.draw()
if game.showmap == true then
love.graphics.setColor(0, 0, 255)
love.graphics.rectangle("fill", 0, 0, 800, 600)
love.graphics.setColor(255, 255, 255)
end
love.graphics.draw(canvas)
--draw goal
if player.cutscene == false then
if (game.map == 5) and (game.stage == 4) then
--boss stage
else
love.graphics.draw(imgsicon[1], map.goalx, map.goaly)
end
else
--cutscene
love.graphics.draw(imgbat, quadbat[9], map.goalx, map.goaly)
if player.seq == 1 then
if game.stage == 1 then
love.graphics.print("Brother!", 94, 333)
elseif game.stage == 2 then
love.graphics.print("Sister!", 455, 230)
elseif game.stage == 3 then
love.graphics.print("Father!", 695, 450)
end
elseif (player.seq == 2) or (player.seq == 3) then
if game.stage == 1 then
love.graphics.print("Your sister is in the forest,\nYou should find her!", 42, 310)
elseif game.stage == 2 then
love.graphics.print("Your father is in the forest,\nYou should find him!", 400, 210)
elseif game.stage == 3 then
love.graphics.print("Your mother is in the Lab,\nYou should find her!", 600, 450)
end
end
end
--draw tutorial
if (game.stage == 1) and (game.map == 1) then
love.graphics.draw(imgtutorialc, 42, 44)
love.graphics.draw(imgtutorialn, 256, 488)
end
--boss battle
if (game.stage == 4) and (game.map == 5) then
boss.draw()
end
player.draw()
end
function scene.game.update(dt)
echo.update(dt)
player.update(dt)
object.update(dt)
--update map
love.graphics.setCanvas(canvas)
canvas:clear()
love.graphics.draw(imgmap)
object.draw()
love.graphics.setCanvas()
--imgmapd = canvas:getImageData()
if (game.stage == 4) and (game.map == 5) then
boss.update(dt)
end
end
function scene.game.keypressed(key)
if (game.stage == 4) and (game.map == 5) then
boss.keypressed(key)
end
end
-------------------------------------------------------------------
function scene.title.load()
game.scene = 1
scene.title.bat = {}
scene.title.bat.x = 175
scene.title.bat.y = 350
scene.title.bat.animation = 1 --animation
scene.title.bat.direction = 2 --1:to left 2:to right
scene.title.bat.tmrani = 0
scene.title.bat.intani = 0.1
scene.title.seq = 0 --title sequence. 0~5
scene.title.tmrseq = 0
scene.title.intseq = 3
end
function scene.title.draw()
love.graphics.setColor(255, 255, 255)
love.graphics.draw(imgtitle)
love.graphics.draw(imgbat, quadbat[scene.title.bat.animation + 4 * (scene.title.bat.direction - 1)], scene.title.bat.x, scene.title.bat.y)
--draw bat's lines
if scene.title.seq == 1 then
love.graphics.print("Mommy?\nDaddy?", 166, 300)
elseif scene.title.seq == 2 then
love.graphics.print("Brother?\nSister?", 166, 300)
elseif scene.title.seq == 3 then
love.graphics.print("Where are you?", 145, 300)
elseif scene.title.seq == 4 then
love.graphics.print("I'll find them...", 145, 300)
end
end
function scene.title.update(dt)
scene.title.bat.tmrani = scene.title.bat.tmrani + dt
if scene.title.bat.tmrani >= scene.title.bat.intani then
scene.title.bat.tmrani = scene.title.bat.tmrani - scene.title.bat.intani
if scene.title.bat.animation == 4 then
scene.title.bat.animation = 1
else
scene.title.bat.animation = scene.title.bat.animation + 1
end
end
scene.title.tmrseq = scene.title.tmrseq + dt
if scene.title.tmrseq >= scene.title.intseq then
scene.title.tmrseq = scene.title.tmrseq - scene.title.intseq
if scene.title.seq < 5 then
scene.title.seq = scene.title.seq + 1
end
end
if not(scene.title.bat.x > 800) then
if scene.title.seq == 5 then
scene.title.bat.x = scene.title.bat.x + dt * 150
end
end
end
function scene.title.keypressed(key)
scene.stage.load()
end
-------------------------------------------------------------------
function scene.stage.load(crsstage, crsmap)
game.scene = 2
--Load saved data
map.loadcleardata()
--cursor position information
if crsstage == nil then
scene.stage.crsstage = 1
scene.stage.crsmap = 1
else
scene.stage.crsstage = crsstage
scene.stage.crsmap = crsmap
end
scene.stage.crsani = 1 --animation
scene.stage.tmrani = 0
scene.stage.intani = 0.1
end
function scene.stage.draw()
local a
local tmpsicon
--draw stage icons
love.graphics.setColor(255, 255, 255)
love.graphics.draw(imgstage[1], 131, 88)
love.graphics.print("Cave", 158, 184)
for a = 1, 5 do
if (game.cleardata[1][a - 1] == true) or (a == 1) then
tmpsicon = 1
if a == 5 then
tmpsicon = 2
end
if game.cleardata[1][a] == true then
tmpsicon = 4
end
love.graphics.draw(imgsicon[tmpsicon], 151, 220 + (a - 1) * 60)
end
end
if game.cleardata[1][5] == true then
love.graphics.draw(imgstage[2], 274, 88)
love.graphics.print("Forest", 299, 184)
for a = 1, 5 do
if (game.cleardata[2][a - 1] == true) or (a == 1) then
tmpsicon = 1
if a == 5 then
tmpsicon = 2
end
if game.cleardata[2][a] == true then
tmpsicon = 4
end
love.graphics.draw(imgsicon[tmpsicon], 299, 220 + (a - 1) * 60)
end
end
end
if game.cleardata[2][5] == true then
love.graphics.draw(imgstage[3], 417, 88)
love.graphics.print("City", 447, 184)
for a = 1, 5 do
if (game.cleardata[3][a - 1] == true) or (a == 1) then
tmpsicon = 1
if a == 5 then
tmpsicon = 2
end
if game.cleardata[3][a] == true then
tmpsicon = 4
end
love.graphics.draw(imgsicon[tmpsicon], 440, 220 + (a - 1) * 60)
end
end
end
if game.cleardata[3][5] == true then
love.graphics.draw(imgstage[4], 560, 88)
love.graphics.print("The Laboratory", 552, 184)
for a = 1, 5 do
if (game.cleardata[4][a - 1] == true) or (a == 1) then
tmpsicon = 1
if a == 5 then
tmpsicon = 3
end
if game.cleardata[4][a] == true then
tmpsicon = 4
end
love.graphics.draw(imgsicon[tmpsicon], 586, 220 + (a - 1) * 60)
end
end
end
--draw cursor
local tmpcrsx
if scene.stage.crsstage == 1 then
tmpcrsx = 114
elseif scene.stage.crsstage == 2 then
tmpcrsx = 264
elseif scene.stage.crsstage == 3 then
tmpcrsx = 405
elseif scene.stage.crsstage == 4 then
tmpcrsx = 554
end
love.graphics.draw(imgbat, quadbat[scene.stage.crsani + 4], tmpcrsx, 224 + (scene.stage.crsmap - 1) * 60)
end
function scene.stage.update(dt)
scene.stage.tmrani = scene.stage.tmrani + dt
if scene.stage.tmrani >= scene.stage.intani then
scene.stage.tmrani = scene.stage.tmrani - scene.stage.intani
if scene.stage.crsani == 4 then
scene.stage.crsani = 1
else
scene.stage.crsani = scene.stage.crsani + 1
end
end
end
function scene.stage.keypressed(key)
if key == "left" then
if not(scene.stage.crsstage == 1) then
scene.stage.crsstage = scene.stage.crsstage - 1
scene.stage.crsmap = 1
end
elseif key == "right" then
if game.cleardata[scene.stage.crsstage][5] == true then
if not(scene.stage.crsstage == 4) then
scene.stage.crsstage = scene.stage.crsstage + 1
scene.stage.crsmap = 1
end
end
elseif key == "up" then
if not(scene.stage.crsmap == 1) then
scene.stage.crsmap = scene.stage.crsmap - 1
end
elseif key == "down" then
if game.cleardata[scene.stage.crsstage][scene.stage.crsmap] == true then
if not(scene.stage.crsmap == 5) then
scene.stage.crsmap = scene.stage.crsmap + 1
end
end
elseif key == "z" then
map.read(scene.stage.crsstage, scene.stage.crsmap)
end
end