Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. Uses graphABC,ABCObjects;
  2.  
  3. var
  4. ball:CircleABC;
  5. player:pictureABC;
  6. block:array[1..10] of PictureABC;
  7. block2:array[1..10] of PictureABC;
  8. xBall,yBall,kx,ky,xPlayer,yPlayer,xBlock,yBlock,xBlock2,yBlock2,right,left,cr,cg,cb:integer;
  9. i,i2,step,start,count,finish:integer;
  10.  
  11.  
  12. procedure keyDown(key:integer);
  13. begin
  14. if(key = VK_Right) then
  15. begin
  16. right := 1;
  17. end;
  18. if(key = VK_Left) then
  19. begin
  20. left := 1;
  21. end;
  22. if(key = vk_S) then
  23. begin
  24. start := 1;
  25. end;
  26. end;
  27.  
  28. procedure keyUp(key:integer);
  29. begin
  30. if(key = VK_Right) then
  31. begin
  32. right := 0;
  33. end;
  34. if(key = VK_Left) then
  35. begin
  36. left := 0;
  37. end;
  38. end;
  39.  
  40.  
  41.  
  42. begin
  43. randomize;
  44.  
  45. count := 0;
  46.  
  47. xBall := 100;
  48. yBall := 100;
  49. ball := CircleABC.Create(xBall,yBall,13,clBlack);
  50.  
  51. xPlayer := 200;
  52. yPlayer := windowheight-100;
  53. player := pictureABC.Create(xPlayer,yPlayer,'player_3.bmp');
  54.  
  55.  
  56. ball.BorderColor := clWhite;
  57. for i:=1 to 10 do
  58. begin
  59. xBlock := 72 + (i-1)*53;
  60. yBlock := 0;
  61. block[i] := PictureABC.Create(xBlock,yBlock,'green_3.bmp');
  62. block[i].TransparentColor := clWhite;
  63. block[i].Transparent := true;
  64. end;
  65.  
  66. for i:=1 to 10 do
  67. begin
  68. xBlock := 72 + (i-1)*53;
  69. yBlock := 30;
  70. block2[i] := PictureABC.Create(xBlock,yBlock,'white.bmp');
  71. block2[i].Transparent := true;
  72. end;
  73.  
  74.  
  75. kx := 1;
  76. ky := 1;
  77.  
  78. onKeyDown := keyDown;
  79. onKeyUp := keyUp;
  80. while(true) do
  81. begin
  82. if(player.Intersect(ball)) then
  83. begin
  84. //kx:=-kx;
  85. ky := -ky;
  86. end;
  87.  
  88. for i:=1 to 10 do
  89. begin
  90. if(ball.Intersect(block[i])) then
  91. begin
  92.  
  93.  
  94. block[i].MoveTo(1000,20);
  95.  
  96. count := count + 1;
  97. ky := -ky;
  98. end ;
  99. end;
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. for i:=1 to 10 do
  107. begin
  108. if(ball.Intersect(block2[i])) then
  109. begin
  110.  
  111. block2[i].MoveTo(1000,20);
  112. ky := -ky;
  113. count := count + 1;
  114. end ;
  115. end;
  116.  
  117.  
  118.  
  119. xBall := xBall + kx;
  120. yBall := yBall + ky;
  121.  
  122. if(count = 20) then
  123. begin
  124. finish := 1;
  125. end;
  126.  
  127.  
  128. if((xBall+40 > windowWidth) or (xBall < 0)) then
  129. begin
  130. kx := -kx;
  131. end;
  132. if((yBall < 0)) then
  133. begin
  134. ky := -ky;
  135. end;
  136.  
  137. if(yBall+40 > windowHeight) then
  138. begin
  139. xBall := 200;
  140. yBall := 20;
  141. end;
  142.  
  143. if(right = 1) then
  144. begin
  145. xPlayer := xPlayer + 1;
  146. player.MoveTo(xPlayer,yPlayer);
  147. end;
  148. if(left = 1) then
  149. begin
  150. xPlayer := xPlayer - 1;
  151. player.MoveTo(xPlayer,yPlayer);
  152. end;
  153.  
  154. step := step + 1;
  155. if(step = 100) then
  156. begin
  157. cr := random(1,255);
  158. cg := random(1,255);
  159. cb := random(1,255);
  160. step := 0;
  161. end;
  162. ball.Color := RGB(cr,cg,cb);
  163.  
  164.  
  165. ball.MoveTo(xBall,yBall);
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. if((start = 1) and (finish = 1)) then
  175. begin
  176. for i:=1 to 10 do
  177. begin
  178. xBlock := 72 + (i-1)*53;
  179. yBlock := 0;
  180. block[i].MoveTo(xBlock,yBlock);
  181. block2[i].MoveTo(xBlock,yBlock+30);
  182. end;
  183. start := 0;
  184. finish := 0;
  185. end;
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. sleep(0);
  196. end;
  197. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement