forked from alesan99/mari0_ae
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmario.lua
More file actions
9195 lines (8497 loc) · 273 KB
/
mario.lua
File metadata and controls
9195 lines (8497 loc) · 273 KB
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:new()
function mario:init(x, y, i, animation, size, t, properties)
self.playernumber = i or 1
if bigmario then
self.size = 1
elseif size and size == 8 then
self.size = 1
else
self.size = size or 1
end
self.t = t or "portal"
--custom character
self.character = mariocharacter[self.playernumber]
self.characterdata = characters.data[mariocharacter[self.playernumber]]
--PHYSICS STUFF
self.speedx = 0
self.speedy = 0
self.x = x
self.width = 12/16
self.height = 12/16
self.portalgun = portalgun
if self.characterdata.noportalgun then
self.portalgun = false
self.t = "classic"
elseif playertype == "classic" or playertype == "cappy" then
self.portalgun = false; portalguni = 2; portalgun = false
end
if self.portalgun then
if portalguni == 3 then
self.portals = "1 only"
elseif portalguni == 4 then
self.portals = "2 only"
elseif portalguni == 5 then
self.portals = "gel"
else
self.portals = "both"
end
else
self.portals = "none"
end
self:updateportalsavailable()
self.gravitydir = "down"
if bigmario then
self.width = self.width*scalefactor
self.height = self.height*scalefactor
end
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,
false, true}
if playercollisions then
self.mask[3] = false
end
if edgewrapping then
self.mask[10] = true
end
self.emancipatecheck = true
--IMAGE STUFF
self.smallgraphic = {}
if self.character and self.characterdata["animations"] then
for j = 0, #self.characterdata["animations"] do
self.smallgraphic[j] = self.characterdata["animations"][j]
end
end
self.biggraphic = {}
if self.character and self.characterdata["biganimations"] then
for j = 0, #self.characterdata["biganimations"] do
self.biggraphic[j] = self.characterdata["biganimations"][j]
end
end
if self.characterdata["fireanimations"] then
self.firegraphic = {}
for j = 0, #self.characterdata["fireanimations"] do
self.firegraphic[j] = self.characterdata["fireanimations"][j]
end
end
if self.characterdata["iceanimations"] then
self.icegraphic = {}
for j = 0, #self.characterdata["iceanimations"] do
self.icegraphic[j] = self.characterdata["iceanimations"][j]
end
end
if self.characterdata["superballanimations"] then
self.superballgraphic = {}
for j = 0, #self.characterdata["superballanimations"] do
self.superballgraphic[j] = self.characterdata["superballanimations"][j]
end
end
self.hammergraphic = {}
if self.character and self.characterdata["hammeranimations"] then
for j = 0, #self.characterdata["hammeranimations"] do
self.hammergraphic[j] = self.characterdata["hammeranimations"][j]
end
end
self.froggraphic = {}
if self.character and self.characterdata["froganimations"] then
for j = 0, #self.characterdata["froganimations"] do
self.froggraphic[j] = self.characterdata["froganimations"][j]
end
end
self.raccoongraphic = {}
if self.character and self.characterdata["raccoonanimations"] then
for j = 0, #self.characterdata["raccoonanimations"] do
self.raccoongraphic[j] = self.characterdata["raccoonanimations"][j]
end
end
self.tinygraphic = {}
if self.character and self.characterdata["tinyanimations"] then
for j = 0, #self.characterdata["tinyanimations"] do
self.tinygraphic[j] = self.characterdata["tinyanimations"][j]
end
end
self.tanookigraphic = {}
if self.character and self.characterdata["tanookianimations"] then
for j = 0, #self.characterdata["tanookianimations"] do
self.tanookigraphic[j] = self.characterdata["tanookianimations"][j]
end
end
self.skinnygraphic = {}
if self.character and self.characterdata["skinnyanimations"] then
for j = 0, #self.characterdata["skinnyanimations"] do
self.skinnygraphic[j] = self.characterdata["skinnyanimations"][j]
end
end
self.capegraphic = {}
if self.character and self.characterdata["capeanimations"] then
for j = 0, #self.characterdata["capeanimations"] do
self.capegraphic[j] = self.characterdata["capeanimations"][j]
end
end
self.shellgraphic = {}
if self.character and self.characterdata["shellanimations"] then
for j = 0, #self.characterdata["shellanimations"] do
self.shellgraphic[j] = self.characterdata["shellanimations"][j]
end
end
self.boomeranggraphic = {}
if self.character and self.characterdata["boomeranganimations"] then
for j = 0, #self.characterdata["boomeranganimations"] do
self.boomeranggraphic[j] = self.characterdata["boomeranganimations"][j]
end
end
self.drawable = true
self.quad = self.characterdata["small"]["idle"][3]
self.quadanim = "idle"
self.quadframe = 3
if self.characterdata.defaultsize then
self.size = self.characterdata.defaultsize
end
self:setsize(self.size)
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 = nil
if (players == 1 and (not CustomPortalColors)) or self.playernumber > 4 then
self.portal1color = {60, 188, 252}
self.portal2color = {232, 130, 30}
else
self.portal1color = portalcolor[self.playernumber][1]
self.portal2color = portalcolor[self.playernumber][2]
end
--OTHER STUFF!
self.controlsenabled = true
self.idleframe = 1
self.idleanimationprogress = 1
self.runframe = math.min(self.characterdata.runframes, 3)
self.jumpframe = 1
self.jumpanimationprogress = 1
self.fallframe = 1
self.fallanimationprogress = 1
self.swimframe = 1
self.swimpush = false
self.climbframe = 1
self.fenceframe = 1
self.fenceanimationprogress = 1
self.fencejumptimer = 0
self.floatframe = 1
self.spinframez = 1
self.raccoonflyframe = 1
self.runanimationprogress = 1
self.runframes = self.characterdata.runframes--4
self.swimanimationprogress = 1
self.floatanimationprogress = 1
self.spinanimationprogress = 1
self.raccoonflyanimationprogress = 1
self.animationstate = "idle" --idle, running, jumping, falling, swimming, sliding, climbing, dead
self.animationdirection = "right" --left, right. duh
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.portaldotstimer = 0
self.pointingangle = -math.pi/2
self.passivemoved = false
self.ducking = false
self.invincible = false
self.rainboomallowed = true
self.water = underwater
self.yoshi = false
self.yoshiquad = false
self.yoshitounge = false
self.yoshitoungewidth = 0
self.yoshitoungespeed = yoshitoungespeed
self.yoshitoungeenemy = false
self.swimwing = false
self.dkhammer = false
self.dkhammeranim = 0
self.dkhammerframe = 1
self.groundfreeze = false
self.noteblock = false
self.noteblock2 = false
self.ice = false
self.shoe = false --goombashoe
self.helmet = false
self.helmetanimtimer = 1
self.propellerjumping = false
self.propellerjumped = false
self.propellertime = 0
self.cannontimer = 0
self.blueshelled = false
self.blueshellframe = 1
self.blueshellanimationprogress = 1
self.statue = false
self.statuetimer = false
self.capeframe = 1
self.capeanim = 0
self.capefly = false
self.capeflyframe = 1
self.capeflyanim = 0
self.capeflybounce = false
self.weight = 1
self.mariolevel = mariolevel --level where mario is from
self.groundpounding = false
self.groundpoundcanceled = false
self.animation = animation --pipedown, piperight, pipeupexit, pipeleft, flag, vine, intermission, pipeup, pipedownexit
self.animationx = nil
self.animationy = nil
self.animationtimer = 0
self.falling = false
self.jumping = false
self.starred = false
self.dead = false
self.vine = false
self.fence = false
self.spring = false
self.springgreen = false
self.startimer = mariostarduration
self.starblinktimer = mariostarblinkrate
self.starcolori = 1
self.fireballcount = 0
self.fireenemycount = {}
self.fireanimationtimer = fireanimationtime
self.spinanimationtimer = raccoonspintime
--turrets
self.hitpoints = maxhitpoints
self.hitpointtimer = 0
self.hitpointsdelay = 0
--health
self.health = self.characterdata.health
--RACCOON STUFF
self.float = false
self.floattimer = 0
self.ignoregravity = false
self.planemode = false
self.planetimer = 0
self.playraccoonplanesound = true
self.raccoonflyingtimer = 0
self.raccoonfly = false
--CAPPY
if playertype == "cappy" then
self.cappy = cappy:new(self)
table.insert(objects["cappy"], self.cappy)
end
--LOOK UP/DOWN
self.upkeytimer = 0
self.downkeytimer = 0
--SLANTS/SLOPES
self.onslant = false
self.mazevar = 0
self.light = 3.5
self.bubbletimer = 0
self.bubbletime = bubblestime[math.random(#bubblestime)]
if self.water then
self.gravity = self.characterdata.uwgravity
elseif currentphysics == 2 or currentphysics == 4 or currentphysics == 6 then --fall slow at start
self.speedy = 0
self.gravity = self.characterdata.yaccelerationjumping
end
self.controlsoverwrite = {}
if self.animation == "intermission" and editormode then
self.animation = nil
end
if mariolivecount ~= false and type(mariolives[self.playernumber]) == "number" and mariolives[self.playernumber] <= 0 then
self.dead = true
self.drawable = false
self.active = false
self.static = true
self.controlsenabled = false
self.animation = nil
end
if self.animation and self.animation:find("pipe") then
local p = exitpipes[tilemap(pipestartx,pipestarty)]
local dir = p.dir
self.controlsenabled = false
self.active = false
self.drawable = false
self.animationx = pipestartx
self.animationy = pipestarty
self.customscissor = p.scissor[dir]
if dir == "up" then
self.x = p.x-self.width/2
self.animationstate = "idle"
elseif dir == "down" then
self.x = p.x-self.width/2
self.animationstate = "idle"
elseif dir == "left" then
self.y = p.y-self.height
self.animationstate = "running"
self.pointingangle = math.pi/2
elseif dir == "right" then
self.y = p.y-self.height
self.animationstate = "running"
self.pointingangle = -math.pi/2
end
self:setquad()
elseif self.animation == "intermission" then
self.controlsenabled = false
self.active = true
self.gravity = self.characterdata.yacceleration
self.animationstate = "running"
self.speedx = 2.61
self.pointingangle = -math.pi/2
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(vinesound)
if #objects["vine"] == 0 then
table.insert(objects["vine"], vine:new(5, mapheight+1, "start"))
end
end
if properties and (not editormode) then
--stay shoed
if properties.shoe and properties.shoe ~= "cloud" then
if type(properties.shoe) == "table" and properties.shoe[1] == "yoshi" then
local obj = yoshi:new(self.x, self.y, properties.shoe[2])
obj:ride(self)
self.yoshi = obj
table.insert(objects["yoshi"], obj)
self:shoed("yoshi", true)
else
self:shoed(properties.shoe, true)
end
end
--keep helmet
if properties.helmet then
self:helmeted(properties.helmet)
end
--keep keys (only if in the same level)
if properties.key and properties.mariolevel then
if mariolevel == properties.mariolevel then --only keep keys in the same level
self.key = properties.key
end
end
--custom powerup
if properties.fireenemy then
self.fireenemy = properties.fireenemy
self.basecolors = properties.customcolors
self.colors = self.basecolors
self.customcolors = false
end
--health
if properties.health and self.characterdata.health then
self.health = properties.health
end
end
if self.characterdata.spawnenemy then
local obj = enemy:new(self.x+self.width/2, self.y+self.height/2, self.characterdata.spawnenemy)
obj.parent = self
table.insert(objects["enemy"], obj)
end
self:setquad()
end
function mario:update(dt)
--RACCOON STUFF
if self.float and not self.raccoonfly then
if self.gravitydir == "up" then
self.speedy = -3
else
self.speedy = 3
end
self.ignoregravity = true
self.animationstate = "floating"
self:setquad()
self.floattimer = self.floattimer + dt
if (self.size == 11 and self.floattimer > 0.3) or (self.size ~= 11 and self.floattimer > 0.25) then
self.floattimer = 0
self.float = false
self.ignoregravity = false
end
end
if (self.size == 6 or self.size == 9 or self.size == 10) and self.animationstate == "running" then --be able to fly when runing for whatever seconds
if (self.animationdirection == "left" and self.speedx < -8.8) or (self.animationdirection == "right" and self.speedx > 8.9) then
self.planetimer = self.planetimer + 1*dt
if self.planetimer > 1.1 then
if self.playraccoonplanesound and self.size ~= 10 then
playsound(raccoonplanesound)
self.playraccoonplanesound = false
end
self.planemode = true
end
end
else
if self.animationstate ~= "jumping" and self.raccoonfly == false then
raccoonplanesound:stop()
self.planemode = false
end
self.playraccoonplanesound = true
self.planetimer = 0
end
if self.raccoonfly then
if (self.size == 6 or self.size == 9) then --fly as raccoon Mario
self.raccoonflyingtimer = self.raccoonflyingtimer + dt
if self.raccoonflyingtimer < self.characterdata.raccoonflytime then
if jumpkey(self.playernumber) and self.controlsenabled then
if self.gravitydir == "up" then
self.speedy = math.min(self.characterdata.raccoonflyjumpforce, self.speedy+100*dt)
else
self.speedy = math.max(-self.characterdata.raccoonflyjumpforce, self.speedy-100*dt)
end
if self.speedy < 0 then
self.y = math.max(-4, self.y)
end
end
else
self.raccoonflyingtimer = 0
self.raccoonfly = false
end
self.raccoonflyanimationprogress = self.raccoonflyanimationprogress + (math.abs(1)+4)/5*dt*self.characterdata.runanimationspeed
while self.raccoonflyanimationprogress >= 4 do
self.raccoonflyanimationprogress = self.raccoonflyanimationprogress - 3
end
if self.raccoonflyframe == 4 then
self.raccoonflyframe = 1
end
self.raccoonflyframe = math.floor(self.raccoonflyanimationprogress)
elseif self.size == 10 then--fly as cape mario
if self.capefly and (not (runkey(self.playernumber) and self.controlsenabled)) then
self.raccoonfly = false
self.capefly = false
self.planemode = false
self.planetimer = 0
elseif self.capefly then
local speed = 4
if (self.speedx > 0 and rightkey(self.playernumber)) or (self.speedx < 0 and leftkey(self.playernumber)) then
speed = 8
end
self.capeflyanim = self.capeflyanim + speed*dt
while self.capeflyanim > 1 do
if ((self.speedx > 0 and leftkey(self.playernumber)) or (self.speedx < 0 and rightkey(self.playernumber))) and self.controlsenabled then
self.capeflyframe = math.max(1, math.min(self.capeflyframe-1, 6))
else
self.capeflyframe = math.max(1, math.min(self.capeflyframe+1, 6))
end
--alsean!!!! cape mario doesnt correct!!!!! please fix!!!
if self.capeflyframe == 1 and self.speedy > 0 and self.capeflybounce then
self.speedy = -30
self.capeflybounce = false
playsound(capeflysound)
elseif self.capeflyframe >= 2 then
self.capeflybounce = true
end
self.capeflyanim = self.capeflyanim - 1
end
if self.capeflyframe < 5 then
self.speedy = math.min(self.speedy, 6)
end
if self.speedy < 0 then
self.y = math.max(-4, self.y)
end
elseif self.speedy > 0 then
self.capefly = true
self.capeflyframe = 1
end
end
end
if raccoonplanesound:isPlaying() and (self.planemode == false or (self.size ~= 6 and self.size ~= 9)) then
raccoonplanesound:stop() --stops raccoon flying sound
end
--double jump?
if self.hasdoublejumped and not (self.jumping or self.falling) then
self.hasdoublejumped = false
end
if self.yoshiswallow then
self.yoshiswallow = self.yoshiswallow + dt
if self.yoshiswallow >= yoshiswallowtime then
self.yoshiswallow = false
else
self.yoshiswallowframe = 1+math.floor((self.yoshiswallow/yoshiswallowtime)*5)
end
end
if self.yoshispitting then
self.yoshispitting = self.yoshispitting - dt
if self.yoshispitting <= 0 then
self.yoshispitting = false
end
end
if self.yoshi and self.yoshitounge and not (self.yoshispitting) then
self.yoshitoungewidth = math.max(0, math.min(yoshitoungemaxwidth, self.yoshitoungewidth + self.yoshitoungespeed*dt))
local dirscale
if self.animationdirection == "left" then
dirscale = -scale
else
dirscale = scale
end
local w, h = self.yoshitoungewidth, yoshitoungeheight
local x, y = self.x+(self.width/2), self.y+self.height
local xoffset, yoffset = 12/16, -22/16
if self.jumping then
if dirscale < 0 then
xoffset = -(7/16)-w
else
xoffset = 7/16
end
else
if dirscale < 0 then
xoffset = -(12/16)-w
else
xoffset = 12/16
end
end
x, y = x+xoffset, y+yoffset
if not self.yoshitoungeenemy then
local dobreak = false
for j, obj in pairs(yoshitoungekill) do
for i, v in pairs(objects[obj]) do
if (not v.shot) and v.width and (not v.delete) and aabb(x, y, w, h, v.x, v.y, v.width, v.height) and (not v.resistsyoshitongue) and (not v.resistsyoshitounge) and (not v.resistseverything) then
--eat enemy
if v and v.width <= 2 and v.height <= 2 then
local pass = true
if v.active and (v.shellanimal or v.small ~= nil or v.yoshispit) then
elseif obj == "enemy" then
if v.active or v.yoshitoungeifnotactive then
local oldtransforms = v.transforms
v.transforms = false
if v:shotted("right", "tounge", false, true) ~= false then
v:output()
addpoints(v.firepoints or 200, self.x, self.y)
else
v.transforms = oldtransforms
pass = false
end
else
pass = false
end
else
if v.shotted then
addpoints(firepoints[obj], v.x, v.y)
v:shotted(self.animationdirection)
elseif v.use then
v:use("player", self)
end
end
if pass then
self.yoshitoungespeed = -yoshitoungespeed
if (v.shellanimal or v.small ~= nil or v.yoshispit) and v.active then
self.yoshitoungeenemy = v
v.eaten = true
v.active = false
v.drawable = false
elseif v.drawable then
--death frame
self.yoshitoungeenemy = {graphic=v.graphic,quad=v.quad,width=v.width,height=v.height,
offsetX=v.offsetX or 0,offsetY=v.offsetY or 0,quadcenterX=v.quadcenterX or 0,quadcenterY=v.quadcenterY or 0,
animationscalex=v.animationscalex, animationscaley=v.animationscaley}
if v.output then
v:output()
end
v.instantdelete = true
end
local dobreak = true
break
end
end
end
end
if dobreak then
break
end
end
end
if self.yoshitoungewidth == yoshitoungemaxwidth then
self.yoshitoungespeed = -yoshitoungespeed
elseif self.yoshitoungewidth == 0 then
self.yoshitoungespeed = yoshitoungespeed
self.yoshitounge = false
local v = self.yoshitoungeenemy
if v and v.eaten then
else
if self.yoshitoungeenemy then
--swallow animation
self.yoshiswallow = 0
self.yoshiswallowframe = 1
end
self.yoshitoungeenemy = false
end
end
end
if self.size == 10 or (self.fireenemy and self.fireenemy.cape) then
if self.speedy > 0 and jumpkey(self.playernumber) and (not self.groundpounding) then --float
self.speedy = math.min(self.speedy, 6)
end
--update cape frame
local delay = 0.1
if self.fence then
self.capeframe = 18
elseif self.speedy > 0 then --falling
if self.capeframe < 4 then
delay = 0.05
self.capeanim = self.capeanim + dt
while self.capeanim > delay do
self.capeframe = self.capeframe - 1
if self.capeframe < 1 then
self.capeframe = 10
end
self.capeanim = self.capeanim - delay
end
elseif self.capeframe < 10 or self.capeframe > 13 then
self.capeframe = 10
else
self.capeanim = self.capeanim + dt
while self.capeanim > delay do
self.capeframe = self.capeframe + 1
if self.capeframe > 13 then
self.capeframe = 10
end
self.capeanim = self.capeanim - delay
end
end
else
if math.abs(self.speedx) >= maxwalkspeed then --walking/running
self.capeanim = self.capeanim + dt
while self.capeanim > delay do
self.capeframe = self.capeframe + 1
if self.capeframe >= 10 then
self.capeframe = 6
end
self.capeanim = self.capeanim - delay
end
else --idle
if self.capeframe > 3 then
self.capeframe = 1
else
self.capeanim = self.capeanim + dt
while self.capeanim > delay do
self.capeframe = self.capeframe + 1
if self.capeframe > 3 then
self.capeframe = 3
end
self.capeanim = self.capeanim - delay
end
end
end
end
end
if self.size == 14 and self.ducking then
self.blueshellanimationprogress = (((self.blueshellanimationprogress + (math.abs(self.speedx))/8*dt*(self.characterdata.runanimationspeed))-1)%(self.characterdata.blueshellframes))+1
self.blueshellframe = math.floor(self.blueshellanimationprogress)
self:setquad()
end
------------------------------------------------------------------------------------------
if autoscrolling and not editormode and not self.customscissor then --autoscrolling stuff
if autoscrollingy then
if self.y < yscroll-4 and (not self.dead) then
if starty >= mapheight/2 then
self.y = yscroll-4
else
self:die("time")
end
elseif self.y > yscroll+height+1 and (not self.dead) then
self:die("pit")
end
end
if autoscrollingx then
if self.x < xscroll and (not self.dead) then
self.x = xscroll
elseif self.x > xscroll+width-self.width and (not self.dead) then
self.x = xscroll+width-self.width
end
end
end
if camerasetting == 3 and self.active and (not self.static) then
if self.x < xscroll then
self:die("time")
end
end
if edgewrapping then --wrap around screen
--teleport player
local teleported = false
local minx, maxx = -self.width, mapwidth
if self.x < minx then
self.x = maxx; teleported = true
elseif self.x > maxx then
self.x = minx; teleported = true
end
if teleported then
local fastestplayer = self
for i = 1, players do
if not objects["player"][i].dead and objects["player"][i].x > fastestplayer.x then
fastestplayer = objects["player"][i]
end
end
if fastestplayer.playernumber == self.playernumber then
xscroll = self.x-width/2
if xscroll < 0 then xscroll = 0 end
if xscroll > mapwidth-width-1 then
xscroll = math.max(0, mapwidth-width-1)
hitrightside()
end
splitxscroll = {xscroll}
end
end
end
--looking up/down
if upkey(self.playernumber) and self.controlsenabled then
self.upkeytimer = self.upkeytimer + dt
else
self.upkeytimer = 0
end
if downkey(self.playernumber) and self.controlsenabled then
self.downkeytimer = self.downkeytimer + dt
else
self.downkeytimer = 0
end
--button press controls joystick
if controls[self.playernumber] then
if controls[self.playernumber]["left"][1] == "joy" and controls[self.playernumber]["left"][3] ~= "but"
and controls[self.playernumber]["right"][1] == "joy" and controls[self.playernumber]["right"][3] ~= "but" then
local left, right = leftkey(self.playernumber), rightkey(self.playernumber)
if not self.leftkeyjoystick and left then
self:button("left")
self:leftkey()
animationsystem_buttontrigger(self.playernumber, "left")
end
if self.leftkeyjoystick and not left then
self:buttonrelease("left")
animationsystem_buttonreleasetrigger(self.playernumber, "left")
end
if not self.rightkeyjoystick and right then
self:button("right")
self:rightkey()
animationsystem_buttontrigger(self.playernumber, "right")
end
if self.rightkeyjoystick and not right then
self:buttonrelease("right")
animationsystem_buttonreleasetrigger(self.playernumber, "right")
end
self.leftkeyjoystick = left
self.rightkeyjoystick = right
end
if controls[self.playernumber]["up"][1] == "joy" and controls[self.playernumber]["up"][3] ~= "but"
and controls[self.playernumber]["down"][1] == "joy" and controls[self.playernumber]["down"][3] ~= "but" then
local up, down = upkey(self.playernumber), downkey(self.playernumber)
if not self.upkeyjoystick and up then
self:button("up")
self:upkey()
animationsystem_buttontrigger(self.playernumber, "up")
end
if self.upkeyjoystick and not up then
self:buttonrelease("up")
animationsystem_buttonreleasetrigger(self.playernumber, "up")
end
if not self.downkeyjoystick and down then
self:button("down")
self:downkey()
animationsystem_buttontrigger(self.playernumber, "down")
end
if self.downkeyjoystick and not down then
self:buttonrelease("down")
animationsystem_buttonreleasetrigger(self.playernumber, "down")
end
self.upkeyjoystick = up
self.downkeyjoystick = down
end
end
--Idle Animation
if self.characterdata.idleframes > 1 then
local frames = self.characterdata.idleframes
self.idleanimationprogress = ((self.idleanimationprogress+self.characterdata.idleanimationspeed*dt-1)%(frames))+1
self.idleframe = math.floor(self.idleanimationprogress)
end
if self.characterdata.jumpframes > 1 then
local frames = self.characterdata.jumpframes
if self.characterdata.jumpanimationloop then
self.jumpanimationprogress = ((self.jumpanimationprogress+self.characterdata.jumpanimationspeed*dt-1)%(frames))+1
else
self.jumpanimationprogress = math.min(frames,self.jumpanimationprogress+self.characterdata.jumpanimationspeed*dt)
end
self.jumpframe = math.floor(self.jumpanimationprogress)
end
if self.characterdata.fallframes > 1 and self.falling and self.speedy > 0 then
local frames = self.characterdata.fallframes
if self.characterdata.fallanimationloop then
self.fallanimationprogress = ((self.fallanimationprogress+self.characterdata.fallanimationspeed*dt-1)%(frames))+1
else
self.fallanimationprogress = math.min(frames,self.fallanimationprogress+self.characterdata.fallanimationspeed*dt)
end
self.fallframe = math.floor(self.fallanimationprogress)
end
--clear pipe invincibility
if self.clearpipeexitinvincibility and (not self.clearpipe) then
self.clearpipeexitinvincibility = self.clearpipeexitinvincibility - 1
if self.clearpipeexitinvincibility < 0 then
self.invincible = false
self.clearpipeexitinvincibility = false
end
end
--Groundpounding
if self.groundpounding then
self.groundpounding = self.groundpounding + dt
if (self.shoe ~= "drybonesshell" and self.groundpounding > groundpoundtime) or (self.shoe == "drybonesshell" and self.groundpounding > 0.2) then
--start falling
if self.static then
self.static = false
self.speedy = groundpoundforce
end
if downkey(self.playernumber) then
end
elseif self.shoe ~= "drybonesshell" then
--begin animation
self.rotation = (self.groundpounding/groundpoundtime)*math.pi*2
if (self.portalgun and self.pointingangle > 0) or (not self.portalgun and self.animationdirection == "left") then self.rotation = -self.rotation end
end
if (not (self.falling or self.jumping)) and not downkey(self.playernumber) then
self:groundpound(false)
end
end
--swim wing
if self.swimwing then
self.swimwing = self.swimwing - dt
if self.swimwing < 0 then
self:dive(false)
self.swimwing = false
end
end
--dk hammer
if self.dkhammer then
self.dkhammeranim = self.dkhammeranim + dt
while self.dkhammeranim > dkhammeranimspeed do
if self.dkhammerframe == 2 then
self.dkhammerframe = 1
else
self.dkhammerframe = 2
end
self.dkhammeranim = self.dkhammeranim - dkhammeranimspeed
end
self.dkhammer = self.dkhammer - dt
if self.dkhammer < 0 then
self.dkhammer = false
end
if self.dkhammer then
local w, h = 1, 1
local x, y = self.x+(self.width/2)-.5, self.y-1
if self.dkhammerframe == 2 then
if self.animationdirection == "right" then
x, y = self.x+self.width, self.y+self.height-1
else
x, y = self.x-1, self.y+self.height-1
end
end
local dobreak = false
for j, obj in pairs(dkhammerkill) do
for i, v in pairs(objects[obj]) do
if v.active and (not v.shot) and v.width and aabb(x, y, w, h, v.x, v.y, v.width, v.height) then
if obj == "enemy" then
if v:shotted("right", "dkhammer", false, false) ~= false then
addpoints(v.firepoints or 200, self.x, self.y)
end
else
addpoints(firepoints[obj], v.x, v.y)
v:shotted(self.animationdirection)
end
local dobreak = true
break
end
end
if dobreak then
break
end
end
end
end
--sledge bros
if self.groundfreeze then
self.controlsenabled = false
self.groundfreeze = self.groundfreeze - dt
if self.groundfreeze < 0 then
self.controlsenabled = true
self.groundfreeze = false
self.frozen = false