Advertisement
Guest User

Casse brique

a guest
Jun 7th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.16 KB | None | 0 0
  1. local line=graydraw.line
  2. local pixeltest=graydraw.pixeltest
  3. graydraw.setcolor(true)
  4. local text=graydraw.text
  5. local rand=misc.random
  6. a,b,e,f=50,50,0,4
  7. x,y=40,60
  8. lvl=1
  9. vie=3
  10. score=0
  11. bonus=0
  12. vitball=1
  13. local fichier = (file.search("LFcasse") ) or file.new("LFcasse",1)
  14.  
  15. best=file.read(fichier,1)
  16.  
  17. repeat --menu
  18. text(30,5,"casse brique")
  19. text(40,20,"c'est parti")
  20. text(1,30,"pour jouer")
  21. text(1,36,"appuyer sur EXE")
  22. text(100,40,"BEST :")
  23. text(105,48,best)
  24. text(1,58,"reinitialiser : DEL")
  25. refresh
  26. if key(36)
  27. then misc.exit()
  28. elseif key(19)
  29. then best=0
  30. end
  31. until key(5)
  32.  
  33. function table(x,y)
  34. line(x,y,x+20,y,4)
  35. line(x-1,y+1,x+21,y+1,3)
  36. line(x,y+2,x+20,y+2,4)
  37. end
  38.  
  39. function brique(x1,y1,x2,y2)
  40. line(x1,y1,x1,y2,4)
  41. line(x2,y1,x2,y2,4)
  42. line(x1,y1,x2,y1,4)
  43. line(x1,y2,x2,y2,4)
  44. line(x1,y1,x2,y2,3)
  45. line(x1,y2,x2,y1,3)
  46. line(x1,y2-1,x2,y2-1,4)
  47. end
  48.  
  49. function balle()
  50. line(a,b,a,b+1,4)
  51. line(a+1,b,a+1,b+1,4)
  52. end
  53. function brik()
  54. if g==0 -- niveau 1
  55. then brique(1,1,21,10)
  56. end
  57. if h==0
  58. then brique(22,1,42,10)
  59. end
  60. if i==0
  61. then brique(43,1,63,10)
  62. end
  63. if j==0
  64. then brique(64,1,84,10)
  65. end
  66. if k==0
  67. then brique(85,1,105,10)
  68. end
  69. if l==0 -- niveau 2
  70. then brique(1,11,21,20)
  71. end
  72. if m==0
  73. then brique(22,11,42,20)
  74. end
  75. if n==0
  76. then brique(43,11,63,20)
  77. end
  78. if o==0
  79. then brique(64,11,84,20)
  80. end
  81. if p==0
  82. then brique(85,11,105,20)
  83. end
  84. if q==0 -- niveau 3
  85. then brique(1,21,21,30)
  86. end
  87. if r==0
  88. then brique(22,21,42,30)
  89. end
  90. if s==0
  91. then brique(43,21,63,30)
  92. end
  93. if t==0
  94. then brique(64,21,84,30)
  95. end
  96. if u==0
  97. then brique(85,21,105,30)
  98. end
  99. if v==0 -- niveau 4
  100. then brique(1,40,16,45)
  101. end
  102. if w==0
  103. then brique(17,40,32,45)
  104. end
  105. if z==0
  106. then brique(33,40,48,45)
  107. end
  108. if ab==0
  109. then brique(49,40,64,45)
  110. end
  111. if ac==0
  112. then brique(65,40,80,45)
  113. end
  114. if ad==0
  115. then brique(81,40,96,45)
  116. end
  117. graydraw.text(107,10,"score")
  118. graydraw.text(109,15,score)
  119. refresh
  120. graydraw.text(107,25,"vie")
  121. graydraw.text(109,30,vie)
  122. refresh
  123. graydraw.text(107,40,"F1 :")
  124. graydraw.text(107,45,"pause")
  125. refresh
  126. table(x,y) -- plateforme
  127. balle()
  128. end
  129.  
  130. repeat
  131. repeat
  132. clear(nil)
  133. clear(0)
  134. graydraw.text(40,30,"niveau :")
  135. graydraw.text(80,30,lvl)
  136. refresh
  137. until key(5)
  138.  
  139. g,h,i,j,k=rand(2),rand(2),rand(2),rand(2),rand(2)-- aleatoire des briques
  140. l,m,n,o,p=rand(2),rand(2),rand(2),rand(2),rand(2)
  141. q,r,s,t,u=rand(2),rand(2),rand(2),rand(2),rand(2)
  142. v,w,z,ab,ac,ad=rand(2),rand(2),rand(2),rand(2),rand(2), rand(2)
  143. repeat
  144. clear(nil)
  145. repeat
  146. brik()
  147. refresh
  148.  if score>=300 -- augmentation de la vitesse de la balle
  149. then vitball=2
  150. end
  151. if key(40)
  152. then x=x+4
  153. elseif key(37)
  154. then x=x-4
  155. end
  156. refresh
  157. line(106,1,106,64,4)
  158. if x>=85
  159. then x=85
  160. elseif x<=1
  161. then x=1
  162. end
  163. if pixeltest(a,b+2)>=1 -- limite bas
  164. then e=1
  165. elseif b>=61
  166. then vie=vie-1
  167. a,b,e,f=50,50,0,4
  168. x,y=40,60
  169. elseif vie<=0
  170. then break
  171. end
  172. if e==1
  173. then b=b-vitball
  174. elseif e==0
  175. then b=b+vitball
  176. end
  177. if b<=2 -- limite haut
  178. then e=0
  179. end
  180. if a<=1 -- limite droite-gauche
  181. then
  182. f=1
  183. elseif a>=104
  184. then
  185. f=0
  186. end
  187. refresh
  188. if f==0
  189. then a=a-vitball
  190. elseif f==1
  191. then a=a+vitball
  192. elseif f==2
  193. then a=a+vitball+1
  194. elseif f==3
  195. then a=a-vitball-1
  196. end
  197. if key(40) and pixeltest(a,b+2)>=1 and b>=55 -- retour de la balle
  198. then f=2
  199. elseif key(37) and pixeltest(a,b+2)>=1 and b>=55
  200. then f=3
  201. end
  202. refresh
  203. if pixeltest(a,b-1)>=1
  204. then e=0
  205. elseif pixeltest(a+2,b)>=1
  206. then f=0
  207. elseif pixeltest(a-1,b)>=1
  208. then f=1
  209. end
  210. if pixeltest(a,b-2)>=1 and e==1 and b<=35
  211. then score=score+10 -- score
  212. end
  213. if key(36) -- option
  214. then
  215. break
  216. elseif key(45)
  217. then
  218. repeat
  219. clear(0)
  220. clear(nil)
  221. misc.wait(1)
  222. text(35,20,"pause")
  223. text(20,41,"appuyer sur EXE")
  224. graydraw.fill(5)
  225. refresh
  226. until key(5)
  227. end
  228. misc.wait(1)
  229. clear(0)
  230. until b<=31 or key(1) or key(36)
  231.  
  232. if a>=1 and a<=21 and b<=11 --brique du haut
  233. then g=1
  234. elseif a>=22 and a<=42 and b<=11
  235. then h=1
  236. elseif a>=43 and a<=63 and b<=11
  237. then i=1
  238. elseif a>=64 and a<=84 and b<=11
  239. then j=1
  240. elseif a>=85 and a<=105 and b<=11
  241. then k=1
  242. end
  243.  
  244. if a>=1 and a<=21 and b>=12 and b<=21 --brique du bas
  245. then l=1
  246. elseif a>=22 and a<=42 and b>=12 and b<=21
  247. then m=1
  248. elseif a>=43 and a<=63 and b>=12 and b<=21
  249. then n=1
  250. elseif a>=64 and a<=84 and b>=12 and b<=21
  251. then o=1
  252. elseif a>=85 and a<=105 and b>=12 and b<=21
  253. then p=1
  254. end
  255.  
  256. if a>=1 and a<=21 and b>=22 and b<=31 --brique 3eme niveau
  257. then q=1
  258. elseif a>=22 and a<=42 and b>=22 and b<=31
  259. then r=1
  260. elseif a>=43 and a<=63 and b>=22 and b<=31
  261. then s=1
  262. elseif a>=64 and a<=84 and b>=22 and b<=31
  263. then t=1
  264. elseif a>=85 and a<=105 and b>=22 and b<=31
  265. then u=1
  266. end
  267.  
  268. if g==1 and h==1 and i==1 and j==1 and k==1 and l==1 and m==1 and n==1 and o==1 and p==1 and q==1 and r==1 and s==1 and t==1 and u==1
  269. then break
  270. end
  271. if vie<=0
  272. then break
  273. end
  274. until key(1) or key(36)
  275. lvl=lvl+1
  276. a,b,e,f=50,50,0,4
  277. x,y=40,60
  278. if vie<=0
  279. then break
  280. end
  281. until key(36) or key(1)
  282. clear(nil)
  283.  
  284. if score >= best
  285. then file.write(fichier,1,score)
  286. end
  287. graydraw.setcolor(false)-- retour au B&W
  288. local print=nbdraw.print
  289. local cursor=nbdraw.setcursor
  290. repeat
  291. best=file.read(fichier,1)
  292. cursor(1,7)
  293. print("perdu")
  294. cursor(3,1)
  295. print("SCORE")
  296. cursor(3,7)
  297. print(score)
  298. cursor(5,1)
  299. print("BEST")
  300. cursor(5,7)
  301. print(best)
  302. until key(5)
  303.  
  304. misc.wait(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement