tiles work

This commit is contained in:
PossiblyAxolotl 2022-06-05 13:14:47 -06:00
parent 76c8189f06
commit df2c9be328
7 changed files with 8868 additions and 4 deletions

View file

@ -39,6 +39,7 @@ 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")
local imgExitMen = gfx.image.new("gfx/leave")
assert(imgFloppy)
assert(imgAdd)
assert(imgMus)
@ -76,7 +77,9 @@ end
function editLoadName(name)
song:stop()
playdate.wait(0.1)
local data = json.decodeFile("levels/"..name)
playdate.wait(0.1)
powers = data.fuel
playerPos = {x = data.rocket.x, y = data.rocket.y}
exitPos = {x = data.bigrocket.x, y = data.bigrocket.y}
@ -86,15 +89,18 @@ function editLoadName(name)
playdate.display.setInverted(data.inverted)
saveTime = 0
mode = "editor"
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)
playdate.display.setInverted(value)
inverted = value
@ -104,7 +110,6 @@ function editLoadName(name)
end)
imgtiles:add()
playdate.wait(0.1)
end
function playdate.keyboard.keyboardWillHideCallback(ok)
@ -156,7 +161,7 @@ local curYlerp = -32
function editSave()
playdate.datastore.delete("levels/"..levelname..".json")
saveTime = 5
playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos, fuel = powers},"levels/"..levelname)
playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos, fuel = powers,saws={},rotators={}},"levels/"..levelname)
end
function editUpdate()
@ -171,7 +176,8 @@ function editUpdate()
curY = math.floor( tileIndex ) * 28 +7
elseif editor == "tiles" then
if tileIndex < 0 then tileIndex = 0 end
if tileIndex < 0 then tileIndex = #tileTable-.1 end
if tileIndex > #tileTable then tileIndex = 0 end
curY = (math.floor( tileIndex ) % 8) * 28 +7
end
@ -296,6 +302,15 @@ function editUpdate()
-- draw changes
if editor == "tiles" then
gfx.drawText("A TO PLACE \nB TO DELETE",0,0)
local ind = math.floor( tileIndex / 8 ) * 8
if tileIndex < 8 then imgExitMen:draw(366,8) else tileTable[1+ind]:draw(373,13) end
tileTable[2+ind]:draw(373,41)
tileTable[3+ind]:draw(373,69)
tileTable[4+ind]:draw(373,97)
tileTable[5+ind]:draw(373,125)
tileTable[6+ind]:draw(373,153)
tileTable[7+ind]:draw(373,181)
tileTable[8+ind]:draw(373,209)
elseif editor == "main" then
imgMus:draw(366, 176)
imgAdd:draw(366,8)

View file

@ -51,7 +51,7 @@ function addMap(_file, rs)
if level.next then next = level.next end
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,7,8,9,10,11,12,13,14,15,16})
sprTiles:remove()
sprTiles = gfx.sprite.new(tilemap)

1271
Source/data/LEVEL 2.json Normal file

File diff suppressed because it is too large Load diff

7578
Source/data/LEVEL.json Normal file

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 B

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 471 B

After

Width:  |  Height:  |  Size: 484 B