SHOW:
|
|
- or go back to the newest paste.
1 | - | #define fbc -s gui |
1 | + | #define fbc -s console |
2 | - | #include "Console.bas" |
2 | + | |
3 | #include "MyTDT\ConsoleEmu.bas" | |
4 | - | #define CharPtr(X, Y) *(pScreen + ((X + (Y * SCREEN_WIDTH)) SHL 1)) |
4 | + | |
5 | - | #define AttrPtr(X, Y) *(pScreen + (X + (Y * SCREEN_WIDTH))) |
5 | + | #define CharPtr(X, Y) *(pScreen + (((X) + ((Y) * SCREEN_WIDTH)) shl 1)) |
6 | #define AttrPtr(X, Y) *(pScreen + (((X) + ((Y) * SCREEN_WIDTH)) shl 1)+1) | |
7 | Const SCREEN_WIDTH = 80, SCREEN_HEIGHT = 25 | |
8 | Dim as Integer BallX, BallY, MoveX, MoveY | |
9 | Dim as Integer OldX, OldY | |
10 | ||
11 | Dim as uByte Ptr pScreen | |
12 | pScreen = pCon.Create(SCREEN_WIDTH,SCREEN_HEIGHT,fb.gfx_fullscreen) | |
13 | ||
14 | MoveX = 1: MoveY = 1 | |
15 | - | Dim as Integer ChangeDirection |
15 | + | |
16 | dim as integer ChangeDirection | |
17 | - | Cls |
17 | + | |
18 | pCon.Lock() | |
19 | for C as integer = 0 to 99 | |
20 | var X = cint(int(rnd*80)),Y = cint(int(rnd*25)) | |
21 | CharPtr(X,Y)=219: AttrPtr(X,Y)=&h1C | |
22 | next C | |
23 | - | If BallX = 0 or BallX = SCREEN_WIDTH-1 Then MoveX = -MoveX: ChangeDirection = -1 |
23 | + | pCon.Unlock() |
24 | - | If BallY = 0 or BallY = SCREEN_HEIGHT-1 Then MoveY = -MoveY: ChangeDirection = -1 |
24 | + | |
25 | Do | |
26 | 'Move ball | |
27 | - | If Not ChangeDirection Then |
27 | + | |
28 | - | If CharPtr(BallX+MoveX, BallY) <> 32 Then MoveX = -MoveX |
28 | + | |
29 | - | If CharPtr(BallX, BallY+MoveY) <> 32 Then MoveY = -MoveY |
29 | + | |
30 | 'If BallX = 0 or BallX = SCREEN_WIDTH-1 Then MoveX = -MoveX: ChangeDirection = -1 | |
31 | 'If BallY = 0 or BallY = SCREEN_HEIGHT-1 Then MoveY = -MoveY: ChangeDirection = -1 | |
32 | If cuint(BallX-1) >= SCREEN_WIDTH-2 Then MoveX = -MoveX: ChangeDirection = -1 | |
33 | If cuint(BallY-1) >= SCREEN_HEIGHT-2 Then MoveY = -MoveY: ChangeDirection = -1 | |
34 | - | CharPtr(OldX, OldY) = 00 'Remove old ball |
34 | + | |
35 | - | CharPtr(BallX, BallY) = 07 'Draw new ball |
35 | + | |
36 | If ChangeDirection=0 Then | |
37 | #if 1 | |
38 | If CharPtr(BallX+MoveX, BallY) > 32 Then MoveX = -MoveX | |
39 | If CharPtr(BallX, BallY+MoveY) > 32 Then MoveY = -MoveY | |
40 | #else | |
41 | If CharPtr(BallX+MoveX, BallY+MoveY) > 32 Then | |
42 | '... | |
43 | end if | |
44 | #endif | |
45 | - | Screen 0 |
45 | + | |
46 | ||
47 | 'Render Screen | |
48 | pCon.Lock() | |
49 | CharPtr(OldX, OldY) = 07 'Remove old ball | |
50 | CharPtr(BallX, BallY) = 02 'Draw new ball | |
51 | pCon.Unlock() | |
52 | ||
53 | OldX = BallX: OldY = BallY | |
54 | ChangeDirection = 0 | |
55 | ||
56 | Sleep 50,1 | |
57 | Loop until Inkey = Chr(27)'<> "" | |
58 | ||
59 | pCon.Destroy() |