editorStart
This commit is contained in:
parent
f8ae182277
commit
cdfec95084
6 changed files with 88 additions and 9 deletions
|
@ -1,7 +1,23 @@
|
||||||
import "CoreLibs/keyboard"
|
import "CoreLibs/keyboard"
|
||||||
|
import "CoreLibs/math"
|
||||||
|
|
||||||
local gfx <const> = playdate.graphics
|
local gfx <const> = playdate.graphics
|
||||||
local prevtext = ""
|
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()
|
function newProject()
|
||||||
mode = "newproj"
|
mode = "newproj"
|
||||||
|
@ -19,6 +35,12 @@ function playdate.keyboard.keyboardWillHideCallback(ok)
|
||||||
page = 0
|
page = 0
|
||||||
playdate.wait(0.3)
|
playdate.wait(0.3)
|
||||||
editLoad()
|
editLoad()
|
||||||
|
else
|
||||||
|
mode = "editor"
|
||||||
|
sprSwitch:add()
|
||||||
|
sprFloppy:add()
|
||||||
|
|
||||||
|
playdate.wait(0.1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,3 +53,50 @@ function playdate.keyboard.textChangedCallback()
|
||||||
|
|
||||||
prevtext = playdate.keyboard.text
|
prevtext = playdate.keyboard.text
|
||||||
end
|
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
|
|
@ -29,8 +29,8 @@ gfx.setFont(font)
|
||||||
gfx.setBackgroundColor(gfx.kColorBlack)
|
gfx.setBackgroundColor(gfx.kColorBlack)
|
||||||
|
|
||||||
song = playdate.sound.fileplayer.new("sfx/song1")
|
song = playdate.sound.fileplayer.new("sfx/song1")
|
||||||
song:setVolume(0)
|
song:setVolume(0.5)
|
||||||
song:setVolume(0.5,0.5, 1)
|
--song:setVolume(0.5,0.5, 1)
|
||||||
song:play(0)
|
song:play(0)
|
||||||
|
|
||||||
local imgSkull = gfx.image.new("gfx/skullEmoji")
|
local imgSkull = gfx.image.new("gfx/skullEmoji")
|
||||||
|
@ -46,9 +46,11 @@ mainMenuCreation()
|
||||||
createMenu(mainmenu)
|
createMenu(mainmenu)
|
||||||
|
|
||||||
local menu = playdate.getSystemMenu()
|
local menu = playdate.getSystemMenu()
|
||||||
local menuButton, error = menu:addMenuItem("Game Menu", function()
|
menuButton, error = menu:addMenuItem("game menu", function()
|
||||||
if mode == "game" then
|
if mode == "game" then
|
||||||
playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame")
|
playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame")
|
||||||
|
elseif mode == "editor" then
|
||||||
|
editClose()
|
||||||
end
|
end
|
||||||
totalEnergy = 0
|
totalEnergy = 0
|
||||||
showEnergy = false
|
showEnergy = false
|
||||||
|
@ -57,9 +59,9 @@ local menuButton, error = menu:addMenuItem("Game Menu", function()
|
||||||
createMenu(mainmenu)
|
createMenu(mainmenu)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local devButton, error = menu:addCheckmarkMenuItem("dev stats", false, function(value)
|
--local devButton, error = menu:addCheckmarkMenuItem("dev stats", false, function(value)
|
||||||
dev = value
|
-- dev = value
|
||||||
end)
|
--end)
|
||||||
|
|
||||||
--addMap("levels/level.json")
|
--addMap("levels/level.json")
|
||||||
|
|
||||||
|
@ -97,6 +99,13 @@ function playdate.update()
|
||||||
elseif mode == "newproj" then
|
elseif mode == "newproj" then
|
||||||
gfx.clear()
|
gfx.clear()
|
||||||
updateNewproj()
|
updateNewproj()
|
||||||
|
elseif mode == "editor" then
|
||||||
|
gfx.clear()
|
||||||
|
editUpdate()
|
||||||
|
|
||||||
|
if playdate.isCrankDocked() then
|
||||||
|
playdate.ui.crankIndicator:update()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if dev then
|
if dev then
|
||||||
local ox, oy = gfx.getDrawOffset()
|
local ox, oy = gfx.getDrawOffset()
|
||||||
|
|
|
@ -35,6 +35,7 @@ function mainMenuCreation()
|
||||||
end
|
end
|
||||||
|
|
||||||
function createMenu(items, invert)
|
function createMenu(items, invert)
|
||||||
|
song:setRate(1.0)
|
||||||
killBlades()
|
killBlades()
|
||||||
killPlayer()
|
killPlayer()
|
||||||
|
|
||||||
|
@ -174,9 +175,9 @@ function menuButtonPress(name)
|
||||||
local m = {}
|
local m = {}
|
||||||
--barpos = 160
|
--barpos = 160
|
||||||
--logopos = -112
|
--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
|
if playdate.file.exists("bonusLevels.rocketbytes") then
|
||||||
m[5] = "EXTRA LEVELS"
|
m[6] = "EXTRA LEVELS"
|
||||||
end
|
end
|
||||||
createMenu(m)
|
createMenu(m)
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ function updatePlayer()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif exists == true then
|
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
|
active = true
|
||||||
end
|
end
|
||||||
local cx, cy = gfx.getDrawOffset()
|
local cx, cy = gfx.getDrawOffset()
|
||||||
|
|
BIN
Source/gfx/floppy.png
Normal file
BIN
Source/gfx/floppy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 179 B |
BIN
Source/gfx/switch-table-30-26.png
Normal file
BIN
Source/gfx/switch-table-30-26.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 202 B |
Loading…
Reference in a new issue