--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")
track1icon = Image.load("IMAGES/track1icon.png")
multiplayercontrolsscreen = Image.load("IMAGES/multiplayercontrolsscreen.png")

--FONTS--

bigfont = Font.load("FONTS/font1.ttf")
bigfont:setPixelSizes(55,60)

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:clear()


screen:blit(0,0,background)

screen:fontPrint(font2,60,227," Multiplayer",black)
screen:fontPrint(font2,85,247," Menu",black)
screen:fontPrint(font2,285,227," Restart",black)
screen:fontPrint(font2,250,247," Championship",black)


if current == 1 then
screen:fontPrint(font2,60,227,"Multiplayer",red)
screen:fontPrint(font2,85,247,"Menu",red)
--screen:blit(140,60,multiplayermenuicon)
end

if current == 2 then
screen:fontPrint(font2,285,227,"Restart",red)
screen:fontPrint(font2,250,247,"Championship",red)
--screen:blit(140,60,track1icon)

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/championshiprace1.lua")
end



if p1wins > p2wins then
screen:fontPrint(bigfont,100,95,"Player 1 Won",blue)
screen:fontPrint(bigfont,25,165,"The Championship!",blue)
end

if p2wins > p1wins then
screen:fontPrint(bigfont,100,95,"Player 2 Won",red)
screen:fontPrint(bigfont,25,165,"The Championship!",red)
end



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


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






































