local line=graydraw.line local pixeltest=graydraw.pixeltest graydraw.setcolor(true) local text=graydraw.text local rand=misc.random a,b,e,f=50,50,0,4 x,y=40,60 lvl=1 vie=3 score=0 bonus=0 vitball=1 local fichier = (file.search("LFcasse") ) or file.new("LFcasse",1) best=file.read(fichier,1) repeat --menu text(30,5,"casse brique") text(40,20,"c'est parti") text(1,30,"pour jouer") text(1,36,"appuyer sur EXE") text(100,40,"BEST :") text(105,48,best) text(1,58,"reinitialiser : DEL") refresh if key(36) then misc.exit() elseif key(19) then best=0 end until key(5) function table(x,y) line(x,y,x+20,y,4) line(x-1,y+1,x+21,y+1,3) line(x,y+2,x+20,y+2,4) end function brique(x1,y1,x2,y2) line(x1,y1,x1,y2,4) line(x2,y1,x2,y2,4) line(x1,y1,x2,y1,4) line(x1,y2,x2,y2,4) line(x1,y1,x2,y2,3) line(x1,y2,x2,y1,3) line(x1,y2-1,x2,y2-1,4) end function balle() line(a,b,a,b+1,4) line(a+1,b,a+1,b+1,4) end function brik() if g==0 -- niveau 1 then brique(1,1,21,10) end if h==0 then brique(22,1,42,10) end if i==0 then brique(43,1,63,10) end if j==0 then brique(64,1,84,10) end if k==0 then brique(85,1,105,10) end if l==0 -- niveau 2 then brique(1,11,21,20) end if m==0 then brique(22,11,42,20) end if n==0 then brique(43,11,63,20) end if o==0 then brique(64,11,84,20) end if p==0 then brique(85,11,105,20) end if q==0 -- niveau 3 then brique(1,21,21,30) end if r==0 then brique(22,21,42,30) end if s==0 then brique(43,21,63,30) end if t==0 then brique(64,21,84,30) end if u==0 then brique(85,21,105,30) end if v==0 -- niveau 4 then brique(1,40,16,45) end if w==0 then brique(17,40,32,45) end if z==0 then brique(33,40,48,45) end if ab==0 then brique(49,40,64,45) end if ac==0 then brique(65,40,80,45) end if ad==0 then brique(81,40,96,45) end graydraw.text(107,10,"score") graydraw.text(109,15,score) refresh graydraw.text(107,25,"vie") graydraw.text(109,30,vie) refresh graydraw.text(107,40,"F1 :") graydraw.text(107,45,"pause") refresh table(x,y) -- plateforme balle() end repeat repeat clear(nil) clear(0) graydraw.text(40,30,"niveau :") graydraw.text(80,30,lvl) refresh until key(5) g,h,i,j,k=rand(2),rand(2),rand(2),rand(2),rand(2) l,m,n,o,p=rand(2),rand(2),rand(2),rand(2),rand(2) q,r,s,t,u=rand(2),rand(2),rand(2),rand(2),rand(2) v,w,z,ab,ac,ad=rand(2),rand(2),rand(2),rand(2),rand(2), rand(2) repeat clear(nil) repeat brik() refresh if score>=300 -- augmentation de la vitesse de la balle then vitball=2 end if key(40) then x=x+4 elseif key(37) then x=x-4 end refresh line(106,1,106,64,4) if x>=85 then x=85 elseif x<=1 then x=1 end if pixeltest(a,b+2)>=1 -- limite bas then e=1 elseif b>=61 then vie=vie-1 a,b,e,f=50,50,0,4 x,y=40,60 elseif vie<=0 then break end if e==1 then b=b-vitball elseif e==0 then b=b+vitball end if b<=2 -- limite haut then e=0 end if a<=1 -- limite droite-gauche then f=1 elseif a>=104 then f=0 end refresh if f==0 then a=a-vitball elseif f==1 then a=a+vitball elseif f==2 then a=a+vitball+1 elseif f==3 then a=a-vitball-1 end if key(40) and pixeltest(a,b+2)>=1 and b>=55 -- retour de la balle then f=2 elseif key(37) and pixeltest(a,b+2)>=1 and b>=55 then f=3 end refresh if pixeltest(a,b-1)>=1 then e=0 elseif pixeltest(a+2,b)>=1 then f=0 elseif pixeltest(a-1,b)>=1 then f=1 end if pixeltest(a,b-2)>=1 and e==1 and b<=35 then score=score+10 -- score end if key(36) -- option then break elseif key(45) then repeat clear(0) clear(nil) misc.wait(1) text(35,20,"pause") text(20,41,"appuyer sur EXE") graydraw.fill(5) refresh until key(5) end misc.wait(1) clear(0) until b<=31 or key(1) or key(36) if a>=1 and a<=21 and b<=11 --brique du haut then g=1 elseif a>=22 and a<=42 and b<=11 then h=1 elseif a>=43 and a<=63 and b<=11 then i=1 elseif a>=64 and a<=84 and b<=11 then j=1 elseif a>=85 and a<=105 and b<=11 then k=1 end if a>=1 and a<=21 and b>=12 and b<=21 --brique du bas then l=1 elseif a>=22 and a<=42 and b>=12 and b<=21 then m=1 elseif a>=43 and a<=63 and b>=12 and b<=21 then n=1 elseif a>=64 and a<=84 and b>=12 and b<=21 then o=1 elseif a>=85 and a<=105 and b>=12 and b<=21 then p=1 end if a>=1 and a<=21 and b>=22 and b<=31 --brique 3eme niveau then q=1 elseif a>=22 and a<=42 and b>=22 and b<=31 then r=1 elseif a>=43 and a<=63 and b>=22 and b<=31 then s=1 elseif a>=64 and a<=84 and b>=22 and b<=31 then t=1 elseif a>=85 and a<=105 and b>=22 and b<=31 then u=1 end 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 then break end if vie<=0 then break end until key(1) or key(36) lvl=lvl+1 a,b,e,f=50,50,0,4 x,y=40,60 if vie<=0 then break end until key(36) or key(1) clear(nil) if score >= best then file.write(fichier,1,score) end repeat best=file.read(fichier,1) graydraw.text(40,10,"perdu") text(40,25,"SCORE") text(70,25,score) text(40,35,"BEST") text(70,35,best) refresh until key(5) misc.wait(50) misc.exit()