program BADASS_RUSH_HOUR; uses graph, crt; (*librairies utilis‚es*) var pilote, mode, x, y, sco:integer; score, name :string; var yr, ybv, ybh, yyv, ygh, yov, yth, yah, ymv, xnh, xvh, xpv, xwv, xcv, xr, xbv, xbh, xyv, xgh, xov, xth, xah, xmv, ynh, yvh, ypv, ywv, ycv, w1,theta,theta1,theta2, x1,y1,x2,s,y2, level: integer; rad:real; K, L, A, B :char; {on declare les variables} t:array [-1..14,-1..14] of Integer; {le tableau boleen} const c=46; xi=176; yi=96; {constantes pour les dimensions du tableau} procedure reset; {procedure pour vider le tableau} begin setlinestyle(0,1,3); for x:=0 to 5 do begin for y:=0 to 5 do begin t[x,y]:=0; (*la matrice-positions se vide*) end;end; end; procedure redcar; begin setfillstyle(1,red); (*couleur de l'auto*) bar(xi+xr*c+2,yi+yr*c+2,xi+2*c+xr*c-2,yi+c+yr*c-2); outtextxy(xi+c+xr*c,yi+21+yr*c,'1'); {on dessinne l'auto et son numero} if t[xr,yr]=0 then inc(t[xr,yr]); if t[xr+1,yr]=0 then inc(t[xr+1,yr]); {dessine l'auto rouge et incremente la valeur dans le tableau aux coordonnees correspondantes a sa position seulement si cette valeur vaut 0} end; procedure bluecarv; {meme chose que pour l'auto rouge} begin setfillstyle(1,blue); bar(xi+xbv*c+2,yi+ybv*c+2,xi+c+xbv*c-2,yi+3*c+ybv*c-2); outtextxy(xi+21+xbv*c,yi+63+ybv*c,'2'); if t[xbv,ybv]=0 then inc(t[xbv,ybv]); if t[xbv,ybv+1]=0 then inc(t[xbv,ybv+1]); if t[xbv,ybv+2]=0 then inc(t[xbv,ybv+2]); end; procedure yellowcarv; begin setfillstyle(1,yellow); bar(xi+xyv*c+2,yi+yyv*c+2,xi+c+xyv*c-2,yi+3*c+yyv*c-2); outtextxy(xi+21+xyv*c,yi+63+yyv*c,'3'); if t[xyv,yyv]=0 then inc(t[xyv,yyv]); if t[xyv,yyv+1]=0 then inc(t[xyv,yyv+1]); if t[xyv,yyv+2]=0 then inc(t[xyv,yyv+2]); end; procedure greencarh; begin setfillstyle(1,green); bar(xi+xgh*c+2,yi+ygh*c+2,xi+2*c+xgh*c-2,yi+c+ygh*c-2); outtextxy(xi+c+xgh*c,yi+21+ygh*c,'4'); if t[xgh,ygh]=0 then inc(t[xgh,ygh]); if t[xgh+1,ygh]=0 then inc(t[xgh+1,ygh]); end; procedure orangecarv; begin setfillstyle(1,brown); bar(xi+xov*c+2,yi+yov*c+2,xi+c+xov*c-2,yi+2*c+yov*c-2); outtextxy(xi+21+xov*c,yi+c+yov*c,'5'); if t[xov,yov]=0 then inc(t[xov,yov]); if t[xov,yov+1]=0 then inc(t[xov,yov+1]); end; procedure turquoisecarh; begin setfillstyle(1,lightgreen); bar(xi+xth*c+2,yi+yth*c+2,xi+3*c+xth*c-2,yi+c+yth*c-2); outtextxy(xi+63+xth*c,yi+21+yth*c,'6'); if t[xth,yth]=0 then inc(t[xth,yth]); if t[xth+1,yth]=0 then inc(t[xth+1,yth]); if t[xth+2,yth]=0 then inc(t[xth+2,yth]); end; procedure bluecarh; begin setfillstyle(1,blue); bar(xi+xbh*c+2,yi+ybh*c+2,xi+3*c+xbh*c-2,yi+c+ybh*c-2); outtextxy(xi+63+xbh*c,yi+21+ybh*c,'2'); if t[xbh,ybh]=0 then inc(t[xbh,ybh]); if t[xbh+1,ybh]=0 then inc(t[xbh+1,ybh]); if t[xbh+2,ybh]=0 then inc(t[xbh+2,ybh]); end; procedure azurcarh; {...encore des autos...} begin setfillstyle(1,cyan); bar(xi+xah*c+2,yi+yah*c+2,xi+2*c+xah*c-2,yi+c+yah*c-2); outtextxy(xi+c+xah*c,yi+21+yah*c,'7'); if t[xah,yah]=0 then inc(t[xah,yah]); if t[xah+1,yah]=0 then inc(t[xah+1,yah]); end; procedure mauvecarv; begin setfillstyle(1,magenta); bar(xi+xmv*c+2,yi+ymv*c+2,xi+c+xmv*c-2,yi+3*c+ymv*c-2); outtextxy(xi+21+xmv*c,yi+63+ymv*c,'8'); if t[xmv,ymv]=0 then inc(t[xmv,ymv]); if t[xmv,ymv+1]=0 then inc(t[xmv,ymv+1]); if t[xmv,ymv+2]=0 then inc(t[xmv,ymv+2]); end; procedure noirecarh; begin setfillstyle(1,darkgray); bar(xi+xnh*c+2,yi+ynh*c+2,xi+2*c+xnh*c-2,yi+c+ynh*c-2); outtextxy(xi+c+xnh*c,yi+21+ynh*c,'9'); if t[xnh,ynh]=0 then inc(t[xnh,ynh]); if t[xnh+1,ynh]=0 then inc(t[xnh+1,ynh]); end; procedure violetcarh; begin setfillstyle(1,lightblue); bar(xi+xvh*c+2,yi+yvh*c+2,xi+2*c+xvh*c-2,yi+c+yvh*c-2); outtextxy(xi+c+xvh*c,yi+21+yvh*c,'Q'); if t[xvh,yvh]=0 then inc(t[xvh,yvh]); if t[xvh+1,yvh]=0 then inc(t[xvh+1,yvh]); end; procedure pinkcarv; begin setfillstyle(1,lightred); bar(xi+xpv*c+2,yi+ypv*c+2,xi+c+xpv*c-2,yi+2*c+ypv*c-2); outtextxy(xi+21+xpv*c,yi+c+ypv*c,'W'); if t[xpv,ypv]=0 then inc(t[xpv,ypv]); if t[xpv,ypv+1]=0 then inc(t[xpv,ypv+1]); end; procedure whitecarv; begin setfillstyle(7,brown); bar(xi+xwv*c+2,yi+ywv*c+2,xi+c+xwv*c-2,yi+2*c+ywv*c-2); outtextxy(xi+21+xwv*c,yi+c+ywv*c,'E'); if t[xwv,ywv]=0 then inc(t[xwv,ywv]); if t[xwv,ywv+1]=0 then inc(t[xwv,ywv+1]); end; procedure couleurcarv; begin setfillstyle(7,red); bar(xi+xcv*c+2,yi+ycv*c+2,xi+c+xcv*c-2,yi+2*c+ycv*c-2); outtextxy(xi+21+xcv*c,yi+c+ycv*c,'R'); if t[xcv,ycv]=0 then inc(t[xcv,ycv]); if t[xcv,ycv+1]=0 then inc(t[xcv,ycv+1]); end; procedure JOUER; {procedure principale} BEGIN initgraph(pilote,mode,'m:/bgi'); (*initialisation du mode graphique*) setcolor(lightgray); setlinestyle(0,1,3); (*parametres de style*) for x:=0 to 5 do begin for y:=0 to 5 do begin rectangle(c*(x)+xi,c*(y)+yi,c*(x+1)+xi,c*(y+1)+yi); {on dessine tous les carreaux} end;end; for x:=-1 to 7 do {on met les valeurs du tableau a 0} begin for y:=-1 to 6 do t[x,y]:=0; end; for x:=8 to 14 do {empeche cles autos inutilisees de bouger} begin for y:=9 to 14 do t[x,y]:=1; end; L:='r'; reset; redcar; bluecarv; bluecarh; yellowcarv; greencarh; orangecarv; turquoisecarh; azurcarh; mauvecarv; noirecarh; violetcarh; pinkcarv; whitecarv; couleurcarv; {on dessinne toutes les autos} str(sco,score); setfillstyle(black,1); bar(250,400,500,450); outtextxy(250,400,'VOTRE SCORE : '+score); {affichage du score} settextstyle(1,0,4); setcolor(lightgray); OuttextXY(234-1,33,'RUSH HOUR'); setcolor(white); {affichage de l'en-tete} outtextXY(234,33,'RUSH HOUR'); settextstyle(0,1,0); setcolor(red); outtextXY(468,188,chr(25)+' EXIT');{signe de sortie} settextstyle(0,0,0); setcolor(lightgray); outtextXY(230,73,'Appuyez ''X'' pour quitter'); repeat {boucle principale} K:=readkey; Case K of '1': L:='r'; '2': L:='b'; '3': L:='y'; '4': L:='g'; '5': L:='o'; '6': L:='t'; '7': L:='a'; '8': L:='m'; '9': L:='n'; 'q': L:='v'; 'w': L:='p'; 'e': L:='w'; 'r': L:='c'; {choix de l'auto} end; Case K of (#77): (*deplacements vers la droite*) begin setfillstyle(1,black); if (xr<6) and (t[xr+2,yr]=0) and (L='r') then begin inc(xr); {si l'auto rouge est selectionnee et quelle nest pas bloquee elle peut avancer} bar(xi+(xr-1)*c+2,yi+yr*c+2,xi+xr*c-2,yi+c+yr*c-2); {efface l'ecran et baisse le score} line(xi+xr*c,yi+yr*c,xi+xr*c,yi+c+yr*c); sco:=sco-100; end; (*meme chose pour les autres autos*) if (xgh<4) and (t[xgh+2,ygh]=0) and (L='g') then begin inc(xgh); bar(xi+(xgh-1)*c+2,yi+ygh*c+2,xi+xgh*c-2,yi+c+ygh*c-2); line(xi+xgh*c,yi+ygh*c,xi+xgh*c,yi+c+ygh*c); sco:=sco-100; end; if (xth<3) and (t[xth+3,yth]=0) and (L='t') then begin inc(xth); bar(xi+(xth-1)*c+2,yi+yth*c+2,xi+xth*c-2,yi+c+yth*c-2); line(xi+xth*c,yi+yth*c,xi+xth*c,yi+c+yth*c); sco:=sco-100; end; if (xah<4) and (t[xah+2,yah]=0) and (L='a') then begin inc(xah); bar(xi+(xah-1)*c+2,yi+yah*c+2,xi+xah*c-2,yi+c+yah*c-2); line(xi+xah*c,yi+yah*c,xi+xah*c,yi+c+yah*c); sco:=sco-100; end; if (xnh<4) and (t[xnh+2,ynh]=0) and (L='n') then begin inc(xnh); bar(xi+(xnh-1)*c+2,yi+ynh*c+2,xi+xnh*c-2,yi+c+ynh*c-2); line(xi+xnh*c,yi+ynh*c,xi+xnh*c,yi+c+ynh*c); sco:=sco-100; end; if (xvh<4) and (t[xvh+2,yvh]=0) and (L='v') then begin inc(xvh); bar(xi+(xvh-1)*c+2,yi+yvh*c+2,xi+xvh*c-2,yi+c+yvh*c-2); line(xi+xvh*c,yi+yvh*c,xi+xvh*c,yi+c+yvh*c); sco:=sco-100; end; if (xbh<3) and (t[xbh+3,ybh]=0) and (L='b') then begin inc(xbh); bar(xi+(xbh-1)*c+2,yi+ybh*c+2,xi+xbh*c-2,yi+c+ybh*c-2); line(xi+xbh*c,yi+ybh*c,xi+xbh*c,yi+c+ybh*c); sco:=sco-100; end; if sco<0 then sco:=sco+100; {le score ne peut aller sous zero} end; (#75): (*deplacements vers la gauche*) {meme chose que pour la droite} begin setfillstyle(1,black); if (xr>0) and (t[xr-1,yr]=0) and (L='r') then begin dec(xr); bar(xi+(xr+2)*c+2,yi+yr*c+2,xi+(xr+3)*c-2,yi+c+yr*c-2); line(xi+(xr+2)*c,yi+yr*c,xi+(xr+2)*c,yi+c+yr*c); sco:=sco-100; end; if (xgh>0) and (t[xgh-1,ygh]=0) and (L='g') then begin dec(xgh); bar(xi+(xgh+2)*c+2,yi+ygh*c+2,xi+(xgh+3)*c-2,yi+c+ygh*c-2); line(xi+(xgh+2)*c,yi+ygh*c,xi+(xgh+2)*c,yi+c+ygh*c); sco:=sco-100; end; if (xth>0) and (t[xth-1,yth]=0) and (L='t') then begin dec(xth); bar(xi+(xth+3)*c+2,yi+yth*c+2,xi+(xth+4)*c-2,yi+c+yth*c-2); line(xi+(xth+3)*c,yi+yth*c,xi+(xth+3)*c,yi+c+yth*c); sco:=sco-100; end; if (xah>0) and (t[xah-1,yah]=0) and (L='a') then begin dec(xah); bar(xi+(xah+2)*c+2,yi+yah*c+2,xi+(xah+3)*c-2,yi+c+yah*c-2); line(xi+(xah+2)*c,yi+yah*c,xi+(xah+2)*c,yi+c+yah*c); sco:=sco-100; end; if (xnh>0) and (t[xnh-1,ynh]=0) and (L='n') then begin dec(xnh); bar(xi+(xnh+2)*c+2,yi+ynh*c+2,xi+(xnh+3)*c-2,yi+c+ynh*c-2); line(xi+(xnh+2)*c,yi+ynh*c,xi+(xnh+2)*c,yi+c+ynh*c); sco:=sco-100; end; if (xvh>0) and (t[xvh-1,yvh]=0) and (L='v') then begin dec(xvh); bar(xi+(xvh+2)*c+2,yi+yvh*c+2,xi+(xvh+3)*c-2,yi+c+yvh*c-2); line(xi+(xvh+2)*c,yi+yvh*c,xi+(xvh+2)*c,yi+c+yvh*c); sco:=sco-100; end; if (xbh>0) and (t[xbh-1,ybh]=0) and (L='b') then begin dec(xbh); bar(xi+(xbh+3)*c+2,yi+ybh*c+2,xi+(xbh+4)*c-2,yi+c+ybh*c-2); line(xi+(xbh+3)*c,yi+ybh*c,xi+(xbh+3)*c,yi+c+ybh*c); sco:=sco-100; end; if sco<0 then sco:=sco+100; end; (#80): (*deplacements vers le bas*) begin setfillstyle(1,black); if (ybv<3) and (t[xbv,ybv+3]=0) and (L='b') then begin inc(ybv); bar(xi+xbv*c+2,yi+(ybv-1)*c+2,xi+c+xbv*c-2,yi+ybv*c-2); line(xi+xbv*c,yi+ybv*c,xi+c+xbv*c,yi+ybv*c); sco:=sco-100; end; if (yyv<3) and (t[xyv,yyv+3]=0) and (L='y') then begin inc(yyv); bar(xi+xyv*c+2,yi+(yyv-1)*c+2,xi+c+xyv*c-2,yi+yyv*c-2); line(xi+xyv*c,yi+yyv*c,xi+c+xyv*c,yi+yyv*c); sco:=sco-100; end; if (yov<4) and (t[xov,yov+2]=0) and (L='o') then begin inc(yov); bar(xi+xov*c+2,yi+(yov-1)*c+2,xi+c+xov*c-2,yi+yov*c-2); line(xi+xov*c,yi+yov*c,xi+c+xov*c,yi+yov*c); sco:=sco-100; end; if (ymv<3) and (t[xmv,ymv+3]=0) and (L='m') then begin inc(ymv); bar(xi+xmv*c+2,yi+(ymv-1)*c+2,xi+c+xmv*c-2,yi+ymv*c-2); line(xi+xmv*c,yi+ymv*c,xi+c+xmv*c,yi+ymv*c); sco:=sco-100; end; if (ypv<4) and (t[xpv,ypv+2]=0) and (L='p') then begin inc(ypv); bar(xi+xpv*c+2,yi+(ypv-1)*c+2,xi+c+xpv*c-2,yi+ypv*c-2); line(xi+xpv*c,yi+ypv*c,xi+c+xpv*c,yi+ypv*c); sco:=sco-100; end; if (ywv<4) and (t[xwv,ywv+2]=0) and (L='w') then begin inc(ywv); bar(xi+xwv*c+2,yi+(ywv-1)*c+2,xi+c+xwv*c-2,yi+ywv*c-2); line(xi+xwv*c,yi+ywv*c,xi+c+xwv*c,yi+ywv*c); sco:=sco-100; end; if (ycv<4) and (t[xcv,ycv+2]=0) and (L='c') then begin inc(ycv); bar(xi+xcv*c+2,yi+(ycv-1)*c+2,xi+c+xcv*c-2,yi+ycv*c-2); line(xi+xcv*c,yi+ycv*c,xi+c+xcv*c,yi+ycv*c); sco:=sco-100; end; if sco<0 then sco:=sco+100; end; (#72): (*deplacements vers le haut*) begin setfillstyle(1,black); if (ybv>0) and (t[xbv,ybv-1]=0) and (L='b') then begin dec(ybv); bar(xi+xbv*c+2,yi+(ybv+3)*c+2,xi+c+xbv*c-2,yi+(ybv+4)*c-2); line(xi+xbv*c,yi+(ybv+3)*c,xi+c+xbv*c,yi+(ybv+3)*c); sco:=sco-100; end; if (yyv>0) and (t[xyv,yyv-1]=0) and (L='y') then begin dec(yyv); bar(xi+xyv*c+2,yi+(yyv+3)*c+2,xi+c+xyv*c-2,yi+(yyv+4)*c-2); line(xi+xyv*c,yi+(yyv+3)*c,xi+c+xyv*c,yi+(yyv+3)*c); sco:=sco-100; end; if (yov>0) and (t[xov,yov-1]=0) and (L='o') then begin dec(yov); bar(xi+xov*c+2,yi+(yov+2)*c+2,xi+c+xov*c-2,yi+(yov+3)*c-2); line(xi+xov*c,yi+(yov+2)*c,xi+c+xov*c,yi+(yov+2)*c); sco:=sco-100; end; if (ymv>0) and (t[xmv,ymv-1]=0) and (L='m') then begin dec(ymv); bar(xi+xmv*c+2,yi+(ymv+3)*c+2,xi+c+xmv*c-2,yi+(ymv+4)*c-2); line(xi+xmv*c,yi+(ymv+3)*c,xi+c+xmv*c,yi+(ymv+3)*c); sco:=sco-100; end; if (ypv>0) and (t[xpv,ypv-1]=0) and (L='p') then begin dec(ypv); bar(xi+xpv*c+2,yi+(ypv+2)*c+2,xi+c+xpv*c-2,yi+(ypv+3)*c-2); line(xi+xpv*c,yi+(ypv+2)*c,xi+c+xpv*c,yi+(ypv+2)*c); sco:=sco-100; end; if (ywv>0) and (t[xwv,ywv-1]=0) and (L='w') then begin dec(ywv); bar(xi+xwv*c+2,yi+(ywv+2)*c+2,xi+c+xwv*c-2,yi+(ywv+3)*c-2); line(xi+xwv*c,yi+(ywv+2)*c,xi+c+xwv*c,yi+(ywv+2)*c); sco:=sco-100; end; if (ycv>0) and (t[xcv,ycv-1]=0) and (L='c') then begin dec(ycv); bar(xi+xcv*c+2,yi+(ycv+2)*c+2,xi+c+xcv*c-2,yi+(ycv+3)*c-2); line(xi+xcv*c,yi+(ycv+2)*c,xi+c+xcv*c,yi+(ycv+2)*c); sco:=sco-100; end; if sco<0 then sco:=sco+100; end; end; reset; {reinitialise le tableau} redcar; bluecarv; bluecarh; yellowcarv; greencarh; orangecarv; turquoisecarh; azurcarh; mauvecarv; noirecarh; violetcarh; pinkcarv; whitecarv; couleurcarv; {redessinne les autos} str(sco,score); setfillstyle(black,1); bar(250,400,500,450); outtextxy(250,400,'VOTRE SCORE : '+score); {affiche le score} if sco=0 then outtextxy(210,420,'Vous ˆtes NUUUUUL,'+name); until (xr=6) OR (K='x'); {le jeu se termine quand le joueur abandonne ou gagne} if xr=6 then begin {message de victoire} delay(500); initgraph(pilote,mode,'m:/bgi'); setbkcolor(red); outtextxy(220,200, 'F‚licitations ! '+name); outtextxy(200,220, 'Votre score est de '+score+' points'); sound(349); delay(200); nosound; delay(20); sound(349); delay(200); sound(392); delay(200); sound(349); delay(200); sound(392); delay(200); sound(440); delay(600); nosound; delay(3000); setbkcolor(black); end (*le score est affich‚ sur fond rouge et une musique joue*) else begin initgraph(pilote,mode,'m:/bgi'); {ecran d'abandon} setbkcolor(white); delay(300); setbkcolor(black); delay(300); setbkcolor(white); delay(300); setbkcolor(black); end; end; procedure welcome; begin for w1:=2 to 120 do {une boucle pour faire bouger le texte} begin setcolor(black); settextstyle(1,0,8); OuttextXY(w1-1,120,'RUSH HOUR'); setcolor(white); outtextXY(w1,120,'RUSH HOUR'); delay(20); {un texte RUSH HOUR qui bouge et s'efface} end; settextstyle(0,0,0); setcolor(darkgray); outtextxy(10,10,'Par Thomas Paradis et Guillaume Verdon'); {tracage des formes principales de la montre} setcolor(white); setfillstyle(1,8); bar(310,320-70,330,240); fillellipse(320,240,10,2); fillellipse(320,320,70,70); setfillstyle(1,15); fillellipse(320,320,60,60); settextstyle(15,0,0); {tracage des lignes de la montre} setlinestyle(9,$c3,1); setcolor(black); for theta:=0 to 360 do begin if (theta mod 30)=0 then{on veut a chaque 30 degres car il y a 12 heures} begin rad:=((Pi/180)*theta);{on convertit l'angle en radians} {on multiplie le rayon voulu par sin ou cos de l'angle puis on arrondit la valeur pour obtenir une valeur integer} x2:=round(60*cos(rad)); x1:=round(50*cos(rad)); y2:=round(60*sin(rad)); y1:=round(50*sin(rad)); line(x1+320,y1+320,x2+320,y2+320);{on trace les lignes} end; end; for theta:=-90 to (360*2+270) do begin if theta mod 15=0 then begin if theta mod 2=0 then sound(200) else sound(400); end; if (theta mod 10)=0 then begin {meme principe que precedemment sauf qu'on efface l'aiguille precedente} rad:=((Pi/180)*(theta-10)); x2:=round(50*cos(rad)); y2:=round(50*sin(rad)); setcolor(white); line(320,320,x2+320,y2+320); delay(15);{on met un delay pour qu'on ait le temps de voir l'effet} setcolor(red); rad:=((Pi/180)*theta); x2:=round(50*cos(rad)); y2:=round(50*sin(rad)); line(320,320,x2+320,y2+320); {meme chose pour la seconde aiguille mais on divise l'angle par 12 pour qu'elle avance plus lentement} rad:=((Pi/(12*180))*(theta-10)); x2:=round(30*cos(rad)); y2:=round(30*sin(rad)); setcolor(white); line(320,320,x2+320,y2+320); delay(25); setcolor(blue); rad:=((Pi/(12*180))*theta); x2:=round(30*cos(rad)); y2:=round(30*sin(rad)); line(320,320,x2+320,y2+320); end; end; nosound; outtextXY(255,400,'Entrez votre nom!'); Gotoxy(36,14); readln(name); {l'usager entre son nom et on le lis} sound(2*250);delay(100);sound(2*300);delay(100);sound(2*350); delay(100);sound(2*400);delay(100);sound(2*450);delay(100); end; procedure chosediff; {choix de la difficulte} begin cleardevice; setfillstyle(9,blue); bar(175,100,450,280); rectangle(180,105,445,275); setfillstyle(8,blue); bar(195,113,310,133); outtextXY(200,120,'1.Facile A'); bar(325,113,440,133); (*on dessine le menu de s‚lection*) outtextXY(330,120,'2.Facile B'); setfillstyle(8,green); bar(195,143,310,163); outtextXY(200,150,'3.Moyen A'); bar(325,143,440,163); outtextXY(330,150,'4.Moyen B'); setfillstyle(8,yellow); bar(195,173,310,193); outtextXY(200,180,'5.Difficile A'); bar(325,173,440,193); outtextXY(330,180,'6.Difficile B'); setfillstyle(8,red); bar(195,203,310,223); outtextXY(200,210,'7.Expert A'); bar(325,203,440,223); outtextXY(330,210,'8.Expert B'); setfillstyle(8,lightblue); bar(195,233,330,253); outtextXY(200,240,'X.Retour au menu'); B:=readkey; {lis la touche entree par l'utilisateur} case B of {boucle de choix de niveau} '1': begin {la selection clignote} sound(392);setfillstyle(1,white); bar(195,113,310,133); delay(100); setfillstyle(8,blue); bar(195,113,310,133); outtextXY(200,120,'1.Facile A'); sound(523); delay(100); setfillstyle(1,white); bar(195,113,310,133); nosound; delay(100); setfillstyle(8,blue); bar(195,113,310,133); outtextXY(200,120,'1.Facile A'); xr:=1; xbv:=3; xyv:=5; xgh:=0; xov:=0; xth:=2; xah:=4; xwv:=0; yr:=2; ybv:=1; yyv:=0; ygh:=0; yov:=4; yth:=5; yah:=4; ywv:=10; {variables pour charger le niveau} xmv:=0; xnh:=10; xvh:=10; xpv:=10; xbh:=10; xcv:=10; ymv:=1; ynh:=10; yvh:=10; ypv:=10; ybh:=10; ycv:=10; sco:=2800; {le score est definit} JOUER; {le jeu commence} end; '2': begin sound(392);setfillstyle(1,white); bar(325,113,440,133); delay(100); setfillstyle(8,blue); bar(325,113,440,133); outtextXY(330,120,'2.Facile B'); sound(523); delay(100); setfillstyle(1,white); bar(325,113,440,133); nosound; delay(100); setfillstyle(8,blue); bar(325,113,440,133); outtextXY(330,120,'2.Facile B'); xr:=0; xbv:=10; xyv:=10; xgh:=0; xov:=3; xth:=3; xah:=10; xwv:=0; yr:=2; ybv:=10; yyv:=10; ygh:=5; yov:=1; yth:=0; yah:=10; ywv:=0; xmv:=5; xnh:=3; xvh:=4; xpv:=2; xbh:=0; xcv:=4; ymv:=1; ynh:=5; yvh:=4; ypv:=4; ybh:=3; ycv:=2; sco:=2600; JOUER; end; '3': begin sound(392);setfillstyle(1,white);bar(195,143,310,163); delay(100); setfillstyle(8,green); bar(195,143,310,163); outtextXY(200,150,'3.Moyen A'); sound(523); delay(100); setfillstyle(1,white);bar(195,143,310,163); nosound; delay(100); setfillstyle(8,green);bar(195,143,310,163); outtextXY(200,150,'3.Moyen A'); xr:=1; xbv:=10; xyv:=0; xgh:=1; xov:=2; xth:=2; xah:=10; xwv:=5; yr:=2; ybv:=10; yyv:=0; ygh:=0; yov:=3; yth:=5; yah:=10; ywv:=4; xmv:=3; xnh:=10; xvh:=10; xpv:=10; xbh:=3; xcv:=10; ymv:=0; ynh:=10; yvh:=10; ypv:=10; ybh:=3; ycv:=10; sco:=7300; JOUER; end; '4': begin sound(392);setfillstyle(1,white);bar(325,143,440,163); delay(100); setfillstyle(8,green); bar(325,143,440,163); outtextXY(330,150,'4.Moyen B'); sound(523); delay(100); setfillstyle(1,white);bar(325,143,440,163); nosound; delay(100); setfillstyle(8,green);bar(325,143,440,163); outtextXY(330,150,'4.Moyen B'); xr:=3; xbv:=10; xyv:=5; xgh:=0; xov:=4; xth:=3; xah:=2; xwv:=1; yr:=2; ybv:=10; yyv:=0; ygh:=0; yov:=0; yth:=3; yah:=0; ywv:=2; xmv:=2; xnh:=0; xvh:=2; xpv:=0; xbh:=10; xcv:=10; ymv:=2; ynh:=5; yvh:=1; ypv:=1; ybh:=10; ycv:=10; sco:=10000; JOUER; end; '5' : begin sound(392);setfillstyle(1,white);bar(195,173,310,193);delay(100); setfillstyle(8,yellow); bar(195,173,310,193); outtextXY(200,180,'5.Difficile A'); sound(523); delay(100); setfillstyle(1,white); bar(195,173,310,193); nosound; delay(100); setfillstyle(8,yellow); bar(195,173,310,193); outtextXY(200,180,'5.Difficile A'); xr:=1; xbv:=10; xyv:=3; xgh:=0; xov:=2; xth:=3; xah:=10; xwv:=10; yr:=2; ybv:=10; yyv:=0; ygh:=0; yov:=0; yth:=5; yah:=10; ywv:=10; xmv:=0; xnh:=10; xvh:=10; xpv:=10; xbh:=1; xcv:=10; ymv:=1; ynh:=10; yvh:=10; ypv:=10; ybh:=3; ycv:=10; sco:=10000; JOUER; end; '6' : begin sound(392);setfillstyle(1,white);bar(325,173,440,193);delay(100); setfillstyle(8,yellow); bar(325,173,440,193); outtextXY(330,180,'6.Difficile B'); sound(523); delay(100); setfillstyle(1,white); bar(325,173,440,193); nosound; delay(100); setfillstyle(8,yellow); bar(325,173,440,193); outtextXY(330,180,'6.Difficile B'); xr:=1; xbv:=5; xyv:=0; xgh:=2; xov:=3; xth:=3; xah:=0; xwv:=2; yr:=2; ybv:=3; yyv:=0; ygh:=5; yov:=1; yth:=0; yah:=3; ywv:=0; xmv:=10; xnh:=2; xvh:=0; xpv:=10; xbh:=10; xcv:=10; ymv:=10; ynh:=3; yvh:=5; ypv:=10; ybh:=10; ycv:=10; sco:=10000; JOUER; end; '7' : begin sound(392);setfillstyle(1,white);bar(195,203,310,223);delay(100); setfillstyle(8,red); bar(195,203,310,223); outtextXY(200,210,'7.Expert A'); sound(523); delay(100); setfillstyle(1,white); bar(195,203,310,223); nosound; delay(100); setfillstyle(8,red); bar(195,203,310,223); outtextXY(200,210,'7.Expert A'); xr:=0; xbv:=10; xyv:=2; xgh:=1; xov:=1; xth:=10; xah:=4; xwv:=3; yr:=2; ybv:=10; yyv:=0; ygh:=4; yov:=0; yth:=10; yah:=0; ywv:=4; xmv:=5; xnh:=1; xvh:=3; xpv:=0; xbh:=0; xcv:=4; ymv:=3; ynh:=3; yvh:=3; ypv:=3; ybh:=5; ycv:=4; sco:=10000; JOUER; end; '8' : begin sound(392);setfillstyle(1,white);bar(325,203,440,223);delay(100); setfillstyle(8,red); bar(325,203,440,223); outtextXY(330,210,'8.Expert B'); sound(523); delay(100); setfillstyle(1,white); bar(325,203,440,223); nosound; delay(100); setfillstyle(8,red); bar(325,203,440,223); outtextXY(330,210,'8.Expert B'); xr:=2; xbv:=10; xyv:=0; xgh:=4; xov:=1; xth:=0; xah:=2; xwv:=2; yr:=2; ybv:=10; yyv:=0; ygh:=4; yov:=1; yth:=3; yah:=1; ywv:=4; xmv:=5; xnh:=0; xvh:=4; xpv:=3; xbh:=1; xcv:=10; ymv:=1; ynh:=5; yvh:=0; ypv:=3; ybh:=0; ycv:=10; sco:=10000; JOUER; end; 'x': begin sound(523); delay(100);sound(392);delay(100);nosound; end; end; end; procedure howto; begin {ecriture du texte de description sur comment jouer} cleardevice; setcolor(white); setfillstyle(9,1); bar(10,10,630,300); rectangle(15,15,625,295); setfillstyle(9,lightblue); bar(195,255,355,275); {description} OuttextXY(20,30,'Bonjour cher(e) '+name+' !'); OuttextXY(20,40,'Le but du jeu est de sortir le v‚hicule rouge du lot de stationnement.'); OuttextXY(20,50,'Vous devez bouger les autres vehicules afin de liberer le chemin.'); OuttextXY(20,60,'Chaque vehicule peut se deplacer uniquement dans l''axe avant-arriere,'); OuttextXY(20,70,'soit dans l''axe de sa longueur. Vous devez selectionner le vehicule'); OuttextXY(20,80,'en buzzant sur la touche correspondante au chiffre alphanumerique'); OuttextXY(20,90,'inscrit sur le vehicule. Une fois selectionne, vous pouvez bouger'); OuttextXY(20,100,'le vehicule grace aux fleches du clavier.'); OuttextXY(20,120,'Vous avez le choix de 8 puzzles differents … 4 niveaux de difficulte '); OuttextXY(20,130,'(facile, moyen, difficile et expert). Il y aura donc 2 puzzles par niveau'); OuttextXY(20,140,'de difficult‚. Vous devez tenter de completer les puzzles en effectuant'); OuttextXY(20,150,'le nombre minimum de deplacements. Si vous completez un puzzle en'); OuttextXY(20,160,'effectuant le nombre minimal de deplacements, vous gagnerez 1000 points.'); OuttextXY(20,170,'Si vous le completez en moins de 150% du nombre minimal, vous'); OuttextXY(20,180,'obtenez 500 points. Si vous vous tardez trop a resoudre le puzzle,'); OuttextXY(20,190,'vous obtiendrez 0 points. Si vous abandonnez le puzzle vous'); OuttextXY(20,200,'obtenez 0 points. Selon le niveau de difficult‚ choisi, votre pointage'); OuttextXY(20,210,'obtenu pour un puzzle sera multiplie par 2 pour un puzzle moyen, par 3'); OuttextXY(20,220,'pour un puzzle difficile et par 4 pour un puzzle de niveau expert.'); OuttextXY(20,230,'Alors, '+name+'... C''est bien compris ?'); outtextXY(205,262,'X.Retour au menu'); repeat B:=readkey; until B=('x'); setfillstyle(1,white); bar(195,255,355,275); sound(523); delay(100); setfillstyle(1,lightblue); bar(195,255,355,275); outtextXY(205,262,'X.Retour au menu'); sound(392);delay(100);nosound; setfillstyle(1,white); bar(195,255,355,275); delay(100);{pour faire clignoter la selection et produire un son} end; procedure menu; begin {menu principal, on trace des rectangles et on ecrit du texte...} cleardevice; setcolor(white); setlinestyle(0,0,0); setfillstyle(9,blue); bar(175,100,400,240); rectangle(180,105,395,235); setfillstyle(9,lightblue); bar(195,113,380,133); Outtextxy(200,120,'1. Choisir difficulte'); bar(195,153,380,173); outtextXY(200,160,'2. Comment jouer'); bar(235,195,325,215); outtextXY(242,202,'X.Quitter'); A:=readkey; Case A of {dependant de ce que l'utilisateur appuie il ira a un menu different} ('1'): begin sound(392);setfillstyle(1,white);bar(195,113,380,133); delay(100); setfillstyle(9,lightblue);bar(195,113,380,133); Outtextxy(200,120,'1. Choisir difficulte');sound(523); delay(100); setfillstyle(1,white);bar(195,113,380,133);nosound; delay(100); setfillstyle(9,lightblue);bar(195,113,380,133); Outtextxy(200,120,'1. Choisir difficulte'); chosediff; {ce bloc de commandes nous permet de jouer un son et faire clignoter le rectangle, ainsi que d'amener l'utilisateur au menu de choix de difficulte} end; ('2'): begin sound(392);setfillstyle(1,white);bar(195,153,380,173); delay(100); setfillstyle(9,lightblue);bar(195,153,380,173); outtextXY(200,160,'2. Comment jouer');sound(523); delay(100); setfillstyle(1,white);bar(195,153,380,173);nosound; delay(100); setfillstyle(9,lightblue);bar(195,153,380,173); outtextXY(200,160,'2. Comment jouer'); howto; {meme principe sauf que dans ce cas-ci sauf qu'on enclenche la procedure du menu sur Comment jouer} end; ('x'): begin setfillstyle(1,white);bar(235,195,325,215);delay(100); setfillstyle(1,lightblue);bar(235,195,325,215);outtextXY(242,202,'X.Quitter'); delay(100);setfillstyle(1,white);bar(235,195,325,215);delay(100); setfillstyle(9,lightblue);bar(235,195,325,215);outtextXY(242,202,'X.Quitter'); {encore un effet pour faire clignoter} end; end; end; procedure byebye; begin cleardevice; settextstyle(1,0,8); outtextxy(140,80,'Au revoir'); outtextxy(140,160,name+'!'); {on ecrit au revoir et le nom de l'usager} setlinestyle(0,$c3,thickwidth); w1:=1; {meme principe que la montre sauf qu'au lieu dun seul angle on en incremente deux, un pour les rayons de la roue et le second pour les faire rotater} for theta2:=0 to 1440 do begin if theta2 mod 6 =0 then begin inc(w1,3); {on incremente w1, la variable qui definira plus tard la position en x de la roue qu'on utilisera pour la faire se deplacer} rad:=(Pi/180*theta2); s:=round(50*sin(rad)+500); sound(s); for theta1:=0 to 360 do begin theta:=(theta1+theta2); if (theta1 mod 20)=0 then begin setcolor(lightgray); rad:=((Pi/180)*theta);{on convertit l'angle en radians} x2:=round(40*cos(rad)); y2:=round(40*sin(rad)); line(w1,320,x2+w1,y2+320);{on trace les lignes} end; end; delay(5); nosound; {on dessine le reste de la roue} setcolor(red); circle(w1,320,60); setfillstyle(1,darkgray); fillellipse(w1,320,60,60); setfillstyle(1,0); fillellipse(w1,320,40,40); settextstyle(15,0,0); for theta1:=0 to 360 do begin theta:=(theta1+theta2); if (theta1 mod 20)=0 then{on veut a chaque 20 degres un rayon qui se dessine} begin setcolor(black); rad:=((Pi/180)*theta);{on convertit l'angle en radians} {on multiplie le rayon voulu par sin ou cos de l'angle puis on arrondit la valeur pour obtenir une valeur integer} x2:=round(40*cos(rad)); y2:=round(40*sin(rad)); line(w1,320,x2+w1,y2+320);{on trace les lignes} end; end; end; end; end; begin pilote:=detect; initgraph(pilote,mode,'m:/bgi'); welcome;{introduction} nosound; repeat menu;{menu principal} until A=('x'); {on repete le menu jusqu'a ce que l'utilisateur appuie sur x pour quitter} byebye;{procedure d'au revoir} end.