Advertisement
Super_Defaultio

Simple Pong for Review : SmileBASIC

Feb 13th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. 'Simple Pong By cmart592
  2.  
  3. @INIT1
  4. SCR% = 0
  5. SCR1% = 0
  6.  
  7. 'Player one paddle stuffs
  8.  
  9. 'SPSET 0,*PADDLE #*
  10. 'SPOFS 0,8,MIDY on the left
  11. SPHOME 0,24,8
  12. SPROT 0,270
  13. SPCOL 0
  14.  
  15. 'Player two paddle stuffs
  16.  
  17. 'SPSET 1,*PADDLE #*
  18. 'SPOFS 1,8,MIDY on the right
  19. SPHOME 1,24,8
  20. SPROT 1,90
  21. SPCOL 1
  22.  
  23. 'Ball 'nuff said
  24. 'SPSET 2,*BALL #*
  25. 'SPOFS 2,MIDX,MIDY
  26. SPCOL 2
  27. BC = 1
  28.  
  29. GOTO @MAIN
  30.  
  31. '---Init 1 basically resets the entire game.
  32. 'Init 2, on the other hand, just resets when the ball is scored
  33.  
  34. @INIT2
  35. ACLS
  36.  
  37. SCR% = SCR% 'Keep the score
  38. SCR1% = SCR1%
  39. LOCATE 8,2:PRINT SCR%
  40. LOCATE 16,2:PRINT SCR1%
  41.  
  42. 'SPSET 0,*PADDLE #*
  43. 'SPOFS 0, *Middle of screen x*,*middle of screen y*
  44. SPHOME 0,24,8
  45. SPROT 0,270
  46.  
  47. 'SPSET 1,*PADDLE #*
  48. 'SPOFS 1,*MIDX*,*MIDY*
  49. SPHOME 1,24,8
  50. SPROT 1,90
  51.  
  52. 'Ball 'nuff said '---resets the ball position as well
  53. 'SPSET 2,*BALL #*
  54. 'SPOFS 2,MIDX,MIDY
  55.  
  56.  
  57. @MAIN
  58. SPOFS 2 OUT BX,BY:SPOFS 0 OUT X1,Y1:SPOFS 1 OUT X2,Y2
  59.  
  60. GOSUB @MOVE
  61. GOSUB @BALL
  62. GOSUB @COLL
  63. GOSUB @SCOR
  64.  
  65. VSYNC 1:BUTTON()=BTN:SPOFS 2,BX,BY:SPOFS 1,X1,X2:SPOFS 0,X1,X2
  66. GOTO @MAIN
  67.  
  68.  
  69. '---MAIN CODE STUFFS---
  70.  
  71. @MOVE
  72. 'To make the padles actually move
  73.  
  74. 'Player 1 movement
  75. IF BTN==#UP THEN SPOFS 0,X1,Y1-2
  76. IF BTN==#DOWN THEN SPOFS 0,X1,Y1+2
  77.  
  78. 'Player 2 movement
  79. IF BTN==#X THEN SPOFS 1,X2,Y2-2
  80. IF BTN==#B THEN SPOFS 1,X2,Y2+2
  81.  
  82. 'Keeps the paddles on the srceen...
  83. IF Y1<0 THEN Y1=0:IF Y1>239 THEN Y1=239
  84. IF Y2<0 THEN Y1=0:IF Y2>239 THEN Y2=239
  85. RETURN
  86.  
  87. @BALL
  88. 'If no buttons are pressed,
  89. 'then keep the ball in the center
  90. IF BUTTON == 0 THEN
  91. BX = 299/2
  92. BY = 329/2
  93. ELSE IF BUTTON == #A THEN
  94. BX = BX + BV
  95. BY = BY + BV
  96. ENDIF
  97.  
  98. 'Keep the ball onscreen
  99. IF BY <= 0 THEN BY=BY+BV
  100. IF BY >= 299 THEN BY=BY-BV
  101.  
  102. 'Scoring boundaries come in the scoring section
  103. RETURN
  104.  
  105. @COLL
  106.  
  107. 'sets up the sprite collision pairs
  108. H1 = SPHITSP '(paddle 1, ball)
  109. H2 = SPHITSP '(paddle 2, ball)
  110.  
  111. 'If the ball hits the paddle,
  112. 'then the ball should bounce
  113. 'back, in a theoretical manner
  114. 'my code sucks, deal with it.
  115. 'At least it works.
  116.  
  117. IF H1 == TRUE THEN
  118. 'Make the ball bounce back
  119. 'play a sound, just ot be sure
  120. BEEP 1
  121. ENDIF
  122.  
  123. IF H2 == THEN
  124. 'Do the same as H1
  125. 'play a sound as well, lol
  126. BEEP 2
  127. ENDIF
  128. RETURN
  129.  
  130. @SCOR
  131. IF BX <= 0 THEN
  132. SCR% = SCR% + 1
  133. GOTO @INIT2
  134. ENDIF
  135.  
  136. '----If the ball touches either side of
  137. '----the screen, then it'll add a point
  138. '----to the score and reset the game...
  139.  
  140. 'IF BX >= *insert edge number here*
  141. SCR1% = SCR% + 1
  142. GOTO @INIT2
  143. ENDIF
  144.  
  145. RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement