--COLOURS--

red = Color.new(200,0,0)
blue = Color.new(0,0,200)
black = Color.new(0,0,0)

--IMAGES--

background = Image.load("IMAGES/endoftrackmenu.png")
multiplayermenuicon = Image.load("IMAGES/multiplayermenuicon.png")
track4icon = Image.load("IMAGES/track4icon.png")
track5icon = Image.load("IMAGES/track5icon.png")
multiplayercontrolsscreen = Image.load("IMAGES/multiplayercontrolsscreen.png")

--FONTS--

font1 = Font.load("FONTS/font1.ttf")
font1:setPixelSizes(25,30)

font2 = Font.load("FONTS/font1.ttf")
font2:setPixelSizes(27,23)

--SOUNDS--

--Wav.load("SOUNDS/menuselection.wav", 0)
Wav.load("SOUNDS/menuclick.wav", 1)



current = 3

while true do

oldpad = pad
pad = Controls.read()


screen:blit(0,0,background)


screen:fontPrint(font2,50,230," Multiplayer",black)
screen:fontPrint(font2,70,250," Menu",black)
screen:fontPrint(font1,205,240," Restart",black)
screen:fontPrint(font1,320,240," Next track",black)



if current == 1 then
screen:fontPrint(font2,50,230,"Multiplayer",red)
screen:fontPrint(font2,70,250,"Menu",red)
screen:blit(140,60,multiplayermenuicon)
end

if current == 2 then
screen:fontPrint(font1,205,240,"Restart",red)
screen:blit(140,60,track4icon)

end

if current == 3 then
screen:fontPrint(font1,320,240,"Next track",red)
screen:blit(140,60,track5icon)
end

--RESTART AND WINS SYSTEM

if p1laps == 6 and pad:cross() and current == 2 then
p1wins = p1wins - 1
end

if p2laps == 6 and pad:cross() and current == 2 then
p2wins = p2wins - 1
end



if pad:left() and oldpad:left() ~= pad:left() then
current = current - 1
--Wav.play(false, 0)
end

if pad:right() and oldpad:right() ~= pad:right() then
current = current + 1
--Wav.play(false, 0)
end

    
     -- FUNCTIONS --
     
    
if pad:cross() and current == 1 then
Wav.play(false, 1)
dofile("FILES/MULTIPLAYER/multiplayermenu.lua")
end

if pad:cross() and current == 2 then
Wav.play(false, 1)
screen:blit(0,0,multiplayercontrolsscreen)
screen:flip()
screen.waitVblankStart(200)
dofile("FILES/MULTIPLAYER/championshiprace2.lua")
end

    
if pad:cross() and current == 3 then
Wav.play(false, 1)
screen:blit(0,0,multiplayercontrolsscreen)
screen:flip()
screen.waitVblankStart(200)
dofile("FILES/MULTIPLAYER/championshiprace5.lua")
end



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


collectgarbage()
screen.waitVblankStart()
screen:flip()
end






































