white = Color.new(255,255,255)
blue = Color.new(30,144,255)
lightblue = Color.new(135,206,250)



menubg = Image.load("images/ztype/menu/main-bg.png")
right = Image.load("images/ztype/menu/cursorright.png")
text = Image.load("images/ztype/menu/main-text.png")
opttext = Image.load("images/ztype/menu/opts-text.png")

musicbg = Image.load("images/ztype/menu/musicroom-bg.png") 
credbg = Image.load("images/ztype/menu/credits-bg.png")

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



Text = {x=-160,y=110,img=text}
Text2 = {x=121,y=110,img=opttext}







Music.stop()


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


if Text.x < 105 then
Text.x = Text.x + 5
end


screen:blit(0,0,menubg)
screen:blit(Text.x,Text.y,Text.img)

if current == 1 then
screen:blit(330,135,right)
end

if current == 2 then
screen:blit(295,190,right)
end

if current == 3 then
screen:blit(275,242,right)
end


if pad:up() and oldpad:up() ~= pad:up() then
current = current - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
current = current + 1
end

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


if pad:cross() and current == 1 then

select:play()

while true do
screen:clear()
screen:blit(0,0,menubg)
screen:blit(Text.x,Text.y,Text.img)


if Text.x > -230 then 
Text.x = Text.x -5
end

screen.flip()
screen.waitVblankStart()


if Text.x < -229 then
Music.stop()
dofile("ztype-stage1.lua")
end
end
end


if pad:cross() and current == 2 then
select:play()

while true do

screen:clear()
screen:blit(0,0,menubg)
screen:blit(Text.x,Text.y,Text.img)


if Text.x > -230 then 
Text.x = Text.x -5
end

---------------------------------------------------------------------
if Text.x < -229 then

Text2 = {x=-151,y=110,img=opttext}
current = 0
while true do
pad = Controls.read()
screen:clear()

screen:blit(0,0,menubg)


screen:blit(Text2.x,Text2.y,Text2.img)

if Text2.x < 121 then
Text2.x= Text2.x +3
end


if current == 1 then
screen:blit(290,135,right)
end

if current == 2 then
screen:blit(260,190,right)
end

if current == 3 then
screen:blit(320,245,right)
end


if pad:up() and oldpad:up() ~= pad:up() then
current = current - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
current = current + 1
end

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






-----MUSIC ROOM
if pad:cross() and current == 2 then
select:play()

Current = 0
while true do
screen:clear()
screen:blit(0,0,musicbg)
screen:print(50,140,"Stage 1",blue)
screen:print(50,160,"Stage 2",blue)
screen:print(50,180,"Stage 3",blue)
screen:print(50,200,"Boss 1",blue)
screen:print(50,220,"Boss 2",blue)
screen:print(150,120,"Songname:",blue)
screen:print(340,120,"Artist:",blue)

if Current == 1 then
screen:print(40,140,">",lightblue)
screen:print(150,140,"Void of the vortex",blue)
screen:print(340,140,"Unknown artist",blue)
end

if Current == 2 then
screen:print(40,160,">",lightblue)
screen:print(150,160,"Voiders",blue)
screen:print(340,160,"Manic",blue)
end

if Current == 3 then
screen:print(40,180,">",lightblue)
screen:print(150,180,"aryx",blue)
screen:print(340,180,"K.Koch",blue)
end

if Current == 4 then
screen:print(40,200,">",lightblue)
screen:print(150,200,"Boss Music",blue)
screen:print(340,200,"Topaz",blue)
end

if Current == 5 then
screen:print(40,220,">",lightblue)
screen:print(150,220,"RType Mix",blue)
screen:print(340,220,"DRGxx",blue)
end


pad = Controls.read()

if pad:up() and oldpad:up() ~= pad:up() then
Current = Current - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
Current = Current + 1
end

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

if pad:cross() and Current == 1 then
Music.stop()
Music.playFile("music/void.s3m")
end

if pad:cross() and Current == 2 then
Music.stop()
Music.playFile("music/voiders.mod")
end

if pad:cross() and Current == 3 then
Music.stop()
Music.playFile("music/unknown-aryx.s3m")
end

if pad:cross() and Current == 4 then
Music.stop()
Music.playFile("music/tz-boss.mod")
end

if pad:cross() and Current == 5 then
Music.stop()
Music.playFile("music/rtypemix.mod")
end


if pad:start() then 
Music.stop()
dofile("ztype-menu.lua")
end

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



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

while true do


screen:blit(0,0,credbg)

screen:print(150,130,"-Main Programmer-",white)
screen:print(175,140,"Rattmuffen",white)
screen:print(180,160,"-Music-",white)
screen:print(130,170,"Check MusicRoom",white)
screen:print(190,190,"-GFX-",white)
screen:print(175,200,"Rattmuffen",white)
screen:print(130,220,"-I've Used Code from:-",white)
screen:print(65,230,"Charlie's Collision detection turorial",white)
screen:print(60,240,"Charlie's Firing Multiple Bullets turorial",white)
screen:print(120,249,"ARza's Simple Menu example",white)

pad = Controls.read()
if pad:start() then 
Music.stop()
dofile("ztype-menu.lua")
end

screen.flip()
screen:clear()
screen.waitVblankStart()
end
end
--------------







if pad:cross() and current == 3 then


while true do

screen:clear()
screen:blit(0,0,menubg)
screen:blit(Text2.x,Text2.y,Text2.img)


if Text2.x > -230 then
Text2.x = Text2.x - 5
end

if Text2.x < -229 then
Music.stop()
dofile("ztype-menu.lua")
end

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





end


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



if pad:cross() and current == 3 then
select:play()
while true do
screen:clear()
screen:blit(0,0,menubg)
screen:blit(Text.x,Text.y,Text.img)


if Text.x > -230 then 
Text.x = Text.x -5
end

screen.flip()
screen.waitVblankStart()


if Text.x < -229 then
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end
end
end
------------
screen.waitVblankStart()
screen.flip()
oldpad = pad
end