Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Simple Pong By cmart592
- @INIT1
- SCR% = 0
- SCR1% = 0
- 'Player one paddle stuffs
- 'SPSET 0,*PADDLE #*
- 'SPOFS 0,8,MIDY on the left
- SPHOME 0,24,8
- SPROT 0,270
- SPCOL 0
- 'Player two paddle stuffs
- 'SPSET 1,*PADDLE #*
- 'SPOFS 1,8,MIDY on the right
- SPHOME 1,24,8
- SPROT 1,90
- SPCOL 1
- 'Ball 'nuff said
- 'SPSET 2,*BALL #*
- 'SPOFS 2,MIDX,MIDY
- SPCOL 2
- BC = 1
- GOTO @MAIN
- '---Init 1 basically resets the entire game.
- 'Init 2, on the other hand, just resets when the ball is scored
- @INIT2
- ACLS
- SCR% = SCR% 'Keep the score
- SCR1% = SCR1%
- LOCATE 8,2:PRINT SCR%
- LOCATE 16,2:PRINT SCR1%
- 'SPSET 0,*PADDLE #*
- 'SPOFS 0, *Middle of screen x*,*middle of screen y*
- SPHOME 0,24,8
- SPROT 0,270
- 'SPSET 1,*PADDLE #*
- 'SPOFS 1,*MIDX*,*MIDY*
- SPHOME 1,24,8
- SPROT 1,90
- 'Ball 'nuff said '---resets the ball position as well
- 'SPSET 2,*BALL #*
- 'SPOFS 2,MIDX,MIDY
- @MAIN
- SPOFS 2 OUT BX,BY:SPOFS 0 OUT X1,Y1:SPOFS 1 OUT X2,Y2
- GOSUB @MOVE
- GOSUB @BALL
- GOSUB @COLL
- GOSUB @SCOR
- VSYNC 1:BUTTON()=BTN:SPOFS 2,BX,BY:SPOFS 1,X1,X2:SPOFS 0,X1,X2
- GOTO @MAIN
- '---MAIN CODE STUFFS---
- @MOVE
- 'To make the padles actually move
- 'Player 1 movement
- IF BTN==#UP THEN SPOFS 0,X1,Y1-2
- IF BTN==#DOWN THEN SPOFS 0,X1,Y1+2
- 'Player 2 movement
- IF BTN==#X THEN SPOFS 1,X2,Y2-2
- IF BTN==#B THEN SPOFS 1,X2,Y2+2
- 'Keeps the paddles on the srceen...
- IF Y1<0 THEN Y1=0:IF Y1>239 THEN Y1=239
- IF Y2<0 THEN Y1=0:IF Y2>239 THEN Y2=239
- RETURN
- @BALL
- 'If no buttons are pressed,
- 'then keep the ball in the center
- IF BUTTON == 0 THEN
- BX = 299/2
- BY = 329/2
- ELSE IF BUTTON == #A THEN
- BX = BX + BV
- BY = BY + BV
- ENDIF
- 'Keep the ball onscreen
- IF BY <= 0 THEN BY=BY+BV
- IF BY >= 299 THEN BY=BY-BV
- 'Scoring boundaries come in the scoring section
- RETURN
- @COLL
- 'sets up the sprite collision pairs
- H1 = SPHITSP '(paddle 1, ball)
- H2 = SPHITSP '(paddle 2, ball)
- 'If the ball hits the paddle,
- 'then the ball should bounce
- 'back, in a theoretical manner
- 'my code sucks, deal with it.
- 'At least it works.
- IF H1 == TRUE THEN
- 'Make the ball bounce back
- 'play a sound, just ot be sure
- BEEP 1
- ENDIF
- IF H2 == THEN
- 'Do the same as H1
- 'play a sound as well, lol
- BEEP 2
- ENDIF
- RETURN
- @SCOR
- IF BX <= 0 THEN
- SCR% = SCR% + 1
- GOTO @INIT2
- ENDIF
- '----If the ball touches either side of
- '----the screen, then it'll add a point
- '----to the score and reset the game...
- 'IF BX >= *insert edge number here*
- SCR1% = SCR% + 1
- GOTO @INIT2
- ENDIF
- RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement