-
Notifications
You must be signed in to change notification settings - Fork 1
/
menu.p8
112 lines (104 loc) · 2.91 KB
/
menu.p8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
pico-8 cartridge // http://www.pico-8.com
version 16
__lua__
state = 0
selection = 1
s_ticks = 0
function _init()
-- prepare games list
games = ls()
del(games,'menu.p8')
for x=1,#games do
local g = games[x]
games[x] = sub(g,1,#g-3)
end
-- custom escape menu
menuitem(5,'shutdown', function() shutdown() end)
end
function _draw()
rectfill(0,0,127,127,0)
if (state==0) then loading() end
if (state==1) then interface() end
end
function _update()
if (state == 1) then
if (btnp(5)) then
load(games[selection]..'.p8')
run()
end
if (btnp(2)) then
if (selection <= 1) then
selection = #games
else
selection -= 1
end
end
if (btnp(3)) then
if (selection >= #games) then
selection = 1
else
selection += 1
end
end
end
end
function loading()
state = 1
end
function interface()
-- logo
spr(0,50,2)
spr(1,58,2)
spr(2,66,2)
for x=1,#games do
print(games[x],65-#games[x]*2,x*8+30,7)
spr(getlogo(games[x]),58-#games[x]*2,x*8+30)
end
if (s_ticks > 12) then
spr(16,51-#games[selection]*2,selection*8+31)
if (s_ticks > 30) then
s_ticks = 0
end
end
s_ticks += 1
print('\x94/\x83: navigate, \x97: start',16,123,7)
end
function getlogo(n)
if (n=='flappy plane') then
return 3
end
if (n=='dungeon-escape') then
return 4
end
if (n=='sidescroller') then
return 5
end
if (n=='pong') then
return 6
end
return 99
end
-- helper functions
function divby(a,b)
local val = a
while (val>0) do
val-=b
end
if (val==0) then
return true
else
return false
end
end
__gfx__
00011000077777507777750000a90000000700000330000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001c62000575575075557500509870000076000000ff000000007000000000000000000000000000000000000000000000000000000000000000000000000000
01c67e200075075075007500888870000076000000ff600070807000000000000000000000000000000000000000000000000000000000000000000000000000
967576e2007507507777750000586000046000000533600070000000000000000000000000000000000000000000000000000000000000000000000000000000
9a675762007507507555750000250000450000000333400000000000000000000000000000000000000000000000000000000000000000000000000000000000
09a76b30007507507500750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0096b300077777507777750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00033000055555505555550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
76000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000