--Colors
red = Color.new(255, 0, 0)
white = Color.new(255, 255, 255)
black = Color.new(0,0,0)



----Images
menubg = Image.load("images/menu/mainmenu.png")
advmenu = Image.load("images/menu/adventure.png")
minigmp = Image.load("images/menu/minig-mp.png")
minigsp = Image.load("images/menu/minig-sp.png")
spmp = Image.load("images/menu/sp-mp.png")
cursor = Image.load("images/menu/cursor.png") 


select = Sound.load("music/cursor1.wav",false)


---Main Menu---



Select = 0
maxSelect = 4
oldpad = Controls.read()

while true do
pad = Controls.read()
screen:clear()
	

if pad:left() and oldpad:left() ~= pad:left() then
Select = Select - 1
end
if pad:right() and oldpad:right() ~= pad:right() then
Select = Select + 1
end
if Select > maxSelect then
Select = 1
elseif Select <= -1 then
Select = maxSelect
end

screen:blit(0,0,menubg)

if Select == 1 then
screen:blit(30,205,cursor)
end

if Select == 2 then
screen:blit(220,205,cursor)
end

if Select == 3 then
screen:blit(345,205,cursor)
end

if Select == 4 then
screen:blit(435,205,cursor)
end



----Adventure---------
if pad:cross() and Select == 1 then
select:play()

current = 0
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()

screen:blit(0,0,advmenu)

if current == 1 then
screen:blit(75,230,cursor)
end
if current == 2 then
screen:blit(245,230,cursor)
end
if current == 3 then
screen:blit(390,205,cursor)
end


if pad:left() and oldpad:left() ~= pad:left() then
current = current - 1
end
if pad:right() and oldpad:right() ~= pad:right() then
current = current + 1
end

if current == 4 then
current = 1
end
if current == -1 then
current = 3
end

-------ZType------
if pad:cross() and current == 1 then
select:play()

screen:clear()
Music.stop()
dofile("ztype-menu.lua")
end


---------?-------------
if pad:cross() and current == 2 then
screen:print(200,140,"Not avalible :(",white)
end


if pad:cross() and current == 3 then
select:play()
screen:clear()
dofile("index.lua")
end



screen.waitVblankStart()
screen.flip()
oldpad = pad
end
end



----Mini games----
if pad:cross() and Select == 2 then

current = 0
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()

screen:blit(0,0,spmp)

if current == 1 then
screen:blit(70,225,cursor)
end

if current == 2 then
screen:blit(270,225,cursor)
end

if current == 3 then
screen:blit(420,205,cursor)
end


if pad:left() and oldpad:left() ~= pad:left() then
current = current - 1
end
if pad:right() and oldpad:right() ~= pad:right() then
current = current + 1
end

if current == 4 then
current = 1
end
if current == -1 then
current = 3
end


if pad:cross() and current == 3 then
select:play()
dofile("index.lua")
end


if pad:cross() and current == 2 then
select:play()
current = 0
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()

screen:blit(0,0,minigmp)

if current == 1 then
screen:blit(35,205,cursor)
end

if current == 2 then
screen:blit(160,205,cursor)
end

if current == 3 then
screen:blit(295,205,cursor)
end

if current == 4 then
screen:blit(415,205,cursor)
end



if pad:left() and oldpad:left() ~= pad:left() then
current = current - 1
end
if pad:right() and oldpad:right() ~= pad:right() then
current = current + 1
end

if current == 5 then
current = 1
end
if current == -1 then
current = 4
end

------avoid--------
if pad:cross() and current == 1 then
select:play()
screen:clear()
Music.stop()
dofile("avoid-mp.lua")
end

--------bounce-------
if pad:cross() and current == 2 then
select:play()
screen:clear()
Music.stop()
dofile("bounce-mp.lua")
end

-------chase-------
if pad:cross() and current == 3 then
select:play()
screen:clear()
Music.stop()
dofile("chase-mp.lua")
end

-------cacnel-------
if pad:cross() and current == 4 then
select:play()
screen:clear()
dofile("index.lua")
end

-----
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
end






------------------------------------------------------------------------------
if pad:cross() and current == 1 then
select:play()
current = 0
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()

screen:blit(0,0,minigsp)

if current == 1 then
screen:blit(25,205,cursor)
end

if current == 2 then
screen:blit(130,205,cursor)
end

if current == 3 then
screen:blit(235,205,cursor)
end

if current == 4 then
screen:blit(325,205,cursor)
end

if current == 5 then
screen:blit(420,205,cursor)
end

if pad:left() and oldpad:left() ~= pad:left() then
current = current - 1
end
if pad:right() and oldpad:right() ~= pad:right() then
current = current + 1
end

if current == 6 then
current = 1
end
if current == -1 then
current = 5
end

------avoid--------
if pad:cross() and current == 1 then
select:play()
screen:clear()
Music.stop()
dofile("avoid.lua")
end

--------bounce-------
if pad:cross() and current == 2 then
select:play()
screen:clear()
Music.stop()
dofile("bounce.lua")
end

-------chase-------
if pad:cross() and current == 3 then
select:play()
screen:clear()
Music.stop()
dofile("chase.lua")
end

-------drop-------
if pad:cross() and current == 4 then
select:play()
screen:clear()
Music.stop()
dofile("drop.lua")
end

-------drop-------
if pad:cross() and current == 5 then
select:play()
screen:clear()
dofile("index.lua")
end

-----
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
end
----------------------------------------------------------















screen.waitVblankStart()
screen.flip()
oldpad = pad
end
end







-------Quiz---------||
if pad:cross() and Select == 3 then
select:play()
screen:clear()
dofile("quiz.lua")
end
--------------------||


----------EXIT---------------||
if pad:cross() and Select == 4 then
select:play()
os.exit()                    
end                          
-----------------------------||

screen.waitVblankStart()
screen.flip()
oldpad = pad
end