-- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- Menu
-- SUBMITTED BY: nathan42100
----------index.lua----------
currstate="startup"
function printCentered(y, text, color)
local tl=string.len(text)
local xmod = 240-((tl*10)/2)
screen:print(xmod, y, text, color)
end
-----------------
dofile("colors.lua")--contains all color codes, make one yourself
-----------------
screen:clear()
printCentered(131,"Starting up...",white)
screen.waitVblankStart(3)
screen.flip()
-----------------
dofile("config.txt")--contains the options changed in the options menu
-----------------
menu={}
menu[1] = "Single Player"
menu[2] = "Multi Player"
menu[3] = "Options"
menu[4] = "Update"
menu[5] = "Quit"
menu[currselect] =1
menu[entries]=table.getn(menu) - 2
-----------------
menuBackground=Image.load("menuBackground.png")
-----------------
screen:clear()
printCentered(131,"Loaded!",white)
screen.waitVblankStart(3)
screen.flip()
currstate="menu"
-----------------
while not Controls.read():start()
pad=Controls.read()
screen:clear()
if currstate=="menu" then
screen:blit(0,0,menuBackground)
for i=1,menu[entries] do
if i==menu[currselect] then
printCentered((20+((i-1)*10)), menu[i], red)
else
printCentered((20+((i-1)*10)), menu[i], white)
end
end
if pad:cross() then
if i==1 then --SP
dofile("singleplayer.lua")
elseif i==2 then --MP
dofile("multiplayer.lua")
elseif i==3 then --Options
dofile("options.lua")
elseif i==4 then --Update
dofile("update.lua")
elseif i==5 then --Quit
break
end
elseif pad:down() then
if menu[currselect]==5 then
menu[currselect]=1
else
menu[currselect]=menu[currselect]+1
end
elseif pad:up() then
if menu[currselect]==1 then
menu[currselect]=5
else
menu[currselect]=menu[currselect]-1
end
end
screen.flip()
screen.waitVblankStart()
end