Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. program Project1;
  2. uses crt, classes;
  3. type
  4.  
  5. { TBlock }
  6.  
  7. TBlock = class(Tobject)
  8. private
  9. public
  10. X,Y,C,Timer,Speed:integer;
  11. constructor Create();
  12. procedure Move();
  13. procedure Draw();
  14. end;
  15.  
  16. { TPlayer }
  17.  
  18. TPlayer = class(TObject)
  19. private
  20. public
  21. X,Y,Life:Integer;
  22. Key:Char;
  23. constructor Create();
  24. procedure Move();
  25. procedure Draw();
  26. end;
  27.  
  28. { TPlayer }
  29.  
  30. constructor TPlayer.Create;
  31. begin
  32. X:=120 div 2;
  33. Y:=40;
  34. Life:=3;
  35.  
  36. end;
  37.  
  38. procedure TPlayer.Move;
  39. begin
  40. key:=' ';
  41. if keypressed then key:=readkey;
  42. if key='a' then x:=x-1;
  43. if key='d' then x:=x+1;
  44.  
  45. end;
  46.  
  47. procedure TPlayer.Draw;
  48. begin
  49. Gotoxy(x,y);
  50. write('=');
  51. Gotoxy(x-1,y);
  52. write('=');
  53. Gotoxy(x+1,y);
  54. write('=');
  55. end;
  56.  
  57. { TBlock }
  58.  
  59. constructor TBlock.Create;
  60. begin
  61. x:=random(140);
  62. y:=1;
  63. speed:=2; //+Random(10)
  64. timer:=3;
  65. end;
  66.  
  67. procedure TBlock.Move;
  68. begin
  69. timer:=timer-1;
  70. if timer=0 then
  71. begin
  72. timer:=timer+speed;
  73. y:=y+1;
  74. end;
  75. end;
  76.  
  77. procedure TBlock.Draw;
  78. begin
  79. Gotoxy(x,y);
  80. write('|');
  81. end;
  82.  
  83. var
  84. Player:TPlayer;
  85. Block:TBlock;
  86. List:TList;
  87. i:integer;
  88. begin
  89.  
  90. Player:=TPlayer.Create;
  91. List:=TList.Create;
  92.  
  93.  
  94. while 1=1 do
  95. begin
  96. clrscr;
  97.  
  98. if random(100)>20 then
  99. begin
  100. Block:=Tblock.Create();
  101. list.add(Block);
  102. end;
  103.  
  104.  
  105. Player.Move;
  106.  
  107. For i:=list.count-1 downto 0 do
  108. begin
  109. Block:=TBlock(list.Items[i]);
  110. Block.Move;
  111. Block.Draw;
  112. gotoxy(1,i+1);
  113. write(Block.X,' ',Block.Y);
  114. if Block.Y>40 Then begin list.Delete(i); Block.free; end;
  115. end;
  116.  
  117.  
  118.  
  119.  
  120. Player.Draw;
  121.  
  122. gotoxy(1,1);
  123. Delay(50);
  124. end;
  125.  
  126. List.Free;
  127. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement