Jeu de boule

Contenu du snippet

simple jeu en langage pascal, une boule tombe sur une règle,le jeu contunue jusqu'a la boule va touche l'interieur du regle 3 fois,

Source / Exemple :


program exe;
 uses Crt,Graph;
 Label 1;
 Const R=5;n=20;
var
 touche: Char;
 score,A,B,X,Y: integer;
 Graphdriver, Graphmode: Integer;
test,votre_choix:shortint;
 Bas:Boolean;
 ValeurR:LongInt;

Procedure Preparer;
 Var i:Integer;
     Ch:String;
Begin
For i:=1 to 3 Do
 begin
    setcolor(15);outtextxy(getmaxx div 2,getmaxy div 2,'attendez s.v.p');
    Delay(1000);
    Sound(100);Delay(300);NoSound;
 End;
  setcolor(0);outtextxy(getmaxx div 2,getmaxy div 2,'attendez s.v.p');delay(900);  Sound(200);Delay(500);NoSound;
End;
Procedure Boule(X,Y,Coul,col:Integer);
  Var i:Integer;
Begin
 setcolor(col);
 SetFillStyle(Coul,random(getmaxcolor)+1);
 FillEllipse(X,Y,R,R);
End;

Procedure Barre(x1,y1,x2,y2,col1:integer);
Begin
 SetColor(Col1);
 Rectangle(x1,y1,x2,y2);
End;

Begin
clrscr;
 X:=0;
 Y:=0;
 A:=0;
 B:=0;       score:=0;
 textcolor(14);
 GotoXy(20,2);Write('ooOoo JEU DE LA BOULE ooOoo');
 GotoXy(20,3);Write('---------------------------');
 GotoXy(20,4);Write('1. facile');
 GotoXy(20,5);Write('2. moyen');
 GotoXy(20,6);Write('3. defficile');
 GotoXy(20,7);Write('0. Quitter');
 Repeat
   GotoXy(20,9);Write('Faites votre choix S.V.P...:');Readln(votre_choix);
   Case votre_Choix Of
     3:begin ValeurR:=5;end;
     2:begin ValeurR:=10;end;
     1:begin ValeurR:=15;end;
     0:Exit;
   End;
 Until (votre_Choix>=0)And(votre_Choix<=3);
  nosound;
 Graphdriver := Detect;
 InitGraph(Graphdriver, Graphmode, ' ');
 if GraphResult <> grOk then Halt(1);
 Preparer;
 Randomize;
 X:=300;Y:=GetMaxY-N;
 Bas:=True;
 Repeat
  If Not keypressed Then
         begin
          Boule(A,B,0,0);
          If B=R Then Begin Bas:=True; A:=Random(GetMaxX); End;
          If B=GetMaxY-R Then begin b:=r; test:=test+1; end;
          if test=3 then
          Begin SetColor(15);OutTextXy(200,200,' Vous avez perdu ! '); Readln; Goto 1; End;
           B:=B+1;
          Boule(A,B,1,random(getmaxcolor)+1);
             Delay(ValeurR);
          Boule(x+25+r,y-r-2,0,0);
         End
  Else   touche := Readkey;
If touche=#0 then
   Begin
    Barre(X,Y,X+25,Y+5,0);
    touche := Readkey;
    If touche=#77 then If X>=GetMaxX Then X:=0       else X:=X+10;
    If touche=#75 then If X<=0       Then X:=getmaxX else X:=X-10;
    Barre(X,Y,X+25,Y+5,random(getmaxcolor)+1);
   End;
 If (X<=A+R) And (A<=X+25+R)And(B=Y-R-2) Then Begin Boule(A,B,0,0); sound(200);delay(10);Nosound;b:=r;
 score:=score+10; if(votre_choix<=3) then begin if  (valeurr<=3) and (score mod 30 = 0) then valeurr:=valeurr-4; end; End;
Until touche=#27;
1:CloseGraph;
textcolor(2);
gotoxy(30,12);
write('votre score est: ', score);
readln;
clrscr;
  end.

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.