# Game? Screen Saver? Benchmark Program? It's Marbles.

January 17 2006 at 10:10 PM

Here's a little program I wrote that might inspire something better. It's not very efficient, so you will see a slowdown near the end. Press [Space] to destroy some of the marbles, and press the arrow keys to change the wind. Press [Q] to quit. :)

'------
'Marbles Screensaver
'Version 1.1, January 17, 2006
'(C) 2005 i-TECH and King Kristopher

SCREEN 12: CLS : RANDOMIZE TIMER: marbles = 800
DIM m(1 TO marbles, 1 TO 4)

FOR a = 1 TO marbles
m(a, 2) = -99
NEXT a

FOR a = 1 TO marbles
m(a, 1) = INT(RND * 640)
m(a, 2) = -20
m(a, 3) = INT(a / 27) + 1 'm(a, 3) = INT(RND * 15) + 1
m(a, 4) = 0

b = 1
WHILE b = 1 AND m(a, 2) < 450
m(a, 2) = m(a, 2) + m(a, 4)
m(a, 4) = m(a, 4) + .5
thekey\$ = INKEY\$: IF thekey\$ <> "" THEN key\$ = thekey\$
IF key\$ = CHR\$(0) + CHR\$(75) AND m(a, 1) > 20 THEN m(a, 1) = m(a, 1) - 10
IF key\$ = CHR\$(0) + CHR\$(77) AND m(a, 1) < 620 THEN m(a, 1) = m(a, 1) + 10

CIRCLE (m(a, 1), m(a, 2)), 15, m(a, 3)

b = 1
IF a > 2 THEN
FOR c = 1 TO a - 2
IF SQR(ABS(m(a, 1) - m(c, 1)) * ABS(m(a, 1) - m(c, 1)) + ABS(m(a, 2) - m(c, 2)) * ABS(m(a, 2) - m(c, 2))) < 30 THEN b = 0
NEXT c
END IF

CIRCLE (m(a, 1), m(a, 2)), 15, 0
WEND

CIRCLE (m(a, 1), m(a, 2)), 15, m(a, 3)
LOCATE 2, 2: PRINT a

IF key\$ = "q" OR key\$ = CHR\$(13) OR key\$ = CHR\$(8) THEN GOSUB theend
IF key\$ = " " THEN
f = INT(RND * a) + 1
WHILE m(f, 1) < 0
f = INT(RND * a) + 1
WEND
FOR g = 15 TO 50 STEP .02 'enlarge circle
CIRCLE (m(f, 1), m(f, 2)), g - 1, 0
CIRCLE (m(f, 1), m(f, 2)), g, m(f, 3)
NEXT g
i = m(f, 1): j = m(f, 2)
FOR h = 1 TO a 'remove nearby circles
IF SQR(ABS(i - m(h, 1)) * ABS(i - m(h, 1)) + ABS(j - m(h, 2)) * ABS(j - m(h, 2))) < 65 THEN
CIRCLE (m(h, 1), m(h, 2)), 15, 0
m(h, 1) = -99
m(h, 2) = -20
m(h, 3) = 0
m(h, 4) = 0
END IF
NEXT h
CIRCLE (i, j), 50, 0 'remove big circle
key\$ = ""
END IF
NEXT a

theend:
LOCATE 27, 23: PRINT "(C) 2006 i-TECH and King Kristopher"
'-----

Kristopher Windsor, :P
Bike or Die gold medalist.

 Respond to this message