added player to editor

This commit is contained in:
PossiblyAxolotl 2022-05-23 11:23:15 -06:00
parent c5a2a585cb
commit 4d475547d5
7 changed files with 71 additions and 15 deletions

View file

@ -18,9 +18,6 @@ local imgtiles = gfx.sprite.new(tilemapEditor)
local w, h = imgtiles:getSize() local w, h = imgtiles:getSize()
imgtiles:moveTo(w/2,h/2) imgtiles:moveTo(w/2,h/2)
local position = {x=100,y=100}
local positionLerp = {x=0,y=0}
local bool2int = {[true]=1,[false]=0} local bool2int = {[true]=1,[false]=0}
local menu = playdate.getSystemMenu() local menu = playdate.getSystemMenu()
local toolTipButton local toolTipButton
@ -35,18 +32,33 @@ local imgLine = gfx.image.new("gfx/line")
local imgSpin = gfx.image.new("gfx/spin") local imgSpin = gfx.image.new("gfx/spin")
local imgCursor = gfx.image.new("gfx/cursor2") local imgCursor = gfx.image.new("gfx/cursor2")
local imgCant = gfx.image.new("gfx/nothing") local imgCant = gfx.image.new("gfx/nothing")
assert(imgSwitch) local imgSquare = gfx.image.new("gfx/square")
local imgRocket = gfx.image.new("gfx/start")
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")
assert(imgFloppy) assert(imgFloppy)
assert(imgAdd) assert(imgAdd)
assert(imgMus) assert(imgMus)
assert(imgLine) assert(imgLine)
assert(imgSpin) assert(imgSpin)
assert(imgCursor) assert(imgCursor)
assert(imgSquare)
assert(imgRocket)
assert(imgEye)
assert(imgPlayer)
assert(imgPlayerExit)
local animFloppy = gfx.animation.loop.new(100, imgFloppy) local animFloppy = gfx.animation.loop.new(100, imgFloppy)
local saveTime = 0 local saveTime = 0
local playerPos = {x=100,y=100}
local exitPos = {x = 105, y = 100}
local position = {x=100,y=100}
local positionLerp = {x=0,y=0}
function newProject() function newProject()
mode = "newproj" mode = "newproj"
playdate.keyboard.show("NEW LEVEL") playdate.keyboard.show("NEW LEVEL")
@ -59,8 +71,9 @@ function updateNewproj()
end end
function editLoadName(name) function editLoadName(name)
position = {x=100,y=100}
local data = json.decodeFile("levels/"..name) local data = json.decodeFile("levels/"..name)
playerPos = {x = data.rocket.x, y = data.rocket.y}
position = {x = data.rocket.x, y = data.rocket.y}
levelname = name:match("(.+)%..+$") levelname = name:match("(.+)%..+$")
inverted = data.inverted inverted = data.inverted
printTable(data) printTable(data)
@ -95,7 +108,8 @@ function playdate.keyboard.keyboardWillHideCallback(ok)
playdate.wait(0.3) playdate.wait(0.3)
editLoad() editLoad()
else else
position = {x=100,y=100} position = {x=89,y=93}
playerPos = {x=100,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
@ -135,7 +149,7 @@ 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},"levels/"..levelname) playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos},"levels/"..levelname)
end end
function editUpdate() function editUpdate()
@ -161,6 +175,12 @@ function editUpdate()
tilemapEditor:setTileAtPosition(position.x+12,position.y+8,2) tilemapEditor:setTileAtPosition(position.x+12,position.y+8,2)
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
playerPos = {x = position.x + 11, y = position.y + 7}
elseif math.floor(tileIndex) == 5 then
exitPos = {x = position.x + 11, y = position.y + 7}
elseif math.floor(tileIndex) == 7 then
editor = "view"
end end
end end
end end
@ -177,6 +197,9 @@ function editUpdate()
end end
imgtiles = gfx.sprite.new(tilemapEditor) imgtiles = gfx.sprite.new(tilemapEditor)
end end
elseif editor == "view" then
editor = "main"
tileIndex = 7.5
end end
end end
@ -200,9 +223,16 @@ function editUpdate()
gfx.setDrawOffset(-positionLerp.x, -positionLerp.y) gfx.setDrawOffset(-positionLerp.x, -positionLerp.y)
imgtiles:update() imgtiles:update()
imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16) imgPlayer:draw((playerPos.x * 16) + 2,playerPos.y * 16)
--gfx.setColor(playdate.graphics.kColorXOR) imgPlayerExit:draw(exitPos.x * 16, exitPos.y * 16)
--gfx.fillRect((position.x + 11) * 16, (position.y + 7) * 16,16,16)
if editor ~= "view" then
imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16)
end
--[[
gfx.setColor(playdate.graphics.kColorXOR)
gfx.fillRect(((position.x + 11) * 16) + 3, ((position.y + 7) * 16) + 3,10,10)
]]
if position.y < 1 then if position.y < 1 then
imgCant:drawTiled((position.x-1) * 16,-112,400,112) imgCant:drawTiled((position.x-1) * 16,-112,400,112)
end end
@ -211,6 +241,7 @@ function editUpdate()
end end
-- draw ui/ -- draw ui/
if editor ~= "view" then
gfx.setDrawOffset(0,0) gfx.setDrawOffset(0,0)
gfx.setColor(gfx.kColorBlack) gfx.setColor(gfx.kColorBlack)
gfx.fillRect(362,0,400,240) gfx.fillRect(362,0,400,240)
@ -220,15 +251,39 @@ function editUpdate()
-- draw changes -- draw changes
if editor == "main" then if editor == "main" then
imgMus:draw(366, 128) imgMus:draw(366, 176)
imgAdd:draw(366,8) imgAdd:draw(366,8)
imgLine:draw(366,36) imgLine:draw(366,64)
imgSpin:draw(366,64) imgSpin:draw(366,92)
imgSquare:draw(366,36)
imgRocket:draw(366, 120)
imgExit:draw(366,148)
imgEye:draw(366,204)
if math.floor( tileIndex ) == 0 then
gfx.drawText("TILES",0,0)
elseif math.floor( tileIndex ) == 1 then
gfx.drawText("FUEL",0,0)
elseif math.floor( tileIndex ) == 2 then
gfx.drawText("MOVERS",0,0)
elseif math.floor( tileIndex ) == 3 then
gfx.drawText("SPINNERS",0,0)
elseif math.floor( tileIndex ) == 4 then
gfx.drawText("PLAYER",0,0)
elseif math.floor( tileIndex ) == 5 then
gfx.drawText("EXIT",0,0)
elseif math.floor( tileIndex ) == 6 then
gfx.drawText("MUSIC",0,0)
elseif math.floor( tileIndex ) == 7 then
gfx.drawText("VIEW",0,0)
end
end end
gfx.setColor(playdate.graphics.kColorXOR) gfx.setColor(playdate.graphics.kColorXOR)
gfx.fillRect(365,curYlerp,33,28) gfx.fillRect(365,curYlerp,33,28)
end
if saveTime > 0 then if saveTime > 0 then
saveTime -= 0.1 saveTime -= 0.1
animFloppy:draw(2,2) animFloppy:draw(2,2)

View file

@ -112,6 +112,7 @@ function playdate.gameWillTerminate()
end end
function playdate.debugDraw() function playdate.debugDraw()
gfx.setDrawOffset(0,0)
playdate.drawFPS(0,228) playdate.drawFPS(0,228)
small:drawText(math.floor( playdate.getCrankPosition() ), 0, 218) small:drawText(math.floor( playdate.getCrankPosition() ), 0, 218)
end end

View file

@ -1 +1 @@
{"bigrocket":{"x":73.333333,"y":144.79638},"song":"song5","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}]} {"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}]}

BIN
Source/gfx/exit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
Source/gfx/eye.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

BIN
Source/gfx/start.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

View file

@ -5,4 +5,4 @@ bundleID=com.PossiblyAxolotl.RocketBytes
version=DEV version=DEV
buildNumber=1 buildNumber=1
imagePath=launcher imagePath=launcher
contentWarning=This game requires extremely precise and quick crank movement. contentWarning=This game requires extremely precise and quick movement of the crank.