bein't a dumbass

This commit is contained in:
PossiblyAxolotl 2022-05-23 11:55:20 -06:00
parent e57bb4d991
commit 2543f4e11f
2 changed files with 10 additions and 7 deletions

View file

@ -73,7 +73,8 @@ end
function editLoadName(name) function editLoadName(name)
local data = json.decodeFile("levels/"..name) local data = json.decodeFile("levels/"..name)
playerPos = {x = data.rocket.x, y = data.rocket.y} playerPos = {x = data.rocket.x, y = data.rocket.y}
position = {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}
levelname = name:match("(.+)%..+$") levelname = name:match("(.+)%..+$")
inverted = data.inverted inverted = data.inverted
printTable(data) printTable(data)
@ -110,6 +111,7 @@ function playdate.keyboard.keyboardWillHideCallback(ok)
else else
position = {x=89,y=93} position = {x=89,y=93}
playerPos = {x=100,y=100} playerPos = {x=100,y=100}
exitPos = {x = 105, y = 100}
for tile = 1, #tiles, 1 do for tile = 1, #tiles, 1 do
tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0) tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0)
end end
@ -149,10 +151,11 @@ local curYlerp = -32
function editSave() function editSave()
playdate.datastore.delete("levels/"..levelname..".json") playdate.datastore.delete("levels/"..levelname..".json")
saveTime = 5 saveTime = 5
playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos},"levels/"..levelname) playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos},"levels/"..levelname)
end end
function editUpdate() function editUpdate()
printTable(exitPos)
local change, aChange = playdate.getCrankChange() local change, aChange = playdate.getCrankChange()
@ -176,9 +179,9 @@ function editUpdate()
tiles[#tiles+1] = {x=position.x + 12, y=position.y + 8, t=2} tiles[#tiles+1] = {x=position.x + 12, y=position.y + 8, t=2}
imgtiles = gfx.sprite.new(tilemapEditor) imgtiles = gfx.sprite.new(tilemapEditor)
elseif math.floor(tileIndex) == 4 then elseif math.floor(tileIndex) == 4 then
playerPos = {x = position.x + 11, y = position.y + 7} playerPos = {x = ((position.x + 11) * 16) + 2, y = ((position.y + 7) * 16)+1}
elseif math.floor(tileIndex) == 5 then elseif math.floor(tileIndex) == 5 then
exitPos = {x = position.x + 11, y = position.y + 7} exitPos = {x = (position.x + 11) * 16, y = (position.y + 7) * 16}
elseif math.floor(tileIndex) == 7 then elseif math.floor(tileIndex) == 7 then
editor = "view" editor = "view"
end end
@ -223,8 +226,8 @@ function editUpdate()
gfx.setDrawOffset(-positionLerp.x, -positionLerp.y) gfx.setDrawOffset(-positionLerp.x, -positionLerp.y)
imgtiles:update() imgtiles:update()
imgPlayer:draw((playerPos.x * 16) + 2,playerPos.y * 16) imgPlayerExit:draw(exitPos.x, exitPos.y)
imgPlayerExit:draw(exitPos.x * 16, exitPos.y * 16) imgPlayer:draw(playerPos.x,playerPos.y)
if editor ~= "view" then if editor ~= "view" then
imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16) imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16)

View file

@ -49,7 +49,7 @@ function addMap(_file, rs)
if level.rotators then loadSpins(level.rotators) end if level.rotators then loadSpins(level.rotators) end
if level.fuel then loadFuel(level.fuel) end if level.fuel then loadFuel(level.fuel) end
if level.next then next = level.next end if level.next then next = level.next end
addPlayer(level.rocket.x+14,level.rocket.y+14, level.bigrocket.x+24, level.bigrocket.y+24) addPlayer(level.rocket.x+14,level.rocket.y+15, level.bigrocket.x+32, level.bigrocket.y+32)
tiles = gfx.sprite.addWallSprites(tilemap, {0,1,6,7,8,10,11,12}) tiles = gfx.sprite.addWallSprites(tilemap, {0,1,6,7,8,10,11,12})