System.memclean()
System.currentDirectory("ms0:/PSP/GAME/IvEr PSP/")
fond = Image.load("Images/USB.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(x,y,sourisimg)

--ms0>>>
if pad:circle() and x >= 80 and x <= 119  and y >= 7 and y <= 264 then
System.usbDiskModeActivate()
end

--flash0>>>
if pad:circle() and x >= 165 and x <= 204  and y >= 7 and y <= 264 then
System.usbDevFlash0()
end

--flash1>>>
if pad:circle() and x >= 254 and x <= 293  and y >= 7 and y <= 264 then
System.usbDevFlash1()
end

--flash2>>>
if pad:circle() and x >= 342 and x <= 381  and y >= 7 and y <= 264 then
System.usbDevFlash2()
end

--flash3>>>
if pad:circle() and x >= 426 and x <= 465  and y >= 7 and y <= 264 then
System.usbDevFlash3()
end


--Afficher mains>>>

if x >= 80 and x <= 119  and y >= 7 and y <= 264 then
screen:blit(x,y,sourisimg2)
elseif x >= 165 and x <= 204  and y >= 7 and y <= 264 then
screen:blit(x,y,sourisimg2)
elseif x >= 254 and x <= 293  and y >= 7 and y <= 264 then
screen:blit(x,y,sourisimg2)
elseif x >= 342 and x <= 381  and y >= 7 and y <= 264 then
screen:blit(x,y,sourisimg2)
elseif x >= 426 and x <= 465  and y >= 7 and y <= 264 then
screen:blit(x,y,sourisimg2)
else
screen:blit(x,y,sourisimg)
end

screen:blit(4,3,batteryL)

--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:triangle() then
Nil_Pictures()
dofile("Scripts/reglages.lua")
end

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

screen.flip()
screen.waitVblankStart()
end
