forked from Mari0-CE/Mari0-Community-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
2261 lines (1921 loc) · 61.5 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
--[[
STEAL MY SHIT AND I'LL FUCK YOU UP
PRETTY MUCH EVERYTHING BY MAURICE GUÉGAN AND IF SOMETHING ISN'T BY ME THEN IT SHOULD BE OBVIOUS OR NOBODY CARES
Please keep in mind that for obvious reasons, I do not hold the rights to artwork, audio or trademarked elements of the game.
This license only applies to the code and original other assets. Obviously. Duh.
Anyway, enjoy.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
]]
function love.run()
if love._version_minor < 9 then
--Cheap af but I don't care, COMPATIBILITY!!!
love.math = {}
love.math.setRandomSeed = math.randomseed
love.math.random = math.random
love.window = {}
love.window.setMode = love.graphics.setMode
love.window.getMode = love.graphics.getMode
love.window.setTitle = love.graphics.setCaption
love.window.setIcon = love.graphics.setIcon
love.window.getFullscreenModes = love.graphics.getModes
love.filesystem.getDirectoryItems = love.filesystem.enumerate
love.filesystem.createDirectory = love.filesystem.mkdir
love.graphics.setDefaultFilter = love.graphics.setDefaultImageFilter
love.graphics.origin = function() --Don't kill me for being cheap
local ptimes = 0
local ok, msg = pcall(love.graphics.pull)
if not ok then
return
else
while ok do
ptimes = ptimes + 1
ok, msg = pcall(love.graphics.pull)
end
for i = 1, ptimes do
love.graphics.push()
end
end
end
love.mouse.setGrabbed = love.mouse.setGrab
end
love.math.setRandomSeed(os.time())
for i=1, 2 do
love.math.random()
end
love.load(arg)
-- Main loop time.
while true do
-- Process events.
love.event.pump()
for e,a,b,c,d in love.event.poll() do
if e == "quit" then
if not love.quit() then
love.audio.stop()
return
end
end
love.handlers[e](a,b,c,d)
end
-- Update dt, as we'll be passing it to update
love.timer.step()
local dt = love.timer.getDelta()
-- Call update and draw
love.update(dt) -- will pass 0 if love.timer is disabled
love.graphics.clear()
love.graphics.origin()
--Fullscreen hack
if not mkstation and fullscreen and gamestate ~= "intro" then
if loveVersion <= 9 then
completecanvas:clear()
else
love.graphics.setCanvas(completecanvas)
love.graphics.clear()
end
love.graphics.setScissor()
completecanvas:renderTo(love.draw)
love.graphics.setScissor()
if loveVersion > 9 then
love.graphics.setCanvas()
end
if fullscreenmode == "full" then
love.graphics.draw(completecanvas, 0, 0, 0, desktopsize.width/(width*16*scale), desktopsize.height/(height*16*scale))
else
love.graphics.draw(completecanvas, 0, touchfrominsidemissing/2, 0, touchfrominsidescaling/scale, touchfrominsidescaling/scale)
love.graphics.setColor(0, 0, 0)
love.graphics.rectangle("fill", 0, 0, desktopsize.width, touchfrominsidemissing/2)
love.graphics.rectangle("fill", 0, desktopsize.height-touchfrominsidemissing/2, desktopsize.width, touchfrominsidemissing/2)
love.graphics.setColor(255, 255, 255, 255)
end
else
love.graphics.setScissor()
love.draw()
end
love.graphics.present()
love.timer.sleep(0.001)
end
end
function love.errhand(msg)
msg = tostring(msg)
local trace = debug.traceback()
local err = {}
table.insert(err, "FLAGRANT SYSTEM ERROR\n")
table.insert(err, "Mari0 Over.")
table.insert(err, "Crash = Very Yes.\n\n")
if not versionerror then
table.insert(err, "Send us a screenshot of this to [email protected], that'd be swell.\nAlso tell us what you were doing.\n")
end
table.insert(err, "Mari0 " .. (marioversion or "UNKNOWN") .. ", LOVE " .. (love._version or "UNKNOWN") .. " running on " .. (love._os or "UNKNOWN") .. "\n")
if love.graphics.getRendererInfo then
local info = {love.graphics.getRendererInfo()}
err[#err] = err[#err].."Graphics: "..info[1].." "..info[2].." ("..info[4]..", "..info[3]..")\n"
end
table.insert(err, msg.."\n\n")
if not versionerror then
for l in string.gmatch(trace, "(.-)\n") do
if not string.match(l, "boot.lua") then
l = string.gsub(l, "stack traceback:", "Traceback\n")
table.insert(err, l)
end
end
end
--error_printer(msg, 2)
if versionerror then
-- The rest of this code will only run on 0.9.0+.
return
end
if not love.graphics.isCreated() or not love.window.isCreated() then
local success, status = pcall(love.window.setMode, 800, 600)
if not success or not status then
return
end
end
local scale = scale or 2
-- Reset state.
if love.mouse then
love.mouse.setVisible(true)
love.mouse.setGrabbed(false)
end
if love.joystick then -- Stop all joystick vibrations.
for i,v in ipairs(love.joystick.getJoysticks()) do
v:setVibration()
end
end
if love.audio then love.audio.stop() end
love.graphics.reset()
love.graphics.setBackgroundColor(89, 157, 220)
local font = love.graphics.setNewFont(scale*7)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.origin()
--love.graphics.clear()
local p = table.concat(err, "\n")
p = string.gsub(p, "\t", "")
p = string.gsub(p, "%[string \"(.-)\"%]", "%1")
local function draw()
--love.graphics.clear()
love.graphics.setColor(0, 0, 0, 200)
love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
love.graphics.setColor(0, 0, 0)
love.graphics.printf(p, 35*scale, 15*scale-1, love.graphics.getWidth() - 35*scale)
love.graphics.printf(p, 35*scale+1, 15*scale, love.graphics.getWidth() - 35*scale)
love.graphics.printf(p, 35*scale-1, 15*scale, love.graphics.getWidth() - 35*scale)
love.graphics.printf(p, 35*scale, 15*scale+1, love.graphics.getWidth() - 35*scale)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.printf(p, 35*scale, 15*scale, love.graphics.getWidth() - 35*scale)
love.graphics.present()
end
draw()
while true do
love.event.pump()
for e, a, b, c in love.event.poll() do
if e == "quit" then
return
end
if e == "keypressed" and a == "escape" then
return
end
end
--love.graphics.present()
if love.timer then
love.timer.sleep(0.03)
end
end
end
function add(desc)
print((desc or "") .. "\n" .. round((love.timer.getTime()-starttime)*1000) .. "ms\tlines " .. lastline+1 .. " - " .. debug.getinfo(2).currentline-1 .. "\n")
lastline = debug.getinfo(2).currentline
totaltime = totaltime + round((love.timer.getTime()-starttime)*1000)
starttime = love.timer.getTime()
end
function love.load(arg)
marioversion = 1107
versionstring = "version 1.0se"
--version check by checking for a const that was added in 0.8.0 --todo: change to 0.9.0
if love._version_major == nil or (love._version_minor and love._version_minor < 9) then
--versionerror = true
--error("You have an outdated version of Love! Get 0.9.0 and retry.")
--HOW ABOUT NO
--Leave backwards compatibility with Hugo!
end
math.mod = math.fmod
math.random = love.math.random
--blame slime
if love._version_minor >= 9 then
love.graphics.drawq = love.graphics.draw
end
print("Loading Mari0 SE!")
print("=======================")
lastline = debug.getinfo(1).currentline
starttime = love.timer.getTime()
totaltime = 0
JSON = require "JSON"
require "notice"
--Get biggest screen size
local sizes = love.window.getFullscreenModes()
desktopsize = sizes[1]
for i = 2, #sizes do
if sizes[i].width > desktopsize.width or sizes[i].height > desktopsize.height then
desktopsize = sizes[i]
end
end
recordtarget = 1/40
recordskip = 1
recordframe = 1
magicdns_session_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
magicdns_session = ""
for i = 1, 8 do
rand = math.random(string.len(magicdns_session_chars))
magicdns_session = magicdns_session .. string.sub(magicdns_session_chars, rand, rand)
end
--use love.filesystem.getIdentity() when it works
magicdns_identity = love.filesystem.getSaveDirectory():split("/")
magicdns_identity = string.upper(magicdns_identity[#magicdns_identity])
shaderlist = love.filesystem.getDirectoryItems( "shaders/" )
local rem
for i, v in pairs(shaderlist) do
if v == "init.lua" then
rem = i
else
shaderlist[i] = string.sub(v, 1, string.len(v)-5)
end
end
table.remove(shaderlist, rem)
table.insert(shaderlist, 1, "none")
--=================--
-- VERSION CONTROL --
--=================--
loveVersion = love._version_minor
if loveVersion > 9 then
lkisDown = love.keyboard.isDown
lmisDown = love.mouse.isDown
function love.keyboard.isDown(key)
if key == " " then key = "space" end
return lkisDown(key)
end
function love.mouse.isDown(button)
if button == "l" then button = 1
elseif button == "r" then button = 2
elseif button == "m" then button = 3 end
return lmisDown(button)
end
end
iconimg = love.image.newImageData("graphics/icon.png")
if loveVersion < 9 then
iconimg = love.graphics.newImage("graphics/icon.png")
end
love.window.setIcon(iconimg)
love.graphics.setDefaultFilter("nearest", "nearest")
add("Variables, shaderlist")
local suc, err = pcall(loadconfig)
if not suc then
players = 1
defaultconfig()
print("== FAILED TO LOAD CONFIG ==")
print(err)
end
physicsdebug = false
incognito = false
portalwalldebug = false
userectdebug = false
speeddebug = false
DEBUG = false
editordebug = DEBUG
skipintro = DEBUG
skiplevelscreen = DEBUG
debugbinds = DEBUG
frameskip = false -- false/0 true is not valid, so stop accidentally writing that.
replaysystem = false
drawreplays = false
drawalllinks = false
bdrawui = true
skippedframes = 0
width = 25 --! default 25
height = 14
fsaa = 0
steptimer = 0
targetdt = 1/60
--Calculate relative scaling factor
touchfrominsidescaling = math.min(desktopsize.width/(width*16), desktopsize.height/(height*16))
touchfrominsidemissing = desktopsize.height-height*16*touchfrominsidescaling
add("Variables")
changescale(scale, true)
add("Resolution change")
require "characterloader"
add("Characterloader")
dlclist = {}
hatcount = #love.filesystem.getDirectoryItems("graphics/standardhats")
saveconfig()
love.window.setTitle( "Mari0 SE" )
love.graphics.setBackgroundColor(0, 0, 0)
fontimage = love.graphics.newImage("graphics/font.png")
fontimageback = love.graphics.newImage("graphics/fontback.png")
fontglyphs = "0123456789abcdefghijklmnopqrstuvwxyz.:/,\"C-_A* !{}?'()+=><#%"
fontquads = {}
for i = 1, string.len(fontglyphs) do
fontquads[string.sub(fontglyphs, i, i)] = love.graphics.newQuad((i-1)*8, 0, 7, 8, fontimage:getWidth(), fontimage:getHeight())
end
fontquadsback = {}
for i = 1, string.len(fontglyphs) do
fontquadsback[string.sub(fontglyphs, i, i)] = love.graphics.newQuad((i-1)*10, 0, 10, 10, fontimageback:getWidth(), fontimageback:getHeight())
end
love.graphics.clear()
love.graphics.setColor(100, 100, 100)
loadingtexts = {"reticulating splines", "rendering important stuff", "01110000011011110110111001111001", "sometimes, i dream about cheese",
"baking cake", "happy explosion day", "raising coolness by a fifth", "yay facepunch", "stabbing myself", "sharpening knives",
"tanaka, thai kick", "slime will find you", "becoming self-aware", "it's a secret to everybody", "there is no minus world",
"oh my god, jc, a bomb", "silly loading message here", "motivational art by jorichi", "love.graphics.print(\"loading..\", 200, 120)",
"you're my favorite deputy", "licensed under wtfpl", "banned in australia", "loading anti-piracy module", "watch out there's a sni",
"attack while its tail's up!", "what a horrible night to have a curse", "han shot first", "establishing connection to nsa servers..",
"how do i programm", "making palette inaccurate..", "y cant mario crawl?"}
loadingtext = loadingtexts[math.random(#loadingtexts)]
if mariocharacter[1] == "rainbow dash-unfinished" then -- /)^3^(\
logo = love.graphics.newImage("graphics/stabyourselfdash.png")
logoblood = love.graphics.newImage("graphics/stabyourselfblooddash.png")
else
logo = love.graphics.newImage("graphics/stabyourself.png")
logoblood = love.graphics.newImage("graphics/stabyourselfblood.png")
end
local logoscale = scale
if logoscale <= 1 then
logoscale = 0.5
else
logoscale = 1
end
love.graphics.setColor(255, 255, 255)
love.graphics.draw(logo, love.graphics.getWidth()/2, love.graphics.getHeight()/2, 0, logoscale, logoscale, 142, 150)
love.graphics.setColor(150, 150, 150)
properprint("loading mari0 se..", love.graphics.getWidth()/2-string.len("loading mari0 se..")*4*scale, love.graphics.getHeight()/2-170*logoscale-7*scale)
love.graphics.setColor(50, 50, 50)
properprint(loadingtext, love.graphics.getWidth()/2-string.len(loadingtext)*4*scale, love.graphics.getHeight()/2+165*logoscale)
love.graphics.present()
add("Variables")
--require ALL the files!
--require "netplay"
--require "client"
--require "server"
--require "lobby"
--require "onlinemenu"
require "shaders"
require "variables"
require "sha1"
class = require "middleclass"
require "camera"
require "animatedquad"
require "intro"
require "menu"
require "levelscreen"
require "game"
require "editor"
require "animationguiline"
require "physics"
require "quad"
require "entity"
require "portalwall"
require "tile"
require "mario"
require "hatconfigs"
require "bighatconfigs"
require "customhats"
require "coinblockanimation"
require "scrollingscore"
require "scrollingtext"
require "platform"
require "platformspawner"
require "portalparticle"
require "portalprojectile"
require "box"
require "emancipationgrill"
require "door"
require "button"
require "groundlight"
require "wallindicator"
require "walltimer"
require "lightbridge"
require "faithplate"
require "laser"
require "laserdetector"
require "gel"
require "geldispenser"
require "cubedispenser"
require "pushbutton"
require "screenboundary"
require "bulletbill"
require "fireball"
require "gui"
require "blockdebris"
require "firework"
require "castlefire"
require "fire"
require "bowser"
require "vine"
require "spring"
require "seesaw"
require "seesawplatform"
require "bubble"
require "rainboom"
require "miniblock"
require "notgate"
require "rsflipflop"
require "andgate"
require "orgate"
require "musicentity"
require "enemyspawner"
require "musicloader"
require "magic"
require "ceilblocker"
require "funnel"
require "panel"
require "rightclickmenu"
require "emancipateanimation"
require "emancipationfizzle"
require "textentity"
require "squarewave"
require "scaffold"
require "animation"
require "animationsystem"
require "regiondrag"
require "regiontrigger"
require "checkpoint"
require "portal"
require "portalent"
require "pedestal"
require "actionblock"
require "animationtrigger"
require "dialogbox"
require "itemanimation"
require "animatedtimer"
require "animatedtiletrigger"
require "delayer"
require "entitylistitem"
require "entitytooltip"
require "enemy"
require "enemies"
add("Requires")
http = require("socket.http")
http.PORT = 55555
http.TIMEOUT = 1
updatenotification = false
if getupdate() then
updatenotification = true
end
http.TIMEOUT = 4
playertypei = 1
playertype = playertypelist[playertypei] --portal, gelcannon
if volumesfx == 0 then
soundenabled = false
else
soundenabled = true
end
love.filesystem.createDirectory( "mappacks" )
editormode = false
yoffset = 0
love.graphics.setPointSize(3*scale)
love.graphics.setLineWidth(2*scale)
uispace = math.floor(width*16*scale/4)
guielements = {}
--limit hats
for playerno = 1, players do
for i = 1, #mariohats[playerno] do
if mariohats[playerno][i] > hatcount then
mariohats[playerno][i] = hatcount
end
end
end
--Backgroundcolors
backgroundcolor = {
{92, 148, 252},
{0, 0, 0},
{32, 56, 236},
{158, 219, 248},
{210, 159, 229},
{237, 241, 243},
{244, 178, 92},
{253, 246, 175},
{249, 183, 206},
}
add("Update Check, variables")
--IMAGES--
overwrittenimages = {}
imagelist = {"blockdebris", "coinblockanimation", "coinanimation", "coinblock", "coin", "axe", "spring", "toad", "peach", "platform",
"platformbonus", "scaffold", "seesaw", "vine", "bowser", "decoys", "box", "flag", "castleflag", "bubble", "fizzle", "emanceparticle", "emanceside", "doorpiece", "doorcenter",
"button", "pushbutton", "wallindicator", "walltimer", "lightbridge", "lightbridgeglow", "lightbridgeside", "laser", "laserside", "excursionbase", "excursionfunnel", "excursionfunnel2", "excursionfunnelend",
"excursionfunnelend2", "faithplateplate", "laserdetector", "gel1", "gel2", "gel3", "gel4", "gel5", "gel1ground", "gel2ground", "gel3ground", "gel4ground", "geldispenser", "cubedispenser", "panel", "pedestalbase",
"pedestalgun", "actionblock", "portal", "markbase", "markoverlay", "andgate", "notgate", "orgate", "squarewave", "rsflipflop", "portalglow", "fireball", "musicentity", "smbtiles", "portaltiles",
"animatedtiletrigger", "delayer", "title", "menuselect"}
for i, v in pairs(imagelist) do
_G["default" .. v .. "img"] = love.graphics.newImage("graphics/DEFAULT/" .. v .. ".png")
_G[v .. "img"] = _G["default" .. v .. "img"]
end
mappackback = love.graphics.newImage("graphics/mappackback.png")
mappacknoicon = love.graphics.newImage("graphics/mappacknoicon.png")
mappackoverlay = love.graphics.newImage("graphics/mappackoverlay.png")
mappackhighlight = love.graphics.newImage("graphics/mappackhighlight.png")
mappackscrollbar = love.graphics.newImage("graphics/mappackscrollbar.png")
--tiles
tilequads = {}
rgblist = {}
--add smb tiles
local imgwidth, imgheight = smbtilesimg:getWidth(), smbtilesimg:getHeight()
local width = math.floor(imgwidth/17)
local height = math.floor(imgheight/17)
local imgdata = love.image.newImageData("graphics/DEFAULT/smbtiles.png")
for y = 1, height do
for x = 1, width do
table.insert(tilequads, quad:new(smbtilesimg, imgdata, x, y, imgwidth, imgheight))
local r, g, b = getaveragecolor(imgdata, x, y)
table.insert(rgblist, {r, g, b})
end
end
smbtilecount = width*height
--add portal tiles
local imgwidth, imgheight = portaltilesimg:getWidth(), portaltilesimg:getHeight()
local width = math.floor(imgwidth/17)
local height = math.floor(imgheight/17)
local imgdata = love.image.newImageData("graphics/DEFAULT/portaltiles.png")
for y = 1, height do
for x = 1, width do
table.insert(tilequads, quad:new(portaltilesimg, imgdata, x, y, imgwidth, imgheight))
local r, g, b = getaveragecolor(imgdata, x, y)
table.insert(rgblist, {r, g, b})
end
end
portaltilecount = width*height
--add entities
entitiesimg = love.graphics.newImage("graphics/entities.png")
entityquads = {}
local imgwidth, imgheight = entitiesimg:getWidth(), entitiesimg:getHeight()
local width = math.floor(imgwidth/17)
local height = math.floor(imgheight/17)
local imgdata = love.image.newImageData("graphics/entities.png")
for y = 1, height do
for x = 1, width do
table.insert(entityquads, entity:new(entitiesimg, x, y, imgwidth, imgheight))
entityquads[#entityquads]:sett(#entityquads)
end
end
entitiescount = width*height
fontimage2 = love.graphics.newImage("graphics/smallfont.png")
numberglyphs = "012458"
font2quads = {}
for i = 1, 6 do
font2quads[string.sub(numberglyphs, i, i)] = love.graphics.newQuad((i-1)*4, 0, 4, 8, 24, 8)
end
oneuptextimage = love.graphics.newImage("graphics/oneuptext.png")
linktoolpointerimg = love.graphics.newImage("graphics/linktoolpointer.png")
blockdebrisquads = {}
for y = 1, 4 do
blockdebrisquads[y] = {}
for x = 1, 2 do
blockdebrisquads[y][x] = love.graphics.newQuad((x-1)*8, (y-1)*8, 8, 8, 16, 32)
end
end
coinblockanimationquads = {}
for i = 1, 30 do
coinblockanimationquads[i] = love.graphics.newQuad((i-1)*8, 0, 8, 52, 256, 64)
end
coinanimationquads = {}
for j = 1, 4 do
coinanimationquads[j] = {}
for i = 1, 5 do
coinanimationquads[j][i] = love.graphics.newQuad((i-1)*5, (j-1)*8, 5, 8, 25, 32)
end
end
--coinblock
coinblockquads = {}
for j = 1, 4 do
coinblockquads[j] = {}
for i = 1, 5 do
coinblockquads[j][i] = love.graphics.newQuad((i-1)*16, (j-1)*16, 16, 16, 80, 64)
end
end
--coin
coinquads = {}
for j = 1, 4 do
coinquads[j] = {}
for i = 1, 5 do
coinquads[j][i] = love.graphics.newQuad((i-1)*16, (j-1)*16, 16, 16, 80, 64)
end
end
--axe
axequads = {}
for i = 1, 5 do
axequads[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 80, 16)
end
--spring
springquads = {}
for i = 1, 4 do
springquads[i] = {}
for j = 1, 3 do
springquads[i][j] = love.graphics.newQuad((j-1)*16, (i-1)*31, 16, 31, 48, 124)
end
end
seesawquad = {}
for i = 1, 4 do
seesawquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 64, 16)
end
playerselectimg = love.graphics.newImage("graphics/playerselectarrow.png")
starquad = {}
for i = 1, 4 do
starquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 64, 16)
end
flowerquad = {}
for i = 1, 4 do
flowerquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 64, 16)
end
fireballquad = {}
for i = 1, 4 do
fireballquad[i] = love.graphics.newQuad((i-1)*8, 0, 8, 8, 80, 16)
end
for i = 5, 7 do
fireballquad[i] = love.graphics.newQuad((i-5)*16+32, 0, 16, 16, 80, 16)
end
vinequad = {}
for i = 1, 4 do
vinequad[i] = {}
for j = 1, 2 do
vinequad[i][j] = love.graphics.newQuad((j-1)*16, (i-1)*16, 16, 16, 32, 64)
end
end
--enemies
goombaquad = {}
for y = 1, 4 do
goombaquad[y] = {}
for x = 1, 2 do
goombaquad[y][x] = love.graphics.newQuad((x-1)*16, (y-1)*16, 16, 16, 32, 64)
end
end
spikeyquad = {}
for y = 1, 4 do
spikeyquad[y] = {}
for x = 1, 4 do
spikeyquad[y][x] = love.graphics.newQuad((x-1)*16, (y-1)*16, 16, 16, 64, 64)
end
end
lakitoquad = {}
for y = 1, 4 do
lakitoquad[y] = {}
for x = 1, 2 do
lakitoquad[y][x] = love.graphics.newQuad((x-1)*16, (y-1)*24, 16, 24, 32, 96)
end
end
koopaquad = {}
for y = 1, 4 do
koopaquad[y] = {}
for x = 1, 5 do
koopaquad[y][x] = love.graphics.newQuad((x-1)*16, (y-1)*24, 16, 24, 80, 96)
end
end
cheepcheepquad = {}
cheepcheepquad[1] = {}
cheepcheepquad[1][1] = love.graphics.newQuad(0, 0, 16, 16, 32, 32)
cheepcheepquad[1][2] = love.graphics.newQuad(16, 0, 16, 16, 32, 32)
cheepcheepquad[2] = {}
cheepcheepquad[2][1] = love.graphics.newQuad(0, 16, 16, 16, 32, 32)
cheepcheepquad[2][2] = love.graphics.newQuad(16, 16, 16, 16, 32, 32)
squidquad = {}
for x = 1, 2 do
squidquad[x] = love.graphics.newQuad((x-1)*16, 0, 16, 24, 32, 24)
end
bulletbillquad = {}
for y = 1, 4 do
bulletbillquad[y] = love.graphics.newQuad(0, (y-1)*16, 16, 16, 16, 64)
end
hammerbrosquad = {}
for y = 1, 4 do
hammerbrosquad[y] = {}
for x = 1, 4 do
hammerbrosquad[y][x] = love.graphics.newQuad((x-1)*16, (y-1)*34, 16, 34, 64, 136)
end
end
hammerquad = {}
for j = 1, 4 do
hammerquad[j] = {}
for i = 1, 4 do
hammerquad[j][i] = love.graphics.newQuad((i-1)*16, (j-1)*16, 16, 16, 64, 64)
end
end
plantquads = {}
for j = 1, 4 do
plantquads[j] = {}
for i = 1, 2 do
plantquads[j][i] = love.graphics.newQuad((i-1)*16, (j-1)*23, 16, 23, 32, 92)
end
end
firequad = {love.graphics.newQuad(0, 0, 24, 8, 48, 8), love.graphics.newQuad(24, 0, 24, 8, 48, 8)}
bowserquad = {}
bowserquad[1] = {love.graphics.newQuad(0, 0, 32, 32, 64, 64), love.graphics.newQuad(32, 0, 32, 32, 64, 64)}
bowserquad[2] = {love.graphics.newQuad(0, 32, 32, 32, 64, 64), love.graphics.newQuad(32, 32, 32, 32, 64, 64)}
decoysquad = {}
for y = 1, 7 do
decoysquad[y] = love.graphics.newQuad(0, (y-1)*32, 32, 32, 64, 256)
end
boxquad = {love.graphics.newQuad(0, 0, 12, 12, 32, 16), love.graphics.newQuad(16, 0, 12, 12, 32, 16)}
--eh
rainboomimg = love.graphics.newImage("graphics/rainboom.png")
rainboomquad = {}
for x = 1, 7 do
for y = 1, 7 do
rainboomquad[x+(y-1)*7] = love.graphics.newQuad((x-1)*204, (y-1)*182, 204, 182, 1428, 1274)
end
end
--magic!
magicimg = love.graphics.newImage("graphics/magic.png")
magicquad = {}
for x = 1, 6 do
magicquad[x] = love.graphics.newQuad((x-1)*9, 0, 9, 9, 54, 9)
end
--GUI
checkboximg = love.graphics.newImage("graphics/checkbox.png")
checkboxquad = {{love.graphics.newQuad(0, 0, 9, 9, 18, 18), love.graphics.newQuad(9, 0, 9, 9, 18, 18)}, {love.graphics.newQuad(0, 9, 9, 9, 18, 18), love.graphics.newQuad(9, 9, 9, 9, 18, 18)}}
dropdownarrowimg = love.graphics.newImage("graphics/dropdownarrow.png")
--portals
portalquad = {}
for i = 0, 7 do
portalquad[i] = love.graphics.newQuad(0, i*4, 32, 4, 32, 28)
end
portalparticleimg = love.graphics.newImage("graphics/portalparticle.png")
portalcrosshairimg = love.graphics.newImage("graphics/portalcrosshair.png")
portaldotimg = love.graphics.newImage("graphics/portaldot.png")
portalprojectileimg = love.graphics.newImage("graphics/portalprojectile.png")
portalprojectileparticleimg = love.graphics.newImage("graphics/portalprojectileparticle.png")
portalbackgroundimg = love.graphics.newImage("graphics/portalbackground.png")
--Menu shit
huebarimg = love.graphics.newImage("graphics/huehuehuebar.png")
huebarmarkerimg = love.graphics.newImage("graphics/huebarmarker.png")
volumesliderimg = love.graphics.newImage("graphics/volumeslider.png")
--Portal props
buttonquad = {love.graphics.newQuad(0, 0, 32, 5, 64, 5), love.graphics.newQuad(32, 0, 32, 5, 64, 5)}
pushbuttonquad = {love.graphics.newQuad(0, 0, 16, 16, 32, 16), love.graphics.newQuad(16, 0, 16, 16, 32, 16)}
wallindicatorquad = {love.graphics.newQuad(0, 0, 16, 16, 32, 16), love.graphics.newQuad(16, 0, 16, 16, 32, 16)}
walltimerquad = {}
for i = 1, 10 do
walltimerquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 160, 16)
end
directionsimg = love.graphics.newImage("graphics/directions.png")
directionsquad = {}
for x = 1, 6 do
directionsquad[x] = love.graphics.newQuad((x-1)*7, 0, 7, 7, 42, 7)
end
excursionquad = {}
for x = 1, 8 do
excursionquad[x] = love.graphics.newQuad((x-1)*8, 0, 8, 32, 64, 32)
end
faithplatequad = {love.graphics.newQuad(0, 0, 32, 16, 32, 32), love.graphics.newQuad(0, 16, 32, 16, 32, 32)}
gelquad = {love.graphics.newQuad(0, 0, 12, 12, 36, 12), love.graphics.newQuad(12, 0, 12, 12, 36, 12), love.graphics.newQuad(24, 0, 12, 12, 36, 12)}
gradientimg = love.graphics.newImage("graphics/gradient.png");gradientimg:setFilter("linear", "linear")
panelquad = {}
for x = 1, 2 do
panelquad[x] = love.graphics.newQuad((x-1)*16, 0, 16, 16, 32, 16)
end
add("Images, quads")
--AUDIO--
--sounds
soundstoload = {"jump", "jumpbig", "stomp", "shot", "blockhit", "blockbreak", "coin", "pipe", "boom", "mushroomappear", "mushroomeat", "shrink", "death", "gameover", "fireball",
"oneup", "levelend", "castleend", "scorering", "intermission", "fire", "bridgebreak", "bowserfall", "vine", "swim", "rainboom", "konami", "pause", "bulletbill",
"lowtime", "tailwag", "planemode", "stab", "portal1open", "portal2open", "portalenter", "portalfizzle"}
soundlist = {}
for i, v in pairs(soundstoload) do
soundlist[v] = {}
soundlist[v].source = love.audio.newSource("sounds/" .. v .. ".ogg", "stream")
soundlist[v].lastplayed = 0
end
soundlist["scorering"].source:setLooping(true)
soundlist["planemode"].source:setLooping(true)
soundlist["portal1open"].source:setVolume(0.3)
soundlist["portal2open"].source:setVolume(0.3)
soundlist["portalenter"].source:setVolume(0.3)
soundlist["portalfizzle"].source:setVolume(0.3)
delaylist = {}
delaylist["blockhit"] = 0.2
musicname = "overworld.ogg"
add("Sounds")
shaders:init()
add("Shaders init")
for i, v in pairs(dlclist) do
delete_mappack(v)
end
firstload = true
if skipintro then
menu_load()
else
intro_load()
end
add("Intro Load")
print("=======================\nDONE!")
print("TOTAL: " .. totaltime .. "ms")
mycamera = camera:new()
mycamera:zoomTo(0.4)
end
function love.update(dt)
if music then
music:update()
end
realdt = dt
dt = math.min(0.5, dt) --ignore any dt higher than half a second
if recording then
dt = recordtarget
end
steptimer = steptimer + dt
dt = targetdt
if skipupdate then
steptimer = 0
skipupdate = false
return
end
--speed
if bullettime and speed ~= speedtarget then