1--[[ 2 STEAL MY SHIT AND I'LL FUCK YOU UP 3 PRETTY MUCH EVERYTHING BY MAURICE GU�GAN AND IF SOMETHING ISN'T BY ME THEN IT SHOULD BE OBVIOUS OR NOBODY CARES 4 5 THIS AWESOME PIECE OF CELESTIAL AMBROSIA IS RELEASED AS NON-COMMERCIAL, SHARE ALIKE, WHATEVER. YOU MAY PRINT OUT THIS CODES AND USE IT AS WALLPAPER IN YOUR BATHROOM. 6 FOR SPECIFIC LICENSE (I know you linux users get a hard on when it comes to licenses) SEE http://creativecommons.org/licenses/by-nc-sa/3.0/ 7 NOW GO AWAY (or stay and modify shit. I don't care as long as you stick to the above license.) 8]] 9 10function love.load() 11 marioversion = 1006 12 versionstring = "version 1.6" 13 shaderlist = love.filesystem.enumerate( "shaders/" ) 14 dlclist = {"dlc_a_portal_tribute", "dlc_acid_trip", "dlc_escape_the_lab", "dlc_scienceandstuff", "dlc_smb2J", "dlc_the_untitled_game"} 15 16 local rem 17 for i, v in pairs(shaderlist) do 18 if v == "init.lua" then 19 rem = i 20 else 21 shaderlist[i] = string.sub(v, 1, string.len(v)-5) 22 end 23 end 24 25 table.remove(shaderlist, rem) 26 table.insert(shaderlist, 1, "none") 27 currentshaderi1 = 1 28 currentshaderi2 = 1 29 30 hatcount = #love.filesystem.enumerate("graphics/SMB/hats") 31 32 if not pcall(loadconfig) then 33 players = 1 34 defaultconfig() 35 end 36 37 saveconfig() 38 width = 25 39 fsaa = 0 40 fullscreen = false 41 changescale(scale, fullscreen) 42 love.graphics.setCaption( "Mari0" ) 43 44 --version check by checking for a const that was added in 0.8.0 45 if love._version_major == nil then error("You have an outdated version of Love! Get 0.8.0 or higher and retry.") end 46 47 iconimg = love.graphics.newImage("graphics/icon.gif") 48 love.graphics.setIcon(iconimg) 49 50 love.graphics.setDefaultImageFilter("nearest", "nearest") 51 52 love.graphics.setBackgroundColor(0, 0, 0) 53 54 55 fontimage = love.graphics.newImage("graphics/SMB/font.png") 56 fontglyphs = "0123456789abcdefghijklmnopqrstuvwxyz.:/,'C-_>* !{}?" 57 fontquads = {} 58 for i = 1, string.len(fontglyphs) do 59 fontquads[string.sub(fontglyphs, i, i)] = love.graphics.newQuad((i-1)*8, 0, 8, 8, 512, 8) 60 end 61 62 math.randomseed(os.time());math.random();math.random() 63 64 love.graphics.clear() 65 love.graphics.setColor(100, 100, 100) 66 loadingtexts = {"reticulating splines..", "loading..", "booting glados..", "growing potatoes..", "voting against acta..", "rendering important stuff..", 67 "baking cake..", "happy explosion day..", "raising coolness by 20 percent..", "yay facepunch..", "stabbing myself..", "sharpening knives..", 68 "tanaka, thai kick..", "loading game genie.."} 69 loadingtext = loadingtexts[math.random(#loadingtexts)] 70 properprint(loadingtext, 25*8*scale-string.len(loadingtext)*4*scale, 108*scale) 71 love.graphics.present() 72 --require ALL the files! 73 require "shaders" 74 require "variables" 75 require "class" 76 require "sha1" 77 78 require "intro" 79 require "menu" 80 require "levelscreen" 81 require "game" 82 require "editor" 83 require "physics" 84 require "quad" 85 require "entity" 86 require "portalwall" 87 require "tile" 88 require "mario" 89 require "goomba" 90 require "koopa" 91 require "cheepcheep" 92 require "mushroom" 93 require "hatconfigs" 94 require "bighatconfigs" 95 require "flower" 96 require "star" 97 require "oneup" 98 require "coinblockanimation" 99 require "scrollingscore" 100 require "platform" 101 require "platformspawner" 102 require "portalparticle" 103 require "portalprojectile" 104 require "box" 105 require "emancipationgrill" 106 require "door" 107 require "button" 108 require "groundlight" 109 require "wallindicator" 110 require "walltimer" 111 require "lightbridge" 112 require "faithplate" 113 require "laser" 114 require "laserdetector" 115 require "gel" 116 require "geldispenser" 117 require "cubedispenser" 118 require "pushbutton" 119 require "screenboundary" 120 require "bulletbill" 121 require "hammerbro" 122 require "fireball" 123 require "gui" 124 require "blockdebris" 125 require "firework" 126 require "plant" 127 require "castlefire" 128 require "fire" 129 require "bowser" 130 require "vine" 131 require "spring" 132 require "flyingfish" 133 require "upfire" 134 require "seesaw" 135 require "seesawplatform" 136 require "lakito" 137 require "bubble" 138 require "squid" 139 require "rainboom" 140 require "miniblock" 141 require "notgate" 142 require "musicloader" 143 144 http = require("socket.http") 145 http.TIMEOUT = 1 146 147 love.filesystem.setIdentity("mari0") 148 149 updatenotification = false 150 if getupdate() then 151 updatenotification = true 152 end 153 http.TIMEOUT = 4 154 155 graphicspack = "SMB" --SMB, ALLSTARS 156 playertypei = 1 157 playertype = playertypelist[playertypei] --portal, minecraft 158 159 if volume == 0 then 160 soundenabled = false 161 else 162 soundenabled = true 163 end 164 love.filesystem.mkdir( "mappacks" ) 165 editormode = false 166 yoffset = 0 167 love.graphics.setPointSize(3*scale) 168 love.graphics.setLineWidth(3*scale) 169 170 uispace = math.floor(width*16*scale/4) 171 guielements = {} 172 173 --Backgroundcolors 174 backgroundcolor = {} 175 backgroundcolor[1] = {92, 148, 252} 176 backgroundcolor[2] = {0, 0, 0} 177 backgroundcolor[3] = {32, 56, 236} 178 179 --IMAGES-- 180 181 menuselection = love.graphics.newImage("graphics/" .. graphicspack .. "/menuselect.png") 182 mappackback = love.graphics.newImage("graphics/" .. graphicspack .. "/mappackback.png") 183 mappacknoicon = love.graphics.newImage("graphics/" .. graphicspack .. "/mappacknoicon.png") 184 mappackoverlay = love.graphics.newImage("graphics/" .. graphicspack .. "/mappackoverlay.png") 185 mappackhighlight = love.graphics.newImage("graphics/" .. graphicspack .. "/mappackhighlight.png") 186 187 mappackscrollbar = love.graphics.newImage("graphics/" .. graphicspack .. "/mappackscrollbar.png") 188 189 --tiles 190 smbtilesimg = love.graphics.newImage("graphics/" .. graphicspack .. "/smbtiles.png") 191 portaltilesimg = love.graphics.newImage("graphics/" .. graphicspack .. "/portaltiles.png") 192 entitiesimg = love.graphics.newImage("graphics/" .. graphicspack .. "/entities.png") 193 tilequads = {} 194 195 rgblist = {} 196 197 --add smb tiles 198 local imgwidth, imgheight = smbtilesimg:getWidth(), smbtilesimg:getHeight() 199 local width = math.floor(imgwidth/17) 200 local height = math.floor(imgheight/17) 201 local imgdata = love.image.newImageData("graphics/" .. graphicspack .. "/smbtiles.png") 202 203 for y = 1, height do 204 for x = 1, width do 205 table.insert(tilequads, quad:new(smbtilesimg, imgdata, x, y, imgwidth, imgheight)) 206 local r, g, b = getaveragecolor(imgdata, x, y) 207 table.insert(rgblist, {r, g, b}) 208 end 209 end 210 smbtilecount = width*height 211 212 --add portal tiles 213 local imgwidth, imgheight = portaltilesimg:getWidth(), portaltilesimg:getHeight() 214 local width = math.floor(imgwidth/17) 215 local height = math.floor(imgheight/17) 216 local imgdata = love.image.newImageData("graphics/" .. graphicspack .. "/portaltiles.png") 217 218 for y = 1, height do 219 for x = 1, width do 220 table.insert(tilequads, quad:new(portaltilesimg, imgdata, x, y, imgwidth, imgheight)) 221 local r, g, b = getaveragecolor(imgdata, x, y) 222 table.insert(rgblist, {r, g, b}) 223 end 224 end 225 portaltilecount = width*height 226 227 --add entities 228 entityquads = {} 229 local imgwidth, imgheight = entitiesimg:getWidth(), entitiesimg:getHeight() 230 local width = math.floor(imgwidth/17) 231 local height = math.floor(imgheight/17) 232 local imgdata = love.image.newImageData("graphics/" .. graphicspack .. "/entities.png") 233 234 for y = 1, height do 235 for x = 1, width do 236 table.insert(entityquads, entity:new(entitiesimg, x, y, imgwidth, imgheight)) 237 entityquads[#entityquads]:sett(#entityquads) 238 end 239 end 240 entitiescount = width*height 241 242 fontimage2 = love.graphics.newImage("graphics/" .. graphicspack .. "/smallfont.png") 243 numberglyphs = "012458" 244 font2quads = {} 245 for i = 1, 6 do 246 font2quads[string.sub(numberglyphs, i, i)] = love.graphics.newQuad((i-1)*4, 0, 4, 8, 32, 8) 247 end 248 249 oneuptextimage = love.graphics.newImage("graphics/" .. graphicspack .. "/oneuptext.png") 250 251 blockdebrisimage = love.graphics.newImage("graphics/" .. graphicspack .. "/blockdebris.png") 252 blockdebrisquads = {} 253 for y = 1, 4 do 254 blockdebrisquads[y] = {} 255 for x = 1, 2 do 256 blockdebrisquads[y][x] = love.graphics.newQuad((x-1)*8, (y-1)*8, 8, 8, 16, 32) 257 end 258 end 259 260 coinblockanimationimage = love.graphics.newImage("graphics/" .. graphicspack .. "/coinblockanimation.png") 261 coinblockanimationquads = {} 262 for i = 1, 30 do 263 coinblockanimationquads[i] = love.graphics.newQuad((i-1)*8, 0, 8, 52, 256, 64) 264 end 265 266 coinanimationimage = love.graphics.newImage("graphics/" .. graphicspack .. "/coinanimation.png") 267 coinanimationquads = {} 268 for j = 1, 4 do 269 coinanimationquads[j] = {} 270 for i = 1, 3 do 271 coinanimationquads[j][i] = love.graphics.newQuad((i-1)*5, (j-1)*8, 5, 8, 16, 32) 272 end 273 end 274 275 --coinblock 276 coinblockimage = love.graphics.newImage("graphics/" .. graphicspack .. "/coinblock.png") 277 coinblockquads = {} 278 for j = 1, 4 do 279 coinblockquads[j] = {} 280 for i = 1, 3 do 281 coinblockquads[j][i] = love.graphics.newQuad((i-1)*16, (j-1)*16, 16, 16, 64, 64) 282 end 283 end 284 285 --coin 286 coinimage = love.graphics.newImage("graphics/" .. graphicspack .. "/coin.png") 287 coinquads = {} 288 for j = 1, 4 do 289 coinquads[j] = {} 290 for i = 1, 3 do 291 coinquads[j][i] = love.graphics.newQuad((i-1)*16, (j-1)*16, 16, 16, 64, 64) 292 end 293 end 294 295 --axe 296 axeimg = love.graphics.newImage("graphics/" .. graphicspack .. "/axe.png") 297 axequads = {} 298 for i = 1, 3 do 299 axequads[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 64, 16) 300 end 301 302 --spring 303 springimg = love.graphics.newImage("graphics/" .. graphicspack .. "/spring.png") 304 springquads = {} 305 for i = 1, 4 do 306 springquads[i] = {} 307 for j = 1, 3 do 308 springquads[i][j] = love.graphics.newQuad((j-1)*16, (i-1)*31, 16, 31, 48, 124) 309 end 310 end 311 312 --toad 313 toadimg = love.graphics.newImage("graphics/" .. graphicspack .. "/toad.png") 314 315 --queen I mean princess 316 peachimg = love.graphics.newImage("graphics/" .. graphicspack .. "/peach.png") 317 318 platformimg = love.graphics.newImage("graphics/" .. graphicspack .. "/platform.png") 319 platformbonusimg = love.graphics.newImage("graphics/" .. graphicspack .. "/platformbonus.png") 320 321 seesawimg = love.graphics.newImage("graphics/" .. graphicspack .. "/seesaw.png") 322 seesawquad = {} 323 for i = 1, 4 do 324 seesawquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 64, 16) 325 end 326 327 titleimage = love.graphics.newImage("graphics/" .. graphicspack .. "/title.png") 328 playerselectimg = love.graphics.newImage("graphics/" .. graphicspack .. "/playerselectarrow.png") 329 330 starimg = love.graphics.newImage("graphics/" .. graphicspack .. "/star.png") 331 starquad = {} 332 for i = 1, 4 do 333 starquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 64, 16) 334 end 335 336 flowerimg = love.graphics.newImage("graphics/" .. graphicspack .. "/flower.png") 337 flowerquad = {} 338 for i = 1, 4 do 339 flowerquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 64, 16) 340 end 341 342 fireballimg = love.graphics.newImage("graphics/" .. graphicspack .. "/fireball.png") 343 fireballquad = {} 344 for i = 1, 4 do 345 fireballquad[i] = love.graphics.newQuad((i-1)*8, 0, 8, 8, 80, 16) 346 end 347 348 for i = 5, 7 do 349 fireballquad[i] = love.graphics.newQuad((i-5)*16+32, 0, 16, 16, 80, 16) 350 end 351 352 vineimg = love.graphics.newImage("graphics/" .. graphicspack .. "/vine.png") 353 vinequad = {} 354 for i = 1, 4 do 355 vinequad[i] = {} 356 for j = 1, 2 do 357 vinequad[i][j] = love.graphics.newQuad((j-1)*16, (i-1)*16, 16, 16, 32, 64) 358 end 359 end 360 361 --enemies 362 goombaimage = love.graphics.newImage("graphics/" .. graphicspack .. "/goomba.png") 363 goombaquad = {} 364 365 for y = 1, 4 do 366 goombaquad[y] = {} 367 for x = 1, 2 do 368 goombaquad[y][x] = love.graphics.newQuad((x-1)*16, (y-1)*16, 16, 16, 32, 64) 369 end 370 end 371 372 spikeyimg = love.graphics.newImage("graphics/" .. graphicspack .. "/spikey.png") 373 374 spikeyquad = {} 375 for x = 1, 4 do 376 spikeyquad[x] = love.graphics.newQuad((x-1)*16, 0, 16, 16, 64, 16) 377 end 378 379 lakitoimg = love.graphics.newImage("graphics/" .. graphicspack .. "/lakito.png") 380 lakitoquad = {} 381 for x = 1, 2 do 382 lakitoquad[x] = love.graphics.newQuad((x-1)*16, 0, 16, 24, 32, 24) 383 end 384 385 koopaimage = love.graphics.newImage("graphics/" .. graphicspack .. "/koopa.png") 386 kooparedimage = love.graphics.newImage("graphics/" .. graphicspack .. "/koopared.png") 387 beetleimage = love.graphics.newImage("graphics/" .. graphicspack .. "/beetle.png") 388 koopaquad = {} 389 390 for y = 1, 4 do 391 koopaquad[y] = {} 392 for x = 1, 5 do 393 koopaquad[y][x] = love.graphics.newQuad((x-1)*16, (y-1)*24, 16, 24, 128, 128) 394 end 395 end 396 397 cheepcheepimg = love.graphics.newImage("graphics/" .. graphicspack .. "/cheepcheep.png") 398 cheepcheepquad = {} 399 400 cheepcheepquad[1] = {} 401 cheepcheepquad[1][1] = love.graphics.newQuad(0, 0, 16, 16, 32, 32) 402 cheepcheepquad[1][2] = love.graphics.newQuad(16, 0, 16, 16, 32, 32) 403 404 cheepcheepquad[2] = {} 405 cheepcheepquad[2][1] = love.graphics.newQuad(0, 16, 16, 16, 32, 32) 406 cheepcheepquad[2][2] = love.graphics.newQuad(16, 16, 16, 16, 32, 32) 407 408 squidimg = love.graphics.newImage("graphics/" .. graphicspack .. "/squid.png") 409 squidquad = {} 410 for x = 1, 2 do 411 squidquad[x] = love.graphics.newQuad((x-1)*16, 0, 16, 24, 32, 32) 412 end 413 414 bulletbillimg = love.graphics.newImage("graphics/" .. graphicspack .. "/bulletbill.png") 415 bulletbillquad = {} 416 417 for y = 1, 4 do 418 bulletbillquad[y] = love.graphics.newQuad(0, (y-1)*16, 16, 16, 16, 64) 419 end 420 421 hammerbrosimg = love.graphics.newImage("graphics/" .. graphicspack .. "/hammerbros.png") 422 hammerbrosquad = {} 423 for y = 1, 4 do 424 hammerbrosquad[y] = {} 425 for x = 1, 4 do 426 hammerbrosquad[y][x] = love.graphics.newQuad((x-1)*16, (y-1)*34, 16, 34, 64, 256) 427 end 428 end 429 430 hammerimg = love.graphics.newImage("graphics/" .. graphicspack .. "/hammer.png") 431 hammerquad = {} 432 for j = 1, 4 do 433 hammerquad[j] = {} 434 for i = 1, 4 do 435 hammerquad[j][i] = love.graphics.newQuad((i-1)*16, (j-1)*16, 16, 16, 64, 64) 436 end 437 end 438 439 plantimg = love.graphics.newImage("graphics/" .. graphicspack .. "/plant.png") 440 plantquads = {} 441 for j = 1, 4 do 442 plantquads[j] = {} 443 for i = 1, 2 do 444 plantquads[j][i] = love.graphics.newQuad((i-1)*16, (j-1)*23, 16, 23, 32, 128) 445 end 446 end 447 448 fireimg = love.graphics.newImage("graphics/" .. graphicspack .. "/fire.png") 449 firequad = {love.graphics.newQuad(0, 0, 24, 8, 48, 8), love.graphics.newQuad(24, 0, 24, 8, 48, 8)} 450 451 upfireimg = love.graphics.newImage("graphics/" .. graphicspack .. "/upfire.png") 452 453 bowserimg = love.graphics.newImage("graphics/" .. graphicspack .. "/bowser.png") 454 bowserquad = {} 455 bowserquad[1] = {love.graphics.newQuad(0, 0, 32, 32, 64, 64), love.graphics.newQuad(32, 0, 32, 32, 64, 64)} 456 bowserquad[2] = {love.graphics.newQuad(0, 32, 32, 32, 64, 64), love.graphics.newQuad(32, 32, 32, 32, 64, 64)} 457 458 decoysimg = love.graphics.newImage("graphics/" .. graphicspack .. "/decoys.png") 459 decoysquad = {} 460 for y = 1, 7 do 461 decoysquad[y] = love.graphics.newQuad(0, (y-1)*32, 32, 32, 64, 256) 462 end 463 464 boximage = love.graphics.newImage("graphics/" .. graphicspack .. "/box.png") 465 boxquad = love.graphics.newQuad(0, 0, 12, 12, 16, 16) 466 467 flagimg = love.graphics.newImage("graphics/" .. graphicspack .. "/flag.png") 468 castleflagimg = love.graphics.newImage("graphics/" .. graphicspack .. "/castleflag.png") 469 470 bubbleimg = love.graphics.newImage("graphics/" .. graphicspack .. "/bubble.png") 471 472 --eh 473 rainboomimg = love.graphics.newImage("graphics/rainboom.png") 474 rainboomquad = {} 475 for x = 1, 7 do 476 for y = 1, 7 do 477 rainboomquad[x+(y-1)*7] = love.graphics.newQuad((x-1)*204, (y-1)*182, 204, 182, 1428, 1274) 478 end 479 end 480 481 logo = love.graphics.newImage("graphics/stabyourself.png") 482 logoblood = love.graphics.newImage("graphics/stabyourselfblood.png") 483 484 --GUI 485 checkboximg = love.graphics.newImage("graphics/GUI/checkbox.png") 486 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)}} 487 488 dropdownarrowimg = love.graphics.newImage("graphics/GUI/dropdownarrow.png") 489 490 --players 491 marioanimations = {} 492 marioanimations[0] = love.graphics.newImage("graphics/" .. graphicspack .. "/player/marioanimations0.png") 493 marioanimations[1] = love.graphics.newImage("graphics/" .. graphicspack .. "/player/marioanimations1.png") 494 marioanimations[2] = love.graphics.newImage("graphics/" .. graphicspack .. "/player/marioanimations2.png") 495 marioanimations[3] = love.graphics.newImage("graphics/" .. graphicspack .. "/player/marioanimations3.png") 496 497 minecraftanimations = {} 498 minecraftanimations[0] = love.graphics.newImage("graphics/Minecraft/marioanimations0.png") 499 minecraftanimations[1] = love.graphics.newImage("graphics/Minecraft/marioanimations1.png") 500 minecraftanimations[2] = love.graphics.newImage("graphics/Minecraft/marioanimations2.png") 501 minecraftanimations[3] = love.graphics.newImage("graphics/Minecraft/marioanimations3.png") 502 503 marioidle = {} 504 mariorun = {} 505 marioslide = {} 506 mariojump = {} 507 mariodie = {} 508 marioclimb = {} 509 marioswim = {} 510 mariogrow = {} 511 512 for i = 1, 5 do 513 marioidle[i] = love.graphics.newQuad(0, (i-1)*20, 20, 20, 512, 128) 514 515 mariorun[i] = {} 516 mariorun[i][1] = love.graphics.newQuad(20, (i-1)*20, 20, 20, 512, 128) 517 mariorun[i][2] = love.graphics.newQuad(40, (i-1)*20, 20, 20, 512, 128) 518 mariorun[i][3] = love.graphics.newQuad(60, (i-1)*20, 20, 20, 512, 128) 519 520 marioslide[i] = love.graphics.newQuad(80, (i-1)*20, 20, 20, 512, 128) 521 mariojump[i] = love.graphics.newQuad(100, (i-1)*20, 20, 20, 512, 128) 522 mariodie[i] = love.graphics.newQuad(120, (i-1)*20, 20, 20, 512, 128) 523 524 marioclimb[i] = {} 525 marioclimb[i][1] = love.graphics.newQuad(140, (i-1)*20, 20, 20, 512, 128) 526 marioclimb[i][2] = love.graphics.newQuad(160, (i-1)*20, 20, 20, 512, 128) 527 528 marioswim[i] = {} 529 marioswim[i][1] = love.graphics.newQuad(180, (i-1)*20, 20, 20, 512, 128) 530 marioswim[i][2] = love.graphics.newQuad(200, (i-1)*20, 20, 20, 512, 128) 531 532 mariogrow[i] = love.graphics.newQuad(260, 0, 20, 24, 512, 128) 533 end 534 535 536 bigmarioanimations = {} 537 bigmarioanimations[0] = love.graphics.newImage("graphics/" .. graphicspack .. "/player/bigmarioanimations0.png") 538 bigmarioanimations[1] = love.graphics.newImage("graphics/" .. graphicspack .. "/player/bigmarioanimations1.png") 539 bigmarioanimations[2] = love.graphics.newImage("graphics/" .. graphicspack .. "/player/bigmarioanimations2.png") 540 bigmarioanimations[3] = love.graphics.newImage("graphics/" .. graphicspack .. "/player/bigmarioanimations3.png") 541 542 bigminecraftanimations = {} 543 bigminecraftanimations[0] = love.graphics.newImage("graphics/Minecraft/bigmarioanimations0.png") 544 bigminecraftanimations[1] = love.graphics.newImage("graphics/Minecraft/bigmarioanimations1.png") 545 bigminecraftanimations[2] = love.graphics.newImage("graphics/Minecraft/bigmarioanimations2.png") 546 bigminecraftanimations[3] = love.graphics.newImage("graphics/Minecraft/bigmarioanimations3.png") 547 548 bigmarioidle = {} 549 bigmariorun = {} 550 bigmarioslide = {} 551 bigmariojump = {} 552 bigmariofire = {} 553 bigmarioclimb = {} 554 bigmarioswim = {} 555 bigmarioduck = {} --hehe duck. 556 557 for i = 1, 5 do 558 bigmarioidle[i] = love.graphics.newQuad(0, (i-1)*36, 20, 36, 512, 256) 559 560 bigmariorun[i] = {} 561 bigmariorun[i][1] = love.graphics.newQuad(20, (i-1)*36, 20, 36, 512, 256) 562 bigmariorun[i][2] = love.graphics.newQuad(40, (i-1)*36, 20, 36, 512, 256) 563 bigmariorun[i][3] = love.graphics.newQuad(60, (i-1)*36, 20, 36, 512, 256) 564 565 bigmarioslide[i] = love.graphics.newQuad(80, (i-1)*36, 20, 36, 512, 256) 566 bigmariojump[i] = love.graphics.newQuad(100, (i-1)*36, 20, 36, 512, 256) 567 bigmariofire[i] = love.graphics.newQuad(120, (i-1)*36, 20, 36, 512, 256) 568 569 bigmarioclimb[i] = {} 570 bigmarioclimb[i][1] = love.graphics.newQuad(140, (i-1)*36, 20, 36, 512, 256) 571 bigmarioclimb[i][2] = love.graphics.newQuad(160, (i-1)*36, 20, 36, 512, 256) 572 573 bigmarioswim[i] = {} 574 bigmarioswim[i][1] = love.graphics.newQuad(180, (i-1)*36, 20, 36, 512, 256) 575 bigmarioswim[i][2] = love.graphics.newQuad(200, (i-1)*36, 20, 36, 512, 256) 576 577 bigmarioduck[i] = love.graphics.newQuad(260, (i-1)*36, 20, 36, 512, 256) 578 end 579 580 --portals 581 portalimage = love.graphics.newImage("graphics/" .. graphicspack .. "/portal.png") 582 portal1quad = {} 583 for i = 0, 7 do 584 portal1quad[i] = love.graphics.newQuad(0, i*4, 32, 4, 64, 32) 585 end 586 587 portal2quad = {} 588 for i = 0, 7 do 589 portal2quad[i] = love.graphics.newQuad(32, i*4, 32, 4, 64, 32) 590 end 591 592 portalglow = love.graphics.newImage("graphics/" .. graphicspack .. "/portalglow.png") 593 594 portalparticleimg = love.graphics.newImage("graphics/" .. graphicspack .. "/portalparticle.png") 595 portalcrosshairimg = love.graphics.newImage("graphics/" .. graphicspack .. "/portalcrosshair.png") 596 portaldotimg = love.graphics.newImage("graphics/" .. graphicspack .. "/portaldot.png") 597 portalprojectileimg = love.graphics.newImage("graphics/" .. graphicspack .. "/portalprojectile.png") 598 portalprojectileparticleimg = love.graphics.newImage("graphics/" .. graphicspack .. "/portalprojectileparticle.png") 599 600 --Menu shit 601 huebarimg = love.graphics.newImage("graphics/" .. graphicspack .. "/huebar.png") 602 huebarmarkerimg = love.graphics.newImage("graphics/" .. graphicspack .. "/huebarmarker.png") 603 volumesliderimg = love.graphics.newImage("graphics/" .. graphicspack .. "/volumeslider.png") 604 605 --Portal props 606 emanceparticleimg = love.graphics.newImage("graphics/" .. graphicspack .. "/emanceparticle.png") 607 emancesideimg = love.graphics.newImage("graphics/" .. graphicspack .. "/emanceside.png") 608 609 doorpieceimg = love.graphics.newImage("graphics/" .. graphicspack .. "/doorpiece.png") 610 doorcenterimg = love.graphics.newImage("graphics/" .. graphicspack .. "/doorcenter.png") 611 612 buttonbaseimg = love.graphics.newImage("graphics/" .. graphicspack .. "/buttonbase.png") 613 buttonbuttonimg = love.graphics.newImage("graphics/" .. graphicspack .. "/buttonbutton.png") 614 615 pushbuttonimg = love.graphics.newImage("graphics/" .. graphicspack .. "/pushbutton.png") 616 pushbuttonquad = {love.graphics.newQuad(0, 0, 16, 16, 32, 16), love.graphics.newQuad(16, 0, 16, 16, 32, 16)} 617 618 wallindicatorimg = love.graphics.newImage("graphics/" .. graphicspack .. "/wallindicator.png") 619 wallindicatorquad = {love.graphics.newQuad(0, 0, 16, 16, 32, 16), love.graphics.newQuad(16, 0, 16, 16, 32, 16)} 620 621 walltimerimg = love.graphics.newImage("graphics/" .. graphicspack .. "/walltimer.png") 622 walltimerquad = {} 623 for i = 1, 10 do 624 walltimerquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 160, 16) 625 end 626 627 lightbridgeimg = love.graphics.newImage("graphics/" .. graphicspack .. "/lightbridge.png") 628 lightbridgesideimg = love.graphics.newImage("graphics/" .. graphicspack .. "/lightbridgeside.png") 629 630 laserimg = love.graphics.newImage("graphics/" .. graphicspack .. "/laser.png") 631 lasersideimg = love.graphics.newImage("graphics/" .. graphicspack .. "/laserside.png") 632 633 faithplateplateimg = love.graphics.newImage("graphics/" .. graphicspack .. "/faithplateplate.png") 634 635 laserdetectorimg = love.graphics.newImage("graphics/" .. graphicspack .. "/laserdetector.png") 636 637 gel1img = love.graphics.newImage("graphics/" .. graphicspack .. "/gel1.png") 638 gel2img = love.graphics.newImage("graphics/" .. graphicspack .. "/gel2.png") 639 gel3img = love.graphics.newImage("graphics/" .. graphicspack .. "/gel3.png") 640 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)} 641 642 gel1ground = love.graphics.newImage("graphics/" .. graphicspack .. "/gel1ground.png") 643 gel2ground = love.graphics.newImage("graphics/" .. graphicspack .. "/gel2ground.png") 644 gel3ground = love.graphics.newImage("graphics/" .. graphicspack .. "/gel3ground.png") 645 646 geldispenserimg = love.graphics.newImage("graphics/" .. graphicspack .. "/geldispenser.png") 647 cubedispenserimg = love.graphics.newImage("graphics/" .. graphicspack .. "/cubedispenser.png") 648 649 gradientimg = love.graphics.newImage("graphics/gradient.png");gradientimg:setFilter("linear", "linear") 650 651 --optionsmenu 652 skinpuppet = {} 653 secondskinpuppet = {} 654 for i = 0, 3 do 655 skinpuppet[i] = love.graphics.newImage("graphics/" .. graphicspack .. "/options/skin" .. i .. ".png") 656 secondskinpuppet[i] = love.graphics.newImage("graphics/" .. graphicspack .. "/options/secondskin" .. i .. ".png") 657 end 658 659 --Ripping off 660 minecraftbreakimg = love.graphics.newImage("graphics/Minecraft/blockbreak.png") 661 minecraftbreakquad = {} 662 for i = 1, 10 do 663 minecraftbreakquad[i] = love.graphics.newQuad((i-1)*16, 0, 16, 16, 160, 16) 664 end 665 minecraftgui = love.graphics.newImage("graphics/Minecraft/gui.png") 666 minecraftselected = love.graphics.newImage("graphics/Minecraft/selected.png") 667 668 --AUDIO-- 669 --sounds 670 jumpsound = love.audio.newSource("sounds/jump.ogg", "static");love.audio.stop(jumpsound) 671 jumpbigsound = love.audio.newSource("sounds/jumpbig.ogg", "static");love.audio.stop(jumpbigsound) 672 stompsound = love.audio.newSource("sounds/stomp.ogg", "static");stompsound:setVolume(0);stompsound:play();stompsound:stop();stompsound:setVolume(1) 673 shotsound = love.audio.newSource("sounds/shot.ogg", "static");shotsound:setVolume(0);shotsound:play();shotsound:stop();shotsound:setVolume(1) 674 blockhitsound = love.audio.newSource("sounds/blockhit.ogg", "static");blockhitsound:setVolume(0);blockhitsound:play();blockhitsound:stop();blockhitsound:setVolume(1) 675 blockbreaksound = love.audio.newSource("sounds/blockbreak.ogg", "static");blockbreaksound:setVolume(0);blockbreaksound:play();blockbreaksound:stop();blockbreaksound:setVolume(1) 676 coinsound = love.audio.newSource("sounds/coin.ogg", "static");coinsound:setVolume(0);coinsound:play();coinsound:stop();coinsound:setVolume(1) 677 pipesound = love.audio.newSource("sounds/pipe.ogg", "static");pipesound:setVolume(0);pipesound:play();pipesound:stop();pipesound:setVolume(1) 678 boomsound = love.audio.newSource("sounds/boom.ogg", "static");boomsound:setVolume(0);boomsound:play();boomsound:stop();boomsound:setVolume(1) 679 mushroomappearsound = love.audio.newSource("sounds/mushroomappear.ogg", "static");mushroomappearsound:setVolume(0);mushroomappearsound:play();mushroomappearsound:stop();mushroomappearsound:setVolume(1) 680 mushroomeatsound = love.audio.newSource("sounds/mushroomeat.ogg", "static");mushroomeatsound:setVolume(0);mushroomeatsound:play();mushroomeatsound:stop();mushroomeatsound:setVolume(1) 681 shrinksound = love.audio.newSource("sounds/shrink.ogg", "static");shrinksound:setVolume(0);shrinksound:play();shrinksound:stop();shrinksound:setVolume(1) 682 deathsound = love.audio.newSource("sounds/death.ogg", "static");deathsound:setVolume(0);deathsound:play();deathsound:stop();deathsound:setVolume(1) 683 gameoversound = love.audio.newSource("sounds/gameover.ogg", "static");gameoversound:setVolume(0);gameoversound:play();gameoversound:stop();gameoversound:setVolume(1) 684 fireballsound = love.audio.newSource("sounds/fireball.ogg", "static");fireballsound:setVolume(0);fireballsound:play();fireballsound:stop();fireballsound:setVolume(1) 685 oneupsound = love.audio.newSource("sounds/oneup.ogg", "static");oneupsound:setVolume(0);oneupsound:play();oneupsound:stop();oneupsound:setVolume(1) 686 levelendsound = love.audio.newSource("sounds/levelend.ogg", "static");levelendsound:setVolume(0);levelendsound:play();levelendsound:stop();levelendsound:setVolume(1) 687 castleendsound = love.audio.newSource("sounds/castleend.ogg", "static");castleendsound:setVolume(0);castleendsound:play();castleendsound:stop();castleendsound:setVolume(1) 688 scoreringsound = love.audio.newSource("sounds/scorering.ogg", "static");scoreringsound:setVolume(0);scoreringsound:play();scoreringsound:stop();scoreringsound:setVolume(1);scoreringsound:setLooping(true) 689 intermissionsound = love.audio.newSource("sounds/intermission.ogg", "static");intermissionsound:setVolume(0);intermissionsound:play();intermissionsound:stop();intermissionsound:setVolume(1) 690 firesound = love.audio.newSource("sounds/fire.ogg", "static");firesound:setVolume(0);firesound:play();firesound:stop();firesound:setVolume(1) 691 bridgebreaksound = love.audio.newSource("sounds/bridgebreak.ogg", "static");bridgebreaksound:setVolume(0);bridgebreaksound:play();bridgebreaksound:stop();bridgebreaksound:setVolume(1) 692 bowserfallsound = love.audio.newSource("sounds/bowserfall.ogg", "static");bowserfallsound:setVolume(0);bowserfallsound:play();bowserfallsound:stop();bowserfallsound:setVolume(1) 693 vinesound = love.audio.newSource("sounds/vine.ogg", "static");vinesound:setVolume(0);vinesound:play();vinesound:stop();vinesound:setVolume(1) 694 swimsound = love.audio.newSource("sounds/swim.ogg", "static");swimsound:setVolume(0);swimsound:play();swimsound:stop();swimsound:setVolume(1) 695 rainboomsound = love.audio.newSource("sounds/rainboom.ogg", "static");rainboomsound:setVolume(0);rainboomsound:play();rainboomsound:stop();rainboomsound:setVolume(1) 696 konamisound = love.audio.newSource("sounds/konami.ogg", "static");konamisound:setVolume(0);konamisound:play();konamisound:stop();konamisound:setVolume(1) 697 pausesound = love.audio.newSource("sounds/pause.ogg", "static");pausesound:setVolume(0);pausesound:play();pausesound:stop();pausesound:setVolume(1) 698 bulletbillsound = love.audio.newSource("sounds/bulletbill.ogg", "static");pausesound:setVolume(0);pausesound:play();pausesound:stop();pausesound:setVolume(1) 699 stabsound = love.audio.newSource("sounds/stab.ogg", "static") 700 701 702 portal1opensound = love.audio.newSource("sounds/portal1open.ogg", "static");portal1opensound:setVolume(0);portal1opensound:play();portal1opensound:stop();portal1opensound:setVolume(0.3) 703 portal2opensound = love.audio.newSource("sounds/portal2open.ogg", "static");portal2opensound:setVolume(0);portal2opensound:play();portal2opensound:stop();portal2opensound:setVolume(0.3) 704 portalentersound = love.audio.newSource("sounds/portalenter.ogg", "static");portalentersound:setVolume(0);portalentersound:play();portalentersound:stop();portalentersound:setVolume(0.3) 705 portalfizzlesound = love.audio.newSource("sounds/portalfizzle.ogg", "static");portalfizzlesound:setVolume(0);portalfizzlesound:play();portalfizzlesound:stop();portalfizzlesound:setVolume(0.3) 706 707 lowtime = love.audio.newSource("sounds/lowtime.ogg", "static");rainboomsound:setVolume(0);rainboomsound:play();rainboomsound:stop();rainboomsound:setVolume(1) 708 709 --music 710 --[[ 711 overworldmusic = love.audio.newSource("sounds/overworld.ogg", "stream");overworldmusic:setLooping(true) 712 undergroundmusic = love.audio.newSource("sounds/underground.ogg", "stream");undergroundmusic:setLooping(true) 713 castlemusic = love.audio.newSource("sounds/castle.ogg", "stream");castlemusic:setLooping(true) 714 underwatermusic = love.audio.newSource("sounds/underwater.ogg", "stream");underwatermusic:setLooping(true) 715 starmusic = love.audio.newSource("sounds/starmusic.ogg", "stream");starmusic:setLooping(true) 716 princessmusic = love.audio.newSource("sounds/princessmusic.ogg", "stream");princessmusic:setLooping(true) 717 718 overworldmusicfast = love.audio.newSource("sounds/overworld-fast.ogg", "stream");overworldmusicfast:setLooping(true) 719 undergroundmusicfast = love.audio.newSource("sounds/underground-fast.ogg", "stream");undergroundmusicfast:setLooping(true) 720 castlemusicfast = love.audio.newSource("sounds/castle-fast.ogg", "stream");castlemusicfast:setLooping(true) 721 underwatermusicfast = love.audio.newSource("sounds/underwater-fast.ogg", "stream");underwatermusicfast:setLooping(true) 722 starmusicfast = love.audio.newSource("sounds/starmusic-fast.ogg", "stream");starmusicfast:setLooping(true) 723 ]] 724 725 soundlist = {jumpsound, jumpbigsound, stompsound, shotsound, blockhitsound, blockbreaksound, coinsound, pipesound, boomsound, mushroomappearsound, mushroomeatsound, shrinksound, deathsound, gameoversound, 726 fireballsound, oneupsound, levelendsound, castleendsound, scoreringsound, intermissionsound, firesound, bridgebreaksound, bowserfallsound, vinesound, swimsound, rainboomsoud, 727 portal1opensound, portal2opensound, portalentersound, portalfizzlesound, lowtime, konamisound, pausesound, stabsound, bulletbillsound} 728 729 -- musiclist = {overworldmusic, undergroundmusic, castlemusic, underwatermusic, starmusic} 730 -- musiclistfast = {overworldmusicfast, undergroundmusicfast, castlemusicfast, underwatermusicfast, starmusicfast} 731 732 musici = 2 733 734 shaders:init() 735 shaders:set(1, shaderlist[currentshaderi1]) 736 shaders:set(2, shaderlist[currentshaderi2]) 737 738 for i, v in pairs(dlclist) do 739 delete_mappack(v) 740 end 741 742 intro_load() 743end 744 745function love.update(dt) 746 if music then 747 music:update() 748 end 749 dt = math.min(0.01666667, dt) 750 751 --speed 752 if speed ~= speedtarget then 753 if speed > speedtarget then 754 speed = math.max(speedtarget, speed+(speedtarget-speed)*dt*5) 755 elseif speed < speedtarget then 756 speed = math.min(speedtarget, speed+(speedtarget-speed)*dt*5) 757 end 758 759 if math.abs(speed-speedtarget) < 0.02 then 760 speed = speedtarget 761 end 762 763 if speed > 0 then 764 for i, v in pairs(soundlist) do 765 v:setPitch( speed ) 766 end 767 music.pitch = speed 768 love.audio.setVolume(volume) 769 else 770 love.audio.setVolume(0) 771 end 772 end 773 774 dt = dt * speed 775 gdt = dt 776 777 if frameadvance == 1 then 778 return 779 elseif frameadvance == 2 then 780 frameadvance = 1 781 end 782 783 if skipupdate then 784 skipupdate = false 785 return 786 end 787 788 --netplay_update(dt) 789 keyprompt_update() 790 791 if gamestate == "menu" or gamestate == "mappackmenu" or gamestate == "onlinemenu" or gamestate == "options" then 792 menu_update(dt) 793 elseif gamestate == "levelscreen" or gamestate == "gameover" or gamestate == "sublevelscreen" or gamestate == "mappackfinished" then 794 levelscreen_update(dt) 795 elseif gamestate == "game" then 796 game_update(dt) 797 elseif gamestate == "intro" then 798 intro_update(dt) 799 end 800 801 for i, v in pairs(guielements) do 802 v:update(dt) 803 end 804end 805 806function love.draw() 807 shaders:predraw() 808 809 if gamestate == "menu" or gamestate == "mappackmenu" or gamestate == "onlinemenu" or gamestate == "options" then 810 menu_draw() 811 elseif gamestate == "levelscreen" or gamestate == "gameover" or gamestate == "mappackfinished" then 812 levelscreen_draw() 813 elseif gamestate == "game" then 814 game_draw() 815 elseif gamestate == "intro" then 816 intro_draw() 817 end 818 819 shaders:postdraw() 820 821 love.graphics.setColor(255, 255,255) 822end 823 824function saveconfig() 825 local s = "" 826 for i = 1, #controls do 827 s = s .. "playercontrols:" .. i .. ":" 828 local count = 0 829 for j, k in pairs(controls[i]) do 830 local c = "" 831 for l = 1, #controls[i][j] do 832 c = c .. controls[i][j][l] 833 if l ~= #controls[i][j] then 834 c = c .. "-" 835 end 836 end 837 s = s .. j .. "-" .. c 838 count = count + 1 839 if count == 12 then 840 s = s .. ";" 841 else 842 s = s .. "," 843 end 844 end 845 end 846 847 for i = 1, #mariocolors do 848 s = s .. "playercolors:" .. i .. ":" 849 for j = 1, 3 do 850 for k = 1, 3 do 851 s = s .. mariocolors[i][j][k] 852 if j == 3 and k == 3 then 853 s = s .. ";" 854 else 855 s = s .. "," 856 end 857 end 858 end 859 end 860 861 for i = 1, #portalhues do 862 s = s .. "portalhues:" .. i .. ":" 863 s = s .. round(portalhues[i][1], 4) .. "," .. round(portalhues[i][2], 4) .. ";" 864 end 865 866 for i = 1, #mariohats do 867 s = s .. "mariohats:" .. i 868 if #mariohats[i] > 0 then 869 s = s .. ":" 870 end 871 for j = 1, #mariohats[i] do 872 s = s .. mariohats[i][j] 873 if j == #mariohats[i] then 874 s = s .. ";" 875 else 876 s = s .. "," 877 end 878 end 879 880 if #mariohats[i] == 0 then 881 s = s .. ";" 882 end 883 end 884 885 s = s .. "scale:" .. scale .. ";" 886 887 s = s .. "shader1:" .. shaderlist[currentshaderi1] .. ";" 888 s = s .. "shader2:" .. shaderlist[currentshaderi2] .. ";" 889 890 s = s .. "volume:" .. volume .. ";" 891 s = s .. "mouseowner:" .. mouseowner .. ";" 892 893 s = s .. "mappack:" .. mappack .. ";" 894 895 if vsync then 896 s = s .. "vsync;" 897 end 898 899 if gamefinished then 900 s = s .. "gamefinished;" 901 end 902 903 --reached worlds 904 for i, v in pairs(reachedworlds) do 905 s = s .. "reachedworlds:" .. i .. ":" 906 for j = 1, 8 do 907 if v[j] then 908 s = s .. 1 909 else 910 s = s .. 0 911 end 912 913 if j == 8 then 914 s = s .. ";" 915 else 916 s = s .. "," 917 end 918 end 919 end 920 921 love.filesystem.write("options.txt", s) 922end 923 924function loadconfig() 925 players = 1 926 defaultconfig() 927 928 if not love.filesystem.exists("options.txt") then 929 return 930 end 931 932 local s = love.filesystem.read("options.txt") 933 s1 = s:split(";") 934 for i = 1, #s1-1 do 935 s2 = s1[i]:split(":") 936 937 if s2[1] == "playercontrols" then 938 if controls[tonumber(s2[2])] == nil then 939 controls[tonumber(s2[2])] = {} 940 end 941 942 s3 = s2[3]:split(",") 943 for j = 1, #s3 do 944 s4 = s3[j]:split("-") 945 controls[tonumber(s2[2])][s4[1]] = {} 946 for k = 2, #s4 do 947 if tonumber(s4[k]) ~= nil then 948 controls[tonumber(s2[2])][s4[1]][k-1] = tonumber(s4[k]) 949 else 950 controls[tonumber(s2[2])][s4[1]][k-1] = s4[k] 951 end 952 end 953 end 954 players = math.max(players, tonumber(s2[2])) 955 956 elseif s2[1] == "playercolors" then 957 if mariocolors[tonumber(s2[2])] == nil then 958 mariocolors[tonumber(s2[2])] = {} 959 end 960 s3 = s2[3]:split(",") 961 mariocolors[tonumber(s2[2])] = {{tonumber(s3[1]), tonumber(s3[2]), tonumber(s3[3])}, {tonumber(s3[4]), tonumber(s3[5]), tonumber(s3[6])}, {tonumber(s3[7]), tonumber(s3[8]), tonumber(s3[9])}} 962 963 elseif s2[1] == "portalhues" then 964 if portalhues[tonumber(s2[2])] == nil then 965 portalhues[tonumber(s2[2])] = {} 966 end 967 s3 = s2[3]:split(",") 968 portalhues[tonumber(s2[2])] = {tonumber(s3[1]), tonumber(s3[2])} 969 970 elseif s2[1] == "mariohats" then 971 local playerno = tonumber(s2[2]) 972 mariohats[playerno] = {} 973 974 if s2[3] == "mariohats" then --SAVING WENT WRONG OMG 975 976 elseif s2[3] then 977 s3 = s2[3]:split(",") 978 for i = 1, #s3 do 979 local hatno = tonumber(s3[i]) 980 if hatno > hatcount then 981 hatno = hatcount 982 end 983 mariohats[playerno][i] = hatno 984 end 985 end 986 987 elseif s2[1] == "scale" then 988 scale = tonumber(s2[2]) 989 990 elseif s2[1] == "shader1" then 991 for i = 1, #shaderlist do 992 if shaderlist[i] == s2[2] then 993 currentshaderi1 = i 994 end 995 end 996 elseif s2[1] == "shader2" then 997 for i = 1, #shaderlist do 998 if shaderlist[i] == s2[2] then 999 currentshaderi2 = i 1000 end 1001 end 1002 elseif s2[1] == "volume" then 1003 volume = tonumber(s2[2]) 1004 love.audio.setVolume( volume ) 1005 elseif s2[1] == "mouseowner" then 1006 mouseowner = tonumber(s2[2]) 1007 elseif s2[1] == "mappack" then 1008 if love.filesystem.exists("mappacks/" .. s2[2] .. "/") then 1009 mappack = s2[2] 1010 end 1011 elseif s2[1] == "gamefinished" then 1012 gamefinished = true 1013 elseif s2[1] == "vsync" then 1014 vsync = true 1015 elseif s2[1] == "reachedworlds" then 1016 reachedworlds[s2[2]] = {} 1017 local s3 = s2[3]:split(",") 1018 for i = 1, #s3 do 1019 if tonumber(s3[i]) == 1 then 1020 reachedworlds[s2[2]][i] = true 1021 end 1022 end 1023 end 1024 end 1025 1026 for i = 1, math.max(4, players) do 1027 portalcolor[i] = {getrainbowcolor(portalhues[i][1]), getrainbowcolor(portalhues[i][2])} 1028 end 1029 players = 1 1030end 1031 1032function defaultconfig() 1033 -------------- 1034 -- CONTORLS -- 1035 -------------- 1036 1037 -- Joystick stuff: 1038 -- joy, #, hat, #, direction (r, u, ru, etc) 1039 -- joy, #, axe, #, pos/neg 1040 -- joy, #, but, # 1041 -- You cannot set Hats and Axes as the jump button. Bummer. 1042 1043 mouseowner = 1 1044 1045 controls = {} 1046 1047 local i = 1 1048 controls[i] = {} 1049 controls[i]["right"] = {"d"} 1050 controls[i]["left"] = {"a"} 1051 controls[i]["down"] = {"s"} 1052 controls[i]["up"] = {"w"} 1053 controls[i]["run"] = {"lshift"} 1054 controls[i]["jump"] = {" "} 1055 controls[i]["aimx"] = {""} --mouse aiming, so no need 1056 controls[i]["aimy"] = {""} 1057 controls[i]["portal1"] = {""} 1058 controls[i]["portal2"] = {""} 1059 controls[i]["reload"] = {"r"} 1060 controls[i]["use"] = {"e"} 1061 1062 for i = 2, 4 do 1063 controls[i] = {} 1064 controls[i]["right"] = {"joy", i-1, "hat", 1, "r"} 1065 controls[i]["left"] = {"joy", i-1, "hat", 1, "l"} 1066 controls[i]["down"] = {"joy", i-1, "hat", 1, "d"} 1067 controls[i]["up"] = {"joy", i-1, "hat", 1, "u"} 1068 controls[i]["run"] = {"joy", i-1, "but", 3} 1069 controls[i]["jump"] = {"joy", i-1, "but", 1} 1070 controls[i]["aimx"] = {"joy", i-1, "axe", 5, "neg"} 1071 controls[i]["aimy"] = {"joy", i-1, "axe", 4, "neg"} 1072 controls[i]["portal1"] = {"joy", i-1, "but", 5} 1073 controls[i]["portal2"] = {"joy", i-1, "but", 6} 1074 controls[i]["reload"] = {"joy", i-1, "but", 4} 1075 controls[i]["use"] = {"joy", i-1, "but", 2} 1076 end 1077 ------------------- 1078 -- PORTAL COLORS -- 1079 ------------------- 1080 1081 portalhues = {} 1082 portalcolor = {} 1083 for i = 1, 4 do 1084 local players = 4 1085 portalhues[i] = {(i-1)*(1/players), (i-1)*(1/players)+0.5/players} 1086 portalcolor[i] = {getrainbowcolor(portalhues[i][1]), getrainbowcolor(portalhues[i][2])} 1087 end 1088 1089 --hats. 1090 mariohats = {} 1091 for i = 1, 4 do 1092 mariohats[i] = {1} 1093 end 1094 1095 ------------------ 1096 -- MARIO COLORS -- 1097 ------------------ 1098 --1: hat, pants (red) 1099 --2: shirt, shoes (brown-green) 1100 --3: skin (yellow-orange) 1101 1102 mariocolors = {} 1103 mariocolors[1] = {{224, 32, 0}, {136, 112, 0}, {252, 152, 56}} 1104 mariocolors[2] = {{255, 255, 255}, { 0, 160, 0}, {252, 152, 56}} 1105 mariocolors[3] = {{ 0, 0, 0}, {200, 76, 12}, {252, 188, 176}} 1106 mariocolors[4] = {{ 32, 56, 236}, { 0, 128, 136}, {252, 152, 56}} 1107 for i = 5, players do 1108 mariocolors[i] = mariocolors[math.random(4)] 1109 end 1110 1111 --STARCOLORS 1112 starcolors = {} 1113 starcolors[1] = {{ 0, 0, 0}, {200, 76, 12}, {252, 188, 176}} 1114 starcolors[2] = {{ 0, 168, 0}, {252, 152, 56}, {252, 252, 252}} 1115 starcolors[3] = {{252, 216, 168}, {216, 40, 0}, {252, 152, 56}} 1116 starcolors[4] = {{216, 40, 0}, {252, 152, 56}, {252, 252, 252}} 1117 1118 flowercolor = {{252, 216, 168}, {216, 40, 0}, {252, 152, 56}} 1119 1120 --options 1121 scale = 2 1122 volume = 1 1123 mappack = "smb" 1124 vsync = false 1125 1126 reachedworlds = {} 1127end 1128 1129function suspendgame() 1130 local s = "" 1131 if marioworld == "M" then 1132 marioworld = 8 1133 mariolevel = 4 1134 end 1135 s = s .. "world/" .. marioworld .. "|" 1136 s = s .. "level/" .. mariolevel .. "|" 1137 s = s .. "coincount/" .. mariocoincount .. "|" 1138 s = s .. "score/" .. marioscore .. "|" 1139 s = s .. "players/" .. players .. "|" 1140 for i = 1, players do 1141 if mariolivecount ~= false then 1142 s = s .. "lives/" .. i .. "/" .. mariolives[i] .. "|" 1143 end 1144 if objects["player"][i] then 1145 s = s .. "size/" .. i .. "/" .. objects["player"][i].size .. "|" 1146 else 1147 s = s .. "size/" .. i .."/1|" 1148 end 1149 end 1150 s = s .. "mappack/" .. mappack 1151 1152 love.filesystem.write("suspend.txt", s) 1153 1154 love.audio.stop() 1155 menu_load() 1156end 1157 1158function continuegame() 1159 if not love.filesystem.exists("suspend.txt") then 1160 return 1161 end 1162 1163 local s = love.filesystem.read("suspend.txt") 1164 1165 mariosizes = {} 1166 mariolives = {} 1167 1168 local split = s:split("|") 1169 for i = 1, #split do 1170 local split2 = split[i]:split("/") 1171 if split2[1] == "world" then 1172 marioworld = tonumber(split2[2]) 1173 elseif split2[1] == "level" then 1174 mariolevel = tonumber(split2[2]) 1175 elseif split2[1] == "coincount" then 1176 mariocoincount = tonumber(split2[2]) 1177 elseif split2[1] == "score" then 1178 marioscore = tonumber(split2[2]) 1179 elseif split2[1] == "players" then 1180 players = tonumber(split2[2]) 1181 elseif split2[1] == "lives" and mariolivecount ~= false then 1182 mariolives[tonumber(split2[2])] = tonumber(split2[3]) 1183 elseif split2[1] == "size" then 1184 mariosizes[tonumber(split2[2])] = tonumber(split2[3]) 1185 elseif split2[1] == "mappack" then 1186 mappack = split2[2] 1187 end 1188 end 1189 1190 love.filesystem.remove("suspend.txt") 1191end 1192 1193function changescale(s, fullscreen) 1194 scale = s 1195 1196 if fullscreen then 1197 fullscreen = true 1198 scale = 2 1199 love.graphics.setMode(800, 600, fullscreen, vsync, fsaa) 1200 end 1201 1202 uispace = math.floor(width*16*scale/4) 1203 love.graphics.setMode(width*16*scale, 224*scale, fullscreen, vsync, fsaa) --27x14 blocks (15 blocks actual height) 1204 1205 gamewidth = love.graphics.getWidth() 1206 gameheight = love.graphics.getHeight() 1207 1208 if shaders then 1209 shaders:refresh() 1210 end 1211end 1212 1213function love.keypressed(key, unicode) 1214 if keyprompt then 1215 keypromptenter("key", key) 1216 return 1217 end 1218 1219 for i, v in pairs(guielements) do 1220 if v:keypress(key) then 1221 return 1222 end 1223 end 1224 1225 if key == "f12" then 1226 love.mouse.setGrab(not love.mouse.isGrabbed()) 1227 end 1228 1229 if gamestate == "menu" or gamestate == "mappackmenu" or gamestate == "onlinemenu" or gamestate == "options" then 1230 --konami code 1231 if key == konami[konamii] then 1232 konamii = konamii + 1 1233 if konamii == #konami+1 then 1234 if konamisound:isStopped() then 1235 playsound(konamisound) 1236 end 1237 gamefinished = true 1238 saveconfig() 1239 konamii = 1 1240 end 1241 else 1242 konamii = 1 1243 end 1244 menu_keypressed(key, unicode) 1245 elseif gamestate == "game" then 1246 game_keypressed(key, unicode) 1247 elseif gamestate == "intro" then 1248 intro_keypressed() 1249 end 1250end 1251 1252function love.keyreleased(key, unicode) 1253 if gamestate == "menu" or gamestate == "options" then 1254 menu_keyreleased(key, unicode) 1255 elseif gamestate == "game" then 1256 game_keyreleased(key, unicode) 1257 end 1258end 1259 1260function love.mousepressed(x, y, button) 1261 if gamestate == "menu" or gamestate == "mappackmenu" or gamestate == "onlinemenu" or gamestate == "options" then 1262 menu_mousepressed(x, y, button) 1263 elseif gamestate == "game" then 1264 game_mousepressed(x, y, button) 1265 elseif gamestate == "intro" then 1266 intro_mousepressed() 1267 end 1268 1269 for i, v in pairs(guielements) do 1270 if v.priority then 1271 if v:click(x, y, button) then 1272 return 1273 end 1274 end 1275 end 1276 1277 for i, v in pairs(guielements) do 1278 if not v.priority then 1279 if v:click(x, y, button) then 1280 return 1281 end 1282 end 1283 end 1284end 1285 1286function love.mousereleased(x, y, button) 1287 if gamestate == "menu" or gamestate == "options" then 1288 menu_mousereleased(x, y, button) 1289 elseif gamestate == "game" then 1290 game_mousereleased(x, y, button) 1291 end 1292 1293 for i, v in pairs(guielements) do 1294 v:unclick(x, y, button) 1295 end 1296end 1297 1298function love.joystickpressed(joystick, button) 1299 if keyprompt then 1300 keypromptenter("joybutton", joystick, button) 1301 return 1302 end 1303 1304 if gamestate == "menu" or gamestate == "options" then 1305 menu_joystickpressed(joystick, button) 1306 elseif gamestate == "game" then 1307 game_joystickpressed(joystick, button) 1308 end 1309end 1310 1311function love.joystickreleased(joystick, button) 1312 if gamestate == "menu" or gamestate == "options" then 1313 menu_joystickreleased(joystick, button) 1314 elseif gamestate == "game" then 1315 game_joystickreleased(joystick, button) 1316 end 1317end 1318 1319function round(num, idp) --Not by me 1320 local mult = 10^(idp or 0) 1321 return math.floor(num * mult + 0.5) / mult 1322end 1323 1324function getrainbowcolor(i) 1325 local whiteness = 255 1326 local r, g, b 1327 if i < 1/6 then 1328 r = 1 1329 g = i*6 1330 b = 0 1331 elseif i >= 1/6 and i < 2/6 then 1332 r = (1/6-(i-1/6))*6 1333 g = 1 1334 b = 0 1335 elseif i >= 2/6 and i < 3/6 then 1336 r = 0 1337 g = 1 1338 b = (i-2/6)*6 1339 elseif i >= 3/6 and i < 4/6 then 1340 r = 0 1341 g = (1/6-(i-3/6))*6 1342 b = 1 1343 elseif i >= 4/6 and i < 5/6 then 1344 r = (i-4/6)*6 1345 g = 0 1346 b = 1 1347 else 1348 r = 1 1349 g = 0 1350 b = (1/6-(i-5/6))*6 1351 end 1352 1353 return {round(r*whiteness), round(g*whiteness), round(b*whiteness), 255} 1354end 1355 1356function newRecoloredImage(path, tablein, tableout) 1357 local imagedata = love.image.newImageData( path ) 1358 local width, height = imagedata:getWidth(), imagedata:getHeight() 1359 1360 for y = 0, height-1 do 1361 for x = 0, width-1 do 1362 local oldr, oldg, oldb, olda = imagedata:getPixel(x, y) 1363 1364 if olda > 128 then 1365 for i = 1, #tablein do 1366 if oldr == tablein[i][1] and oldg == tablein[i][2] and oldb == tablein[i][3] then 1367 local r, g, b = unpack(tableout[i]) 1368 imagedata:setPixel(x, y, r, g, b, olda) 1369 end 1370 end 1371 end 1372 end 1373 end 1374 1375 return love.graphics.newImage(imagedata) 1376end 1377 1378function string:split(delimiter) --Not by me 1379 local result = {} 1380 local from = 1 1381 local delim_from, delim_to = string.find( self, delimiter, from ) 1382 while delim_from do 1383 table.insert( result, string.sub( self, from , delim_from-1 ) ) 1384 from = delim_to + 1 1385 delim_from, delim_to = string.find( self, delimiter, from ) 1386 end 1387 table.insert( result, string.sub( self, from ) ) 1388 return result 1389end 1390 1391function tablecontains(t, entry) 1392 for i, v in pairs(t) do 1393 if v == entry then 1394 return true 1395 end 1396 end 1397 return false 1398end 1399 1400function getaveragecolor(imgdata, cox, coy) 1401 local xstart = (cox-1)*17 1402 local ystart = (coy-1)*17 1403 1404 local r, g, b = 0, 0, 0 1405 1406 local count = 0 1407 1408 for x = xstart, xstart+15 do 1409 for y = ystart, ystart+15 do 1410 local pr, pg, pb, a = imgdata:getPixel(x, y) 1411 if a > 127 then 1412 r, g, b = r+pr, g+pg, b+pb 1413 count = count + 1 1414 end 1415 end 1416 end 1417 1418 r, g, b = r/count, g/count, b/count 1419 1420 return r, g, b 1421end 1422 1423function keyprompt_update() 1424 if keyprompt then 1425 for i = 1, prompt.joysticks do 1426 for j = 1, #prompt.joystick[i].validhats do 1427 local dir = love.joystick.getHat(i, prompt.joystick[i].validhats[j]) 1428 if dir ~= "c" then 1429 keypromptenter("joyhat", i, prompt.joystick[i].validhats[j], dir) 1430 return 1431 end 1432 end 1433 1434 for j = 1, prompt.joystick[i].axes do 1435 local value = love.joystick.getAxis(i, j) 1436 if value > prompt.joystick[i].axisposition[j] + joystickdeadzone then 1437 keypromptenter("joyaxis", i, j, "pos") 1438 return 1439 elseif value < prompt.joystick[i].axisposition[j] - joystickdeadzone then 1440 keypromptenter("joyaxis", i, j, "neg") 1441 return 1442 end 1443 end 1444 end 1445 end 1446end 1447 1448function print_r (t, indent) --Not by me 1449 local indent=indent or '' 1450 for key,value in pairs(t) do 1451 io.write(indent,'[',tostring(key),']') 1452 if type(value)=="table" then io.write(':\n') print_r(value,indent..'\t') 1453 else io.write(' = ',tostring(value),'\n') end 1454 end 1455end 1456 1457function love.focus(f) 1458 if not f and gamestate == "game"and not editormode and not levelfinished and not everyonedead then 1459 pausemenuopen = true 1460 love.audio.pause() 1461 end 1462end 1463 1464function openSaveFolder(subfolder) --By Slime 1465 local path = love.filesystem.getSaveDirectory() 1466 path = subfolder and path.."/"..subfolder or path 1467 1468 local cmdstr 1469 local successval = 0 1470 1471 if os.getenv("WINDIR") then -- lolwindows 1472 --cmdstr = "Explorer /root,%s" 1473 if path:match("LOVE") then --hardcoded to fix ISO characters in usernames and made sure release mode doesn't mess anything up -saso 1474 cmdstr = "Explorer %%appdata%%\\LOVE\\mari0" 1475 else 1476 cmdstr = "Explorer %%appdata%%\\mari0" 1477 end 1478 path = path:gsub("/", "\\") 1479 successval = 1 1480 elseif os.getenv("HOME") then 1481 if path:match("/Library/Application Support") then -- OSX 1482 cmdstr = "open \"%s\"" 1483 else -- linux? 1484 cmdstr = "xdg-open \"%s\"" 1485 end 1486 end 1487 1488 -- returns true if successfully opened folder 1489 return cmdstr and os.execute(cmdstr:format(path)) == successval 1490end 1491 1492function getupdate() 1493 local onlinedata, code = http.request("http://server.stabyourself.net/mari0/?mode=mappacks") 1494 1495 if code ~= 200 then 1496 return false 1497 elseif not onlinedata then 1498 return false 1499 end 1500 1501 local latestversion 1502 1503 local split1 = onlinedata:split("<") 1504 for i = 2, #split1 do 1505 local split2 = split1[i]:split(">") 1506 if split2[1] == "latestversion" then 1507 latestversion = tonumber(split2[2]) 1508 end 1509 end 1510 1511 if latestversion and latestversion > marioversion then 1512 return true 1513 end 1514 return false 1515end 1516 1517function properprint(s, x, y) 1518 local startx = x 1519 for i = 1, string.len(tostring(s)) do 1520 local char = string.sub(s, i, i) 1521 if char == "|" then 1522 x = startx-((i)*8)*scale 1523 y = y + 10*scale 1524 elseif fontquads[char] then 1525 love.graphics.drawq(fontimage, fontquads[char], x+((i-1)*8)*scale, y, 0, scale, scale) 1526 end 1527 end 1528end 1529 1530function loadcustombackground() 1531 local i = 1 1532 custombackgroundimg = {} 1533 custombackgroundwidth = {} 1534 custombackgroundheight = {} 1535 --try to load map specific background first 1536 local levelstring = marioworld .. "-" .. mariolevel 1537 if mariosublevel ~= 0 then 1538 levelstring = levelstring .. "_" .. mariosublevel 1539 end 1540 1541 while love.filesystem.exists("mappacks/" .. mappack .. "/" .. levelstring .. "background" .. i .. ".png") do 1542 custombackgroundimg[i] = love.graphics.newImage("mappacks/" .. mappack .. "/" .. levelstring .. "background" .. i .. ".png") 1543 custombackgroundwidth[i] = custombackgroundimg[i]:getWidth()/16 1544 custombackgroundheight[i] = custombackgroundimg[i]:getHeight()/16 1545 i = i +1 1546 end 1547 1548 if #custombackgroundimg == 0 then 1549 while love.filesystem.exists("mappacks/" .. mappack .. "/background" .. i .. ".png") do 1550 custombackgroundimg[i] = love.graphics.newImage("mappacks/" .. mappack .. "/background" .. i .. ".png") 1551 custombackgroundwidth[i] = custombackgroundimg[i]:getWidth()/16 1552 custombackgroundheight[i] = custombackgroundimg[i]:getHeight()/16 1553 i = i +1 1554 end 1555 end 1556 1557 if #custombackgroundimg == 0 then 1558 custombackgroundimg[i] = love.graphics.newImage("graphics/SMB/portalbackground.png") 1559 custombackgroundwidth[i] = custombackgroundimg[i]:getWidth()/16 1560 custombackgroundheight[i] = custombackgroundimg[i]:getHeight()/16 1561 end 1562end