From 1b402cb4c867f417d3a70c1f2dba4fc884954773 Mon Sep 17 00:00:00 2001 From: Latchezar Tzvetkoff Date: Tue, 26 Apr 2016 15:28:16 +0300 Subject: [PATCH] LOVE 0.10.1 support A brief list of changes: - Drawing methods in 0.9 got simplified - e.g. `draw` instead of `drawq` - Threads share variables through "channels", there's no `set` or `get` anymore - Seems like GIF support was dropped (algnough there's no mention in LOVE's documentation), so the icon was converted to PNG - Non-PO2 shader support is guaranteed now, checks removed - Mouse clicks now emit numbers for buttons instead of strings - Mouse wheel events got their own callback now, giving the change in x/y (we're only using the vertical wheel currently) - Added a .gitignore --- .gitignore | 3 ++ blockdebris.lua | 2 +- bowser.lua | 2 +- conf.lua | 2 +- editor.lua | 78 ++++++++++++++++++++-------------------- firework.lua | 2 +- flower.lua | 2 +- game.lua | 80 +++++++++++++++++++++++------------------ graphics/icon.gif | Bin 233 -> 0 bytes graphics/icon.png | Bin 0 -> 408 bytes groundlight.lua | 2 +- gui.lua | 14 +++++++- lakito.lua | 2 +- levelscreen.lua | 2 +- main.lua | 50 +++++++++++++++++++------- menu.lua | 34 +++++++----------- miniblock.lua | 2 +- mushroom.lua | 2 +- musicloader.lua | 8 ++--- musicloader_thread.lua | 6 ++-- notgate.lua | 2 +- oneup.lua | 2 +- pushbutton.lua | 2 +- rainboom.lua | 38 +++++++++++++++++++- scrollingscore.lua | 18 +++++++++- seesaw.lua | 14 ++++---- shaders/init.lua | 77 ++++++++++++--------------------------- spring.lua | 2 +- star.lua | 2 +- vine.lua | 4 +-- wallindicator.lua | 2 +- walltimer.lua | 2 +- 32 files changed, 260 insertions(+), 198 deletions(-) create mode 100644 .gitignore delete mode 100644 graphics/icon.gif create mode 100644 graphics/icon.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dfe7cc8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +._.* +Thumbs.db diff --git a/blockdebris.lua b/blockdebris.lua index 42ad2e9..8ecdfa4 100644 --- a/blockdebris.lua +++ b/blockdebris.lua @@ -35,5 +35,5 @@ function blockdebris:update(dt) end function blockdebris:draw() - love.graphics.drawq(blockdebrisimage, blockdebrisquads[spriteset][self.frame], math.floor((self.x-xscroll)*16*scale), math.floor((self.y-.5)*16*scale), 0, scale, scale, 4, 4) + love.graphics.draw(blockdebrisimage, blockdebrisquads[spriteset][self.frame], math.floor((self.x-xscroll)*16*scale), math.floor((self.y-.5)*16*scale), 0, scale, scale, 4, 4) end \ No newline at end of file diff --git a/bowser.lua b/bowser.lua index 8e0dec3..f9f18d5 100644 --- a/bowser.lua +++ b/bowser.lua @@ -160,7 +160,7 @@ function bowser:draw() --just for the hammers if not self.fall and not self.backwards then if self.hammertimer > self.hammertime - bowserhammerdrawtime then - love.graphics.drawq(hammerimg, hammerquad[spriteset][1], math.floor((self.x-xscroll)*16*scale), (self.y-.5-11/16)*16*scale, 0, scale, scale) + love.graphics.draw(hammerimg, hammerquad[spriteset][1], math.floor((self.x-xscroll)*16*scale), (self.y-.5-11/16)*16*scale, 0, scale, scale) end end end diff --git a/conf.lua b/conf.lua index 20fde69..5eb9fd2 100644 --- a/conf.lua +++ b/conf.lua @@ -4,5 +4,5 @@ function love.conf(t) t.console = false --t.screen = false t.modules.physics = false - t.version = "0.8.0" + t.version = "0.10.1" end \ No newline at end of file diff --git a/editor.lua b/editor.lua index eef9c16..833c2c5 100644 --- a/editor.lua +++ b/editor.lua @@ -137,12 +137,12 @@ function editor_update(dt) return end - if love.mouse.isDown("l") and allowdrag then + if love.mouse.isDown(1) and allowdrag then local x, y = love.mouse.getPosition() placetile(x, y) end elseif editorstate == "main" then - if love.mouse.isDown("l") then + if love.mouse.isDown(1) then local mousex, mousey = love.mouse.getPosition() if mousey >= minimapy*scale and mousey < (minimapy+34)*scale then if mousex >= minimapx*scale and mousex < (minimapx+394)*scale then @@ -218,15 +218,15 @@ function editor_draw() if inmap(x, y+1) then love.graphics.setColor(255, 255, 255, 200) if editentities == false then - love.graphics.drawq(tilequads[currenttile].image, tilequads[currenttile].quad, math.floor((x-splitxscroll[1]-1)*16*scale), ((y-1)*16+8)*scale, 0, scale, scale) + love.graphics.draw(tilequads[currenttile].image, tilequads[currenttile].quad, math.floor((x-splitxscroll[1]-1)*16*scale), ((y-1)*16+8)*scale, 0, scale, scale) else - love.graphics.drawq(entityquads[currenttile].image, entityquads[currenttile].quad, math.floor((x-splitxscroll[1]-1)*16*scale), ((y-1)*16+8)*scale, 0, scale, scale) + love.graphics.draw(entityquads[currenttile].image, entityquads[currenttile].quad, math.floor((x-splitxscroll[1]-1)*16*scale), ((y-1)*16+8)*scale, 0, scale, scale) end end end if editorstate == "linktool" and editorstate ~= "portalgun" then - if linktoolX and love.mouse.isDown("l") then + if linktoolX and love.mouse.isDown(1) then love.graphics.line(math.floor((linktoolX-xscroll-.5)*16*scale), math.floor((linktoolY-1)*16*scale), mousex, mousey) end @@ -247,17 +247,17 @@ function editor_draw() local r = map[x][y] local drawline = false - if tablecontains(r, "link") and cox == x and coy == y and not love.mouse.isDown("l") then + if tablecontains(r, "link") and cox == x and coy == y and not love.mouse.isDown(1) then love.graphics.setColor(0, 255, 0, 255) drawline = true elseif tablecontains(r, "link") then love.graphics.setColor(150, 255, 150, 100) drawline = true - elseif tablecontains(outputsi, map[x][y][2]) and cox == x and coy == y and linktoolX and love.mouse.isDown("l") then + elseif tablecontains(outputsi, map[x][y][2]) and cox == x and coy == y and linktoolX and love.mouse.isDown(1) then love.graphics.setColor(255, 255, 0, 255) elseif tablecontains(outputsi, map[x][y][2]) then love.graphics.setColor(255, 255, 150, 150) - elseif cox == x and coy == y and not love.mouse.isDown("l") then + elseif cox == x and coy == y and not love.mouse.isDown(1) then love.graphics.setColor(255, 0, 0, 255) else love.graphics.setColor(255, 150, 150, 150) @@ -314,11 +314,11 @@ function editor_draw() if editentities == false then for i = 1, tilelistcount+1 do - love.graphics.drawq(tilequads[i+tileliststart-1].image, tilequads[i+tileliststart-1].quad, math.mod((i-1), 22)*17*scale+5*scale, math.floor((i-1)/22)*17*scale+38*scale-tilesoffset, 0, scale, scale) + love.graphics.draw(tilequads[i+tileliststart-1].image, tilequads[i+tileliststart-1].quad, math.mod((i-1), 22)*17*scale+5*scale, math.floor((i-1)/22)*17*scale+38*scale-tilesoffset, 0, scale, scale) end else for i = 1, entitiescount do - love.graphics.drawq(entityquads[i].image, entityquads[i].quad, math.mod((i-1), 22)*17*scale+5*scale, math.floor((i-1)/22)*17*scale+38*scale-tilesoffset, 0, scale, scale) + love.graphics.draw(entityquads[i].image, entityquads[i].quad, math.mod((i-1), 22)*17*scale+5*scale, math.floor((i-1)/22)*17*scale+38*scale-tilesoffset, 0, scale, scale) end end @@ -817,7 +817,7 @@ function editor_mousepressed(x, y, button) return end - if button == "l" then + if button == 1 then if editormenuopen == false then if editorstate == "linktool" then local tileX, tileY = getMouseTile(x, y+8*scale) @@ -857,7 +857,7 @@ function editor_mousepressed(x, y, button) end end end - elseif button == "m" then + elseif button == 3 then local cox, coy = getMouseTile(x, y+8*scale) if inmap(cox, coy) == false then return @@ -866,29 +866,7 @@ function editor_mousepressed(x, y, button) tilesall() currenttile = map[cox][coy][1] - elseif button == "wu" then - if editormenuopen then - else - if currenttile > 1 then - currenttile = currenttile - 1 - end - end - - elseif button == "wd" then - if editormenuopen then - else - if editentities then - if currenttile < #entitylist then - currenttile = currenttile + 1 - end - else - if currenttile < smbtilecount+portaltilecount+customtilecount then - currenttile = currenttile + 1 - end - end - end - - elseif button == "r" then + elseif button == 2 then if editormenuopen == false then local tileX, tileY = getMouseTile(x, y+8*scale) if inmap(tileX, tileY) == false then @@ -951,6 +929,30 @@ function editor_mousepressed(x, y, button) end end +function editor_wheelmoved(x, y) + if y > 0 then + if editormenuopen then + else + if currenttile > 1 then + currenttile = currenttile - 1 + end + end + elseif y < 0 then + if editormenuopen then + else + if editentities then + if currenttile < #entitylist then + currenttile = currenttile + 1 + end + else + if currenttile < smbtilecount+portaltilecount+customtilecount then + currenttile = currenttile + 1 + end + end + end + end +end + function rightclickmenuclick(i) if i > 1 then map[rightclickmenucox][rightclickmenucoy][3] = rightclickvalues[rightclickmenutile][i] @@ -958,7 +960,7 @@ function rightclickmenuclick(i) end function editor_mousereleased(x, y, button) - if button == "l" then + if button == 1 then guirepeattimer = 0 minimapdragging = false if editorstate == "linktool" then @@ -1176,8 +1178,8 @@ function savesettings() s = s .. "lives=" .. mariolivecount .. "\n" end - love.filesystem.mkdir( "mappacks" ) - love.filesystem.mkdir( "mappacks/" .. mappack ) + love.filesystem.createDirectory( "mappacks" ) + love.filesystem.createDirectory( "mappacks/" .. mappack ) love.filesystem.write("mappacks/" .. mappack .. "/settings.txt", s) end diff --git a/firework.lua b/firework.lua index 71d415d..4d56a02 100644 --- a/firework.lua +++ b/firework.lua @@ -29,5 +29,5 @@ function fireworkboom:draw() frame = 7 end - love.graphics.drawq(fireballimg, fireballquad[frame], math.floor((self.x-xscroll)*16*scale), (self.y-0.5)*16*scale, 0, scale, scale, 8, 8) + love.graphics.draw(fireballimg, fireballquad[frame], math.floor((self.x-xscroll)*16*scale), (self.y-0.5)*16*scale, 0, scale, scale, 8, 8) end \ No newline at end of file diff --git a/flower.lua b/flower.lua index 55c9bba..15f57bc 100644 --- a/flower.lua +++ b/flower.lua @@ -67,7 +67,7 @@ end function flower:draw() if self.uptimer < mushroomtime and not self.destroy then --Draw it coming out of the block. - love.graphics.drawq(self.graphic, self.quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor((self.y*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY) + love.graphics.draw(self.graphic, self.quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor((self.y*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY) end end diff --git a/game.lua b/game.lua index 074f6a2..d06abd6 100644 --- a/game.lua +++ b/game.lua @@ -345,10 +345,10 @@ function game_update(dt) gelcannontimer = 0 end else - if love.mouse.isDown("l") then + if love.mouse.isDown(1) then gelcannontimer = gelcannondelay objects["player"][mouseowner]:shootgel(1) - elseif love.mouse.isDown("r") then + elseif love.mouse.isDown(2) then gelcannontimer = gelcannondelay objects["player"][mouseowner]:shootgel(2) end @@ -965,12 +965,12 @@ function game_draw() local tilenumber = t[1] if tilequads[tilenumber].coinblock and tilequads[tilenumber].invisible == false then --coinblock - love.graphics.drawq(coinblockimage, coinblockquads[spriteset][coinframe], math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1-bounceyoffset)*16-8)*scale, 0, scale, scale) + love.graphics.draw(coinblockimage, coinblockquads[spriteset][coinframe], math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1-bounceyoffset)*16-8)*scale, 0, scale, scale) elseif tilequads[tilenumber].coin then --coin - love.graphics.drawq(coinimage, coinquads[spriteset][coinframe], math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1-bounceyoffset)*16-8)*scale, 0, scale, scale) + love.graphics.draw(coinimage, coinquads[spriteset][coinframe], math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1-bounceyoffset)*16-8)*scale, 0, scale, scale) elseif bounceyoffset ~= 0 then if tilequads[tilenumber].invisible == false or editormode then - love.graphics.drawq(tilequads[tilenumber].image, tilequads[tilenumber].quad, math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1-bounceyoffset)*16-8)*scale, 0, scale, scale) + love.graphics.draw(tilequads[tilenumber].image, tilequads[tilenumber].quad, math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1-bounceyoffset)*16-8)*scale, 0, scale, scale) end end @@ -1002,13 +1002,13 @@ function game_draw() if editormode then if tilequads[t[1]].invisible and t[1] ~= 1 then - love.graphics.drawq(tilequads[t[1]].image, tilequads[t[1]].quad, math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1)*16-8)*scale, 0, scale, scale) + love.graphics.draw(tilequads[t[1]].image, tilequads[t[1]].quad, math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1)*16-8)*scale, 0, scale, scale) end if #t > 1 and t[2] ~= "link" then tilenumber = t[2] love.graphics.setColor(255, 255, 255, 150) - love.graphics.drawq(entityquads[tilenumber].image, entityquads[tilenumber].quad, math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1)*16-8)*scale, 0, scale, scale) + love.graphics.draw(entityquads[tilenumber].image, entityquads[tilenumber].quad, math.floor((x-1-math.mod(xscroll, 1))*16*scale), ((y-1)*16-8)*scale, 0, scale, scale) love.graphics.setColor(255, 255, 255, 255) end end @@ -1027,7 +1027,7 @@ function game_draw() properprint("*", uispace*1.5-8*scale, 16*scale) - love.graphics.drawq(coinanimationimage, coinanimationquads[spriteset][coinframe], uispace*1.5-16*scale, 16*scale, 0, scale, scale) + love.graphics.draw(coinanimationimage, coinanimationquads[spriteset][coinframe], uispace*1.5-16*scale, 16*scale, 0, scale, scale) properprint(addzeros(mariocoincount, 2), uispace*1.5-0*scale, 16*scale) properprint("world", uispace*2.5 - 20*scale, 8*scale) @@ -1107,7 +1107,7 @@ function game_draw() love.graphics.setColor(255, 255, 255) --axe if axex then - love.graphics.drawq(axeimg, axequads[coinframe], math.floor((axex-1-xscroll)*16*scale), (axey-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(axeimg, axequads[coinframe], math.floor((axex-1-xscroll)*16*scale), (axey-1.5)*16*scale, 0, scale, scale) if marioworld ~= 8 then love.graphics.draw(toadimg, math.floor((mapwidth-7-xscroll)*16*scale), 177*scale, 0, scale, scale) @@ -1300,7 +1300,7 @@ function game_draw() else love.graphics.setColor(255, 255, 255) end - love.graphics.drawq(v.graphic[k], v.quad, math.floor(((v.x-xscroll)*16+v.offsetX)*scale), math.floor((v.y*16-v.offsetY)*scale), v.rotation, dirscale, horscale, v.quadcenterX, v.quadcenterY) + love.graphics.draw(v.graphic[k], v.quad, math.floor(((v.x-xscroll)*16+v.offsetX)*scale), math.floor((v.y*16-v.offsetY)*scale), v.rotation, dirscale, horscale, v.quadcenterX, v.quadcenterY) end if v.drawhat and hatoffsets[v.animationstate] then @@ -1354,11 +1354,11 @@ function game_draw() if v.graphic[0] then love.graphics.setColor(255, 255, 255) - love.graphics.drawq(v.graphic[0], v.quad, math.floor(((v.x-xscroll)*16+v.offsetX)*scale), math.floor((v.y*16-v.offsetY)*scale), v.rotation, dirscale, horscale, v.quadcenterX, v.quadcenterY) + love.graphics.draw(v.graphic[0], v.quad, math.floor(((v.x-xscroll)*16+v.offsetX)*scale), math.floor((v.y*16-v.offsetY)*scale), v.rotation, dirscale, horscale, v.quadcenterX, v.quadcenterY) end else if v.graphic and v.quad then - love.graphics.drawq(v.graphic, v.quad, math.floor(((v.x-xscroll)*16+v.offsetX)*scale), math.floor((v.y*16-v.offsetY)*scale), v.rotation, dirscale, horscale, v.quadcenterX, v.quadcenterY) + love.graphics.draw(v.graphic, v.quad, math.floor(((v.x-xscroll)*16+v.offsetX)*scale), math.floor((v.y*16-v.offsetY)*scale), v.rotation, dirscale, horscale, v.quadcenterX, v.quadcenterY) end end @@ -1397,7 +1397,7 @@ function game_draw() else love.graphics.setColor(255, 255, 255) end - love.graphics.drawq(v.graphic[k], v.quad, math.ceil(((px-xscroll)*16+v.offsetX)*scale), math.ceil((py*16-v.offsetY)*scale), pr, dirscale, horscale, v.quadcenterX, v.quadcenterY) + love.graphics.draw(v.graphic[k], v.quad, math.ceil(((px-xscroll)*16+v.offsetX)*scale), math.ceil((py*16-v.offsetY)*scale), pr, dirscale, horscale, v.quadcenterX, v.quadcenterY) end if v.drawhat and hatoffsets[v.animationstate] then @@ -1451,10 +1451,10 @@ function game_draw() if v.graphic[0] then love.graphics.setColor(255, 255, 255) - love.graphics.drawq(v.graphic[0], v.quad, math.floor(((px-xscroll)*16+v.offsetX)*scale), math.floor((py*16-v.offsetY)*scale), pr, dirscale, horscale, v.quadcenterX, v.quadcenterY) + love.graphics.draw(v.graphic[0], v.quad, math.floor(((px-xscroll)*16+v.offsetX)*scale), math.floor((py*16-v.offsetY)*scale), pr, dirscale, horscale, v.quadcenterX, v.quadcenterY) end else - love.graphics.drawq(v.graphic, v.quad, math.ceil(((px-xscroll)*16+v.offsetX)*scale), math.ceil((py*16-v.offsetY)*scale), pr, dirscale, horscale, v.quadcenterX, v.quadcenterY) + love.graphics.draw(v.graphic, v.quad, math.ceil(((px-xscroll)*16+v.offsetX)*scale), math.ceil((py*16-v.offsetY)*scale), pr, dirscale, horscale, v.quadcenterX, v.quadcenterY) end end end @@ -1543,7 +1543,7 @@ function game_draw() end love.graphics.setColor(unpack(objects["player"][i].portal1color)) - love.graphics.drawq(portalimage, portal1quad[portalframe], math.floor(((objects["player"][i].portal1X-1-xscroll)*16+offsetx)*scale), math.floor(((objects["player"][i].portal1Y-1)*16+offsety)*scale), rotation, scale, scale, 8, 8) + love.graphics.draw(portalimage, portal1quad[portalframe], math.floor(((objects["player"][i].portal1X-1-xscroll)*16+offsetx)*scale), math.floor(((objects["player"][i].portal1Y-1)*16+offsety)*scale), rotation, scale, scale, 8, 8) end if objects["player"][i].portal2X ~= false then @@ -1570,7 +1570,7 @@ function game_draw() end love.graphics.setColor(unpack(objects["player"][i].portal2color)) - love.graphics.drawq(portalimage, portal2quad[portalframe], math.floor(((objects["player"][i].portal2X-1-xscroll)*16+offsetx)*scale), math.floor(((objects["player"][i].portal2Y-1)*16+offsety)*scale), rotation, scale, scale, 8, 8) + love.graphics.draw(portalimage, portal2quad[portalframe], math.floor(((objects["player"][i].portal2X-1-xscroll)*16+offsetx)*scale), math.floor(((objects["player"][i].portal2Y-1)*16+offsety)*scale), rotation, scale, scale, 8, 8) end end @@ -1578,7 +1578,7 @@ function game_draw() --COINBLOCKANIMATION for i, v in pairs(coinblockanimations) do - love.graphics.drawq(coinblockanimationimage, coinblockanimationquads[coinblockanimations[i].frame], math.floor((coinblockanimations[i].x - xscroll)*16*scale), math.floor((coinblockanimations[i].y*16-8)*scale), 0, scale, scale, 4, 54) + love.graphics.draw(coinblockanimationimage, coinblockanimationquads[coinblockanimations[i].frame], math.floor((coinblockanimations[i].x - xscroll)*16*scale), math.floor((coinblockanimations[i].y*16-8)*scale), 0, scale, scale, 4, 54) end --SCROLLING SCORE @@ -1694,12 +1694,12 @@ function game_draw() breakingblockX = cox breakingblockY = coy breakingblockprogress = 0 - elseif not breakingblockX and love.mouse.isDown("l") then + elseif not breakingblockX and love.mouse.isDown(1) then breakingblockX = cox breakingblockY = coy breakingblockprogress = 0 end - elseif love.mouse.isDown("l") then + elseif love.mouse.isDown(1) then breakingblockX = cox breakingblockY = coy breakingblockprogress = 0 @@ -1712,7 +1712,7 @@ function game_draw() love.graphics.setColor(255, 255, 255, 255) local frame = math.ceil((breakingblockprogress/minecraftbreaktime)*10) if frame ~= 0 then - love.graphics.drawq(minecraftbreakimg, minecraftbreakquad[frame], (breakingblockX-1-xscroll)*16*scale, (breakingblockY-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(minecraftbreakimg, minecraftbreakquad[frame], (breakingblockX-1-xscroll)*16*scale, (breakingblockY-1.5)*16*scale, 0, scale, scale) end end love.graphics.setColor(255, 255, 255, 255) @@ -1731,7 +1731,7 @@ function game_draw() elseif t <= smbtilecount+portaltilecount then img = portaltilesimg end - love.graphics.drawq(img, tilequads[t].quad, (width*8-88+(i-1)*20)*scale, 205*scale, 0, scale, scale) + love.graphics.draw(img, tilequads[t].quad, (width*8-88+(i-1)*20)*scale, 205*scale, 0, scale, scale) end end @@ -2584,11 +2584,11 @@ function generatespritebatch() local tilenumber = t[1] if tilenumber ~= 0 and tilequads[tilenumber].invisible == false and tilequads[tilenumber].coinblock == false and tilequads[tilenumber].coin == false then if tilenumber <= smbtilecount then - smbmsb:addq( tilequads[tilenumber].quad, (x-1)*16*scale, ((y-1)*16-8)*scale, 0, scale, scale ) + smbmsb:add( tilequads[tilenumber].quad, (x-1)*16*scale, ((y-1)*16-8)*scale, 0, scale, scale ) elseif tilenumber <= smbtilecount+portaltilecount then - portalmsb:addq( tilequads[tilenumber].quad, (x-1)*16*scale, ((y-1)*16-8)*scale, 0, scale, scale ) + portalmsb:add( tilequads[tilenumber].quad, (x-1)*16*scale, ((y-1)*16-8)*scale, 0, scale, scale ) elseif tilenumber <= smbtilecount+portaltilecount+customtilecount then - custommsb:addq( tilequads[tilenumber].quad, (x-1)*16*scale, ((y-1)*16-8)*scale, 0, scale, scale ) + custommsb:add( tilequads[tilenumber].quad, (x-1)*16*scale, ((y-1)*16-8)*scale, 0, scale, scale ) end end end @@ -2916,7 +2916,7 @@ function game_mousepressed(x, y, button) if not noupdate and objects["player"][mouseowner] and objects["player"][mouseowner].controlsenabled and objects["player"][mouseowner].vine == false then - if button == "l" or button == "r" and objects["player"][mouseowner] then + if button == 1 or button == 2 and objects["player"][mouseowner] then --knockback if portalknockback then local xadd = math.sin(objects["player"][mouseowner].pointingangle)*30 @@ -2929,7 +2929,7 @@ function game_mousepressed(x, y, button) end end - if button == "l" then + if button == 1 then if playertype == "portal" then local sourcex = objects["player"][mouseowner].x+6/16 local sourcey = objects["player"][mouseowner].y+6/16 @@ -2951,7 +2951,7 @@ function game_mousepressed(x, y, button) end end - elseif button == "r" then + elseif button == 2 then if playertype == "portal" then local sourcex = objects["player"][mouseowner].x+6/16 local sourcey = objects["player"][mouseowner].y+6/16 @@ -2972,8 +2972,18 @@ function game_mousepressed(x, y, button) end end end - - if button == "wd" then + end +end + +function game_wheelmoved(x, y) + if editormode and editorstate ~= "portalgun" then + editor_wheelmoved(x, y) + else + if editormode then + editor_wheelmoved(x, y) + end + + if y < 0 then if playertype == "minecraft" then mccurrentblock = mccurrentblock + 1 if mccurrentblock >= 10 then @@ -2985,7 +2995,7 @@ function game_mousepressed(x, y, button) speedtarget = 0.1 end end - elseif button == "wu" then + elseif y > 0 then if playertype == "minecraft" then mccurrentblock = mccurrentblock - 1 if mccurrentblock <= 0 then @@ -3461,7 +3471,7 @@ function warpzone(i) end function game_mousereleased(x, y, button) - if button == "l" then + if button == 1 then if playertype == "minecraft" then breakingblockX = false end @@ -3525,8 +3535,8 @@ function savemap(filename) --tileset - love.filesystem.mkdir( "mappacks" ) - love.filesystem.mkdir( "mappacks/" .. mappack ) + love.filesystem.createDirectory( "mappacks" ) + love.filesystem.createDirectory( "mappacks/" .. mappack ) love.filesystem.write("mappacks/" .. mappack .. "/" .. filename .. ".txt", s) print("Map saved as " .. "mappacks/" .. filename .. ".txt") @@ -3828,7 +3838,7 @@ end function properprint2(s, x, y) for i = 1, string.len(tostring(s)) do if fontquads[string.sub(s, i, i)] then - love.graphics.drawq(fontimage2, font2quads[string.sub(s, i, i)], x+((i-1)*4)*scale, y, 0, scale, scale) + love.graphics.draw(fontimage2, font2quads[string.sub(s, i, i)], x+((i-1)*4)*scale, y, 0, scale, scale) end end end diff --git a/graphics/icon.gif b/graphics/icon.gif deleted file mode 100644 index e0424013a1e5784d85045a52d74a4f51a4ce42e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 233 zcmV39tWlq jt`~Z&8MF(yTe=6lA6bMiY+4h*e8$CZF3QQs2MGW>9-m_7 diff --git a/graphics/icon.png b/graphics/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cf520673a84e8e16ff2437bdf23a918fdf10463e GIT binary patch literal 408 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvmUKs7M+SzC{oH>NSwWJ?9znhg z3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fgArasc;`;yp{|5>T9R&=3 zW?1O!>tDWnIm8Mm_Fv%ost-Ulj3q&S!3+-1Zlr-YN#5=*3>~bp9zYIziKnkC`vVq9 zJ~_+g+f%iGLIs{Kjv*T7YcF*39#G(52?$GQjcyc;XcXP`pQClv*Y4>VUtBvHH4X_% zZDQKKgu#L3l6P1`{F7+$8L90SR!mbECQb?9Vwldfx1nl*FW-W+{+Aa@7`ZlRZ!rIQ z{=cvJkMuk8ZvwWnyh=INdA5Pi;sCeTbj|Bb1#ERdyH!hEBT7;dOH!?pi&B9UgOP!u znXZ9}u90bop^25Tft9Jbwt=ygfq{s!`AifIx%nxXX_dG&q}KJT0yQvry85}Sb4q9e E04vpiBme*a literal 0 HcmV?d00001 diff --git a/groundlight.lua b/groundlight.lua index 4ea1d9b..a5f6f30 100644 --- a/groundlight.lua +++ b/groundlight.lua @@ -40,7 +40,7 @@ function groundlight:draw() love.graphics.setColor(60, 188, 252, 255) end - love.graphics.drawq(entityquads[42+self.dir].image, entityquads[42+self.dir].quad, math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale) + love.graphics.draw(entityquads[42+self.dir].image, entityquads[42+self.dir].quad, math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale) end function groundlight:input(t) diff --git a/gui.lua b/gui.lua index 2625234..b70f7c1 100644 --- a/gui.lua +++ b/gui.lua @@ -149,7 +149,7 @@ function guielement:draw() high = 2 end - love.graphics.drawq(checkboximg, checkboxquad[high][quad], self.x*scale, self.y*scale, 0, scale, scale) + love.graphics.draw(checkboximg, checkboxquad[high][quad], self.x*scale, self.y*scale, 0, scale, scale) elseif self.type == "dropdown" then local high = self:inhighlight(love.mouse.getPosition()) @@ -400,6 +400,18 @@ function guielement:click(x, y, button) end end +function guielement:wheel(x, y) + if self.active then + if self.type == "scrollbar" then + if y < 0 then + self.value = math.min(1, self.value+0.2) + elseif y > 0 then + self.value = math.max(0, self.value-0.2) + end + end + end +end + function guielement:keypress(key) if self.active then if self.type == "input" then diff --git a/lakito.lua b/lakito.lua index f7e365c..4be46a8 100644 --- a/lakito.lua +++ b/lakito.lua @@ -124,7 +124,7 @@ function lakito:draw() quad = 2 end - love.graphics.drawq(lakitoimg, lakitoquad[quad], math.floor((self.x-xscroll-2/16+.5)*16*scale), (self.y-0.5+1/16)*16*scale, 0, horscale, verscale, 8, 12) + love.graphics.draw(lakitoimg, lakitoquad[quad], math.floor((self.x-xscroll-2/16+.5)*16*scale), (self.y-0.5+1/16)*16*scale, 0, horscale, verscale, 8, 12) end function lakito:stomp() diff --git a/levelscreen.lua b/levelscreen.lua index b8dfb03..7b4344f 100644 --- a/levelscreen.lua +++ b/levelscreen.lua @@ -193,7 +193,7 @@ function levelscreen_draw() properprint("*", uispace*1.5-8*scale, 16*scale) - love.graphics.drawq(coinanimationimage, coinanimationquads[2][coinframe], uispace*1.5-16*scale, 16*scale, 0, scale, scale) + love.graphics.draw(coinanimationimage, coinanimationquads[2][coinframe], uispace*1.5-16*scale, 16*scale, 0, scale, scale) properprint(addzeros(mariocoincount, 2), uispace*1.5-0*scale, 16*scale) properprint("world", uispace*2.5 - 20*scale, 8*scale) diff --git a/main.lua b/main.lua index b19d939..8168918 100644 --- a/main.lua +++ b/main.lua @@ -10,7 +10,7 @@ function love.load() marioversion = 1006 versionstring = "version 1.6" - shaderlist = love.filesystem.enumerate( "shaders/" ) + shaderlist = love.filesystem.getDirectoryItems( "shaders/" ) dlclist = {"dlc_a_portal_tribute", "dlc_acid_trip", "dlc_escape_the_lab", "dlc_scienceandstuff", "dlc_smb2J", "dlc_the_untitled_game"} local rem @@ -27,7 +27,7 @@ function love.load() currentshaderi1 = 1 currentshaderi2 = 1 - hatcount = #love.filesystem.enumerate("graphics/SMB/hats") + hatcount = #love.filesystem.getDirectoryItems("graphics/SMB/hats") if not pcall(loadconfig) then players = 1 @@ -36,18 +36,20 @@ function love.load() saveconfig() width = 25 - fsaa = 0 fullscreen = false changescale(scale, fullscreen) - love.graphics.setCaption( "Mari0" ) + love.window.setTitle( "Mari0" ) - --version check by checking for a const that was added in 0.8.0 - if love._version_major == nil then error("You have an outdated version of Love! Get 0.8.0 or higher and retry.") end + --version check + local loveversion = string.format("%02d.%02d.%02d", love._version_major, love._version_minor, love._version_revision) + if loveversion < "00.10.01" then + error("You have an outdated version of Love! Get 0.10.1 or higher and retry.") + end - iconimg = love.graphics.newImage("graphics/icon.gif") - love.graphics.setIcon(iconimg) + iconimg = love.graphics.newImage("graphics/icon.png") + love.window.setIcon(iconimg:getData()) - love.graphics.setDefaultImageFilter("nearest", "nearest") + love.graphics.setDefaultFilter("nearest", "nearest") love.graphics.setBackgroundColor(0, 0, 0) @@ -161,7 +163,7 @@ function love.load() else soundenabled = true end - love.filesystem.mkdir( "mappacks" ) + love.filesystem.createDirectory( "mappacks" ) editormode = false yoffset = 0 love.graphics.setPointSize(3*scale) @@ -1196,11 +1198,11 @@ function changescale(s, fullscreen) if fullscreen then fullscreen = true scale = 2 - love.graphics.setMode(800, 600, fullscreen, vsync, fsaa) + love.window.setMode(800, 600, {fullscreen=fullscreen, vsync=vsync}) end uispace = math.floor(width*16*scale/4) - love.graphics.setMode(width*16*scale, 224*scale, fullscreen, vsync, fsaa) --27x14 blocks (15 blocks actual height) + love.window.setMode(width*16*scale, 224*scale, {fullscreen=fullscreen, vsync=vsync}) --27x14 blocks (15 blocks actual height) gamewidth = love.graphics.getWidth() gameheight = love.graphics.getHeight() @@ -1295,6 +1297,28 @@ function love.mousereleased(x, y, button) end end +function love.wheelmoved(x, y) + if gamestate == "game" then + game_wheelmoved(x, y) + end + + for i, v in pairs(guielements) do + if v.priority then + if v:wheel(x, y) then + return + end + end + end + + for i, v in pairs(guielements) do + if not v.priority then + if v:wheel(x, y) then + return + end + end + end +end + function love.joystickpressed(joystick, button) if keyprompt then keypromptenter("joybutton", joystick, button) @@ -1522,7 +1546,7 @@ function properprint(s, x, y) x = startx-((i)*8)*scale y = y + 10*scale elseif fontquads[char] then - love.graphics.drawq(fontimage, fontquads[char], x+((i-1)*8)*scale, y, 0, scale, scale) + love.graphics.draw(fontimage, fontquads[char], x+((i-1)*8)*scale, y, 0, scale, scale) end end end diff --git a/menu.lua b/menu.lua index cc047dd..4334ae7 100644 --- a/menu.lua +++ b/menu.lua @@ -217,9 +217,9 @@ function menu_draw() local t = map[x][y] local tilenumber = tonumber(t[1]) if tilequads[tilenumber].coinblock and tilequads[tilenumber].invisible == false then --coinblock - love.graphics.drawq(coinblockimage, coinblockquads[spriteset][coinframe], math.floor((x-1)*16*scale), ((y-1)*16-8)*scale, 0, scale, scale) + love.graphics.draw(coinblockimage, coinblockquads[spriteset][coinframe], math.floor((x-1)*16*scale), ((y-1)*16-8)*scale, 0, scale, scale) elseif tilenumber ~= 0 and tilequads[tilenumber].invisible == false then - love.graphics.drawq(tilequads[tilenumber].image, tilequads[tilenumber].quad, math.floor((x-1)*16*scale), ((y-1)*16-8)*scale, 0, scale, scale) + love.graphics.draw(tilequads[tilenumber].image, tilequads[tilenumber].quad, math.floor((x-1)*16*scale), ((y-1)*16-8)*scale, 0, scale, scale) end end end @@ -231,7 +231,7 @@ function menu_draw() properprint("*", uispace*1.5-8*scale, 16*scale) - love.graphics.drawq(coinanimationimage, coinanimationquads[1][coinframe], uispace*1.5-16*scale, 16*scale, 0, scale, scale) + love.graphics.draw(coinanimationimage, coinanimationquads[1][coinframe], uispace*1.5-16*scale, 16*scale, 0, scale, scale) properprint("00", uispace*1.5-0*scale, 16*scale) properprint("world", uispace*2.5 - 20*scale, 8*scale) @@ -784,9 +784,9 @@ function menu_draw() love.graphics.draw(portalglow, 142*scale, 57*scale, 0, scale, scale) love.graphics.setColor(unpack(portalcolor[skinningplayer][1])) - love.graphics.drawq(portalimage, portal1quad[portalframe], 174*scale, 46*scale, math.pi, scale, scale) + love.graphics.draw(portalimage, portal1quad[portalframe], 174*scale, 46*scale, math.pi, scale, scale) love.graphics.setColor(unpack(portalcolor[skinningplayer][2])) - love.graphics.drawq(portalimage, portal1quad[portalframe], 142*scale, 70*scale, 0, scale, scale) + love.graphics.draw(portalimage, portal1quad[portalframe], 142*scale, 70*scale, 0, scale, scale) love.graphics.setScissor() @@ -922,11 +922,7 @@ function menu_draw() end properprint("shader1:", 30*scale, 55*scale) - if shaderssupported == false then - properprint("unsupported", (180-string.len("unsupported")*8)*scale, 55*scale) - else - properprint(string.lower(shaderlist[currentshaderi1]), (180-string.len(shaderlist[currentshaderi1])*8)*scale, 55*scale) - end + properprint(string.lower(shaderlist[currentshaderi1]), (180-string.len(shaderlist[currentshaderi1])*8)*scale, 55*scale) if optionsselection == 4 then love.graphics.setColor(255, 255, 255, 255) @@ -934,11 +930,7 @@ function menu_draw() love.graphics.setColor(100, 100, 100, 255) end properprint("shader2:", 30*scale, 65*scale) - if shaderssupported == false then - properprint("unsupported", (180-string.len("unsupported")*8)*scale, 65*scale) - else - properprint(string.lower(shaderlist[currentshaderi2]), (180-string.len(shaderlist[currentshaderi2])*8)*scale, 65*scale) - end + properprint(string.lower(shaderlist[currentshaderi2]), (180-string.len(shaderlist[currentshaderi2])*8)*scale, 65*scale) love.graphics.setColor(100, 100, 100, 255) properprint("shaders will really", 30*scale, 80*scale) @@ -1262,7 +1254,7 @@ end function loadmappacks() mappacktype = "local" - mappacklist = love.filesystem.enumerate( "mappacks" ) + mappacklist = love.filesystem.getDirectoryItems( "mappacks" ) local delete = {} for i = 1, #mappacklist do @@ -1344,7 +1336,7 @@ end function loadonlinemappacks() mappacktype = "online" downloadmappacks() - onlinemappacklist = love.filesystem.enumerate( "mappacks" ) + onlinemappacklist = love.filesystem.getDirectoryItems( "mappacks" ) local delete = {} for i = 1, #onlinemappacklist do @@ -1477,7 +1469,7 @@ function downloadmappacks() love.filesystem.remove("mappacks/" .. maplist[i] .. "/") end - love.filesystem.mkdir("mappacks/" .. maplist[i]) + love.filesystem.createDirectory("mappacks/" .. maplist[i]) local onlinedata, code = http.request("http://server.stabyourself.net/mari0/index2.php?mode=getmap&get=" .. maplist[i]) if code == 200 then @@ -1532,7 +1524,7 @@ function downloadmappacks() --Delete stuff and stuff. if not success then if love.filesystem.exists("mappacks/" .. maplist[i] .. "/") then - local list = love.filesystem.enumerate("mappacks/" .. maplist[i] .. "/") + local list = love.filesystem.getDirectoryItems("mappacks/" .. maplist[i] .. "/") for j = 1, #list do love.filesystem.remove("mappacks/" .. maplist[i] .. "/" .. list[j]) end @@ -2158,7 +2150,7 @@ function delete_mappack(pack) return false end - local list = love.filesystem.enumerate("mappacks/" .. pack .. "/") + local list = love.filesystem.getDirectoryItems("mappacks/" .. pack .. "/") for i = 1, #list do love.filesystem.remove("mappacks/" .. pack .. "/" .. list[i]) end @@ -2174,7 +2166,7 @@ function createmappack() mappack = "custom_mappack_" .. i - love.filesystem.mkdir("mappacks/" .. mappack .. "/") + love.filesystem.createDirectory("mappacks/" .. mappack .. "/") local s = "" s = s .. "name=new mappack" .. "\n" diff --git a/miniblock.lua b/miniblock.lua index b7150a0..d692569 100644 --- a/miniblock.lua +++ b/miniblock.lua @@ -53,5 +53,5 @@ function miniblock:draw() end local yadd = math.sin(self.timer)*0.1+0.15 - love.graphics.drawq(img, tilequads[self.i].quad, math.floor((self.x-xscroll)*16*scale), math.floor((self.y-.5-yadd)*16*scale), 0, scale/2, scale/2, 8, 16) + love.graphics.draw(img, tilequads[self.i].quad, math.floor((self.x-xscroll)*16*scale), math.floor((self.y-.5-yadd)*16*scale), 0, scale/2, scale/2, 8, 16) end \ No newline at end of file diff --git a/mushroom.lua b/mushroom.lua index 7399f70..27c1810 100644 --- a/mushroom.lua +++ b/mushroom.lua @@ -74,7 +74,7 @@ end function mushroom:draw() if self.uptimer < mushroomtime and not self.destroy then --Draw it coming out of the block. - love.graphics.drawq(entitiesimg, entityquads[2].quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor((self.y*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY) + love.graphics.draw(entitiesimg, entityquads[2].quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor((self.y*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY) end end diff --git a/musicloader.lua b/musicloader.lua index c4d2117..0f80f59 100644 --- a/musicloader.lua +++ b/musicloader.lua @@ -1,5 +1,5 @@ music = { - thread = love.thread.newThread("musicthread", "musicloader_thread.lua"), + thread = love.thread.newThread("musicloader_thread.lua"), toload = {}, loaded = {}, list = {}, @@ -22,7 +22,7 @@ function music:load(musicfile) -- can take a single file string or an array of f self:preload(musicfile) end self.stringlist = table.concat(self.toload, ";") - self.thread:set("musiclist", self.stringlist) + love.thread.getChannel("musiclist"):push(self.stringlist) end function music:preload(musicfile) @@ -62,7 +62,7 @@ end function music:update() for i,v in ipairs(self.toload) do - local source = self.thread:get(v) + local source = love.thread.getChannel(v):pop() if source then self:onLoad(v, source) end @@ -72,7 +72,7 @@ function music:update() source:setPitch(self.pitch) end end - local err = self.thread:get("error") + local err = self.thread:getError() if err then print(err) end end diff --git a/musicloader_thread.lua b/musicloader_thread.lua index 9951718..6a07b72 100644 --- a/musicloader_thread.lua +++ b/musicloader_thread.lua @@ -1,5 +1,3 @@ -local this = love.thread.getThread() - require("love.filesystem") require("love.sound") require("love.audio") @@ -15,7 +13,7 @@ local musictoload = {} -- waiting to be loaded into memory local function getmusiclist() -- the music string should have names separated by the ";" character -- music will be loaded in in the same order as they appear in the string - local musicliststr = this:get("musiclist") + local musicliststr = love.thread.getChannel("musiclist"):pop() if musicliststr then for musicname in musicliststr:gmatch("[^;]+") do if not musiclist[musicname] then @@ -42,7 +40,7 @@ local function loadmusic() if filename then local source = love.audio.newSource(love.sound.newDecoder(filename, 512 * 1024), "static") --print("thread loaded music", name) - this:set(name, source) + love.thread.getChannel(name):push(source) end end end diff --git a/notgate.lua b/notgate.lua index 0c2f24d..233f3fc 100644 --- a/notgate.lua +++ b/notgate.lua @@ -40,7 +40,7 @@ end function notgate:draw() love.graphics.setColor(255, 255, 255) - love.graphics.drawq(entitiesimg, entityquads[84].quad, math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale) + love.graphics.draw(entitiesimg, entityquads[84].quad, math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale) end function notgate:out(t) diff --git a/oneup.lua b/oneup.lua index 605c202..38a095e 100644 --- a/oneup.lua +++ b/oneup.lua @@ -79,7 +79,7 @@ end function oneup:draw() if self.drawable == false then --Draw it coming out of the block. - love.graphics.drawq(entitiesimg, entityquads[3].quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor((self.y*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY) + love.graphics.draw(entitiesimg, entityquads[3].quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor((self.y*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY) end end diff --git a/pushbutton.lua b/pushbutton.lua index a929978..3e58741 100644 --- a/pushbutton.lua +++ b/pushbutton.lua @@ -34,7 +34,7 @@ function pushbutton:draw() horscale = -scale end - love.graphics.drawq(pushbuttonimg, pushbuttonquad[quad], math.floor((self.cox-0.5-xscroll)*16*scale), (self.coy-1.5)*16*scale, 0, horscale, scale, 8) + love.graphics.draw(pushbuttonimg, pushbuttonquad[quad], math.floor((self.cox-0.5-xscroll)*16*scale), (self.coy-1.5)*16*scale, 0, horscale, scale, 8) end function pushbutton:addoutput(a) diff --git a/rainboom.lua b/rainboom.lua index 7503181..8c30adc 100644 --- a/rainboom.lua +++ b/rainboom.lua @@ -1 +1,37 @@ ---Can't believe I'm doing this rainboom = class:new() function rainboom:init(x, y, dir) self.x = x self.y = y self.dir = dir self.timer = 0 self.frame = 1 self.r = 0 if dir == "up" then self.r = -math.pi/2 elseif dir == "down" then self.r = math.pi/2 elseif dir == "left" then self.r = math.pi end end function rainboom:update(dt) self.timer = self.timer + dt while self.timer > rainboomdelay do self.frame = self.frame + 1 self.timer = self.timer - rainboomdelay end if self.frame > rainboomframes then return true end return false end function rainboom:draw() love.graphics.drawq(rainboomimg, rainboomquad[self.frame], (self.x-xscroll)*16*scale, (self.y-0.5)*16*scale, self.r, scale, scale, 29, 92) end \ No newline at end of file +--Can't believe I'm doing this +rainboom = class:new() + +function rainboom:init(x, y, dir) + self.x = x + self.y = y + self.dir = dir + self.timer = 0 + self.frame = 1 + + self.r = 0 + if dir == "up" then + self.r = -math.pi/2 + elseif dir == "down" then + self.r = math.pi/2 + elseif dir == "left" then + self.r = math.pi + end +end + +function rainboom:update(dt) + self.timer = self.timer + dt + while self.timer > rainboomdelay do + self.frame = self.frame + 1 + self.timer = self.timer - rainboomdelay + end + + if self.frame > rainboomframes then + return true + end + + return false +end + +function rainboom:draw() + love.graphics.draw(rainboomimg, rainboomquad[self.frame], (self.x-xscroll)*16*scale, (self.y-0.5)*16*scale, self.r, scale, scale, 29, 92) +end diff --git a/scrollingscore.lua b/scrollingscore.lua index 6f48125..ecd3b12 100644 --- a/scrollingscore.lua +++ b/scrollingscore.lua @@ -1 +1,17 @@ -scrollingscore = class:new() function scrollingscore:init(i, x, y) self.x = x-xscroll self.y = y self.i = i self.timer = 0 end function scrollingscore:update(dt) self.timer = self.timer + dt if self.timer > scrollingscoretime then return true end return false end \ No newline at end of file +scrollingscore = class:new() + +function scrollingscore:init(i, x, y) + self.x = x-xscroll + self.y = y + self.i = i + self.timer = 0 +end + +function scrollingscore:update(dt) + self.timer = self.timer + dt + if self.timer > scrollingscoretime then + return true + end + + return false +end \ No newline at end of file diff --git a/seesaw.lua b/seesaw.lua index cd059ab..97687c7 100644 --- a/seesaw.lua +++ b/seesaw.lua @@ -94,18 +94,18 @@ end function seesaw:draw() --left - love.graphics.drawq(seesawimg, seesawquad[1], math.floor((self.x-1-xscroll)*16*scale), (self.y-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(seesawimg, seesawquad[1], math.floor((self.x-1-xscroll)*16*scale), (self.y-1.5)*16*scale, 0, scale, scale) if self.falloff == false and self.leftplatform.y-self.y >= 0 then love.graphics.setScissor((self.x-1-xscroll)*16*scale, (self.y-0.5)*16*scale, 16*scale, math.floor((self.leftplatform.y-self.y)*16*scale)) for i = 1, math.ceil(self.leftplatform.y-self.y) do - love.graphics.drawq(seesawimg, seesawquad[3], math.floor((self.x-1-xscroll)*16*scale), (self.y+i-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(seesawimg, seesawquad[3], math.floor((self.x-1-xscroll)*16*scale), (self.y+i-1.5)*16*scale, 0, scale, scale) end love.graphics.setScissor() else if self.falloffside == "left" then for i = 1, self.dist1+self.dist2-2 do - love.graphics.drawq(seesawimg, seesawquad[3], math.floor((self.x-1-xscroll)*16*scale), (self.y+i-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(seesawimg, seesawquad[3], math.floor((self.x-1-xscroll)*16*scale), (self.y+i-1.5)*16*scale, 0, scale, scale) end end end @@ -113,22 +113,22 @@ function seesaw:draw() --middle for i = 1, self.range-1 do - love.graphics.drawq(seesawimg, seesawquad[4], math.floor((self.x-1+i-xscroll)*16*scale), (self.y-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(seesawimg, seesawquad[4], math.floor((self.x-1+i-xscroll)*16*scale), (self.y-1.5)*16*scale, 0, scale, scale) end --right - love.graphics.drawq(seesawimg, seesawquad[2], math.floor((self.x-1+self.range-xscroll)*16*scale), (self.y-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(seesawimg, seesawquad[2], math.floor((self.x-1+self.range-xscroll)*16*scale), (self.y-1.5)*16*scale, 0, scale, scale) if self.falloff == false and self.rightplatform.y-self.y >= 0 then love.graphics.setScissor((self.x-1+self.range-xscroll)*16*scale, (self.y-0.5)*16*scale, 16*scale, math.floor((self.rightplatform.y-self.y)*16*scale)) for i = 1, math.ceil(self.rightplatform.y-self.y) do - love.graphics.drawq(seesawimg, seesawquad[3], math.floor((self.x+self.range-1-xscroll)*16*scale), (self.y+i-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(seesawimg, seesawquad[3], math.floor((self.x+self.range-1-xscroll)*16*scale), (self.y+i-1.5)*16*scale, 0, scale, scale) end love.graphics.setScissor() else if self.falloffside == "right" then for i = 1, self.dist1+self.dist2-2 do - love.graphics.drawq(seesawimg, seesawquad[3], math.floor((self.x+self.range-1-xscroll)*16*scale), (self.y+i-1.5)*16*scale, 0, scale, scale) + love.graphics.draw(seesawimg, seesawquad[3], math.floor((self.x+self.range-1-xscroll)*16*scale), (self.y+i-1.5)*16*scale, 0, scale, scale) end end end diff --git a/shaders/init.lua b/shaders/init.lua index afe27e7..d67c50c 100644 --- a/shaders/init.lua +++ b/shaders/init.lua @@ -1,11 +1,3 @@ -local supported = love.graphics.isSupported and love.graphics.isSupported("canvas") and love.graphics.isSupported("pixeleffect") -local supports_npo2 = love.graphics.isSupported and love.graphics.isSupported("npot") or false -- on the safe side -if not supported then - shaderssupported = false - print("post-processing shaders not supported") -end - - local function FindNextPO2(x) return 2 ^ math.ceil(math.log(x)/math.log(2)) end @@ -13,7 +5,6 @@ end shaders = {} shaders.effects = {} -shaders.supported = supported local function CreateShaderPass() local pass = { @@ -23,11 +14,10 @@ local function CreateShaderPass() yres = love.graphics.getHeight(), } - function pass:useCanvas(usenpo2) - local po2xr = usenpo2 and shaders.xres or shaders.po2xres - local po2yr = usenpo2 and shaders.yres or shaders.po2yres - - local c = usenpo2 and self.canvas_npo2 or self.canvas_po2 + function pass:useCanvas() + local po2xr = shaders.xres + local po2yr = shaders.yres + local c = self.canvas_npo2 if not c or c.canvas:getWidth() ~= po2xr or c.canvas:getHeight() ~= po2yr then c = {} @@ -42,17 +32,13 @@ local function CreateShaderPass() self.on = false return end - if usenpo2 then - self.canvas_npo2 = c - else - self.canvas_po2 = c - end + self.canvas_npo2 = c elseif self.xres ~= shaders.xres or self.yres ~= shaders.yres then c.quad = love.graphics.newQuad(0, 0, shaders.xres, shaders.yres, po2xr, po2yr) end self.xres, self.yres = shaders.xres, shaders.yres - + self.defs = { ["textureSize"] = {po2xr/scale, po2yr/scale}, -- ["textureSizeReal"] = {po2xr, po2yr}, @@ -65,16 +51,16 @@ local function CreateShaderPass() end function pass:predraw() - if supported and self.on and self.canvas then - self.canvas.canvas:clear(love.graphics.getBackgroundColor()) + if self.on and self.canvas then love.graphics.setCanvas(self.canvas.canvas) + love.graphics.clear(love.graphics.getBackgroundColor()) return self.canvas.canvas end end function pass:postdraw() local effect = shaders.effects[self.cureffect] - if supported and self.on and self.cureffect and effect and self.canvas then + if self.on and self.cureffect and effect and self.canvas then for def in pairs(effect[3]) do if self.defs[def] then if def == "time" then @@ -84,16 +70,16 @@ local function CreateShaderPass() end end if effect.supported == nil then - effect.supported = pcall(love.graphics.setPixelEffect, effect[1]) + effect.supported = pcall(love.graphics.setShader, effect[1]) if not effect.supported then print(string.format("Error setting shader: %s!", self.cureffect)) end elseif effect.supported then - love.graphics.setPixelEffect(effect[1]) + love.graphics.setShader(effect[1]) else - love.graphics.setPixelEffect() + love.graphics.setShader() end - love.graphics.drawq(self.canvas.canvas, self.canvas.quad, 0, 0) + love.graphics.draw(self.canvas.canvas, self.canvas.quad, 0, 0) end end @@ -101,13 +87,6 @@ local function CreateShaderPass() end --- list of shaders that need po2-sized canvases -shaders.needspo2 = { - ["4xBR"] = true, - ["waterpaint"] = true, - ["CRT"] = true, -} - shaders.passes = {} @@ -116,11 +95,7 @@ shaders.passes = {} function shaders:init(numpasses) numpasses = numpasses or 2 - if not supported then - return - end - - local files = love.filesystem.enumerate("shaders") + local files = love.filesystem.getDirectoryItems("shaders") for i,v in ipairs(files) do local filename, filetype = v:match("(.+)%.(.-)$") @@ -128,13 +103,13 @@ function shaders:init(numpasses) local name = "shaders".."/"..v if love.filesystem.isFile(name) then local str = love.filesystem.read(name) - local success, effect = pcall(love.graphics.newPixelEffect, str) + local success, effect = pcall(love.graphics.newShader, str) if success then local defs = {} for vtype, extern in str:gmatch("extern (%w+) (%w+)") do defs[extern] = true end - self.effects[filename] = {effect, str, defs, needspo2 = not not self.needspo2[filename]} + self.effects[filename] = {effect, str, defs} else print(string.format("shader (%s) is fucked up, yo:\n", filename), effect) end @@ -156,19 +131,17 @@ end -- pass nil as the second argument to disable that shader pass -- don't call before shaders:init() function shaders:set(i, shadername) - if not supported then return end - i = i or 1 local pass = self.passes[i] if not pass then return end - if shadername == nil or not self.effects[shadername] or not supported then + if shadername == nil or not self.effects[shadername] then pass.on = false pass.cureffect = nil else pass.on = true pass.cureffect = shadername - pass:useCanvas(supports_npo2 and not self.effects[shadername].needspo2) + pass:useCanvas() print(string.format("post-processing shader selected for pass %d: %s", i, shadername)) end end @@ -187,8 +160,6 @@ end -- automatically called on init -- should also be called when resolution changes or fullscreen is toggled function shaders:refresh() - if not supported then return end - if not self.scale or self.scale ~= scale or not self.xres or not self.yres or self.xres ~= love.graphics.getWidth() or self.yres ~= love.graphics.getHeight() then @@ -209,8 +180,6 @@ end -- call in love.draw before drawing whatever you want post-processed -- note: don't change shaders in between predraw and postdraw! function shaders:predraw() - if not supported then return end - -- only predraw the first available pass here (we'll do the rest in postdraw) self.curcanvas = nil for i,v in ipairs(self.passes) do @@ -225,10 +194,10 @@ end -- call in love.draw after drawing whatever you want post-processed function shaders:postdraw() - if not supported or not self.curcanvas then return end + if not self.curcanvas then return end - local blendmode = love.graphics.getBlendMode() - love.graphics.setBlendMode("premultiplied") + local blendmode, alphamode = love.graphics.getBlendMode() + love.graphics.setBlendMode("alpha", "premultiplied") love.graphics.setColor(255, 255, 255) local activepasses = {} @@ -249,6 +218,6 @@ function shaders:postdraw() v:postdraw() end - love.graphics.setBlendMode(blendmode) - love.graphics.setPixelEffect() + love.graphics.setBlendMode(blendmode, alphamode) + love.graphics.setShader() end diff --git a/spring.lua b/spring.lua index 346ca96..f962959 100644 --- a/spring.lua +++ b/spring.lua @@ -37,7 +37,7 @@ function spring:update(dt) end function spring:draw() - love.graphics.drawq(springimg, springquads[spriteset][self.frame], math.floor((self.x-xscroll)*16*scale), (self.y*16-8)*scale, 0, scale, scale) + love.graphics.draw(springimg, springquads[spriteset][self.frame], math.floor((self.x-xscroll)*16*scale), (self.y*16-8)*scale, 0, scale, scale) end function spring:hit() diff --git a/star.lua b/star.lua index 5f8a914..877be3e 100644 --- a/star.lua +++ b/star.lua @@ -88,7 +88,7 @@ end function star:draw() if self.drawable == false then --Draw it coming out of the block. - love.graphics.drawq(self.graphic, self.quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor((self.y*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY) + love.graphics.draw(self.graphic, self.quad, math.floor(((self.x-xscroll)*16+self.offsetX)*scale), math.floor((self.y*16-self.offsetY)*scale), 0, scale, scale, self.quadcenterX, self.quadcenterY) end end diff --git a/vine.lua b/vine.lua index d5be7b6..9521fa0 100644 --- a/vine.lua +++ b/vine.lua @@ -47,9 +47,9 @@ end function vine:draw() love.graphics.setScissor(0, 0, width*16*scale, (self.coy-1.5)*16*scale) - love.graphics.drawq(vineimg, vinequad[spriteset][1], math.floor((self.x-xscroll-1/16-((1-self.width)/2))*16*scale), (self.y-0.5-2/16)*16*scale, 0, scale, scale) + love.graphics.draw(vineimg, vinequad[spriteset][1], math.floor((self.x-xscroll-1/16-((1-self.width)/2))*16*scale), (self.y-0.5-2/16)*16*scale, 0, scale, scale) for i = 1, math.ceil(self.height-14/16+.7) do - love.graphics.drawq(vineimg, vinequad[spriteset][2], math.floor((self.x-xscroll-1/16-((1-self.width)/2))*16*scale), (self.y-0.5-2/16+i)*16*scale, 0, scale, scale) + love.graphics.draw(vineimg, vinequad[spriteset][2], math.floor((self.x-xscroll-1/16-((1-self.width)/2))*16*scale), (self.y-0.5-2/16+i)*16*scale, 0, scale, scale) end diff --git a/wallindicator.lua b/wallindicator.lua index 6fbe8f0..15e3331 100644 --- a/wallindicator.lua +++ b/wallindicator.lua @@ -32,7 +32,7 @@ function wallindicator:draw() quad = 2 end - love.graphics.drawq(wallindicatorimg, wallindicatorquad[quad], math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale) + love.graphics.draw(wallindicatorimg, wallindicatorquad[quad], math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale) end function wallindicator:input(t) diff --git a/walltimer.lua b/walltimer.lua index a96a4cd..09b2754 100644 --- a/walltimer.lua +++ b/walltimer.lua @@ -54,7 +54,7 @@ end function walltimer:draw() love.graphics.setColor(255, 255, 255) - love.graphics.drawq(walltimerimg, walltimerquad[self.quad], math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale) + love.graphics.draw(walltimerimg, walltimerquad[self.quad], math.floor((self.x-1-xscroll)*16*scale), ((self.y-1)*16-8)*scale, 0, scale, scale) end function walltimer:out(t)