-
Notifications
You must be signed in to change notification settings - Fork 17
/
mario.lua
3999 lines (3515 loc) · 107 KB
/
mario.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
mario = class("mario")
function mario:init(x, y, i, animation, size, t)
if (SERVER or CLIENT) and i ~= netplayernumber then
self.remote = true
end
self.alwaysactive = true
self.char = characters[mariocharacter[i]]
self.playernumber = i or 1
if bigmario then
self.size = 1
else
self.size = size or 1
end
self.t = t or "portal"
self.portalsavailable = {unpack(portalsavailable)}
--PHYSICS STUFF
self.speedx = 0
self.speedy = 0
self.x = x
self.width = 12/16
self.height = 12/16
self.previouslyonground = true --for start falling
if bigmario then
self.width = self.width*scalefactor
self.height = self.height*scalefactor
end
self.lastground = {0, 0}
self.y = y+1-self.height
self.static = false
self.active = true
self.category = 3
self.mask = { true,
false, true, false, false, false,
false, true, false, false, false,
false, true, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false}
if playercollisions then
self.mask[3] = false
end
self.emancipatecheck = true
--IMAGE STUFF
if self.portalsavailable[1] or self.portalsavailable[2] or not self.char.nogunanimations then
self.smallgraphic = self.char.animations
self.biggraphic = self.char.biganimations
else
self.smallgraphic = self.char.nogunanimations
self.biggraphic = self.char.nogunbiganimations
end
self.drawable = true
self.quad = self.char.idle[3]
self.colors = mariocolors[self.playernumber]
self.customscale = self.char.customscale
if self.size == 1 then
self.offsetX = self.char.smalloffsetX
self.offsetY = self.char.smalloffsetY
self.quadcenterX = self.char.smallquadcenterX
self.quadcenterY = self.char.smallquadcenterY
self.graphic = self.smallgraphic
else
self.graphic = self.biggraphic
self.quadcenterY = self.char.bigquadcenterY
self.quadcenterX = self.char.bigquadcenterX
self.offsetY = self.char.bigoffsetY
self.offsetX = self.char.bigoffsetX
self.y = self.y - 12/16
self.height = 24/16
if self.size == 3 then
self.colors = self.char.flowercolor or flowercolor
end
end
if bigmario then
self.offsetX = self.offsetX*scalefactor
self.offsetY = self.offsetY*-scalefactor
end
--hat
self.hats = mariohats[self.playernumber]
self.drawhat = true
--Change height according to hats
--for i = 1, #self.hats do
--self.height = self.height + (hat[self.hats[i]].height/16)
--self.y = self.y - (hat[self.hats[i]].height/16)
--self.offsetY = self.offsetY - hat[self.hats[i]].height
--end
self.customscissor = false
if players == 1 and not arcade then
self.portal1color = {60 / 255, 188 / 255, 252 / 255}
self.portal2color = {232 / 255, 130 / 255, 30 / 255}
else
self.portal1color = portalcolor[self.playernumber][1]
self.portal2color = portalcolor[self.playernumber][2]
end
if self.portalsavailable[1] then
self.lastportal = 1
elseif self.portalsavailable[2] then
self.lastportal = 2
end
--OTHER STUFF!
self.controlsenabled = true
self.runframe = self.char.runframes
self.jumpframe = 1
self.swimframe = 1
self.climbframe = 1
self.runanimationprogress = 1
self.jumpanimationprogress = 1
self.swimanimationprogress = 1
self.animationstate = "idle" --idle, running, jumping, falling, swimming, sliding, climbing, dead
self.animationdirection = "right" --left, right. duh
self.platform = false
self.combo = 1
if not portals[self.playernumber] then
portals[self.playernumber] = portal:new(self.playernumber, self.portal1color, self.portal2color)
end
self.portal = portals[self.playernumber]
self.rotation = 0 --for portals
self.pointingangle = -math.pi/2
self.animationdirection = "right"
self.passivemoved = false
self.ducking = false
self.invincible = false
self.rainboomallowed = true
self.looktimer = 0
self.raccoonstarttimer = 0
self.raccoontimer = 0
self.raccoonascendtimer = 0
self.tailwagframe = 1
self.tailwagtimer = 0
self.gravitydirection = math.pi/2
self.animation = animation or false --pipedown, piperight, pipeup, flag, vine, intermission
self.animationx = false
self.animationy = false
self.animationtimer = 0
self.falling = false
self.jumping = false
self.starred = false
self.dead = false
self.vine = false
self.spring = false
self.startimer = mariostarduration
self.starblinktimer = mariostarblinkrate
self.starcolori = 1
self.fireballcount = 0
self.fireanimationtimer = fireanimationtime
self.mazevar = 0
self.bubbletimer = 0
self.bubbletime = bubblestime[math.random(#bubblestime)]
self.underwater = underwater
if self.underwater then
self:dive(true)
end
if self.animation == "intermission" and editormode then
self.animation = false
end
if mariolivecount ~= false and mariolives[self.playernumber] <= 0 then
self.dead = true
self.drawable = false
self.active = false
self.static = true
self.controlsenabled = false
self.animation = false
end
if self.animation == "pipeup" then
self.controlsenabled = false
self.active = false
self.animationx = x
self.animationy = y
self.customscissor = {x-2.5, y-4, 6, 4}
self.y = self.animationy + 20/16
self.animationstate = "idle"
self:setquad()
if self.size > 1 then
self.animationy = y - 12/16
end
if arcade and not arcadeplaying[self.playernumber] then
self.y = self.animationy + 20/16 - pipeanimationdistancedown
self.animation = false
end
elseif self.animation == "intermission" then
self.controlsenabled = false
self.active = true
self.gravity = mariogravity
self.animationstate = "running"
self.speedx = 2.61
self.pointingangle = -math.pi/2
self.animationdirection = "right"
elseif self.animation == "vinestart" then
self.controlsenabled = false
self.active = false
self.pointingangle = -math.pi/2
self.animationdirection = "right"
self.climbframe = 2
self.animationstate = "climbing"
self:setquad()
self.x = 4-3/16
self.y = mapheight+0.4*(self.playernumber-1)
self.vineanimationclimb = false
self.vineanimationdropoff = false
self.vinemovetimer = 0
playsound("vine")
if #objects["vine"] == 0 then
table.insert(objects["vine"], vine:new(5, mapheight+1, "start"))
end
end
self:setquad()
end
function mario:adddata()
--i, x, y, cscale, offsetX, offsetY, rotation, quadcenterX, quadcenterY, animationstate, underwater, ducking, hats, graphic, quad, pointingangle, shot, upsidedown, colors, lastportal, portal1color, portal2color)
--local colors = {}
--for i = 1, #self.colors do
-- colors[i] = {unpack(self.colors[i])}
--end
table.insert(livereplaydata[self.playernumber], {time=love.timer.getTime()-livereplaytimer})
local data = {
x=self.x,
y=self.y,
offsetX=self.offsetX,
offsetY=self.offsetY,
rotation=self.rotation,
quadcenterX=self.quadcenterX,
quadcenterY=self.quadcenterY,
animationstate=self.animationstate,
underwater=self.underwater,
ducking=self.ducking,
--hats={unpack(self.hats)}, --!
pointingangle=self.pointingangle,
--shot=self.shot, --!
--upsidedown=self.upsidedown, --!
colors=self.colors, --!
--lastportal=self.lastportal, --!
--portal1color={unpack(self.portal1color)}, --!
--portal2color={unpack(self.portal2color)}, --!
runframe=self.runframe,
jumpframe=self.jumpframe,
climbframe=self.climbframe,
swimframe=self.swimframe,
fireanimationtimer=self.fireanimationtimer,
size=self.size,
drawable=self.drawable,
customscissor=self.customscissor,
world=marioworld,
level=mariolevel,
sublevel=mariosublevel,
animationdirection=self.animationdirection
}
for i, v in pairs(data) do
if livereplaystored[self.playernumber][i] == nil or livereplaystored[self.playernumber][i] ~= v then
livereplaydata[self.playernumber][#livereplaydata[self.playernumber]][i] = v
livereplaystored[self.playernumber][i] = v
end
end
end
function mario:update(dt)
if replaysystem then
livereplaydelay[self.playernumber] = livereplaydelay[self.playernumber] + dt
while livereplaydelay[self.playernumber] >= 1/60 do
self:adddata()
livereplaydelay[self.playernumber] = livereplaydelay[self.playernumber] - 1/60
end
end
self.passivemoved = false
self.rotation = unrotate(self.rotation, self.gravitydirection, dt)
--Tailwag!
if self.char.raccoon and (self.tailwag or self.tailwagtimer > 0) then
if self.tailwagtimer == 0 then
self.tailwag = false
playsound("tailwag")
end
self.tailwagtimer = self.tailwagtimer + dt
while self.tailwagtimer > raccoontailwagdelay do
self.tailwagframe = self.tailwagframe + 1
self.tailwagtimer = self.tailwagtimer - raccoontailwagdelay
if self.tailwagframe > 3 then
self.tailwagframe = 1
self.tailwagtimer = 0
end
end
end
--Spin!
if self.char.raccoon and self.raccoonspinframe then
if self.raccoonspintimer == 0 then
playsound("tailwag")
end
self.raccoonspintimer = self.raccoonspintimer + dt
while self.raccoonspintimer > raccoonspindelay and self.raccoonspinframe do
self.raccoonspintimer = self.raccoonspintimer - raccoonspindelay
self.raccoonspinframe = self.raccoonspinframe + 1
if self.raccoonspinframe >= 4 then
self.raccoonspinframe = false
end
end
end
if self.startimer < mariostarduration and not self.dead then
self.startimer = self.startimer + dt
self.starblinktimer = self.starblinktimer + dt
local lmariostarblinkrate = mariostarblinkrate
if self.startimer >= mariostarduration-mariostarrunout then
lmariostarblinkrate = mariostarblinkrateslow
end
while self.starblinktimer > lmariostarblinkrate do
self.starcolori = self.starcolori + 1
if self.starcolori > 4 then
self.starcolori = self.starcolori - 4
end
self.colors = starcolors[self.starcolori]
self.starblinktimer = self.starblinktimer - lmariostarblinkrate
end
if self.startimer >= mariostarduration-mariostarrunout and self.startimer-dt < mariostarduration-mariostarrunout then
--check if another starman is playing
local starstill = false
for i = 1, players do
if i ~= self.playernumber and objects["player"][i].starred then
starstill = true
end
end
if not starstill and not levelfinished then
playmusic()
music:stop("starmusic.ogg")
end
end
if self.startimer >= mariostarduration then
if self.size == 3 then --flower colors
self.colors = self.char.flowercolor or flowercolor
else
self.colors = mariocolors[self.playernumber]
end
self.starred = false
self.startimer = mariostarduration
end
end
if self.jumping then
if self.underwater then
self.gravity = uwyaccelerationjumping
else
self.gravity = yaccelerationjumping
end
if self.speedy > 0 then
self.jumping = false
self.falling = true
end
else
if self.underwater then
self.gravity = uwyacceleration
else
self.gravity = yacceleration
end
end
if self.size ~= 1 then
self.gravitydirection = math.pi/2
end
--animationS
if self.animation == "animationwalk" then
if self.animationmisc == "right" then
self.speedx = maxwalkspeed
else
self.speedx = -maxwalkspeed
end
self:runanimation(dt)
self:setquad()
return
elseif self.animation == "pipedown" and self.animationy and self.animationx then
self.animationtimer = self.animationtimer + dt
if self.animationtimer < pipeanimationtime then
self.y = self.animationy - 28/16 + self.animationtimer/pipeanimationtime*pipeanimationdistancedown
else
self.y = self.animationy - 28/16 + pipeanimationdistancedown
if self.animationtimer >= pipeanimationtime+pipeanimationdelay then
updatesizes()
if type(self.animationmisc) == "number" then --sublevel
levelscreen_load("sublevel", self.animationmisc)
else --warpzone
warpzone(self.animationmisc2, self.animationmisc3)
end
end
end
return
elseif self.animation == "pipeup" and self.animationy and self.animationx then
self.animationtimer = self.animationtimer + dt
if self.animationtimer < pipeupdelay then
elseif self.animationtimer < pipeanimationtime+pipeupdelay then
self.y = self.animationy + 20/16 - (self.animationtimer-pipeupdelay)/pipeanimationtime*pipeanimationdistancedown
else
self.y = self.animationy + 20/16 - pipeanimationdistancedown
if self.animationtimer >= pipeanimationtime then
self.active = true
self.controlsenabled = true
self.animation = false
self.customscissor = false
end
end
return
elseif self.animation == "piperight" and self.animationy and self.animationx then
self.animationtimer = self.animationtimer + dt
if self.animationtimer < pipeanimationtime then
self.x = self.animationx - 28/16 + self.animationtimer/pipeanimationtime*pipeanimationdistanceright
--Run animation
if self.animationstate == "running" then
self:runanimation(dt)
end
self:setquad()
else
self.x = self.animationx - 28/16 + pipeanimationdistanceright
if self.animationtimer >= pipeanimationtime+pipeanimationdelay then
updatesizes()
if type(self.animationmisc) == "number" then --sublevel
levelscreen_load("sublevel", self.animationmisc)
else --warpzone
warpzone(self.animationmisc2, self.animationmisc3)
end
end
end
return
elseif self.animation == "flag" and flagx then
if self.animationtimer < flagdescendtime then
flagimgy = flagy-10+1/16 + flagydistance * (self.animationtimer/flagdescendtime)
self.y = self.y + flagydistance/flagdescendtime * dt
self.animationtimer = self.animationtimer + dt
if self.y > flagy-9+4/16 + flagydistance-self.height then
self.y = flagy-9+4/16 + flagydistance-self.height
self.climbframe = 2
else
if math.mod(self.animationtimer, flagclimbframedelay*2) >= flagclimbframedelay then
self.climbframe = 1
else
self.climbframe = 2
end
end
self.animationstate = "climbing"
self:setquad()
if self.animationtimer >= flagdescendtime then
flagimgy = flagy-10+1/16 + flagydistance
self.pointingangle = math.pi/2
self.animationdirection = "left"
self.x = flagx + 6/16
end
return
elseif self.animationtimer < flagdescendtime+flaganimationdelay then
self.animationtimer = self.animationtimer + dt
if self.animationtimer >= flagdescendtime+flaganimationdelay then
self.active = true
self.gravity = mariogravity
self.animationstate = "running"
self.speedx = 4.27
self.pointingangle = -math.pi/2
self.animationdirection = "right"
end
else
self.animationtimer = self.animationtimer + dt
end
local add = 6
if (self.x >= flagx + add or self.speedx < maxwalkspeed/2) and self.active then
self.drawable = false
self.active = false
if mariotime > 0 then
playsound("scorering")
subtractscore = true
subtracttimer = 0
else
castleflagmove = true
end
end
if subtractscore == true and mariotime >= 0 then
subtracttimer = subtracttimer + dt
while subtracttimer > scoresubtractspeed do
subtracttimer = subtracttimer - scoresubtractspeed
if mariotime > 0 then
mariotime = math.ceil(mariotime - 1)
marioscore = marioscore + 50
end
if mariotime <= 0 then
subtractscore = false
soundlist["scorering"].source:stop()
soundlist["scorering"].source:seek(0)
castleflagmove = true
mariotime = 0
end
end
end
if castleflagmove then
if self.animationtimer < castlemintime then
castleflagtime = self.animationtimer
return
end
castleflagy = castleflagy - castleflagspeed*dt
if castleflagy <= 0 then
castleflagy = 0
castleflagmove = false
firework = true
castleflagtime = self.animationtimer
end
end
if firework then
local timedelta = self.animationtimer - castleflagtime
for i = 1, fireworkcount do
local fireworktime = i*fireworkdelay
if timedelta >= fireworktime and timedelta - dt < fireworktime then
table.insert(fireworks, fireworkboom:new(flagx+6, flagy-13))
end
end
if timedelta > math.max(fireworkcount*fireworkdelay, soundlist["levelend"].source:getDuration()-castleflagtime)+endtime then
nextlevel()
return
end
end
--500 points per firework, appear at 1 3 and 6 (Who came up with this?)
--Run animation
if self.animationstate == "running" then
self:runanimation(dt)
self:setquad()
end
return
elseif self.animation == "axe" then
self.animationtimer = self.animationtimer + dt
if not bowserfall and self.animationtimer - dt < castleanimationchaindisappear and self.animationtimer >= castleanimationchaindisappear then
bridgedisappear = true
end
if bridgedisappear then
local v = objects["bowser"][1]
if v then
v.walkframe = round(math.mod(self.animationtimer, castleanimationbowserframedelay*2)*(1/(castleanimationbowserframedelay*2)))+1
end
self.animationtimer2 = self.animationtimer2 + dt
while self.animationtimer2 > castleanimationbridgedisappeardelay and self.animationbridgex > 0 do
self.animationtimer2 = self.animationtimer2 - castleanimationbridgedisappeardelay
local removedtile = false
for y = 1, mapheight do
if tilequads[map[self.animationbridgex][y][1]]:getproperty("bridge", self.animationbridgex, y) then
removedtile = true
map[self.animationbridgex][y][1] = 1
objects["tile"][self.animationbridgex .. "-" .. y] = nil
end
end
if removedtile then
generatespritebatch()
playsound("bridgebreak")
self.animationbridgex = self.animationbridgex - 1
else
bowserfall = true
bridgedisappear = false
end
end
end
if bowserfall then
local v = objects["bowser"][1]
if v and not v.fall then
v.fall = true
v.speedx = 0
v.speedy = 0
v.active = true
v.gravity = 27.5
playsound("bowserfall")
self.animationtimer = 0
return
end
end
if bowserfall and self.animationtimer - dt < castleanimationmariomove and self.animationtimer >= castleanimationmariomove then
self.active = true
self.gravity = mariogravity
self.animationstate = "running"
self.speedx = 4.27
self.pointingangle = -math.pi/2
self.animationdirection = "right"
love.audio.stop()
playsound("castleend")
end
if self.speedx > 0 and self.x >= mapwidth - 8 then
self.x = mapwidth - 8
self.animationstate = "idle"
self:setquad()
self.speedx = 0
end
if levelfinishedmisc2 == 1 then
if self.animationtimer - dt < castleanimationtextfirstline and self.animationtimer >= castleanimationtextfirstline then
levelfinishedmisc = 1
end
if self.animationtimer - dt < castleanimationtextsecondline and self.animationtimer >= castleanimationtextsecondline then
levelfinishedmisc = 2
end
local nextlvltime = math.max(castleanimationnextlevel, soundlist["castleend"].source:getDuration()+castleendmusicstopdelay)
if self.animationtimer - dt < nextlvltime and self.animationtimer >= nextlvltime then
nextlevel()
end
else
if self.animationtimer - dt < endanimationtextfirstline and self.animationtimer >= endanimationtextfirstline then
levelfinishedmisc = 1
end
local castlemusicwait = math.max(soundlist["castleend"].source:getDuration()+endmusicstopdelay-endanimationtextsecondline, 0)
if self.animationtimer - dt < endanimationtextsecondline+castlemusicwait and self.animationtimer >= endanimationtextsecondline+castlemusicwait then
levelfinishedmisc = 2
love.audio.stop()
music:play("princessmusic.ogg")
end
if self.animationtimer - dt < endanimationtextthirdline+castlemusicwait and self.animationtimer >= endanimationtextthirdline+castlemusicwait then
levelfinishedmisc = 3
end
if self.animationtimer - dt < endanimationtextfourthline+castlemusicwait and self.animationtimer >= endanimationtextfourthline+castlemusicwait then
levelfinishedmisc = 4
end
if self.animationtimer - dt < endanimationtextfifthline+castlemusicwait and self.animationtimer >= endanimationtextfifthline+castlemusicwait then
levelfinishedmisc = 5
end
if self.animationtimer - dt < endanimationend+castlemusicwait and self.animationtimer >= endanimationend+castlemusicwait then
endpressbutton = true
end
end
--Run animation
if self.animationstate == "running" and self.animationtimer >= castleanimationmariomove then
self:runanimation(dt)
self:setquad()
end
return
elseif self.animation == "death" or self.animation == "deathpit" then
self.animationtimer = self.animationtimer + dt
self.animationstate = "dead"
self:setquad()
if self.animation == "death" then
if self.animationtimer >= deathanimationjumptime then
if self.animationtimer - dt < deathanimationjumptime then
self.speedy = -deathanimationjumpforce
end
self.speedy = self.speedy + deathgravity*dt
self.y = self.y + self.speedy*dt
end
end
if self.animationtimer > deathtotaltime then
if self.animationmisc == "everyonedead" then
levelscreen_load("death")
elseif not everyonedead then
self:respawn()
end
end
return
elseif self.animation == "intermission" then
--Run animation
if self.animationstate == "running" then
self:runanimation(dt)
self:setquad()
end
return
elseif self.animation == "vine" then
self.y = self.y - vinemovespeed*dt
self.vinemovetimer = self.vinemovetimer + dt
self.climbframe = math.ceil(math.mod(self.vinemovetimer, vineframedelay*2)/vineframedelay)
self.climbframe = math.max(self.climbframe, 1)
self:setquad()
if self.y < -4 then
levelscreen_load("vine", self.animationmisc)
end
return
elseif self.animation == "vinestart" then
self.animationtimer = self.animationtimer + dt
if self.vineanimationdropoff == false and self.animationtimer - dt <= vineanimationmariostart and self.animationtimer > vineanimationmariostart then
self.vineanimationclimb = true
end
if self.vineanimationclimb then
self.vinemovetimer = self.vinemovetimer + dt
self.climbframe = math.ceil(math.mod(self.vinemovetimer, vineframedelay*2)/vineframedelay)
self.climbframe = math.max(self.climbframe, 1)
self.y = self.y - vinemovespeed*dt
if self.y <= mapheight-vineanimationgrowheight+vineanimationstop+0.4*(self.playernumber-1) then
self.vineanimationclimb = false
self.vineanimationdropoff = true
self.animationtimer = 0
self.y = mapheight-vineanimationgrowheight+vineanimationstop+0.4*(self.playernumber-1)
self.climbframe = 2
self.pointingangle = math.pi/2
self.animationdirection = "left"
self.x = self.x+9/16
end
self:setquad()
end
if self.vineanimationdropoff and self.animationtimer - dt <= vineanimationdropdelay and self.animationtimer > vineanimationdropdelay then
self.active = true
self.controlsenabled = true
self.x = self.x + 7/16
self.animation = false
end
return
elseif self.animation == "shrink" then
self.animationtimer = self.animationtimer + dt
--set frame lol
local frame = math.ceil(math.mod(self.animationtimer, growframedelay*3)/shrinkframedelay)
if frame == 1 then
self.graphic = self.biggraphic
self:setquad("idle", 2)
self.quadcenterY = self.char.shrinkquadcenterY
self.quadcenterX = self.char.shrinkquadcenterX
self.offsetY = self.char.bigoffsetY
self.animationstate = "idle"
else
self.graphic = self.smallgraphic
self.quadcenterX = self.char.smallquadcenterX
self.offsetY = self.char.smalloffsetY
if frame == 2 then
self.animationstate = "grow"
self:setquad("grow")
self.quadcenterY = self.char.shrinkquadcenterY2
else
self.animationstate = "idle"
self:setquad()
self.quadcenterY = self.char.smallquadcenterY
end
end
local invis = math.ceil(math.mod(self.animationtimer, invicibleblinktime*2)/invicibleblinktime)
if invis == 1 then
self.drawable = true
else
self.drawable = false
end
if self.animationtimer - dt < shrinktime and self.animationtimer > shrinktime then
self:goinvincible()
end
return
elseif self.animation == "invincible" then
self.animationtimer = self.animationtimer + dt
local invis = math.ceil(math.mod(self.animationtimer, invicibleblinktime*2)/invicibleblinktime)
if invis == 1 then
self.drawable = true
else
self.drawable = false
end
if self.animationtimer - dt < invincibletime and self.animationtimer > invincibletime then
self.animation = false
self.invincible = false
self.drawable = true
end
elseif self.animation == "grow1" then
self.animationtimer = self.animationtimer + dt
--set frame lol
local frame = math.ceil(math.mod(self.animationtimer, growframedelay*3)/growframedelay)
if frame == 3 then
self.animationstate = "idle"
self.graphic = self.biggraphic
self:setquad("idle")
self.quadcenterY = self.char.bigquadcenterY
self.quadcenterX = self.char.bigquadcenterX
self.offsetY = self.char.bigoffsetY
else
self.graphic = self.smallgraphic
self.quadcenterX = self.char.smallquadcenterX
self.offsetY = self.char.smalloffsetY
if frame == 2 then
self.animationstate = "grow"
self:setquad("grow", 1)
self.quadcenterY = self.char.growquadcenterY
else
self.animationstate = "idle"
self:setquad(nil, 1)
self.quadcenterY = self.char.growquadcenterY2
end
end
if self.animationtimer - dt < growtime and self.animationtimer > growtime then
self.animationstate = self.animationmisc
self.animation = false
noupdate = false
self.quadcenterY = self.char.bigquadcenterY
self.graphic = self.biggraphic
self.animationtimer = 0
self.quadcenterX = self.char.bigquadcenterX
self.offsetY = self.char.bigoffsetY
end
return
elseif self.animation == "grow2" then
self.animationtimer = self.animationtimer + dt
--set frame lol
local frame = math.ceil(math.mod(self.animationtimer, growframedelay*3)/growframedelay)
self.colors = starcolors[frame]
if self.animationtimer - dt < growtime and self.animationtimer > growtime then
self.animation = false
noupdate = false
self.animationtimer = 0
self.colors = self.char.flowercolor or flowercolor
end
return
end
if noupdate then
return
end
if self.fireanimationtimer < fireanimationtime then
self.fireanimationtimer = self.fireanimationtimer + dt
if self.fireanimationtimer > fireanimationtime then
self.fireanimationtimer = fireanimationtime
end
end
--Funnels and fuck
if self.funnel and not self.infunnel then
self:enteredfunnel(true)
end
if self.infunnel and not self.funnel then
self:enteredfunnel(false)
end
if self.funnel then
self.animationstate = "jumping"
self:setquad()
end
self.funnel = false
--vine controls and shit
if self.vine then
self.gravity = 0
self.animationstate = "climbing"
if upkey(self.playernumber) then
self.vinemovetimer = self.vinemovetimer + dt
self.climbframe = math.ceil(math.mod(self.vinemovetimer, vineframedelay*2)/vineframedelay)
self.climbframe = math.max(self.climbframe, 1)
self.y = self.y-vinemovespeed*dt
local t = checkrect(self.x, self.y, self.width, self.height, {"tile", "portalwall"})
if #t ~= 0 then
self.y = objects[t[1]][t[2]].y + objects[t[1]][t[2]].height
self.climbframe = 2
end
elseif downkey(self.playernumber) then
self.vinemovetimer = self.vinemovetimer + dt
self.climbframe = math.ceil(math.mod(self.vinemovetimer, vineframedelaydown*2)/vineframedelaydown)
self.climbframe = math.max(self.climbframe, 1)
checkportalHOR(self, self.y+vinemovedownspeed*dt)
self.y = self.y+vinemovedownspeed*dt
local t = checkrect(self.x, self.y, self.width, self.height, {"tile", "portalwall"})
if #t ~= 0 then
self.y = objects[t[1]][t[2]].y - self.height
self.climbframe = 2
end
else
self.climbframe = 2
self.vinemovetimer = 0
end
if self.vine.limit == -1 and self.y+self.height <= vineanimationstart then
self:vineanimation()
end
--check if still on vine
local t = checkrect(self.x, self.y, self.width, self.height, {"vine"})
if #t == 0 then
self:dropvine(self.vineside)
end
self:setquad()
return
end
--springs
if self.spring then
self.x = self.springx
self.springtimer = self.springtimer + dt
self.y = self.springy - self.height - 31/16 + springytable[self.springb.frame]
if self.springtimer > springtime then
self:leavespring()
end
return
end
--coins
if not editormode then
local x = math.floor(self.x+self.width/2)+1
local y = math.floor(self.y+self.height)+14/16
if inmap(x, y) and coinmap[x][y] then
collectcoin(x, y)
end
local y = math.floor(self.y+self.height/2)+1
if inmap(x, y) and coinmap[x][y] then
collectcoin(x, y)
end
if self.size > 1 then