Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. program theGame;
  2.  
  3. uses crt;
  4.  
  5. const
  6. // les sizes maxi d'une fenetres de commande peut etre configurer
  7. // par defaut elle est 80 * 25
  8. maxH = 77;
  9. maxV = 25;
  10. var
  11. Hposition : integer;
  12.  
  13. //procedure deplacePressed; forward;
  14.  
  15. procedure cleanCanon(Hposition : Integer);
  16. begin
  17. GotoXY(Hposition, maxV);
  18. write(' ');
  19. end;
  20.  
  21. procedure deplaceCanon(Hposition : integer);
  22. begin
  23. if (Hposition <= 0) then
  24. Hposition:= 1;
  25. if Hposition > maxH then
  26. Hposition:= maxH ;
  27.  
  28. //ClrScr;
  29. //writeln(Hposition, ' | ', Vposition);
  30. GotoXY(Hposition, maxV);
  31. Write('-!-');
  32.  
  33. end;
  34.  
  35. procedure tirMissile(Hposition : integer);
  36. var i, Vposition: integer;
  37. begin
  38. Vposition:= maxV;
  39. for i:=Vposition downTo 2 do
  40. begin
  41. Vposition:= Vposition -1;
  42. GotoXY(Hposition, Vposition);
  43. write('|');
  44. Delay(20);
  45. GotoXY(Hposition, Vposition);
  46. write(' ');
  47. //if KeyPressed then
  48. //keyCanon(Hposition-1);
  49. end;
  50. end;
  51.  
  52. function posEnnemies : byte;
  53. begin
  54. Randomize;
  55. posEnnemies:= Random(25)+1;
  56. end;
  57.  
  58.  
  59. procedure deplacePressed;
  60. var
  61. a : char;
  62. begin
  63. while (True) do
  64. begin
  65. a := readkey;
  66. case a of
  67. #75 : begin
  68. cleanCanon(Hposition);
  69. Hposition := Hposition - 1;
  70. deplaceCanon(Hposition);
  71. end;
  72. #77 : begin
  73. cleanCanon(Hposition);
  74. Hposition := Hposition + 1;
  75. deplaceCanon(Hposition);
  76. end;
  77.  
  78. #32 : begin
  79. tirMissile(Hposition+1);
  80. end;
  81. end;
  82. end;
  83. end;
  84.  
  85. procedure ennemies(posEnnemies : byte);
  86. var
  87. i, Vposition: integer;
  88. begin
  89. Vposition:= 2;
  90. for i:=2 To maxV-1 do
  91. begin
  92. Vposition:= Vposition +1;
  93. GotoXY(posEnnemies, Vposition);
  94. write('O');
  95. Delay(30);
  96. GotoXY(posEnnemies, Vposition);
  97. write(' ');
  98. //if i= maxV-1 then
  99. //write('La machine gagne');
  100. //if KeyPressed then
  101. //keyCanon(Hposition-1);
  102. end;
  103. end;
  104.  
  105. BEGIN
  106. Hposition := 40;
  107. gotoxy(Hposition, MaxV);
  108. write('-!-');
  109. deplacePressed;
  110. ennemies(posEnnemies);
  111. END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement