System.memclean()
System.currentDirectory("ms0:/PSP/GAME/IvEr PSP/")
fond = Image.load("images/emulateurs.png")
battery1 = Image.load("images/battery4.png")
battery2 = Image.load("images/battery3.png")
battery3 = Image.load("images/battery2.png")
battery4 = Image.load("images/battery1.png")
sourisimg = Image.load("Images/souris1.png")
sourisimg2 = Image.load ("Images/souris2.png")

function Nil_Pictures()
fond = nil
battery1 = nil
battery2 = nil
battery3 = nil
battery4 = nil
sourisimg = nil
sourisimg2 = nil
end

x = 240
y = 136 

--Boucle Principale
while true do 
pad = Controls.read() 
screen:clear()
screen:blit(0,0,fond)


if System.powerGetBatteryLifePercent() >= 0 then batteryL = battery1 end
if System.powerGetBatteryLifePercent() > 30 then batteryL = battery2 end
if System.powerGetBatteryLifePercent() > 50 then batteryL = battery3 end
if System.powerGetBatteryLifePercent() > 70 then batteryL = battery4 end

screen:blit(4,3,batteryL)
screen:blit(x,y,sourisimg)

--nintendo 64>>>

if pad:circle() and x >= 128 and x <= 153 and y >= 231 and y <= 255 then
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/Nintendo 64/EBOOT.PBP")
end

--Super Nintendo>>>

if pad:circle() and x >= 165 and x <= 190 and y >= 231 and y <= 255 then
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/Super Nintendo/EBOOT.PBP")
end

--game boy color>>>

if pad:circle() and x >= 203 and x <= 228 and y >= 231 and y <= 255 then
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/Game Boy/EBOOT.PBP")
end

--nesterj>>>

if pad:circle() and x >= 279 and x <= 304 and y >= 231 and y <= 255 then
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/NesterJ/EBOOT.PBP")
end

--super mega drive>>>

if pad:circle() and x >= 316 and x <= 341 and y >= 231 and y <= 255 then
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/Super Mega Drive/EBOOT.PBP")
end

--game gear>>>

if pad:circle() and x >= 353 and x <= 378 and y >= 231 and y <= 255 then
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/Game Gear/EBOOT.PBP")
end

--pc engine>>>

if pad:circle() and x >= 390 and x <= 415 and y >= 231 and y <= 255 then
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/PC Engine/EBOOT.PBP")
end

--Afficher mains>>>

if x >= 128 and x <= 153 and y >= 231 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 165 and x <= 190 and y >= 231 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 203 and x <= 228 and y >= 231 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 279 and x <= 304 and y >= 231 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 316 and x <= 341 and y >= 231 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 353 and x <= 378 and y >= 231 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 390 and x <= 415 and y >= 231 and y <= 255 then
screen:blit(x,y,sourisimg2)
else
screen:blit(x,y,sourisimg)
end

--BOUGE TA SOURIS !

if math.abs(pad:analogY()) > 32 then
y = y + pad:analogY() / 32;
end

if math.abs(pad:analogX()) > 32 then
x = x + pad:analogX() / 32;
end

-- Collision souris

if x < 0 then x = 0 elseif x + sourisimg:width() > 480 then x = 480 -  sourisimg:width() end
if y < 0 then y = 0 elseif y + sourisimg:height() > 272 then y = 272 -  sourisimg:width() end

if pad:square() then
Nil_Pictures()
dofile ("Scripts/menu.lua")
end

screen.flip()
screen.waitVblankStart()
end
