editorStart

This commit is contained in:
PossiblyAxolotl 2022-05-20 11:01:59 -06:00
parent f8ae182277
commit cdfec95084
6 changed files with 88 additions and 9 deletions

View file

@ -1,7 +1,23 @@
import "CoreLibs/keyboard"
import "CoreLibs/math"
local gfx <const> = 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

View file

@ -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()

View file

@ -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)

View file

@ -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()

BIN
Source/gfx/floppy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B