-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
3255 lines (2899 loc) · 67.7 KB
/
main.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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-----------------------------
-----------------------------
---------BASE CODE-----------
-----------------------------
-----------------------------
--RECT
-----------------------------
function Rect_new(self, x, y, width, height)
self.type = "Rect"
self.x = x or 0
self.y = y or self.x
self.width = width or 0
self.height = height or self.width
return self
end
function Rect_draw(self)
if self.color then color(self.color) end
rect(self.x, self.y, self.width, self.height)
end
function Rect_set(self, x, y, width, height)
self.x = x or self.x
self.y = y or self.y
self.width = width or self.width
self.height = height or self.height
end
function Rect_get(self)
return self.x, self.y, self.width, self.height
end
function Rect_clone(self, r)
self.x = r.x
self.y = r.y
self.width = r.width
self.height = r.height
end
--If rect overlaps with rect or point
function Rect_overlaps(self, r)
return self.x + self.width > r.x and
self.x < r.x + (r.width or 0) and
self.y + self.height > r.y and
self.y < r.y + (r.height or 0)
end
function Rect_overlapsX(self, r)
return self.x + self.width > r.x and
self.x < r.x + (r.width or 0)
end
function Rect_overlapsY(self, r)
return self.y + self.height > r.y and
self.y < r.y + (r.height or 0)
end
function Rect_top(self, val)
if val then self.y = val end
return self.y
end
function Rect_bottom(self, val)
if val then self.y = val - self.height end
return self.y + self.height
end
function Rect_centerX(self, val)
if val then self.x = val - self.width / 2 end
return self.x + self.width / 2
end
function Rect_centerY(self, val)
if val then self.y = val - self.height / 2 end
return self.y + self.height / 2
end
function Rect_distance(self, r)
return sqrt(abs(self.x - r.x)^2 + abs(self.y - r.y)^2)
end
function Rect_distanceCenter(self, r)
return sqrt(abs(self.x + self.width/2 - r.x + r.width/2)^2 + abs(self.y + self.height/2 - r.y + r.height/2))
end
function Rect_distanceY(self, r)
return abs(self.y - r.y)
end
function Rect_distanceCenterX(self, r)
return abs((self.x + self.width/2) - (r.x + r.width/2))
end
function Rect_distanceCenterY(self, r)
return abs((self.y + self.height/2) - (r.y + r.height/2))
end
-----------------------------
--Spr
-----------------------------
function Spr_new(self, x, y, img)
Rect_new(self, x, y, 8)
self.type = "Spr"
self.__save = {}
self.dead = nil
self.img = img
self.imgWidth = 1
self.imgHeight = 1
-- self.flip = {x = nil, y = nil}
self.flip_x = nil
self.flip_y = nil
self.offset_x = 0
self.offset_y = 0
self.visible = true
self.frame = 1
self.frameTimer = 1
self.frameTimerDir = 1
self.anim = nil
-- self.anims = {}
self.animEnded = nil
return self
end
function Spr_update(self)
Spr_simplify(self)
Spr_animate(self)
end
function Spr_draw(self)
if self.visible and not self.dead then
blit(self.img + (self.anim and self["anim__" .. self.anim][self.frame] * self.imgWidth - 1 or 0), self.x + self.offset_x, self.y + self.offset_y, self.imgWidth, self.imgHeight, self.flip_x, self.flip_y)
end
end
function Spr_animate(self)
if self.anim then
local ani = self["anim__" .. self.anim]
if not (ani.mode == "once" and self.animEnded) then
self.frameTimer = self.frameTimer + 1 / self["anim__" .. self.anim].speed
if self.frameTimer >= #ani + 1 or self.frameTimer <= 0 then
if self.mode == "pingpong" then
self.frameTimerDir = -self.frameTimerDir
self.frameTimer = self.frameTimerDir > 0 and 2 or self.frameTimer - #ani
elseif ani.mode == "once" then
self.frameTimer = #ani
else
self.frameTimer = self.frameTimer - #ani
end
self.animEnded = true
end
self.frame = flr(self.frameTimer)
end
end
end
function Spr_addAnim(self, name, t, speed, mode)
local a = {}
self["anim__" .. name] = a
a.speed = speed or 1
a.mode = mode or "loop"
for i=1,#t do
a[i] = t[i]
end
end
function Spr_setAnim(self, anim, force)
if self.anim ~= anim or force then
self.frame = 1
self.frameTimer = 1
self.frameTimerDir = 1
self.anim = anim
self.animEnded = nil
end
end
function Spr_simplify(self)
if self.type == "Eye" then
return Eye_simplify(self)
else
return Spr_simplify_real(self)
end
end
function Spr_simplify_real(self)
--I check if it's out of screen, then I save the important variables, and remove everything else
if Spr_canSimplify(self) then
puts(self.__save,{"x","y","width","height","type","__save"})
local new = {}
for i,k in pairs(self.__save) do
new[k] = self[k]
end
new.simplified = true
local t = data(new.type)
local i = find(t, self)
del(t, i)
put(t, new)
end
end
function Spr_renew(self)
if not Spr_canSimplify(self) then
local old = {}
for i,k in ipairs(self.__save) do
if k ~= "__save" then
old[k] = self[k]
end
end
self.simplified = nil
data(self.type, true)(self, self.x, self.y)
for k,v in pairs(old) do
self[k] = old[k]
end
return true
end
return nil
end
function Spr_canSimplify(self)
if self.type == "Plr" then
return nil
elseif self.type == "Torch" then
return Torch_canSimplify(self)
elseif self.type == "Bat" then
return Bat_canSimplify(self)
elseif self.type == "Spider" then
return Spd_canSimplify(self)
elseif self.type == "Spear" then
return Spear_canSimplify(self)
elseif self.type == "Lava" then
return Lava_canSimplify(self)
elseif self.type == "Bolt" then
return nil
elseif self.type == "Wzrd" then
return nil
elseif self.type == "Crown" then
return nil
elseif self.type == "Stairs" then
return nil
elseif self.type == "Platform" then
return nil
else
return Spr_canSimplify_real(self)
end
end
function Spr_canSimplify_real(self)
return not Rect_overlaps(self, {x = cam_x, y = cam_y, width = cam_width, height = cam_height})
end
-----------------------------
--Ent
-----------------------------
function Ent_new(self, x, y, img)
Spr_new(self, x, y, img)
self.type = "Ent"
self.velocity_x = 0
self.velocity_y = 0
self.last = Rect_new({}, x, y)
self.priority_x = 0
self.priority_y = 0
self._prior_x = 0
self._prior_y = 0
self.bounce_x = 0
self.bounce_y = 0
self.mass = 0
self.ignoreMap = nil
self.grounded = nil
self.solid = true
self.dead = nil
return self
end
function Ent_update(self)
if not self.dead then
Rect_clone(self.last, self)
self._prior_x = self.priority_x
self._prior_y = self.priority_y
self.velocity_y = self.velocity_y + self.mass
self.velocity_y = min(5, self.velocity_y)
self.x = self.x + self.velocity_x
self.y = self.y + self.velocity_y
if not self.ignoreMap then
Ent_resolveMapCollision(self)
end
if self.velocity_x ~= 0 then
self.flip_x = self.velocity_x < 0
end
Spr_update(self)
end
end
function Ent_resolveMapCollision(self)
--I feel like this can be optimized. Not sure how much it would save kb wise though
if self.x - self.last.x > 0 then
if getWOP(self.x + self.width-1, self.y) and not getWOP(self.last.x + self.width-1, self.y) then
Ent_hitMapRight(self)
elseif getWOP(self.x + self.width-1, self.y + self.height-1) and not getWOP(self.last.x + self.width-1, self.y + self.height-1) then
Ent_hitMapRight(self)
end
else
if getWOP(self.x, self.y) and not getWOP(self.last.x, self.y) then
Ent_hitMapLeft(self)
elseif getWOP(self.x, self.y + self.height-1) and not getWOP(self.last.x, self.y + self.height-1) then
Ent_hitMapLeft(self)
end
end
if self.y - self.last.y > 0 then
if getWOP(self.x, self.y + self.height-1) and not getWOP(self.x, self.last.y + self.height-1) then
Ent_hitMapBottom(self)
elseif getWOP(self.x + self.width-1, self.y + self.height-1) and not getWOP(self.x + self.width-1, self.last.y + self.height-1) then
Ent_hitMapBottom(self)
end
else
if getWOP(self.x, self.y) and not getWOP(self.x, self.last.y) then
Ent_hitMapTop(self)
elseif getWOP(self.x + self.width-1, self.y) and not getWOP(self.x + self.width-1, self.last.y) then
Ent_hitMapTop(self)
end
end
end
function Ent_overlaps(self, e)
return self ~= e and not self.dead
and not e.dead
and Rect_overlaps(self, e)
end
function Ent_resolveCollision(self, e)
if self.simplified or e.simplified then return end
if Ent_overlaps(self, e) then
Ent_onOverlap(self, e)
end
end
function Ent_onOverlap(self, e)
if self.type == "Plr" then
Plr_onOverlap(self, e)
elseif self.type == "Crate" then
Crate_onOverlap(self, e)
elseif self.type == "Button" then
Btn_onOverlap(self, e)
elseif self.type == "Switch" then
Stc_onOverlap(self, e)
elseif self.type == "Bat" then
Bat_onOverlap(self, e)
elseif self.type == "Spider" then
Spd_onOverlap(self, e)
elseif self.type == "Wzrd" then
Wzrd_onOverlap(self, e)
else
Ent_onOverlap_real(self)
end
end
function Ent_onOverlap_real(self, e)
if self.solid and e.solid then
Ent_separate(self, e)
end
end
function Ent_separate(self, e)
Ent_separateAxis(self, e, Rect_overlapsY(self.last, e.last) and "x" or "y")
end
function Ent_separateAxis(self, e, a)
local s = a == "x" and "width" or "height"
if self["_prior_" .. a] >= e["_prior_" .. a] then
if (e.last[a] + e.last[s] / 2) < (self.last[a] + self.last[s] / 2) then
e[a] = self[a] - e[s]
else
e[a] = self[a] + self[s]
end
e["velocity_" .. a] = e["velocity_" .. a] * -e["bounce_" .. a]
e["_prior_" .. a] = self["_prior_" .. a]
else
Ent_separateAxis(e, self, a)
end
Ent_resolveMapCollision(e)
end
function Ent_hitMapBottom(self)
if self.type == "Plr" then
Plr_hitMapBottom(self)
elseif self.type == "Crate" then
Crate_hitMapBottom(self)
elseif self.type == "Spider" then
Spd_hitMapBottom(self)
elseif self.type == "Crown" then
Crown_hitMapBottom(self)
elseif self.type == "Spear" then
Spear_hitMapBottom(self)
else
Ent_hitMapBottom_real(self)
end
end
function Ent_hitMapTop(self)
if self.type == "Bat" then
Bat_hitMapTop(self)
elseif self.type == "Spider" then
Spd_hitMapTop(self)
elseif self.type == "Spear" then
Spear_hitMapTop(self)
else
Ent_hitMapTop_real(self)
end
end
function Ent_hitMapLeft(self)
if self.type == "Crate" then
Crate_hitMapLeft(self)
else
Ent_hitMapLeft_real(self)
end
end
function Ent_hitMapRight(self)
if self.type == "Crate" then
Crate_hitMapRight(self)
else
Ent_hitMapRight_real(self)
end
end
function Ent_hitMapLeft_real(self)
self.velocity_x = self.velocity_x * -self.bounce_x
self.x = toGrid(self.x + self.width)*8
self._prior_x = 10000
end
function Ent_hitMapTop_real(self)
self.velocity_y = self.velocity_y * -self.bounce_y
self.y = toGrid(self.y + self.height)*8
self._prior_y = 10000
end
function Ent_hitMapRight_real(self)
self.velocity_x = self.velocity_x * -self.bounce_x
self.x = toGrid(self.x + self.width)*8 - self.width
self._prior_x = 10000
end
function Ent_hitMapBottom_real(self)
self.velocity_y = self.velocity_y * -self.bounce_y
self.y = toGrid(self.y + self.height)*8 - self.height
self._prior_y = 10000
self.grounded = true
end
-----------------------------
--UTILS
-----------------------------
function ceil(a)
local b = flr(a)
return b < a and b + 1 or a
end
function round(a)
local b = flr(a)
return a - b < 0.5 and b or b + 1
end
function sign(a)
return a > 0 and 1 or -1
end
function random(a, b)
if not b then b = a a = 0 end
return a + flr(rand() * (b-a+1))
end
function frandom(a, b)
if not b then b = a a = 0 end
return a + rand() * (b-a+1)
end
function toGrid(x, y)
if y then
return flr(round(x) / 8), flr(round(y) / 8)
else
return flr(round(x) / 8)
end
end
function puts(t, a)
for i,v in ipairs(a) do
put(t, v)
end
end
--get Map On Position
function getWOP(x, y)
return isWall(mget(toGrid(x, y)))
end
function isWall(a)
return a >= 29 and a <= 63
end
function simple(v)
return v.simplified and not Spr_renew(v)
end
function has(t, val)
for i,v in ipairs(t) do
if v == val then
return true
end
end
return nil
end
function find(t, val)
for i,v in ipairs(t) do
if v == val then
return i
end
end
return -1
end
function data(class, a)
if class == "Bat" then
return a and Bat_new or bats
elseif class == "Spider" then
return a and Spd_new or spiders
elseif class == "Torch" then
return a and Torch_new or torches
elseif class == "Crate" then
return a and Crate_new or crates
elseif class == "Door" then
return a and Door_new or doors
elseif class == "Button" then
return a and Btn_new or buttons
elseif class == "Switch" then
return a and Stc_new or switches
elseif class == "Key" then
return a and Key_new or keys
elseif class == "Coin" then
return a and Coin_new or coins
elseif class == "Spring" then
return a and Spring_new or springs
elseif class == "Spikes" then
return a and Spk_new or spikes
elseif class == "Lava" then
return a and Lava_new or lavas
elseif class == "Platform" then
return a and Platform_new or platforms
elseif class == "Spear" then
return a and Spear_new or spears
elseif class == "Window" then
return a and Window_new or windows
end
end
voice = 0
function sfx(b, c, d, e, f, g)
if MENU then return end
voice = (voice + 1) % 3
play(voice, b, c, d, e ,f ,g)
end
-----------------------------
-----------------------------
-----------GAME--------------
-----------------------------
-----------------------------
function init()
LEVEL = random(1, 6)
BOSS = 8
CREDITS = 9
CONGRATS = 11
-- MENU = LEVEL == 1
MENU = true
SPECIAL = 0
SPEEDRUN = false
cam_x, cam_y = 0, 0
cam_width, cam_height = 128, 128
cam_scene = nil
cam_sceneTo = {x = 0, y = 0, width = 1, height = 1}
lightsTimer = 0
speed_timer = 0
restart_timer = 90
level_init()
end
function update(s)
if fadeDir ~= 0 then
fadeTimer = fadeTimer + fadeDir
if fadeTimer >= 20 then
fadeDir = 0
if Plr.dead then
level_reset()
elseif Plr.onStairs then
LEVEL = LEVEL + 1
level_reset()
return
elseif MENU then
LEVEL = 1
MENU = nil
level_reset()
end
elseif fadeTimer <= 0 then
fadeDir = 0
end
end
if LEVEL == CONGRATS then
cam_x = level.x
cam_y = level.y - 32
camera(cam_x, cam_y)
if button(4, true) then init() end
return
end
Plr_update(Plr)
if crown then Ent_resolveCollision(Plr, crown) end
if stairs and not MENU then
Stairs_update(stairs)
Ent_resolveCollision(Plr, stairs)
end
lightsTimer = (lightsTimer + 0.2)
if lightsTimer >= 13 then lightsTimer = lightsTimer - 14 end
if #eyes > 6 then
del(eyes, 1)
del(eyes, 1)
end
if LEVEL == BOSS then
if crown then Ent_update(crown) end
Wzrd_update(Wzrd)
for i,v in ipairs(bolts) do
if Bolt_update(v) then
del(bolts, i)
else
Ent_resolveCollision(Wzrd, v)
Ent_resolveCollision(Plr, v)
end
end
for i,v in ipairs(light_clouds) do
Cloud.update(v)
end
for i,v in ipairs(dark_clouds) do
Cloud.update(v)
end
end
if scene then
scene_update()
end
for i,v in ipairs(platforms) do
if not simple(v) then
for i=1,4 do
Ent_resolveCollision(Plr, v)
for j,w in ipairs(platforms) do
Ent_resolveCollision(v, w)
end
end
Ent_update(v)
end
end
for i,v in ipairs(eyes) do
if not simple(v) then
Eye_update(v)
end
end
for i,v in ipairs(coins) do
if not simple(v) then
Coin_update(v)
if v.dead then del(coins, i) end
end
end
for i,v in ipairs(keys) do
if not simple(v) then
Key_update(v)
for j,w in ipairs(doors) do
Ent_resolveCollision(v, w)
end
if v.dead then del(keys, i) end
end
end
for i,v in ipairs(doors) do
if not simple(v) then
Door_update(v)
Ent_resolveCollision(Plr, v)
end
end
for i,v in ipairs(springs) do
if not simple(v) then
Spring_update(v)
Ent_resolveCollision(Plr, v)
end
end
for i,v in ipairs(crates) do
if not simple(v) then
Crate_update(v)
for i=1,4 do
Ent_resolveCollision(Plr, v)
for j,w in ipairs(crates) do
Ent_resolveCollision(v, w)
end
for j,w in ipairs(doors) do
Ent_resolveCollision(v, w)
end
end
end
end
for i,v in ipairs(buttons) do
if not simple(v) then
Btn_update(v)
for i=1,4 do
Ent_resolveCollision(v, Plr)
for j,w in ipairs(crates) do
Ent_resolveCollision(v, w)
end
end
end
end
for i,v in ipairs(switches) do
if not simple(v) then
Stc_update(v)
Ent_resolveCollision(v, Plr)
end
end
for i,v in ipairs(bats) do
if not simple(v) then
Bat_update(v)
Ent_resolveCollision(Plr, v)
for i=1,4 do
for j,w in ipairs(doors) do
Ent_resolveCollision(v, w)
end
end
if LEVEL == BOSS and v.anim == "sleeping" then
del(bats, i)
end
end
end
for i,v in ipairs(spiders) do
if not simple(v) then
Spd_update(v)
Ent_resolveCollision(Plr, v)
for i=1,4 do
for j,w in ipairs(doors) do
Ent_resolveCollision(v, w)
end
end
if LEVEL == BOSS and v.anim == "sleeping" then
del(spiders, i)
end
end
end
for i,v in ipairs(spikes) do
if not simple(v) then
Spk_update(v)
Ent_resolveCollision(Plr, v)
end
end
for i,v in ipairs(torches) do
if not simple(v) then
Spr_update(v)
end
end
for i,v in ipairs(spears) do
if not simple(v) then
Spear_update(v)
Ent_resolveCollision(Plr, v)
end
end
for i,v in ipairs(lavas) do
if not simple(v) then
Ent_update(v)
Ent_resolveCollision(Plr, v)
end
end
for i,v in ipairs(windows) do
if not simple(v) then
Spr_update(v)
end
end
if LEVEL == CREDITS then
credit_x = credit_x - 1
if Plr.x >= level.x + level.width + 140 then
if button(4, true) then
level_reset(true)
return
end
end
end
cam_update()
if music.play then
playMusic(music.play)
end
if tune then
playMusic(tune, true)
end
if MENU then
cam_x = level.x + level.width / 2 - 64
cam_y = level.y + level.height / 2 - 64
camera(cam_x, cam_y)
if button(4, true) or button(0, true) then
fadeDir = 1
elseif button(5, true) then
SPEEDRUN = true
fadeDir = 1
end
elseif LEVEL ~= CREDITS then
if button(5) then
restart_timer = restart_timer - 1
if restart_timer <= 0 then
level_reset(true)
end
else
restart_timer = 90
end
end
end
function draw()
color(0)
clear()
if LEVEL == BOSS then
for i,v in ipairs(light_clouds) do
Cloud.draw(v)
end
end
if LEVEL == CONGRATS then
color(3)
rect(level.x, level.y, level.width, level.height)
mblit()
color(1)
rect(level.x, level.y-32, level.width, 32)
rect(level.x, level.y+56, level.width, 64)
color(2)
print("CONGRATULATIONS!", level.x + 33, level.y - 16)
print("THOU ART WONDROUS", level.x + 33, level.y + 70)
if SPEEDRUN then
print("Time: " .. flr(speed_timer/30), level.x + 40, level.y + 85)
end
return
end
for i,v in ipairs(torches) do
if not simple(v) then
Torch_draw(v)
end
end
for i,v in ipairs(windows) do
if not simple(v) then
Window_draw(v)
end
end
if stairs then Stairs_draw(stairs) end
for i,v in ipairs(coins) do
if not simple(v) then
Spr_draw(v)
end
end
for i,v in ipairs(keys) do
if not simple(v) then
Spr_draw(v)
end
end
for i,v in ipairs(springs) do
if not simple(v) then
Spr_draw(v)
end
end
for i,v in ipairs(crates) do
if not simple(v) then
Spr_draw(v)
end
end
for i,v in ipairs(platforms) do
if not simple(v) then
Spr_draw(v)
end
end
for i,v in ipairs(bats) do
if not simple(v) then
Spr_draw(v)
end
end
for i,v in ipairs(doors) do
if not simple(v) then
Door_draw(v)
end
end
for i,v in ipairs(spiders) do
if not simple(v) then
Spd_draw(v)
end
end
if LEVEL == BOSS or LEVEL == BOSS - 1 then
Wzrd_draw(Wzrd)
end
Plr_draw(Plr)
if crown then Spr_draw(crown) end
mblit()
if LEVEL == BOSS then
for i,v in ipairs(bolts) do
Bolt_draw(v)
end
for i,v in ipairs(dark_clouds) do
Cloud.draw(v, true)
end
for i,v in ipairs(dark_clouds) do
Cloud.draw(v)
end
end
-- for i,v in ipairs(walls) do
-- blit(v.img, v.x, v.y)
-- end
for i,v in ipairs(secrets) do
Spr_draw(v)
end
for i,v in ipairs(eyes) do
if not simple(v) then
Spr_draw(v)
end
end