Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.38 KB | None | 0 0
  1. IntraFont.init()
  2. IntraFont.load("flash0:/font/ltn4.pgf", 1)
  3.  
  4. local oldpad = Controls.read()
  5.  
  6. math.randomseed(os.time())
  7.  
  8. ----------------------------
  9.  
  10. local blanc = Color.new(255,255,255)
  11. local rouge = Color.new(255,0,0)
  12. local bleu = Color.new(0,0,255)
  13. local vert = Color.new(0,255,0)
  14. local gris = Color.new(175,175,175)
  15. local noir = Color.new(0,0,0)
  16.  
  17. ----------------------------
  18.  
  19. local blancI = IntraFont.color(255,255,255,255)
  20. local rougeI = IntraFont.color(255,0,0,255)
  21. local bleuI = IntraFont.color(0,0,255,255)
  22. local vertI = IntraFont.color(0,255,0,255)
  23. local grisI = IntraFont.color(175,175,175,255)
  24. local noirI = IntraFont.color(0,0,0,255)
  25.  
  26. -----------------------------
  27.  
  28. local pistolet = Mp3me.load("sons/gun.mp3")
  29. Mp3me.stop()
  30. local imagemenu = Image.load("images/menu.png")
  31. local credits = Image.load("images/credits.png")
  32. local decor = Image.load("images/decor.png")
  33. local viseur = {x=230,y=90,pic=Image.load("images/viseur.png")}
  34. local cible = {x=0,y=50,pic=Image.load("images/cible.png"),vitesse=2}
  35. local cible2 = {x=0,y=60,pic=Image.load("images/cible.png"),vitesse=3}
  36. local cible3 = {x=0,y=70,pic=Image.load("images/cible.png"),vitesse=4}
  37. local cible4 = {x=0,y=80,pic=Image.load("images/cible.png"),vitesse=5}
  38. local cible5 = {x=0,y=90,pic=Image.load("images/cible.png"),vitesse=6}
  39. local cible6 = {x=0,y=100,pic=Image.load("images/cible.png"),vitesse=7}
  40. local cible7 = {x=0,y=110,pic=Image.load("images/cible.png"),vitesse=8}
  41. local cible8 = {x=0,y=120,pic=Image.load("images/cible.png"),vitesse=9}
  42. local cible9 = {x=0,y=130,pic=Image.load("images/cible.png"),vitesse=10}
  43. local cible10 = {x=0,y=140,pic=Image.load("images/cible.png"),vitesse=11}
  44. ccible = Timer.new()
  45. local statut = "install"
  46. Score = { }
  47. dofile("score.cfg")
  48. local Selec = 1
  49. Score.actuel = 0
  50.  
  51. -----------------------------
  52.  
  53. while true do
  54.  
  55.   screen:clear()
  56.   pad = Controls.read()
  57.  
  58.   if statut == "install" then
  59.  
  60.     if System.doesDirExist("flash1:/LPHMDRIVER") == 1 then
  61.    
  62.         System.message("Les drivers sont bien installes \nO pour aller au menu !", 0)
  63.         statut = "menu"
  64.        
  65.     else
  66.    
  67.         System.message("Les drivers ne sont pas installes !\nVeuillez les installer pour que l'homebrew fonctionne correctement\nLes installer ?", 1)
  68.        
  69.         if System.buttonPressed(0) == 1 then
  70.        
  71.             System.createDirectory("flash1:/LPHMDRIVER")
  72.             System.copyFile("ms0:/PSP/GAME/CibleAttack/LPHMDRIVER/hook.prx", "flash1:/LPHMDRIVER/hook.prx", 1)
  73.             System.copyFile("ms0:/PSP/GAME/CibleAttack/LPHMDRIVER/rdriver.prx", "flash1:/LPHMDRIVER/rdriver.prx", 1)
  74.             System.copyFile("ms0:/PSP/GAME/CibleAttack/LPHMDRIVER/syslib.prx", "flash1:/LPHMDRIVER/syslib.prx", 1)
  75.             System.removeDirectory("ms0:/PSP/GAME/CibleAttack/LPHMDRIVER")
  76.             System.message("Les drivers ont bien ete installes !", 0)
  77.             statut = "menu"
  78.            
  79.         end
  80.        
  81.     end
  82.     end
  83.     if statut == "menu" then
  84.    
  85.       screen:clear()
  86.       screen:blit(0,0,imagemenu)
  87.       Gu.start3d()
  88.       IntraFont.print(200,120,"Jouer",1,rougeI,100)
  89.       IntraFont.print(200,160,"Credits",1,rougeI,100)
  90.       IntraFont.print(200,200,"Quitter",1,rougeI,100)
  91.       IntraFont.print(160,(80 + Selec * 40),"=>",1,rougeI,150)
  92.       Gu.end3d()
  93.       if pad:cross() and not oldpad:cross() and Selec == 1 then
  94.         statut = "jeu"
  95.       elseif pad:cross() and Selec == 2 then
  96.         statut = "credits"
  97.       elseif pad:cross() and not oldpad:cross() and Selec == 3 then
  98.         statut = "quitter"
  99.       elseif pad:down() and not oldpad:down() then
  100.         Selec = Selec + 1
  101.       elseif pad:up() and not oldpad:up() then
  102.         Selec = Selec - 1
  103.       elseif Selec > 3 then
  104.         Selec = 3
  105.       elseif Selec < 1 then
  106.         Selec = 1
  107.       end
  108.      
  109.     end
  110.    
  111.     if statut == "jeu" then
  112.    
  113.         screen:clear()
  114.         ccible:start()
  115.         screen:blit(cible.x,cible.y,cible.pic)
  116.         cible.x = cible.x + cible.vitesse
  117.         if ccible:time() >= 5000 then
  118.           screen:blit(cible2.x,cible2.y,cible2.pic)
  119.           cible2.x = cible2.x + cible2.vitesse
  120.         elseif ccible:time() >= 10000 then
  121.           screen:blit(cible3.x,cible3.y,cible3.pic)
  122.           cible3.x = cible3.x + cible3.vitesse
  123.         elseif ccible:time() >= 15000 then
  124.           screen:blit(cible4.x,cible4.y,cible4.pic)
  125.           cible4.x = cible4.x + cible4.vitesse
  126.         end
  127.         if pad:r() and not oldpad:r() then
  128.           Mp3me.play()
  129.           end
  130.           if viseur.x >= cible.x and viseur.x <= (cible.x + cible.pic:width()) and viseur.y >= cible.y and viseur.y <= (cible.y + cible.pic:height() ) then
  131.             cible.y = cible.y - 15
  132.             Score.actuel = Score.actuel + 10
  133.             if cible.y > 272 then
  134.               cible = nil
  135.               screen:blit(cible.x,cible.y,cible.pic)
  136.             end
  137.           elseif viseur.x >= cible2.x and viseur.x <= (cible2.x + cible2.pic:width()) and viseur.y >= cible2.y and viseur.y <= (cible2.y + cible2.pic:height() ) then
  138.             cible2.y = cible2.y - 15
  139.             Score.actuel = Score.actuel + 12
  140.             if cible2.y > 272 then
  141.               cible2 = nil
  142.               screen:blit(cible2.x,cible2.y,cible2.pic)
  143.             end
  144.             elseif viseur.x >= cible3.x and viseur.x <= (cible3.x + cible3.pic:width()) and viseur.y >= cible3.y and viseur.y <= (cible3.y +cible3.pic:height() ) then
  145.             cible2.y = cible2.y - 15
  146.             Score.actuel = Score.actuel + 14
  147.             if cible2.y > 272 then
  148.               cible3 = nil
  149.               screen:blit(cible3.x,cible3.y,cible3.pic)
  150.               end
  151.               elseif viseur.x >= cible4.x and viseur.x <= (cible4.x + cible4.pic:width()) and viseur.y >= cible4.y and viseur.y <= (cible4.y +cible4.pic:height() ) then
  152.             cible4.y = cible4.y - 15
  153.             Score.actuel = Score.actuel + 16
  154.             if cible4.y > 272 then
  155.               cible4 = nil
  156.               screen:blit(cible4.x,cible4.y,cible4.pic)
  157.             end
  158.             end
  159.         screen:blit(viseur.x,viseur.y,viseur.pic)
  160.         if math.abs(pad:analogY()) > 13 then -- controles du pad
  161.           viseur.y = viseur.y + pad:analogY() / 13
  162.         end
  163.         if math.abs(pad:analogX()) > 13 then
  164.           viseur.x = viseur.x + pad:analogX() / 13
  165.         end
  166.         screen:blit(0,0,decor)
  167.         Gu.start3d()
  168.         IntraFont.print(250,400,"Meilleur score : "..Score.best,1,bleuI,150)
  169.         IntraFont.print(250,420,"Score actuel : "..Score.actuel,1,vertI,150)
  170.         Gu.end3d()
  171.        
  172.         end
  173.         end
  174.         if statut == "credits" then
  175.           screen:clear()
  176.           screen:blit(0,0,credits)
  177.           if pad:circle() then
  178.             statut = "menu"
  179.           end
  180.         end
  181.         if statut == "quitter" then
  182.           System.message("Etes vous sur ?",1)
  183.           if System.buttonPressed(0) == 1 then
  184.             System.Quit()
  185.           else statut = "menu"     
  186.           end
  187.         end      
  188. oldpad=pad
  189. screen.flip()
  190. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement