Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define fbc -s gui
- #include "Console.bas"
- #define CharPtr(X, Y) *(pScreen + ((X + (Y * SCREEN_WIDTH)) SHL 1))
- #define AttrPtr(X, Y) *(pScreen + (X + (Y * SCREEN_WIDTH)))
- Const SCREEN_WIDTH = 80, SCREEN_HEIGHT = 25
- Dim as Integer BallX, BallY, MoveX, MoveY
- Dim as Integer OldX, OldY
- Dim as uByte Ptr pScreen
- pScreen = pCon.Create(SCREEN_WIDTH,SCREEN_HEIGHT,fb.gfx_fullscreen)
- MoveX = 1: MoveY = 1
- BallX = 9: BallY = 9
- Dim as Integer ChangeDirection
- Cls
- Do
- 'Move ball
- BallX += MoveX: BallY += MoveY
- 'If we hit a wall, bounce
- If BallX = 0 or BallX = SCREEN_WIDTH-1 Then MoveX = -MoveX: ChangeDirection = -1
- If BallY = 0 or BallY = SCREEN_HEIGHT-1 Then MoveY = -MoveY: ChangeDirection = -1
- 'Check for collision with text
- If Not ChangeDirection Then
- If CharPtr(BallX+MoveX, BallY) <> 32 Then MoveX = -MoveX
- If CharPtr(BallX, BallY+MoveY) <> 32 Then MoveY = -MoveY
- End If
- 'Render Screen
- pCon.Lock()
- CharPtr(OldX, OldY) = 00 'Remove old ball
- CharPtr(BallX, BallY) = 07 'Draw new ball
- pCon.Unlock()
- OldX = BallX: OldY = BallY
- ChangeDirection = 0
- Sleep 50,1
- Loop until Inkey = Chr(27)'<> ""
- Screen 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement