DIM sprite(1000) AS INTEGER
DIM lin(100) AS INTEGER
RANDOMIZE TIMER
SCREEN 2
LINE (2, 5)-(370, 145), , B
CIRCLE (100, 100), 10, , , , .3
GET (90, 90)-(110, 110), sprite
PUT (90, 90), sprite, XOR
LINE (10, 130)-(40, 130)
GET (10, 130)-(40, 130), lin
PUT (10, 130), lin, XOR
v = 2
k = 2
x1 = 3
y1 = 2 + 2 * RND
z = 50
a = 2
FOR n = 1 TO 500 STEP 1
   ss$ = INKEY$
   IF ss$ = CHR$(50) THEN a = a - 1
   IF ss$ = CHR$(51) THEN a = a + 1
   IF ss$ = CHR$(49) THEN v = v + 1
   IF ss$ = CHR$(48) THEN v = v - 1
   x = x + x1
   y = y + y1
   PUT (x, y), sprite
   PUT (oldx, oldy), sprite, XOR
   IF x > 350 THEN x1 = -x1
   IF y > 110 THEN y1 = -y1
   IF x < 1 THEN x1 = -x1
   IF y < 1 THEN y1 = -y1
   z = z + a
   PUT (z, 130), lin
   PUT (oldz, 130), lin, XOR
   oldz = z
   IF z < 10 THEN a = -a
   IF z > 350 THEN a = -a
   IF y > 110 AND x < z - 20 THEN EXIT FOR
   IF y > 110 AND x > z + 30 THEN EXIT FOR
   IF v = 0 THEN v = 1
   SOUND 20000, v
   oldx = x
   oldy = y
NEXT n
PUT (x, y), sprite
END


