Advertisement
atm959

Sega Genesis Pong Code by atm959 (In development.)

Aug 23rd, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. OPTION TITLE, "Pong for Sega Genesis"
  2.  
  3. Palette rgb(255, 255, 255), 0, 1
  4. Palette rgb(255, 255, 0), 1, 1
  5. Palette rgb(0, 255, 255), 2, 1
  6. Palette rgb(0, 0, 255), 3, 1
  7.  
  8. dim x as integer
  9. dim y as integer
  10. dim x2 as integer
  11. dim y2 as integer
  12.  
  13. dim ballX as integer
  14. dim ballY as integer
  15.  
  16. dim velocity as integer
  17.  
  18. velocity = 1
  19.  
  20. dim points1 as integer
  21. dim points2 as integer
  22.  
  23. x = 128
  24. y = 128
  25.  
  26. x2 = 128 + 320 - 8
  27. y2 = 128
  28.  
  29. ballX = 128 + 100
  30. ballY = 128 + 100
  31.  
  32. 'Paddle 1
  33. s11 = addsprite(1, 1)
  34. s12 = addsprite(1, 1)
  35. s13 = addsprite(1, 1)
  36. s14 = addsprite(1, 1)
  37. s15 = addsprite(1, 1)
  38.  
  39. 'Paddle 2
  40. s21 = addsprite(1, 1)
  41. s22 = addsprite(1, 1)
  42. s23 = addsprite(1, 1)
  43. s24 = addsprite(1, 1)
  44. s25 = addsprite(1, 1)
  45.  
  46. 'The ball
  47. ball = addsprite(1, 1)
  48.  
  49. propsprite s11, 1, 1
  50. propsprite s12, 1, 1
  51. propsprite s13, 1, 1
  52. propsprite s14, 1, 1
  53. propsprite s15, 1, 1
  54.  
  55. propsprite s21, 1, 2
  56. propSprite s22, 1, 2
  57. propSprite s23, 1, 2
  58. propsprite s24, 1, 2
  59. propsprite s25, 1, 2
  60.  
  61.  
  62. propsprite ball, 1, 3
  63.  
  64. movesprite s11, x, y
  65. moveSprite s12, x, y + 8
  66. moveSprite s13, x, y + 16
  67. moveSprite s14, x, y + 24
  68. moveSprite s15, x, y + 32
  69.  
  70. moveSprite s21, x2, y2
  71. movesprite s22, x2, y2 + 8
  72. movesprite s23, x2, y2 + 16
  73. movesprite s24, x2, y2 + 24
  74. movesprite s25, x2, y2 + 32
  75.  
  76. moveSprite ball, ballX, ballY
  77.  
  78. do
  79.  
  80. if y < 128 then y = 128
  81. if y > (128 + 224) - 32 then y = (128 + 224) - (32 + 8)
  82. if y = 317 then y = 312
  83.  
  84. if velocity = 2 and ballY < 128 then
  85.  
  86. velocity = 3
  87.  
  88. end if
  89.  
  90. if velocity = 3 and ballY < 128 then
  91.  
  92. velocity = 5
  93.  
  94. end if
  95.  
  96. if velocity = 5 and ballY > (128 + 224) - 8 then
  97.  
  98. velocity = 3
  99.  
  100. end if
  101.  
  102. if velocity = 4 and ballY > (128 + 224) - 8 then
  103.  
  104. velocity = 2
  105.  
  106. end if
  107.  
  108. if ballX < 128 then
  109.  
  110. ballX = 128 + 100
  111. ballY = 128 + 100
  112. movesprite ball, ballX, ballY
  113. velocity = 1
  114.  
  115. points2 = points2 + 1
  116.  
  117. end if
  118.  
  119. if ballX > 128 + 320 then
  120.  
  121. ballX = 128 + 100
  122. ballY = 128 + 100
  123. movesprite ball, ballX, ballY
  124. velocity = 1
  125.  
  126. points1 = points1 + 1
  127.  
  128. end if
  129.  
  130. locate 0, 10
  131. print points1
  132.  
  133. locate 0, 25
  134. print points2
  135.  
  136. locate 20, 5
  137. print x
  138.  
  139. locate 21, 5
  140. print y
  141.  
  142. locate 20, 15
  143. print ballX
  144.  
  145. locate 21, 15
  146. print ballY
  147.  
  148. locate 20, 25
  149. print x2
  150.  
  151. locate 21, 25
  152. print y2
  153.  
  154. if joypad(0).0 then y = y - 5
  155. if joypad(1).0 then y2 = y2 - 5
  156. if joypad(0).1 then y = y + 5
  157. if joypad(1).1 then y2 = y2 + 5
  158.  
  159. movesprite s11, x, y
  160. moveSprite s12, x, y + 8
  161. moveSprite s13, x, y + 16
  162. moveSprite s14, x, y + 24
  163. moveSprite s15, x, y + 32
  164.  
  165. moveSprite s21, x2, y2
  166. movesprite s22, x2, y2 + 8
  167. movesprite s23, x2, y2 + 16
  168. movesprite s24, x2, y2 + 24
  169. movesprite s25, x2, y2 + 32
  170.  
  171. if velocity = 1 and ballX = x + 8 and ballY > y and ballY < y + 32 then velocity = 0
  172. if velocity = 0 and ballX = x2 - 8 and ballY > y2 and ballY < y2 + 32 then velocity = 1
  173. if velocity = 2 and ballX = x + 8 and ballY > y and ballY < y + 32 then velocity = 3
  174.  
  175. if velocity = 0 then ballX = ballX + 1
  176. if velocity = 1 then ballX = ballX - 1
  177. if velocity = 2 then
  178.  
  179. ballX = ballX - 30
  180. ballY = ballY - 30
  181.  
  182. end if
  183.  
  184. if velocity = 3 then
  185.  
  186. ballX = ballX + 30
  187. ballY = ballY - 30
  188.  
  189. end if
  190.  
  191. if velocity = 4 then
  192.  
  193. ballX = ballX - 30
  194. ballY = ballY + 30
  195.  
  196. end if
  197.  
  198. if velocity = 5 then
  199.  
  200. ballX = ballX + 30
  201. ballY = ballY + 30
  202.  
  203. end if
  204.  
  205. moveSprite ball, ballX, ballY
  206. sleep 1
  207.  
  208. loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement