-----Misc
black = Color.new(255,255,0)

bg = Image.load("images/quiz/quiz-bg.png")

img1 = Image.load("images/link/left1.png")
img2 = Image.load("images/quiz/img1.png")
img3 = Image.load("images/quiz/img2.png")




-------------Dont--look!-----------------------Questions
function q10()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(210,260,"10/10",black)

screen:print(20,170,"What is this enemy called?",black)

screen:print(230,190,"Triangle: Gibdo",black)
screen:print(230,210,"Square:   Kesse",black)
screen:print(230,230,"Cross:    Pols Voice",black)
screen:blit(40,200,img3)

if pad:cross() and oldpad:cross() ~= pad:cross() then  
finish()
end
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then 
Gameover()
end
if pad:square() and oldpad:square() ~= pad:square() then
Gameover()
end
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end



function q9()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(210,260,"9/10",black)

screen:print(20,170,"How old am I in TLoZ:Majora's Mask?",black)

screen:print(230,190,"Triangle: 35",black)
screen:print(230,210,"Square:   40",black)
screen:print(230,230,"Cross:    45",black)
screen:blit(350,155,img2)

if pad:triangle() and oldpad:triangle() ~= pad:triangle() then  
q10()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then   
Gameover()
end
if pad:square() and oldpad:square() ~= pad:square() then
Gameover()
end
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end
if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end




function q8()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(210,260,"8/10",black)

screen:print(20,170,"Who is the youngest sister on Malon Ranch?",black)

screen:print(230,190,"Triangle: Kafei",black)
screen:print(230,210,"Square:   Cremia",black)
screen:print(230,230,"Cross:    Romani",black)

if pad:square() and oldpad:square() ~= pad:square() then  
q9()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then   
Gameover()
end
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then 
Gameover()
end
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end
if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end





function q7()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(210,260,"7/10",black)

screen:print(20,170,"Which of the following games was released in 1993?",black)
screen:print(230,190,"Triangle: Links Awakening DX",black)
screen:print(230,210,"Square:   A Link to the Past",black)
screen:print(230,230,"Cross:    Links Awakening",black)

if pad:cross() and oldpad:cross() ~= pad:cross() then  
q8()
end
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then  
Gameover()
end
if pad:square() and oldpad:square() ~= pad:square() then
Gameover()
end
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end



function q6()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(210,260,"6/10",black)

screen:print(20,170,"Whats the name of the island in Links Awakening?",black)
screen:print(230,190,"Triangle: Ghoma Island",black)
screen:print(230,210,"Square:   Koholint Island",black)
screen:print(230,230,"Cross:    Outset Island",black)

if pad:square() and oldpad:square() ~= pad:square() then  
q7()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then  
Gameover()
end
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then 
Gameover()
end
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end




function q5()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(210,260,"5/10",black)


screen:print(20,170,"Who makes most of the music in the Zelda series?",black)

screen:print(230,190,"Triangle: Yasuroni Mitsuda",black)
screen:print(230,210,"Square:   Nobuo Uematsu",black)
screen:print(230,230,"Cross:    Koji Kondo",black)
if pad:cross() and oldpad:cross() ~= pad:cross() then  
q6()
end
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then 
Gameover()
end
if pad:square() and oldpad:square() ~= pad:square() then
Gameover()
end
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end



function q4()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)
screen:print(210,260,"4/10",black)

screen:print(20,170,"Which company made 'Oracle of Seasons'?",black)

screen:print(230,190,"Triangle: SquareSoft",black)
screen:print(230,210,"Square:   Capcom",black)
screen:print(230,230,"Cross:    Konami",black)
if pad:square() and oldpad:square() ~= pad:square() then  
q5()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then  
Gameover()
end
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then 
Gameover()
end
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end



function q3()
while true do
oldpad = pad
pad = Controls.read()

screen:clear()
screen:blit(0,0,bg)

screen:print(210,260,"3/10",black)

screen:print(20,170,"Who is the creator of the Legend of Zelda series?",black)

screen:print(230,190,"Triangle: Shigeru Miyamoto",black)
screen:print(230,210,"Square:   Saturo Iwata",black)
screen:print(230,230,"Cross:    Keiji Inafune",black)
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then  
q4()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then  
Gameover()
end
if pad:square() and oldpad:square() ~= pad:square() then
Gameover()
end
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end
if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end




function q2()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(210,260,"2/10",black)

screen:print(20,170,"How many Zelda games were produced for the NES?",black)

screen:print(230,190,"Triangle: 2",black)
screen:print(230,210,"Square:   1",black)
screen:print(230,230,"Cross:    3",black)
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then 
q3()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then  
Gameover()
end
if pad:square() and oldpad:square() ~= pad:square() then
Gameover()
end

if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end

screen.waitVblankStart()
screen.flip()
end
end





function q1()
oldpad = pad
pad = Controls.read()
screen:print(210,260,"1/10",black)
screen:print(20,170,"Who is this?",black)
screen:blit(40,200,img1)
screen:print(230,190,"Triangle: Zelda",black)
screen:print(230,210,"Square:   Link",black)
screen:print(230,230,"Cross:    Ganon",black)
if pad:square() then 
q2()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then  
Gameover()
end
if pad:triangle() then 
Gameover()
end
end





----------------------------------
function restart()
while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)
q1()
if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end
if pad:select() then 
restart()
end
screen.waitVblankStart()
screen.flip()
end
end


function finish()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(200,200,"CONGRATULATIONS!!!",black)
screen:print(170,220,"You've got some mad skillz there!",black)

if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end

screen.waitVblankStart()
screen.flip()
end
end



function Gameover()
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)

screen:print(200,200,"GAME OVER",black)
screen:print(170,220,"I know you can do better...",black)

if pad:start() then
Music.stop() 
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end

screen.waitVblankStart()
screen.flip()
end
end



Music.playFile("music/moby-turrigol.mod",true)
-------------Main Loop
while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg)
q1()

if pad:start() then 
Music.stop()
Music.playFile("music/4mat-menu12.mod")
dofile("index.lua")
end

if pad:select() then 
restart()
end

screen.waitVblankStart()
screen.flip()
end