DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
Posted: Thu Oct 30, 2003 6:20 am Post subject: Bouncing balls |
[quote] |
|
this can help make a pong-ish game
Code: |
DEFINT A-Z
CONST QUITSTATE = 255
CONST RUNSTATE = 1
TYPE BallTyp
x AS INTEGER
y AS INTEGER
xv AS INTEGER
yv AS INTEGER
clr AS INTEGER
END TYPE
CONST MAXBALLS = 100
DIM SHARED Balls(MAXBALLS) AS BallTyp
DIM SHARED State
CLS
SCREEN 7, 0, 1, 0
FOR index = 0 To 255
OUT &H3c8, index
OUT &H3c9, i + 64
OUT &H3c9, i + 64
OUT &H3c9, i + 64
NEXT
FOR index = 0 To MAXBALLS-1
Balls(index).x = INT(RND*319-16)+16
Balls(index).y = INT(RND*199-16)+16
Balls(index).xv = 2 * INT(RND * 3) + 1
Balls(index).yv = 2 * INT(RND * 3) + 1
Balls(index).clr = INT(RND * 15) + 1
NEXT
DO
CLS
K$ = INKEY$
IF K$ = CHR$(27) THEN State = QUITSTATE
FOR index = 0 To MAXBALLS-1
' move balls
Balls(index).x = Balls(index).x + Balls(index).xv
Balls(index).y = Balls(index).y + Balls(index).yv
IF Balls(index).x < 16 THEN Balls(index).xv = -Balls(index).xv
IF Balls(index).x > 319-16 THEN Balls(index).xv = -Balls(index).xv
IF Balls(index).y < 16 THEN Balls(index).yv = -Balls(index).yv
IF Balls(index).y > 199-16 THEN Balls(index).yv = -Balls(index).yv
' draw balls
CIRCLE (Balls(index).x, Balls(index).y),INT(RND*4)+16,Balls(index).clr
PAINT(Balls(index).x, Balls(index).y), Balls(index).clr, Balls(index).clr
NEXT
PCOPY 1,0
LOOP UNTIL State = QUITSTATE
SCREEN 0
WIDTH 80
SYSTEM
|
enjoy! _________________ Principal Software Architect
Rambling Indie Games, LLC
See my professional portfolio
|
|