Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define fbc -s console
- #include "MyTDT\ConsoleEmu.bas"
- #define CharPtr(X, Y) *(pScreen + (((X) + ((Y) * SCREEN_WIDTH)) shl 1))
- #define AttrPtr(X, Y) *(pScreen + (((X) + ((Y) * SCREEN_WIDTH)) shl 1)+1)
- 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
- pCon.Lock()
- for C as integer = 0 to 99
- var X = cint(int(rnd*80)),Y = cint(int(rnd*25))
- CharPtr(X,Y)=219: AttrPtr(X,Y)=&h1C
- next C
- pCon.Unlock()
- 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
- If cuint(BallX-1) >= SCREEN_WIDTH-2 Then MoveX = -MoveX: ChangeDirection = -1
- If cuint(BallY-1) >= SCREEN_HEIGHT-2 Then MoveY = -MoveY: ChangeDirection = -1
- 'Check for collision with text
- If ChangeDirection=0 Then
- #if 1
- If CharPtr(BallX+MoveX, BallY) > 32 Then MoveX = -MoveX
- If CharPtr(BallX, BallY+MoveY) > 32 Then MoveY = -MoveY
- #else
- If CharPtr(BallX+MoveX, BallY+MoveY) > 32 Then
- '...
- end if
- #endif
- End If
- 'Render Screen
- pCon.Lock()
- CharPtr(OldX, OldY) = 07 'Remove old ball
- CharPtr(BallX, BallY) = 02 'Draw new ball
- pCon.Unlock()
- OldX = BallX: OldY = BallY
- ChangeDirection = 0
- Sleep 50,1
- Loop until Inkey = Chr(27)'<> ""
- pCon.Destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement