Added proper cursor to menu and started selection

This commit is contained in:
PossiblyAxolotl 2022-04-22 23:50:57 -06:00
parent e8c43c72df
commit c9368c4031
6 changed files with 106 additions and 7 deletions

View file

@ -8,7 +8,7 @@ local mode = "menu"
local gfx <const> = playdate.graphics local gfx <const> = playdate.graphics
local disp <const> = playdate.display local disp <const> = playdate.display
local font <const> = gfx.font.new("gfx/font") local font <const> = gfx.font.new("gfx/big")
gfx.setFont(font) gfx.setFont(font)
gfx.setBackgroundColor(gfx.kColorBlack) gfx.setBackgroundColor(gfx.kColorBlack)
@ -17,6 +17,14 @@ local song1 <const> = playdate.sound.sampleplayer.new("sfx/song1")
song1:play(0, 1) song1:play(0, 1)
gfx.setColor(gfx.kColorWhite) gfx.setColor(gfx.kColorWhite)
-- {"START NEW GAME","CONTINUE","USER LEVELS", "EXIT"}
local mainmenu = {}
if playdate.datastore.read("savegame") then
mainmenu[4],mainmenu[3],mainmenu[2],mainmenu[1], mainmenu[0] = "START NEW GAME", "CONTINE", "USER LEVELS", "ABOUT THE CREATOR", "mainPlay"
else
mainmenu[3],mainmenu[2],mainmenu[1], mainmenu[0] = "START NEW GAME", "USER LEVELS", "ABOUT THE CREATOR", "mainNoPlay"
end
createMenu(mainmenu)
--addMap("levels/level1.json") --addMap("levels/level1.json")

View file

@ -1,16 +1,47 @@
local gfx <const> = playdate.graphics local gfx <const> = playdate.graphics
local controlY = 0 local controlY = 0
local controlX = 0
local crankY = 0 local index = 0
local menuitems = {}
local menu = null
local imgCursor = gfx.image.new("gfx/cursor")
assert(imgCursor)
function createMenu(items)
controlX = -80
index = 0
menuitems = {}
local _y =220
menu = items[0]
for i=1, #items, 1 do
menuitems[i] = {name=items[i],y=_y}
_y -= 20
end
end
function updateMenu() function updateMenu()
gfx.clear(gfx.kColorBlack) gfx.clear(gfx.kColorBlack)
-- input -- input
if playdate.buttonJustPressed(playdate.kButtonUp) then local change, aChange = playdate.getCrankChange()
crankY -= 1
elseif playdate.buttonJustPressed(playdate.kButtonDown) then if playdate.buttonJustPressed(playdate.kButtonUp) or change < -10 then
crankY += 1 index -= 1
elseif playdate.buttonJustPressed(playdate.kButtonDown) or change > 10 then
index += 1
end end
gfx.fillRect(0,controlY + (10 * crankY),50,10) if index < 0 then index = #menuitems -1 end
if 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)
print(index)
imgCursor:draw(3,controlY + (243 - (20 * #menuitems)))
for i = 1, #menuitems, 1 do
local item = menuitems[i]
gfx.drawText(item.name,controlX,item.y)
end
end end

60
Source/gfx/big.fnt Normal file
View file

@ -0,0 +1,60 @@
--metrics={"baseline":26,"xHeight":2,"capHeight":2,"pairs":{},"left":[],"right":[]}
datalen=3208
data=iVBORw0KGgoAAAANSUhEUgAAAHAAAAB+CAYAAAD86pU7AAAJLElEQVR4Xu1d7WLsKgg8ff+H7ul+JFUDzoBoki73V29XIzIMDJo9/fp3/O9b+N3jV1/K79tfb/Ot49vnoPlWOzW7kL3aOqy9XjuRu5/+kZxkXTABfHlACzirP00BUy76nPj9Lc//+tqHdg3d5lvHH8JZX89qZzW+sOu5ZMfe7jqEvUN2Qvq9/ZMAvgNWCLjbAEhF6BYR7EY7DOyut60jMENjTBWs1nksA1vmCgzZyODdXzVfY2Br72NSAvgoYMeUTQFROPq2AO6kATUFiZ2q+CJmsBHqYLQJCEG8eIFHZU98bgQDE8Da9dcAsGUAoS41w6l+rlW/bA0dVYOj81Hq1WhFqHSKGCoDE8C9r5vSDkwDUFCbqF+iIkWIRJRqrI0xslNscNnMElVzOzW53S+V0Q4MTAAPJyrdkxFr23JFAJF63GPi/QNi3qEsWeYRjGIzBmXnBAAp5pVOFXO89cgJyfVCblOOmdBfiW0Malc0gNB+HfNQ+yKWlJGjNO9RU1WrUPNjVXlR4qCwyypiRIZb1S67jwRQPwv1AuGdZ0qdbV0qA0Qr2i5VKKTCaoOIgUXqFVOgMB/1ndpz0DyrX9A+kT+RPc/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pe88qz+4pqJzEhO1ILthdtzdj8RG90kBO3KUNprzrRu0jl9tXxQRKODKGlg5Zv9A//csz2JGAih4PuI6SYx0q1qbOH61fZoYMTGLHZwAYk95L2a987BFxQj20rb30FFDt/ntGhG2mZxxx8ERTkoAT0ReSqEsqKGi4kA/u4g60Y3nLZ0Anuf7kJUPfSDxLsxov6Mxt9qQ4wwxxCF3e0gCeDfEGntPT6FC/zdaW28Oic38BNDmr8uNZhWnZHg0U6KfdzlnzzAoAZzh1YXPPDOFjqrZhW667lIJ4HWxoSwbaSMqBglqkjKgGDR6JGdd70+MTwBvDmOm0ATwlfkMR3Cty7J9GAiikTYia+CA46OmJoBRnjzpOf8BzZYDOdc3yrYAAAAASUVORK5CYII=
width=14
height=18
tracking=1
0 14
1 14
2 14
3 14
4 14
5 14
6 14
7 14
8 14
9 14
space 12
<EFBFBD> 14
A 14
B 14
C 14
D 14
E 14
F 14
G 14
H 14
I 14
J 14
K 14
L 14
M 14
N 14
O 14
@ 4
P 14
Q 14
R 14
S 14
T 14
U 14
V 14
W 14
X 14
Y 14
Z 14
[ 8
] 8
\ 10
( 8
) 8
{ 8
| 6
} 8
~ 12
: 6
! 6
? 14

BIN
Source/gfx/cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

BIN
Source/gfx/play.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.