fixed menu sys
This commit is contained in:
parent
49f32674e5
commit
48d062b2f0
1 changed files with 16 additions and 10 deletions
|
@ -16,11 +16,11 @@ assert(imgBytes)
|
|||
mainmenu = {}
|
||||
function mainMenuCreation()
|
||||
mainmenu = {}
|
||||
mainmenu[3],mainmenu[2],mainmenu[1], mainmenu[0] = "START NEW GAME", "USER LEVELS", "ABOUT THE CREATOR", "mainNoPlay"
|
||||
mainmenu[4],mainmenu[3],mainmenu[2], mainmenu[1], mainmenu[0] = "START NEW GAME", "USER LEVELS", "LEVEL EDITOR", "ABOUT THE CREATOR", "mainNoPlay"
|
||||
|
||||
if playdate.datastore.read("savegame") then
|
||||
map = playdate.datastore.read("savegame").savedLevel
|
||||
mainmenu[4], mainmenu[0] = "CONTINUE", "mainPlay"
|
||||
mainmenu[5], mainmenu[0] = "CONTINUE", "mainPlay"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,17 +44,19 @@ function updateMenu()
|
|||
-- input
|
||||
local change, aChange = playdate.getCrankChange()
|
||||
|
||||
if playdate.buttonJustPressed(playdate.kButtonUp) or change < -10 then
|
||||
if playdate.buttonJustPressed(playdate.kButtonUp) then
|
||||
index -= 1
|
||||
elseif playdate.buttonJustPressed(playdate.kButtonDown) or change > 10 then
|
||||
elseif playdate.buttonJustPressed(playdate.kButtonDown) then
|
||||
index += 1
|
||||
end
|
||||
|
||||
if index < 0 then index = #menuitems -1 end
|
||||
if index > #menuitems - 1 then index = 0 end
|
||||
index += change * 0.01
|
||||
|
||||
if math.floor(index) < 0 then index = #menuitems -0.01 end
|
||||
if math.floor(index) > #menuitems - 1 then index = 0 end
|
||||
|
||||
controlX = playdate.math.lerp(controlX, 20, 0.3)
|
||||
controlY = playdate.math.lerp(controlY, (20 * index) - 1, 0.5)
|
||||
controlY = playdate.math.lerp(controlY, (20 * math.floor(index)) - 1, 0.5)
|
||||
for i = 1, #menuitems, 1 do
|
||||
local item = menuitems[i]
|
||||
gfx.drawText(item.name,controlX,item.y)
|
||||
|
@ -62,7 +64,7 @@ function updateMenu()
|
|||
imgCursor:draw(controlX - 17,controlY + (243 - (20 * #menuitems)))
|
||||
|
||||
if playdate.buttonJustPressed(playdate.kButtonA) then
|
||||
menuButtonPress(menuitems[#menuitems - index].name)
|
||||
menuButtonPress(menuitems[#menuitems - math.floor(index)].name)
|
||||
end
|
||||
|
||||
imgBytes:draw(0,0)
|
||||
|
@ -72,7 +74,7 @@ local function customLoad()
|
|||
local lvls = playdate.file.listFiles("levels")
|
||||
local m = {}
|
||||
m[0], m[1] = "customs", "BACK"
|
||||
if #lvls - (1 + (7*page)) <= 0 then page = 0 end
|
||||
if #lvls - ((7*page)) <= 0 then page = 0 end
|
||||
if #lvls < 7 then
|
||||
for i = 1, #lvls, 1 do
|
||||
m[i+1] = lvls[i]:upper()
|
||||
|
@ -113,7 +115,11 @@ function menuButtonPress(name)
|
|||
customLoad()
|
||||
elseif name == "NEXT PAGE" then
|
||||
page += 1
|
||||
customLoad()
|
||||
if menu == "customs" then
|
||||
customLoad()
|
||||
else
|
||||
editLoad()
|
||||
end
|
||||
|
||||
elseif name == "BACK" or name == "CANCEL" then
|
||||
createMenu(mainmenu)
|
||||
|
|
Loading…
Reference in a new issue