From b84ea25a15e7bd168db6bfc682db1a18a1c7305e Mon Sep 17 00:00:00 2001 From: PossiblyAxolotl Date: Sat, 28 May 2022 23:53:46 -0600 Subject: [PATCH] fixed invert saving, nerfed save & quit --- Source/Editor.lua | 79 +++++++++++++++++++++------------- Source/Menu.lua | 4 +- Source/Player.lua | 27 ++++++++---- Source/Saws.lua | 3 +- Source/data/level.rocketbyte | 1 - Source/data/level2.rocketbyte | 1 - Source/gfx/bButton.png | Bin 0 -> 210 bytes Source/gfx/eye.png | Bin 215 -> 153 bytes Source/gfx/line.png | Bin 200 -> 196 bytes Source/gfx/music.png | Bin 172 -> 182 bytes Source/gfx/spin.png | Bin 261 -> 195 bytes Source/gfx/square.png | Bin 133 -> 193 bytes 12 files changed, 70 insertions(+), 45 deletions(-) delete mode 100644 Source/data/level.rocketbyte delete mode 100644 Source/data/level2.rocketbyte create mode 100644 Source/gfx/bButton.png diff --git a/Source/Editor.lua b/Source/Editor.lua index 61448e2..2d1fb54 100644 --- a/Source/Editor.lua +++ b/Source/Editor.lua @@ -38,6 +38,7 @@ local imgExit = gfx.image.new("gfx/exit") local imgEye = gfx.image.new("gfx/eye") local imgPlayer = gfx.image.new("gfx/rocket") local imgPlayerExit = gfx.image.new("gfx/bigrocket") +local imgB = gfx.image.new("gfx/bButton") assert(imgFloppy) assert(imgAdd) assert(imgMus) @@ -49,16 +50,19 @@ assert(imgRocket) assert(imgEye) assert(imgPlayer) assert(imgPlayerExit) +assert(imgB) local animFloppy = gfx.animation.loop.new(100, imgFloppy) local saveTime = 0 -local playerPos = {x=100,y=100} -local exitPos = {x = 105, y = 100} +local playerPos = {x=1562,y=1564} +local exitPos = {x = 1616, y = 1536} local position = {x=100,y=100} local positionLerp = {x=0,y=0} +local powers = {} + function newProject() mode = "newproj" playdate.keyboard.show("NEW LEVEL") @@ -71,13 +75,14 @@ function updateNewproj() end function editLoadName(name) + removeMap() local data = json.decodeFile("levels/"..name) + powers = data.fuel playerPos = {x = data.rocket.x, y = data.rocket.y} exitPos = {x = data.bigrocket.x, y = data.bigrocket.y} - position = {x = (data.rocket.x - 2) / 16, y = (data.rocket.y-1)/16} + position = {x = (data.rocket.x + 6) / 16, y = (data.rocket.y + 4)/16} levelname = name:match("(.+)%..+$") inverted = data.inverted - printTable(data) playdate.display.setInverted(data.inverted) saveTime = 0 mode = "editor" @@ -90,16 +95,15 @@ function editLoadName(name) tilemapEditor:setTileAtPosition(data.tiles[tile].x,data.tiles[tile].y,data.tiles[tile].t) tiles[tile] = {x=data.tiles[tile].x,y=data.tiles[tile].y,t=data.tiles[tile].t} end - - toolTipButton = menu:addMenuItem("save",data.inverted, function() - editSave() - end) altClrButton = menu:addCheckmarkMenuItem("alt colours",inverted, function(value) playdate.display.setInverted(value) inverted = value end) + toolTipButton = menu:addMenuItem("save", function() + editSave() + end) + imgtiles:add() - menuButton:setTitle("save & quit") playdate.wait(0.1) end @@ -109,9 +113,10 @@ function playdate.keyboard.keyboardWillHideCallback(ok) playdate.wait(0.3) editLoad() else + removeMap() position = {x=89,y=93} - playerPos = {x=100,y=100} - exitPos = {x = 105, y = 100} + playerPos = {x=1562,y=1564} + exitPos = {x = 1616, y = 1536} for tile = 1, #tiles, 1 do tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0) end @@ -119,22 +124,22 @@ function playdate.keyboard.keyboardWillHideCallback(ok) playdate.display.setInverted(false) saveTime = 0 mode = "editor" + altClrButton, error = menu:addCheckmarkMenuItem("alt colours",false, function(value) + playdate.display.setInverted(value) + inverted = value + end) toolTipButton, error = menu:addMenuItem("save",false, function() editSave() end) playdate.wait(0.1) - altClrButton, error = menu:addCheckmarkMenuItem("alt colours",false, function(value) - playdate.display.setInverted(value) - end) + levelname = playdate.keyboard.text:upper() imgtiles:add() - menuButton:setTitle("save & quit") playdate.wait(0.1) end end function playdate.keyboard.textChangedCallback() - print(#playdate.keyboard.text) if #playdate.keyboard.text > 24 then playdate.keyboard.text = prevtext @@ -151,11 +156,10 @@ local curYlerp = -32 function editSave() playdate.datastore.delete("levels/"..levelname..".json") saveTime = 5 - playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos},"levels/"..levelname) + playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos, fuel = powers},"levels/"..levelname) end function editUpdate() - printTable(exitPos) local change, aChange = playdate.getCrankChange() @@ -178,8 +182,10 @@ function editUpdate() tilemapEditor:setTileAtPosition(position.x+12,position.y+8,2) tiles[#tiles+1] = {x=position.x + 12, y=position.y + 8, t=2} imgtiles = gfx.sprite.new(tilemapEditor) + elseif math.floor(tileIndex) == 1 then + powers[#powers+1] = {x=((position.x + 11) * 16)-7, y=((position.y + 7) * 16)-5} elseif math.floor(tileIndex) == 4 then - playerPos = {x = ((position.x + 11) * 16) + 2, y = ((position.y + 7) * 16)+1} + playerPos = {x = ((position.x + 11) * 16) - 6, y = ((position.y + 7) * 16) - 4} elseif math.floor(tileIndex) == 5 then exitPos = {x = (position.x + 11) * 16, y = (position.y + 7) * 16} elseif math.floor(tileIndex) == 7 then @@ -199,6 +205,13 @@ function editUpdate() end end imgtiles = gfx.sprite.new(tilemapEditor) + elseif math.floor(tileIndex) == 1 then + for power = 1, #powers, 1 do + if powers[power].x == ((position.x + 11) * 16)-7 and powers[power].y == ((position.y + 7) * 16)-5 then + table.remove(powers,power) + break + end + end end elseif editor == "view" then editor = "main" @@ -229,6 +242,10 @@ function editUpdate() imgPlayerExit:draw(exitPos.x, exitPos.y) imgPlayer:draw(playerPos.x,playerPos.y) + for power = 1, #powers, 1 do + imgSquare:draw(powers[power].x,powers[power].y) + end + if editor ~= "view" then imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16) end @@ -236,6 +253,7 @@ function editUpdate() gfx.setColor(playdate.graphics.kColorXOR) gfx.fillRect(((position.x + 11) * 16) + 3, ((position.y + 7) * 16) + 3,10,10) ]] + if position.y < 1 then imgCant:drawTiled((position.x-1) * 16,-112,400,112) end @@ -245,13 +263,13 @@ function editUpdate() -- draw ui/ if editor ~= "view" then - gfx.setDrawOffset(0,0) - gfx.setColor(gfx.kColorBlack) - gfx.fillRect(362,0,400,240) - - gfx.setColor(gfx.kColorWhite) - gfx.drawLine(360,0,360,240) + gfx.setDrawOffset(0,0) + gfx.setColor(gfx.kColorBlack) + gfx.fillRect(362,0,400,240) + gfx.setColor(gfx.kColorWhite) + gfx.drawLine(360,0,360,240) + -- draw changes if editor == "main" then imgMus:draw(366, 176) @@ -266,7 +284,7 @@ function editUpdate() if math.floor( tileIndex ) == 0 then gfx.drawText("TILES",0,0) elseif math.floor( tileIndex ) == 1 then - gfx.drawText("FUEL",0,0) + gfx.drawText("POWER",0,0) elseif math.floor( tileIndex ) == 2 then gfx.drawText("MOVERS",0,0) elseif math.floor( tileIndex ) == 3 then @@ -284,25 +302,24 @@ function editUpdate() gfx.setColor(playdate.graphics.kColorXOR) gfx.fillRect(365,curYlerp,33,28) - end if saveTime > 0 then saveTime -= 0.1 - animFloppy:draw(2,2) + animFloppy:draw(2,16) end end function editClose() - editSave() for tile = 1, #tiles, 1 do tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0) tiles[tile] = nil end + powers = {} playdate.display.setInverted(false) imgtiles = gfx.sprite.new(tilemapEditor) imgtiles:remove() playdate.getSystemMenu():removeMenuItem(toolTipButton) playdate.getSystemMenu():removeMenuItem(altClrButton) - menuButton:setTitle("game menu") -end \ No newline at end of file +end + diff --git a/Source/Menu.lua b/Source/Menu.lua index 7f96e22..045bc65 100644 --- a/Source/Menu.lua +++ b/Source/Menu.lua @@ -189,8 +189,8 @@ function menuButtonPress(name) elseif name == "START NEW GAME" or name == "CONFIRM" then deaths = 0 - map = "data/level.rocketbyte" - addMapSave("data/level.rocketbyte") + map = "data/level.json" + addMapSave("data/level.json") elseif name == "CONTINUE" then addMap(map) diff --git a/Source/Player.lua b/Source/Player.lua index 1ccb919..bf8489a 100644 --- a/Source/Player.lua +++ b/Source/Player.lua @@ -20,6 +20,7 @@ sprRocket = gfx.sprite.new(imgRocket) local loopFire = gfx.animation.loop.new(200,imgFire) sprRocket:setCollideRect(9, 9, 10, 10) local startpos = {x=0,y=0} +sprRocket:setGroups({1,2,3}) local imgBigRocket = gfx.image.new("gfx/bigrocket") local imgBigFire = gfx.imagetable.new("gfx/bigrocketfire") @@ -27,8 +28,18 @@ assert(imgBigRocket) assert(imgBigFire) local loopBigFire = gfx.animation.loop.new(200,imgBigFire) local sprBigRocket = gfx.sprite.new(imgBigRocket) -sprBigRocket:setCollideRect(8,8,48,48) +sprBigRocket:setCollideRect(0,0,64,64) sprBigRocket:setGroups({2}) +sprBigRocket:setCollidesWithGroups({2}) + +local resetButton = nil + +local function die() + deaths +=1 + active = false + velocity = {x=0,y=0} + sprRocket:moveTo(startpos.x, startpos.y) +end function addPlayer(_x,_y,__x,__y) exists = true @@ -43,6 +54,9 @@ function addPlayer(_x,_y,__x,__y) sprRocket:moveTo(_x,_y) sprRocket:add() sprRocket:setVisible(true) + resetButton = playdate.getSystemMenu():addMenuItem("respawn", function() + die() + end) end function killPlayer() @@ -51,10 +65,12 @@ function killPlayer() sprRocket:remove() sprBigRocket:remove() gfx.setDrawOffset(0,0) + if resetButton ~= nil then playdate.getSystemMenu():removeMenuItem(resetButton) end end local function playerWin() if active then + playdate.getSystemMenu():removeMenuItem(resetButton) song:stop() song:load("sfx/song3") song:play(1) @@ -96,13 +112,6 @@ local function playerWin() end -local function die() - deaths +=1 - active = false - velocity = {x=0,y=0} - sprRocket:moveTo(startpos.x, startpos.y) -end - function updatePlayer() playdate.timer.updateTimers() sprRocket:setImage(imgRocket) @@ -155,7 +164,7 @@ function updatePlayer() end function updateExit() - if sprBigRocket:alphaCollision(sprRocket) and energy == totalEnergy then + if #sprBigRocket:overlappingSprites() > 0 and energy == totalEnergy then playerWin() end end diff --git a/Source/Saws.lua b/Source/Saws.lua index 73c03d0..fef69e5 100644 --- a/Source/Saws.lua +++ b/Source/Saws.lua @@ -75,8 +75,9 @@ function loadFuel(_fuel) for i = 1, #_fuel, 1 do local fuel = _fuel[i] fuels[i] = gfx.sprite.new() - fuels[i]:moveTo(fuel.x,fuel.y) + fuels[i]:moveTo(fuel.x+15,fuel.y+15) fuels[i]:setGroups({2}) + fuels[i]:setCollidesWithGroups({3}) fuels[i].active = true fuels[i]:setZIndex(1) fuels[i]:setCollideRect(-6,-6 ,30,30) diff --git a/Source/data/level.rocketbyte b/Source/data/level.rocketbyte deleted file mode 100644 index d66fadc..0000000 --- a/Source/data/level.rocketbyte +++ /dev/null @@ -1 +0,0 @@ -{"bigrocket":{"x":73.333333,"y":144.79638},"song":"song6","next":"data/level2.rocketbyte","fuel":[{"x":73.333333,"y":100}],"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]} \ No newline at end of file diff --git a/Source/data/level2.rocketbyte b/Source/data/level2.rocketbyte deleted file mode 100644 index adfaa7c..0000000 --- a/Source/data/level2.rocketbyte +++ /dev/null @@ -1 +0,0 @@ -{"bigrocket":{"x":73.333333,"y":144.79638},"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]} \ No newline at end of file diff --git a/Source/gfx/bButton.png b/Source/gfx/bButton.png new file mode 100644 index 0000000000000000000000000000000000000000..64027fa9d56cbf83eb7c57826e1c29a405e744fd GIT binary patch literal 210 zcmV;@04@KCP)D83t<`T_wR|A;ze+=OMo6G7AyhzN<=CF~-{^MP}0f|6YF1KSyc>n+a M07*qoM6N<$g4$SH0ssI2 literal 0 HcmV?d00001 diff --git a/Source/gfx/eye.png b/Source/gfx/eye.png index ae657a1392b0c1ce5cfcd8ac2ce37e28ad39551d..e75fc8b375b11b6a9622afbeb5b5bc65c5d5ab20 100644 GIT binary patch delta 124 zcmV-?0E7S60hs}iBz0g(L_t(YiS3fn3V=LO5tq5e1G751 z4iOQ9*;G!F0Jfy;HTK4x8h0hVhN;{q8b3|kdpDGu*0`FsSnm5@3gBGIifnFLV~Z`e e*y8_*&H5bvWe+PLDVU1@00008${jD1L>ogeA>Mx49Gy6{`M7u!< pgzRZRDx;(pXDgFB~}dNAeg8z+AV?*{Lk#GZsL~hi0ZVz5~79 zorY2`Y+-Eg*jo>oZ;@&(nX^q(FWq^Kg~m%(wW8V9Jil>|ULh9#XDoQ;WRyQMK92{* WWGg5C7A@`o0000AeTY)d|Y_GPuyO$!46Gc#s76gcXRT?yT>!yU95 zzBF7tXiwKV-i6aU_8_eSw{+^HjvAUZL4}Jkko`Hno7wY{ge77IE=ywum!3fcmxOBs ads`LYH*@eT3t3hG0000HI0k#2K>z>%07*qo IM6N<$f=1&+Qvd(} delta 144 zcmV;B0B`@c0jvR#B!6>BL_t(YiS3h14uBvGM5o64U%9R@+Av~~g(JQd3BSBf3(SVG z4R_y{Lq0M){k4pEw1+iumR6@hwPF&+0Duq`<;9{ZFZt)VAk)?Ju>n4vB{EtQ&O-nI00{s|MNUMnLSTXxZ9lXC diff --git a/Source/gfx/spin.png b/Source/gfx/spin.png index f05b0c42e98153c3ff5cddbace2a583e524f73c6..a0eaa14d51c7844271268fb6397c32476082bd8a 100644 GIT binary patch delta 167 zcmV;Y09gNp0>c52B!7xYL_t(YiRG3-4uBvG1dH+iU&d1p7I#~Si5r=lc14Dw!E84g zD)iomTPtI>_WX*YIN0k9(;=pCbt?I2{+aPfYO|(}=jroO#+hlXqdZ+HDPsqj#X8DU zB#lwesy#MVmom;~o?W9oaYM=&G23HmE@@o-BTemQN7A_ZoghX^d7Tr8^V>7meq8UF VBtAyKYIOhr002ovPDHLkV1kg#O+^3z delta 233 zcmV9EU^SR7cJ4$lFaY_&gu9?3Hum|#BbnRE$(g5@n?sh&&)xgBRPU7! zM)HaoVSlEGg#l2})PNLbL{%l%`)toy<$|{54r6ed7bKIs#*II zal+xJnpIET19DvR2fQusb}1wRx!U_myDHwYF^s- zg{)G=+%;uN8ml*FGsQGTNn^J|WqY`!q%kwqp`u@^?(f7n)gJ41Hj8D(hy8f~%tj|K T7T$Yn00000NkvXXu0mjfFXc>B delta 104 zcmV-u0GI#40fhmOBwc$l6$C)BYP~G4stPSE#vaH30000< KMNUMnLSTYHX)K=r