HOLY SHIT I FIXED THE CRASH FR THIS TIME
This commit is contained in:
parent
4ff84eb6ba
commit
a2d5a9d92d
3 changed files with 17 additions and 28 deletions
|
@ -6,7 +6,6 @@ local gfx <const> = playdate.graphics
|
|||
local prevtext = ""
|
||||
local levelname = nil
|
||||
local inverted = false
|
||||
gfx.setLineWidth(5)
|
||||
|
||||
local tileTable <const> = gfx.imagetable.new("gfx/tiles")
|
||||
local tilemapEditor = gfx.tilemap.new()
|
||||
|
@ -20,7 +19,6 @@ local w, h = imgtiles:getSize()
|
|||
imgtiles:moveTo(w/2,h/2)
|
||||
|
||||
local bool2int = {[true]=1,[false]=0}
|
||||
local menu = playdate.getSystemMenu()
|
||||
local toolTipButton
|
||||
local altClrButton
|
||||
|
||||
|
@ -83,36 +81,27 @@ end
|
|||
function editLoadName(name)
|
||||
song:stop()
|
||||
mode = "editor"
|
||||
playdate.wait(0.1)
|
||||
local data = json.decodeFile("levels/"..name)
|
||||
playdate.wait(0.1)
|
||||
powers = data.fuel
|
||||
sawblades = data.saws
|
||||
playerPos = {x = data.rocket.x, y = data.rocket.y}
|
||||
exitPos = {x = data.bigrocket.x, y = data.bigrocket.y}
|
||||
position = {x = (data.rocket.x + 6) / 16, y = (data.rocket.y + 4)/16}
|
||||
playdate.wait(0.1)
|
||||
levelname = name:match("(.+)%..+$")
|
||||
inverted = data.inverted
|
||||
playdate.display.setInverted(data.inverted)
|
||||
saveTime = 0
|
||||
playdate.wait(0.1)
|
||||
|
||||
-- loading tiles
|
||||
for tile = 1, #tiles, 1 do
|
||||
tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0)
|
||||
end
|
||||
playdate.wait(0.1)
|
||||
for tile = 1, #data.tiles, 1 do
|
||||
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
|
||||
playdate.wait(0.1)
|
||||
altClrButton = menu:addCheckmarkMenuItem("alt colours",inverted, function(value)
|
||||
altClrButton = playdate.getSystemMenu():addCheckmarkMenuItem("alt colours",inverted, function(value)
|
||||
playdate.display.setInverted(value)
|
||||
inverted = value
|
||||
end)
|
||||
toolTipButton = menu:addMenuItem("save", function()
|
||||
toolTipButton = playdate.getSystemMenu():addMenuItem("save", function()
|
||||
editSave()
|
||||
end)
|
||||
|
||||
|
@ -127,7 +116,6 @@ function playdate.keyboard.keyboardWillHideCallback(ok)
|
|||
else
|
||||
song:stop()
|
||||
mode = "editor"
|
||||
playdate.wait(0.1)
|
||||
position = {x=89,y=93}
|
||||
playerPos = {x=1562,y=1564}
|
||||
exitPos = {x = 1616, y = 1536}
|
||||
|
@ -135,20 +123,16 @@ function playdate.keyboard.keyboardWillHideCallback(ok)
|
|||
playdate.display.setInverted(false)
|
||||
saveTime = 0
|
||||
song:stop()
|
||||
mode = "editor"
|
||||
playdate.wait(0.1)
|
||||
altClrButton, error = menu:addCheckmarkMenuItem("alt colours",false, function(value)
|
||||
playdate.getSystemMenu():addCheckmarkMenuItem("alt colours",false, function(value)
|
||||
playdate.display.setInverted(value)
|
||||
inverted = value
|
||||
end)
|
||||
toolTipButton, error = menu:addMenuItem("save",false, function()
|
||||
playdate.getSystemMenu():addMenuItem("save",false, function()
|
||||
editSave()
|
||||
end)
|
||||
playdate.wait(0.1)
|
||||
|
||||
levelname = playdate.keyboard.text:upper()
|
||||
imgtiles:add()
|
||||
playdate.wait(0.1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -410,7 +394,9 @@ function editClose()
|
|||
playdate.display.setInverted(false)
|
||||
imgtiles = gfx.sprite.new(tilemapEditor)
|
||||
imgtiles:remove()
|
||||
playdate.getSystemMenu():removeMenuItem(toolTipButton)
|
||||
playdate.getSystemMenu():removeMenuItem(altClrButton)
|
||||
if #playdate.getSystemMenu():getMenuItems() > 1 then
|
||||
playdate.getSystemMenu():removeMenuItem(playdate.getSystemMenu():getMenuItems()[3])
|
||||
playdate.getSystemMenu():removeMenuItem(playdate.getSystemMenu():getMenuItems()[2])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -182,6 +182,7 @@ end
|
|||
function menuButtonPress(name)
|
||||
logopos = 0
|
||||
barpos = 0
|
||||
|
||||
if name == "START NEW GAME" and menu == "mainPlay" then
|
||||
local m = {}
|
||||
m[0], m[1], m[2] = "newgame", "CANCEL", "CONFIRM"
|
||||
|
@ -226,14 +227,15 @@ function menuButtonPress(name)
|
|||
|
||||
elseif name == "BACK" or name == "CANCEL" or name == "MENU" then
|
||||
createMenu(mainmenu)
|
||||
|
||||
elseif menu == "edits" then
|
||||
mode = "editor"
|
||||
menu = nil
|
||||
editLoadName(name)
|
||||
elseif menu == "customs" then
|
||||
addMap("levels/"..name, true)
|
||||
mode = "play"
|
||||
elseif menu == "data" then
|
||||
addMap("data/"..name, true)
|
||||
mode = "play"
|
||||
elseif menu == "edits" then
|
||||
editLoadName(name)
|
||||
end
|
||||
end
|
|
@ -63,7 +63,7 @@ function addPlayer(_x,_y,__x,__y)
|
|||
end
|
||||
|
||||
function killPlayer()
|
||||
rocketfly = nil
|
||||
song:setFinishCallback(nil)
|
||||
exists = false
|
||||
active = false
|
||||
sprRocket:remove()
|
||||
|
@ -94,24 +94,25 @@ local function playerWin()
|
|||
end)
|
||||
|
||||
song:setFinishCallback(function()
|
||||
song:setFinishCallback(nil)
|
||||
if next then
|
||||
map = next
|
||||
end
|
||||
totalEnergy = 0
|
||||
showEnergy = false
|
||||
energy = 0
|
||||
killBlades()
|
||||
killPlayer()
|
||||
removeMap()
|
||||
killBlades()
|
||||
if mode == "game" and next then
|
||||
playdate.datastore.delete("savegame")
|
||||
playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame")
|
||||
next = nil
|
||||
addMapSave(map)
|
||||
else
|
||||
next = nil
|
||||
mainMenuCreation()
|
||||
createMenu(mainmenu)
|
||||
next = nil
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
Loading…
Reference in a new issue