System.memclean()
System.currentDirectory("ms0:/PSP/GAME/IvEr PSP/")
fond = Image.load("Images/fond d'ecran.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)

--horloge>>>

if pad:circle() and x >= 39 and x <= 85 and y >= 14 and y <= 95 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/horloge.lua")
end

--calculatrice>>>

if pad:circle() and x >= 39 and x <= 85 and y >= 76 and y <= 122 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/calculatrice.lua")
end

--paint>>>

if pad:circle() and x >= 39 and x <= 85 and y >= 144 and y <= 190 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/PSPaint/paint.lua")
end

--MSN>>>

if pad:circle() and x >= 412 and x <= 458 and y >= 209 and y <= 255 then
Nil_Pictures()
collectgarbage()
System.webbrowser("ms0:/PSP/GAME/IvEr PSP","http://m.ebuddy.com")
end

--Ipod>>>

if pad:circle() and x >= 412 and x <= 458  and y >= 13 and y <= 59 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/mp3.lua")
end

--Internet>>>

if pad:circle() and x >= 412 and x <= 458 and y >= 76 and y <= 122 then
Nil_Pictures()
collectgarbage()
System.webbrowser("ms0:/PSP/GAME/IvEr PSP","http://www.google.fr")
end

--Finder>>>

if pad:circle() and x >= 118 and x <= 164  and y >= 144 and y <= 190 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/finder.lua")
end

--youtube>>>

if pad:circle() and x >= 118 and x <= 164  and y >= 76 and y <= 122 then
Nil_Pictures()
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/Ultimate PSPTube/EBOOT.PBP")
end

--systeme>>>

if pad:circle() and x >= 39 and x <= 85  and y >= 209 and y <= 255 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/system.lua")
end

--maps>>>

if pad:circle() and x >= 199 and x <= 245  and y >= 76 and y <= 122 then
Nil_Pictures()
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/maps/EBOOT.PBP")
end

--email>>>

if pad:circle() and x >= 412 and x <= 459  and y >= 144 and y <= 190 then
Nil_Pictures()
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/email/EBOOT.PBP")
end

--credits>>>

if pad:circle() and x >= 118 and x <= 164  and y >= 209 and y <= 255 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/credits.lua")
end

--jeux>>>

if pad:circle() and x >= 118 and x <= 164  and y >= 13 and y <= 59 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/jeux.lua")
end

--réglages>>>

if pad:circle() and x >= 197 and x <= 243  and y >= 144 and y <= 190 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/reglages.lua")
end

--revenir au xmb>>>

if pad:circle() and x >= 199 and x <= 245  and y >= 14 and y <= 59 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/quitter.lua")
end

--dump umd>>>

if pad:circle() and x >= 278 and x <= 322  and y >= 210 and y <= 254 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/Dump_2.lua")
end

--luaprog>>>

if pad:circle() and x >= 197 and x <= 243  and y >= 210 and y <= 254 then
Nil_Pictures()
collectgarbage()
System.runeboot("ms0:/PSP/GAME/IvEr PSP/Scripts/LUAPROG/EBOOT.PBP")
end

--emulateurs>>>

if pad:circle() and x >= 279 and x <= 325  and y >= 145 and y <= 191 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/emulateurs.lua")
end

--zip>>>

if pad:circle() and x >= 279 and x <= 325  and y >= 76 and y <= 122 then
Nil_Pictures()
collectgarbage()
dofile("Scripts/zip.lua")
end

--Facebook>>>

if pad:circle() and x >= 279 and x <= 325 and y >= 14 and y <= 59 then
Nil_Pictures()
collectgarbage()
System.webbrowser("ms0:/PSP/GAME/IvEr PSP","http://iphone.facebook.com/login.php?next=http%253A%252F%252Fiphone.facebook.com%252F")
end

--Afficher mains>>>

if x >= 39 and x <= 85 and y >= 14 and y <= 63 then
screen:blit(x,y,sourisimg2)
elseif x >= 39 and x <= 85 and y >= 76 and y <= 122 then
screen:blit(x,y,sourisimg2)
elseif x >= 39 and x <= 85 and y >= 144 and y <= 190 then
screen:blit(x,y,sourisimg2)
elseif x >= 412 and x <= 458 and y >= 209 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 412 and x <= 458 and y >= 13 and y <= 59 then
screen:blit(x,y,sourisimg2)
elseif x >= 412 and x <= 458 and y >= 76 and y <= 122 then
screen:blit(x,y,sourisimg2)
elseif x >= 118 and x <= 164 and y >= 144 and y <= 190 then
screen:blit(x,y,sourisimg2)
elseif x >= 118 and x <= 164 and y >= 76 and y <= 122 then
screen:blit(x,y,sourisimg2)
elseif x >= 39 and x <= 85 and y >= 209 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 199 and x <= 245 and y >= 76 and y <= 122 then
screen:blit(x,y,sourisimg2)
elseif x >= 412 and x <= 459 and y >= 144 and y <= 190 then
screen:blit(x,y,sourisimg2)
elseif x >= 118 and x <= 164 and y >= 209 and y <= 255 then
screen:blit(x,y,sourisimg2)
elseif x >= 118 and x <= 164 and y >= 13 and y <= 59 then
screen:blit(x,y,sourisimg2)
elseif x >= 197 and x <= 243 and y >= 144 and y <= 190 then
screen:blit(x,y,sourisimg2)
elseif x >= 199 and x <= 245 and y >= 14 and y <= 59 then
screen:blit(x,y,sourisimg2)
elseif x >= 278 and x <= 322 and y >= 210 and y <= 254 then
screen:blit(x,y,sourisimg2)
elseif x >= 197 and x <= 243 and y >= 210 and y <= 254 then
screen:blit(x,y,sourisimg2)
elseif x >= 279 and x <= 325  and y >= 145 and y <= 191 then
screen:blit(x,y,sourisimg2)
elseif x >= 279 and x <= 325  and y >= 76 and y <= 122 then
screen:blit(x,y,sourisimg2)
elseif x >= 279 and x <= 325 and y >= 14 and y <= 59 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

screen.flip()
screen.waitVblankStart()
end
