Guest User

Untitled

a guest
Jul 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. setscreen ("graphics:max,max")
  2. setscreen ("offscreenonly")
  3. var paddlex : int := 400
  4. var ballx, bally : int := 500 % Location of ball
  5. var dx, dy : int := 1 % Speed of ball
  6. var size : int := 70 % half the size of paddle
  7. var mx, my, mb : int
  8. var go : int := Pic.FileNew ("gameover.bmp")
  9.  
  10. drawfillbox (400, 400, 350, 420, 3)
  11. drawfillbox (400, 400, 450, 420, 7)
  12. drawfillbox (450, 400, 500, 420, 6)
  13. drawfillbox (500, 400, 550, 420, 5)
  14. drawfillbox (550, 400, 600, 420, 4)
  15. loop
  16. mousewhere (mx, my, mb)
  17.  
  18. drawfilloval (ballx, bally, 20, 20, 0) % Erases ball
  19. ballx := ballx + dx % Moves ball (left and right)
  20. bally := bally + dy % Moves ball (up and down)
  21. if bally < 40 then
  22.  
  23. if whatdotcolour (ballx, bally - 20) > 0 then
  24. dy := - (dy)
  25. end if
  26. end if
  27. if bally > 40 then
  28. if whatdotcolour (ballx, bally - 20) = 7 then
  29. dy := - (dy)
  30. drawfillbox (400, 400, 450, 420, 0)
  31.  
  32. end if
  33. if whatdotcolour (ballx, bally + 20) = 7 then
  34. dy := - (dy)
  35. drawfillbox (400, 400, 450, 420, 0)
  36.  
  37. end if
  38. if whatdotcolour (ballx + 20, bally) = 7 then
  39. dx := - (dx)
  40. drawfillbox (400, 400, 450, 420, 0)
  41.  
  42. end if
  43. if whatdotcolour (ballx - 20, bally) = 7 then
  44. dx := - (dx)
  45. drawfillbox (400, 400, 450, 420, 0)
  46. end if
  47. if whatdotcolour (ballx, bally - 20) = 6 then
  48. dy := - (dy)
  49. drawfillbox (500, 400, 550, 420, 0)
  50.  
  51. end if
  52. if whatdotcolour (ballx, bally + 20) = 6 then
  53. dy := - (dy)
  54. drawfillbox (450, 400, 500, 420, 0)
  55.  
  56. end if
  57. if whatdotcolour (ballx + 20, bally) = 6 then
  58. dx := - (dx)
  59. drawfillbox (450, 400, 500, 420, 0)
  60.  
  61. end if
  62. if whatdotcolour (ballx - 20, bally) = 6 then
  63. dx := - (dx)
  64. drawfillbox (450, 400, 500, 420, 0)
  65. end if
  66.  
  67. if whatdotcolour (ballx, bally - 20) = 5 then
  68. dy := - (dy)
  69. drawfillbox (450, 400, 500, 420, 0)
  70.  
  71. end if
  72. if whatdotcolour (ballx, bally + 20) = 5 then
  73. dy := - (dy)
  74. drawfillbox (500, 400, 550, 420, 0)
  75.  
  76. end if
  77. if whatdotcolour (ballx + 20, bally) = 5 then
  78. dx := - (dx)
  79. drawfillbox (500, 400, 550, 420, 0)
  80.  
  81. end if
  82. if whatdotcolour (ballx - 20, bally) = 5 then
  83. dx := - (dx)
  84. drawfillbox (500, 400, 550, 420, 0)
  85. end if
  86.  
  87. if whatdotcolour (ballx, bally - 20) = 4 then
  88. dy := - (dy)
  89.  
  90. drawfillbox (550, 400, 600, 420, 0)
  91. end if
  92. if whatdotcolour (ballx, bally + 20) = 4 then
  93. dy := - (dy)
  94.  
  95. drawfillbox (550, 400, 600, 420, 0)
  96. end if
  97. if whatdotcolour (ballx + 20, bally) = 4 then
  98. dx := - (dx)
  99.  
  100. drawfillbox (550, 400, 600, 420, 0)
  101. end if
  102. if whatdotcolour (ballx - 20, bally) = 4 then
  103. dx := - (dx)
  104.  
  105. drawfillbox (550, 400, 600, 420, 0)
  106.  
  107. end if
  108. if whatdotcolour (ballx, bally - 20) = 3 then
  109. dy := - (dy)
  110.  
  111. drawfillbox (400, 400, 350, 420, 0)
  112. end if
  113. if whatdotcolour (ballx, bally + 20) = 3 then
  114. dy := - (dy)
  115.  
  116. drawfillbox (400, 400, 350, 420, 0)
  117. end if
  118. if whatdotcolour (ballx + 20, bally) = 3 then
  119. dx := - (dx)
  120.  
  121. drawfillbox (400, 400, 350, 420, 0)
  122. end if
  123. if whatdotcolour (ballx - 20, bally) = 3 then
  124. dx := - (dx)
  125.  
  126. drawfillbox (400, 400, 350, 420, 0)
  127.  
  128. end if
  129.  
  130. end if
  131. if ballx > maxx then %%%%%%%%Changes direction of ball if
  132. dx := - (dx) %%%%%%%%it touches edge of screen
  133. elsif ballx < 0 then
  134. dx := - (dx)
  135. elsif bally > maxy then
  136. dy := - (dy)
  137. elsif bally < 0 then
  138.  
  139.  
  140. dy := - (dy)
  141. bally := 400
  142. Pic.Draw (go, -100, -450, picCopy)
  143. View.Update
  144. loop
  145. mousewhere (mx, my, mb)
  146. if mb = 1 then
  147. cls
  148. drawfillbox (550, 400, 350, 420, 3)
  149. drawfillbox (400, 400, 450, 420, 7)
  150. drawfillbox (450, 400, 500, 420, 6)
  151. drawfillbox (500, 400, 550, 420, 5)
  152. drawfillbox (550, 400, 600, 420, 4)
  153. exit
  154. end if
  155. end loop
  156.  
  157. end if
  158. drawfilloval (ballx, bally, 20, 20, purple) % ball
  159. paddlex := mx
  160. drawfillbox (mx - size, 0, mx + size, 20, 7) %paddle
  161. drawfillbox (mx - size, 0, 0, 20, 0) % erase paddle (left)
  162. drawfillbox (maxx, 0, mx + size, 20, 0) % erase paddle (right)
  163. View.Update
  164.  
  165. end loop
Add Comment
Please, Sign In to add comment