1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| Program readkeytest1;
Uses SysUtils, crt;
Const roulable=0; (* Case sur laquelle on peut rouler *)
bordure=1; (* Bord du circuit *)
lignedepart=2; (* Ligne de départ *)
largeur=79; (* Largeur du circuit *)
hauteur=24; (* Hauteur du circuit *)
Type tcircuit=Array [0..largeur,0..hauteur] of integer;
Var circuit: tcircuit; (* Grille représentant le circuit *)
xcircuit, ycircuit: integer; (* Case actuelle dans la grille *)
x, y, tour: byte;
mv: char;
Procedure Formecircuit;
Begin
GotoXY (6,1); WriteLn ('--------------------'); GotoXY (11,5); WriteLn ('----------------'); GotoXY (23,2); WriteLn (' |');
GotoXY (5,2); WriteLn ('| '); GotoXY (23,3); WriteLn (' |'); GotoXY (5,3); WriteLn ('| ');
GotoXY (23,4); WriteLn (' |'); GotoXY (5,4); WriteLn ('| '); GotoXY (23,5); WriteLn (' |'); GotoXY (5,5); WriteLn ('| ');
GotoXY (23,6); WriteLn ('| '); GotoXY (5,6); WriteLn ('| |'); GotoXY (23,7); WriteLn ('| '); GotoXY (5,7); WriteLn ('| |');
GotoXY (23,8); WriteLn ('| '); GotoXY (5,8); WriteLn ('| |'); GotoXY (27,6); WriteLn ('----------------'); GotoXY (5,9); WriteLn ('| |');
GotoXY (24,9); WriteLn ('----------------'); GotoXY (5,10); WriteLn ('| |'); GotoXY (38,7); WriteLn (' |'); GotoXY (5,11); WriteLn ('| |');
GotoXY (38,8); WriteLn (' |'); GotoXY (5,12); WriteLn ('| |'); GotoXY (38,9); WriteLn (' |'); GotoXY (5,13); WriteLn ('| |');
GotoXY (38,10); WriteLn ('| |'); GotoXY (5,14); WriteLn ('| |'); GotoXY (38,11); WriteLn ('| |'); GotoXY (5,15); WriteLn ('| |');
GotoXY (38,12); WriteLn ('| |'); GotoXY (5,16); WriteLn ('| |'); GotoXY (38,13); WriteLn ('| |'); GotoXY (5,17); WriteLn ('| |');
GotoXY (38,14); WriteLn ('| |'); GotoXY (5,18); WriteLn ('| |'); GotoXY (38,15); WriteLn ('| |'); GotoXY (5,19); WriteLn ('| |');
GotoXY (38,16); WriteLn ('| |'); GotoXY (5,20); WriteLn ('| |'); GotoXY (38,17); WriteLn ('| '); GotoXY (5,21); WriteLn ('| ');
GotoXY (38,18); WriteLn ('| '); GotoXY (5,22); WriteLn ('| '); GotoXY (38,19); WriteLn ('| '); GotoXY (5,23); WriteLn ('| ');
GotoXY (11,21); WriteLn ('---------------------------------------------------------------'); GotoXY (6,24); WriteLn ('------------------------------------------------------------------------');
GotoXY (73,23); WriteLn (' |'); GotoXY (73,22); WriteLn (' |'); GotoXY (73,21); WriteLn (' |'); GotoXY (73,20); WriteLn ('| |');
GotoXY (73,19); WriteLn ('| |'); GotoXY (73,18); WriteLn ('| |'); GotoXY (73,17); WriteLn ('| |'); GotoXY (73,16); WriteLn ('| |');
GotoXY (73,15); WriteLn ('| |'); GotoXY (73,14); WriteLn ('| |'); GotoXY (73,13); WriteLn ('| |');
GotoXY (73,12); WriteLn ('| |'); GotoXY (73,11); WriteLn ('| |'); GotoXY (73,10); WriteLn (' |'); GotoXY (73,11); WriteLn (' |');
GotoXY (73,12); WriteLn (' |'); GotoXY (57,12); WriteLn ('----------------'); GotoXY (62,9); WriteLn ('----------------');
GotoXY (56,9); WriteLn ('|'); GotoXY (56,10); WriteLn ('|'); GotoXY (56,11); WriteLn ('|'); GotoXY (56,8); WriteLn ('| |');
GotoXY (56,7); WriteLn ('| |'); GotoXY (56,6); WriteLn ('| |'); GotoXY (56,5); WriteLn ('| |'); GotoXY (56,4); WriteLn (' |');
GotoXY (56,3); WriteLn (' |'); GotoXY (56,2); WriteLn (' |'); GotoXY (47,1); WriteLn ('--------------'); GotoXY (52,4); WriteLn ('----');
GotoXY (46,2); WriteLn ('|'); GotoXY (46,3); WriteLn ('|'); GotoXY (46,4); WriteLn ('|'); GotoXY (46,5); WriteLn ('| |');
GotoXY (46,6); WriteLn ('| |'); GotoXY (46,7); WriteLn ('| |'); GotoXY (46,8); WriteLn ('| |'); GotoXY (46,9); WriteLn ('| |');
GotoXY (46,10); WriteLn ('| |'); GotoXY (46,11); WriteLn ('| |'); GotoXY (46,12); WriteLn ('| |'); GotoXY (46,13); WriteLn ('| |');
GotoXY (46,14); WriteLn ('| |'); GotoXY (46,15); WriteLn ('| |'); GotoXY (46,16); WriteLn ('| |'); GotoXY (46,17); WriteLn (' |');
GotoXY (46,18); WriteLn (' |'); GotoXY (46,19); WriteLn (' |'); GotoXY (44,17); WriteLn ('--'); GotoXY (39,20); WriteLn ('------------');
GotoXY (41,23); WriteLn ('|'); GotoXY (41,22); WriteLn ('|');
textcolor (4); GotoXY (31,3); WriteLn ('F1 *******');
GotoXY (63,3); WriteLn ('Tour(s): ', tour);
End;
Function casesuivante (const circuit : tcircuit; x, y : integer; touche : Char) : integer;
Begin
Case touche of
'q' : casesuivante:=circuit[x-1,y];
'd' : casesuivante:=circuit[x+1,y];
'z' : casesuivante:=circuit[x,y-1];
's' : casesuivante:=circuit[x,y+1];
End;
End;
Begin
tour:=5;
mv:='a';
cursoroff;
x:=40;
y:=23;
GotoXY (x,y); textcolor (4); WriteLn ('>');
While not(keypressed) AND (mv<>#13) do
Begin
textcolor (8);
Formecircuit;
GotoXY (x,y);
textcolor (4);
mv:=readkey;
Case mv of
'q' : WriteLn ('<');
'd' : WriteLn ('>');
'z' : WriteLn ('^');
's' : WriteLn ('V');
End;
Case Casesuivante(circuit,xcircuit,ycircuit,mv) of
roulable : Begin xcircuit:=xcircuit+1; ycircuit:=ycircuit+1; End;
bordure : ;
lignedepart : tour:=tour-1; { On incrémente le compteur de tours }
End;
Clrscr;
End;
clrscr;
GotoXY (15,10); WriteLn ('Vous avez fait les 5 tours ! Relancez le jeu pour rejouez');
ReadLn;
End. |