Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program theGame;
- uses crt;
- const
- // les sizes maxi d'une fenetres de commande peut etre configurer
- // par defaut elle est 80 * 25
- maxH = 77;
- maxV = 25;
- var
- Hposition : integer;
- //procedure deplacePressed; forward;
- procedure cleanCanon(Hposition : Integer);
- begin
- GotoXY(Hposition, maxV);
- write(' ');
- end;
- procedure deplaceCanon(Hposition : integer);
- begin
- if (Hposition <= 0) then
- Hposition:= 1;
- if Hposition > maxH then
- Hposition:= maxH ;
- //ClrScr;
- //writeln(Hposition, ' | ', Vposition);
- GotoXY(Hposition, maxV);
- Write('-!-');
- end;
- procedure tirMissile(Hposition : integer);
- var i, Vposition: integer;
- begin
- Vposition:= maxV;
- for i:=Vposition downTo 2 do
- begin
- Vposition:= Vposition -1;
- GotoXY(Hposition, Vposition);
- write('|');
- Delay(20);
- GotoXY(Hposition, Vposition);
- write(' ');
- //if KeyPressed then
- //keyCanon(Hposition-1);
- end;
- end;
- function posEnnemies : byte;
- begin
- Randomize;
- posEnnemies:= Random(25)+1;
- end;
- procedure deplacePressed;
- var
- a : char;
- begin
- while (True) do
- begin
- a := readkey;
- case a of
- #75 : begin
- cleanCanon(Hposition);
- Hposition := Hposition - 1;
- deplaceCanon(Hposition);
- end;
- #77 : begin
- cleanCanon(Hposition);
- Hposition := Hposition + 1;
- deplaceCanon(Hposition);
- end;
- #32 : begin
- tirMissile(Hposition+1);
- end;
- end;
- end;
- end;
- procedure ennemies(posEnnemies : byte);
- var
- i, Vposition: integer;
- begin
- Vposition:= 2;
- for i:=2 To maxV-1 do
- begin
- Vposition:= Vposition +1;
- GotoXY(posEnnemies, Vposition);
- write('O');
- Delay(30);
- GotoXY(posEnnemies, Vposition);
- write(' ');
- //if i= maxV-1 then
- //write('La machine gagne');
- //if KeyPressed then
- //keyCanon(Hposition-1);
- end;
- end;
- BEGIN
- Hposition := 40;
- gotoxy(Hposition, MaxV);
- write('-!-');
- deplacePressed;
- ennemies(posEnnemies);
- END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement