load1 = nil
load2 = nil
transition = nil 
niveau = nil
allumetteniveau = nil 
continuer = nil
credits = nil
Imfond = nil
Imimmeuble = nil
Imfeu = nil
Imperso = nil
Imgoutte = nil
Imechelle = nil
Imdialogue = nil
Imdialogue = nil
Impause = nil
Impausefond = nil
Imgagne = nil
Imperdu = nil 
n0 = nil
n1 = nil
n2 = nil
n3 = nil
n4 = nil
n5 = nil
n6 = nil
n7 = nil
n8 = nil
n9 = nil
n10 = nil
n11 = nil
n12 = nil
n13 = nil
n14 = nil
n15 = nil
n16 = nil
n17 = nil
n18 = nil
n19 = nil
n20 = nil

--images
menu = Image.load("datas/menu.png")
menu1 = Image.load("datas/menu1.png")
menu2 = Image.load("datas/menu2.png")
menu3 = Image.load("datas/menu3.png")
allumette = Image.load("datas/allumette.png")

--sons
mmove = Sound.load("datas/MenuMove.wav",false)
mnext = Sound.load("datas/MenuNext.wav",false)

--variables
Select = 1
maxSelect = 3

--fonction quitter
function exit()
while true do
screen:clear()
screen.flip()
os.exit()
break
end
end

--boucle principale

while true do

pad = Controls.read()
screen:clear()
screen:blit(0, 0, menu)

--choix

if pad:up() and oldpad:up() ~= pad:up() then
Select = Select - 1
mmove:play()
end

if pad:down() and oldpad:down() ~= pad:down() then
Select = Select + 1
mmove:play()
end

if Select > maxSelect then
Select = 1
elseif Select <= 0 then
Select = maxSelect
end

if Select == 1 then
screen:blit(144, 23, menu1)
screen:blit(290, 70, allumette)
end
if Select == 2 then
screen:blit(144, 23, menu2)
screen:blit(295, 130, allumette)
end
if Select == 3 then
screen:blit(144, 23, menu3)
screen:blit(290, 190, allumette)
end

--jouer

if pad:cross() and Select == 1 then
mnext:play()
screen:flip()
screen.waitVblankStart(20)
dofile ("menu2.lua")
end

if pad:cross() and Select == 2 then
mnext:play()
screen:flip()
screen.waitVblankStart(20)
dofile "credits.lua"
break
end

--eteindre

if pad:cross() and Select == 3 then
mnext:play()
screen.waitVblankStart(20)
exit()
end 

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