Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1. Uses graphABC, ABCObjects;
  2.  
  3. var
  4. ball:PictureABC;
  5. ballX, ballY, stepX, stepY, r,playerX,playerY,i,j,snowX,snowY,stepSnowY,stepBounce:integer;
  6. player:RectangleABC;
  7. right, left,space:boolean;
  8. blocks:array[1..12] of RectangleABC;
  9. text:TextABC;
  10. rect:rectangleABC;
  11.  
  12. snow:array[1..50] of CircleABC;
  13.  
  14. procedure keyDown(key:integer);
  15. begin
  16. if(key = vk_Right) then right := true;
  17. if(key = vk_Left) then left := true;
  18. if(key = vk_Space) then space := true;
  19. end;
  20.  
  21. procedure keyUp(key:integer);
  22. begin
  23. if(key = vk_Right) then right := false;
  24. if(key = vk_Left) then left := false;
  25. end;
  26.  
  27.  
  28.  
  29.  
  30. begin
  31. window.init(300,100,640,480,clBlack);
  32.  
  33. ballX := 100;
  34. ballY := 100;
  35. stepX := 1;
  36. stepY := 1;
  37.  
  38.  
  39. // ball.angle := ball.angle + 90;
  40.  
  41. randomize;
  42.  
  43. for i:=1 to 50 do
  44. begin
  45. snowX := random(0,windowWidth-10);
  46. snowY := random(0,windowHeight-10);
  47.  
  48. snow[i] := CircleABC.Create(snowX,snowY,10,clWhite);
  49. snow[i].ToBack();
  50.  
  51. end;
  52.  
  53. stepBounce := 2;
  54. stepSnowY := 2;
  55.  
  56. rect := RectangleABC.Create(windowWIdth div 2-100,windowHeight div 2 - 20,250,90,clBlack);
  57. rect.ToFront();
  58. text := TextABC.Create(windowWIdth div 2-100,windowHeight div 2 - 20,30,'Press ''Space''',clWhite);
  59. text.ToFront();
  60.  
  61.  
  62.  
  63. onKeyDown := keyDown;
  64. while(space <> true) do
  65. begin
  66.  
  67. for i:=1 to 50 do
  68. begin
  69. if(i mod 4 = 0) then stepBounce := -stepBounce;
  70.  
  71. snow[i].MoveTo(snow[i].Position.X,snow[i].Position.Y+stepSnowY);
  72.  
  73. snow[i].MoveTo(snow[i].Position.X+stepBounce,snow[i].Position.Y+stepSnowY);
  74.  
  75. if(snow[i].Position.Y > windowHeight+100) then
  76. begin
  77. snow[i].MoveTo(snow[i].Position.X,0);
  78. end;
  79.  
  80. end;
  81.  
  82. end;
  83.  
  84. window.init(300,100,640,480,clBlack);
  85.  
  86.  
  87. for i:=1 to 50 do
  88. begin
  89.  
  90.  
  91. snow[i].MoveTo(700,700);
  92.  
  93.  
  94.  
  95.  
  96. end;
  97. text.MoveTo(700,700);
  98.  
  99.  
  100.  
  101. ball := PictureABC.Create(ballX,ballY,'ball2.png');
  102. ball.scaleX := 0.3;
  103. ball.ScaleY := 0.3;
  104.  
  105. playerX := windowWidth div 2 - 100;
  106. playerY := windowHeight - 30;
  107.  
  108. player := RectangleABC.Create(playerX,playerY,200,30,clblue);
  109.  
  110.  
  111. onKeyUp := keyUp;
  112.  
  113. for i:=1 to 2 do
  114. begin
  115. for j:=1 to 6 do
  116. begin
  117.  
  118. blocks[(i-1)*6 + j] := RectangleABC.Create(100*(j-1) + 20,30*(i-1) + 80,100,30,clred);
  119. end;
  120. end;
  121.  
  122.  
  123.  
  124.  
  125.  
  126. while(true) do
  127. begin
  128. // logic moving player
  129. if(right = true) then playerX := playerX + 3;
  130. if(left = true) then playerX := playerX - 3;
  131. player.MoveTo(playerX,playerY);
  132. if((playerX + player.Width > windowWidth)
  133. ) then
  134. begin
  135. playerX := windowWidth - player.Width;
  136. end;
  137.  
  138. if((playerX < 0)) then
  139. begin
  140. playerX := 0;
  141. end;
  142.  
  143. //----------------------------------
  144.  
  145. // logic moving ball1
  146. ballX := ballX + stepX;
  147. ballY := ballY + stepY;
  148. ball.MoveTo(ballX,ballY);
  149. if((ballX + ball.Width > windowWidth) or
  150. (ballX < 0)) then
  151. begin
  152. stepX := -stepX;
  153.  
  154. end;
  155. if((ballY + ball.Height > windowHeight) or
  156. (ballY < 0)) then
  157. begin
  158. stepY := -stepY;
  159.  
  160. end;
  161. //----------------------------------
  162.  
  163. //logic contact (player, ball and player2) and disappearance (player2 and ...)
  164. if((ball.Intersect(player) = true) and (player.Intersect(ball) = true) ) then
  165. begin
  166. stepY := -stepY;
  167. end;
  168.  
  169.  
  170.  
  171. for i:=1 to 12 do
  172. begin
  173. if(ball.Intersect(blocks[i]) = true) then
  174. begin
  175.  
  176. blocks[i].MoveTo(700,700);
  177.  
  178. stepY := -stepY;
  179. end;
  180. end;
  181.  
  182.  
  183. end;
  184.  
  185.  
  186. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement