diff --git a/Source/Editor.lua b/Source/Editor.lua index e8ebc33..9407ae3 100644 --- a/Source/Editor.lua +++ b/Source/Editor.lua @@ -1,7 +1,23 @@ import "CoreLibs/keyboard" +import "CoreLibs/math" local gfx = playdate.graphics local prevtext = "" +gfx.setLineWidth(5) + +local position = {x=0,y=0} + +local bool2int = {[true]=1,[false]=0} + +local imgSwitch = gfx.imagetable.new("gfx/switch") +local imgFloppy = gfx.image.new("gfx/floppy") +assert(imgSwitch) +assert(imgFloppy) +local sprSwitch = gfx.sprite.new(imgSwitch:getImage(1)) +local sprFloppy = gfx.sprite.new(imgFloppy) + +sprSwitch:moveTo(381,47) +sprFloppy:moveTo(381,17) function newProject() mode = "newproj" @@ -19,6 +35,12 @@ function playdate.keyboard.keyboardWillHideCallback(ok) page = 0 playdate.wait(0.3) editLoad() + else + mode = "editor" + sprSwitch:add() + sprFloppy:add() + + playdate.wait(0.1) end end @@ -30,4 +52,51 @@ function playdate.keyboard.textChangedCallback() end prevtext = playdate.keyboard.text +end + +local tileIndex = 0.0 + +local curY = math.floor( tileIndex ) * 30 + 2 +local curYlerp = -32 + +function editUpdate() + + local change, aChange = playdate.getCrankChange() + + tileIndex += change * 0.01 + + curY = math.floor( tileIndex ) * 30 + 2 + + curYlerp = playdate.math.lerp(curYlerp, curY, 0.3) + + if playdate.buttonJustPressed(playdate.kButtonA) then + if math.floor( tileIndex ) == 1 then + playdate.display.setInverted(not playdate.display.getInverted()) + sprSwitch:setImage(imgSwitch:getImage(bool2int[playdate.display.getInverted()] + 1)) + end + end + + if playdate.buttonJustPressed(playdate.kButtonLeft) then + position.x -= 1 + elseif playdate.buttonJustPressed(playdate.kButtonRight) then + position.x += 1 + end + + -- draw map + gfx.setDrawOffset(position.x*16,position.y*16) + + -- draw ui + gfx.setDrawOffset(0,0) + gfx.sprite.update() + + gfx.setColor(gfx.kColorWhite) + gfx.drawLine(360,0,360,240) + + gfx.setColor(playdate.graphics.kColorXOR) + gfx.fillRect(365,curYlerp,33,30) +end + +function editClose() + sprSwitch:remove() + sprFloppy:remove() end \ No newline at end of file diff --git a/Source/Main.lua b/Source/Main.lua index c3a440a..bb6ad2c 100644 --- a/Source/Main.lua +++ b/Source/Main.lua @@ -29,8 +29,8 @@ gfx.setFont(font) gfx.setBackgroundColor(gfx.kColorBlack) song = playdate.sound.fileplayer.new("sfx/song1") -song:setVolume(0) -song:setVolume(0.5,0.5, 1) +song:setVolume(0.5) +--song:setVolume(0.5,0.5, 1) song:play(0) local imgSkull = gfx.image.new("gfx/skullEmoji") @@ -46,9 +46,11 @@ mainMenuCreation() createMenu(mainmenu) local menu = playdate.getSystemMenu() -local menuButton, error = menu:addMenuItem("Game Menu", function() +menuButton, error = menu:addMenuItem("game menu", function() if mode == "game" then playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame") + elseif mode == "editor" then + editClose() end totalEnergy = 0 showEnergy = false @@ -57,9 +59,9 @@ local menuButton, error = menu:addMenuItem("Game Menu", function() createMenu(mainmenu) end) -local devButton, error = menu:addCheckmarkMenuItem("dev stats", false, function(value) - dev = value -end) +--local devButton, error = menu:addCheckmarkMenuItem("dev stats", false, function(value) +-- dev = value +--end) --addMap("levels/level.json") @@ -97,6 +99,13 @@ function playdate.update() elseif mode == "newproj" then gfx.clear() updateNewproj() + elseif mode == "editor" then + gfx.clear() + editUpdate() + + if playdate.isCrankDocked() then + playdate.ui.crankIndicator:update() + end end if dev then local ox, oy = gfx.getDrawOffset() diff --git a/Source/Menu.lua b/Source/Menu.lua index a7b90cd..d070562 100644 --- a/Source/Menu.lua +++ b/Source/Menu.lua @@ -35,6 +35,7 @@ function mainMenuCreation() end function createMenu(items, invert) + song:setRate(1.0) killBlades() killPlayer() @@ -174,9 +175,9 @@ function menuButtonPress(name) local m = {} --barpos = 160 --logopos = -112 - m[0],m[1], m[2], m[3], m[4] = "extras", "BACK", "MUSIC BOX", "END CUTSCENE", "START CUTSCENE" + m[0],m[1], m[2], m[3], m[4], m[5] = "extras", "BACK", "MUSIC BOX", "END CUTSCENE", "START CUTSCENE", "LEVEL SELECT" if playdate.file.exists("bonusLevels.rocketbytes") then - m[5] = "EXTRA LEVELS" + m[6] = "EXTRA LEVELS" end createMenu(m) diff --git a/Source/Player.lua b/Source/Player.lua index 3b2d292..d44318c 100644 --- a/Source/Player.lua +++ b/Source/Player.lua @@ -129,7 +129,7 @@ function updatePlayer() end elseif exists == true then - if playdate.buttonJustPressed(playdate.kButtonUp) or playdate.buttonJustPressed(playdate.kButtonA) then + if (playdate.buttonJustPressed(playdate.kButtonUp) or playdate.buttonJustPressed(playdate.kButtonA)) and playdate.isCrankDocked() == false then active = true end local cx, cy = gfx.getDrawOffset() diff --git a/Source/gfx/floppy.png b/Source/gfx/floppy.png new file mode 100644 index 0000000..ea0e8a5 Binary files /dev/null and b/Source/gfx/floppy.png differ diff --git a/Source/gfx/switch-table-30-26.png b/Source/gfx/switch-table-30-26.png new file mode 100644 index 0000000..877b10d Binary files /dev/null and b/Source/gfx/switch-table-30-26.png differ