Bubbles
A simple program for drawing 'bubbles' on the screen. But wait! The program remembers the position of each bubble and then removes them (pops them?) so that only a certain number remain on the screen at any one time. You can adjust two parameters: the size of the bubbles, and the number displayed on screen at anyone time.
REM bubbles
REM Tim Goliath Street
REM 11/10/2012
REM screen parameters
X_WIDTH% = 1400
Y_WIDTH% = 1200
ON ERROR RUN
MODE 10 : OFF
REM set up space to remember some bubbles
MAX% = 100
*font Courier New, 50b
PRINT"Bubbles"
REM get number of bubbles on screen
*font Courier New, 12
REPEAT
PRINT "Enter max bubbles on screen (1-"STR$(MAX%)") ",": ";
INPUT "" NO_ON_SCREEN%
UNTIL NO_ON_SCREEN% >0 AND NO_ON_SCREEN% <= MAX%
REPEAT
PRINT "Enter max bubbles size (1-"STR$(X_WIDTH%)") ",": ";
INPUT "" MAX_RADIUS%
UNTIL MAX_RADIUS% >0 AND MAX_RADIUS% <= X_WIDTH%
CLS
DIM bubble{( MAX% ) x%, y%, r% }
REM pointers
destroyBubble% = -NO_ON_SCREEN%
makeBubble% = 0
REM colours
cyan% = 6
black% = 0
REM bubble parameters
border% = 4 : REM bubble size
DELAY% = 4
IF NO_ON_SCREEN% > 40 DELAY% = 0
REM ==========================
REM MAIN LOOP
REM ==========================
REPEAT
REM make a new bubble
x% = RND(X_WIDTH%)
y% = RND(Y_WIDTH%)
r% = RND(MAX_RADIUS%)+12
REM save new bubble
bubble{(makeBubble%)}.x% = x%
bubble{(makeBubble%)}.y% = y%
bubble{(makeBubble%)}.r% = r%
GCOL cyan%
REM display bubble
FOR n% = 1 TO border%
FOR m% = 1 TO border%
CIRCLE x%+n%, y%+m%, r%
NEXT
NEXT
REM destroy a bubble
IF NOT(SGNdestroyBubble% =-1) THEN
GCOL black%
FOR n% = 1 TO border%
FOR m% = 1 TO border%
CIRCLE bubble{(destroyBubble%)}.x%+n%, bubble{(destroyBubble%)}.y%+m%, bubble{(destroyBubble%)}.r%
NEXT
NEXT
REM re-draw all the other bubbles
GCOL cyan%
REM start with the bubble just destroyed
redo% = destroyBubble%
REPEAT
REM increment the redo pointer
redo% += 1
REM check boundary
IF redo% > MAX% THEN
redo% = 0 : REM return to the left
ENDIF
REM display bubble
FOR n% = 1 TO border%
FOR m% = 1 TO border%
CIRCLE bubble{(redo%)}.x%+n%, bubble{(redo%)}.y%+m%, bubble{(redo%)}.r%
NEXT
NEXT
UNTIL redo% = makeBubble%
ENDIF
REM increment destroy pointer
destroyBubble% += 1
REM check boundary
IF destroyBubble% > MAX% THEN
destroyBubble% = 0
ENDIF
REM increment bubble pointer
makeBubble% += 1
REM check boundary
IF makeBubble% > MAX% THEN
makeBubble% = 0
ENDIF
WAIT DELAY%
UNTIL FALSE