Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define horizontalMovementRight $1
- define verticalMovementDown $2
- updateBallNoClip:
- lda #horizontalMovementRight
- bit ballDirection ;check if direction to the right
- bne right
- left:
- dec ballX
- jmp verticalCheck
- right:
- inc ballX
- verticalCheck:
- lda #verticalMovementDown
- bit ballDirection ;check if going down
- bne down
- up:
- dec ballY
- jmp endUpdateBallNoClip
- down:
- inc ballY
- endUpdateBallNoClip:
- rts
- ;check if the ball should bounce off walls
- checkBallWallCollision:
- leftWallCheck:
- lda ballX
- bpl rightWallCheck
- ;hit left wall
- jsr toggleHorizontalDirection
- ;move right two places
- inc ballX
- inc ballX
- rightWallCheck:
- cmp #$20 ;over the right wall
- bne topWallCheck
- ;hit right wall
- jsr toggleHorizontalDirection
- dec ballX
- dec ballX
- topWallCheck:
- lda ballY
- bpl bottomWallCheck
- ;hit top wall
- jsr toggleVerticalDirection
- inc ballY
- inc ballY
- bottomWallCheck:
- cmp #$20
- bne endCheckBallWallCollision
- jsr toggleVerticalDirection
- dec ballY
- dec ballY
- endCheckBallWallCollision:
- rts
- toggleHorizontalDirection:
- lda ballDirection ; toggle horizontal bit
- eor #horizontalMovementRight
- sta ballDirection
- rts
- toggleVerticalDirection:
- lda ballDirection ; toggle vertical bit
- eor #verticalMovementDown
- sta ballDirection
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement