Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 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. count,i,i2,step: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. end;
  23.  
  24. procedure keyUp(key:integer);
  25. begin
  26. if(key = VK_Right) then
  27. begin
  28. right := 0;
  29. end;
  30. if(key = VK_Left) then
  31. begin
  32. left := 0;
  33. end;
  34. end;
  35.  
  36.  
  37.  
  38. begin
  39. randomize;
  40.  
  41. count := 0;
  42.  
  43. xBall := 100;
  44. yBall := 100;
  45. ball := CircleABC.Create(xBall,yBall,13,clBlack);
  46.  
  47. xPlayer := 200;
  48. yPlayer := windowheight-100;
  49. player := pictureABC.Create(xPlayer,yPlayer,'player 3.bmp');
  50.  
  51.  
  52. ball.BorderColor := clWhite;
  53. for i:=1 to 10 do
  54. begin
  55. xBlock := 72 + (i-1)*53;
  56. yBlock := 0;
  57. block[i] := PictureABC.Create(xBlock,yBlock,'green 3.bmp');
  58. block[i].TransparentColor := clWhite;
  59. block[i].Transparent := true;
  60. end;
  61.  
  62. for i2:=1 to 10 do
  63. begin
  64. xBlock2 := 72 + (i2-1)*106;
  65. yBlock2 := 0;
  66. block[i2] := PictureABC.Create(xBlock,yBlock,'white.bmp');
  67. block[i2].Transparent := true;
  68. end;
  69.  
  70.  
  71. kx := 1;
  72. ky := 1;
  73.  
  74. onKeyDown := keyDown;
  75. onKeyUp := keyUp;
  76. while(true) do
  77. begin
  78. if(player.Intersect(ball)) then
  79. begin
  80. //kx:=-kx;
  81. ky := -ky;
  82. end;
  83.  
  84. for i:=1 to 10 do
  85. begin
  86. if(ball.Intersect(block[i])) then
  87. begin
  88.  
  89.  
  90. block[i].MoveTo(1000,20);
  91.  
  92.  
  93. ky := -ky;
  94. end ;
  95. end;
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. for i2:=1 to 10 do
  103. begin
  104. if(ball.Intersect(block2[i2])) then
  105. begin
  106.  
  107.  
  108. block2[i2].MoveTo(1000,20);
  109.  
  110.  
  111. ky := -ky;
  112. end ;
  113. end;
  114.  
  115.  
  116.  
  117. xBall := xBall + kx;
  118. yBall := yBall + ky;
  119.  
  120.  
  121.  
  122.  
  123. if((xBall+40 > windowWidth) or (xBall < 0)) then
  124. begin
  125. kx := -kx;
  126. end;
  127. if((yBall < 0)) then
  128. begin
  129. ky := -ky;
  130. end;
  131.  
  132. if(yBall+40 > windowHeight) then
  133. begin
  134. xBall := 200;
  135. yBall := 20;
  136. end;
  137.  
  138. if(right = 1) then
  139. begin
  140. xPlayer := xPlayer + 1;
  141. player.MoveTo(xPlayer,yPlayer);
  142. end;
  143. if(left = 1) then
  144. begin
  145. xPlayer := xPlayer - 1;
  146. player.MoveTo(xPlayer,yPlayer);
  147. end;
  148.  
  149. step := step + 1;
  150.  
  151. if(step = 100) then
  152. begin
  153. cr := random(1,255);
  154. cg := random(1,255);
  155. cb := random(1,255);
  156. step := 0;
  157. end;
  158. ball.Color := RGB(cr,cg,cb);
  159.  
  160.  
  161. ball.MoveTo(xBall,yBall);
  162. sleep(1);
  163. end;
  164. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement