10 REM ATOM3.BAS.txt
20 GOSUB 1000 : REM Clear the Screen
25 C=16
30 PI = 3.14159
40 DZOP "C",1 : REM Color mode [Range = 16-23]
50 XC = 128 : YC = 128 : REM Initial center of the ovals
60 DIM HX(62), HY(62) : REM Array for horizontal oval points
70 DIM RX(62), RY(62) : REM Array for tilted right oval points
80 DIM LX(62), LY(62) : REM Array for tilted left oval points
90 REM Pre-calculate oval points
100 GOSUB 6000 : REM Calculate horizontal oval points
110 GOSUB 6100 : REM Calculate right-tilted oval points
120 GOSUB 6200 : REM Calculate left-tilted oval points
130 REM Set initial colors for the three ovals
140 OC = 17 : REM Initial outer color (horizontal oval)
150 MC = 18 : REM Initial middle color (tilted right oval)
160 CC = 19 : REM Initial center color (tilted left oval)
170 FOR STEPS = 1 TO 1000 : REM Loop to keep ovals wandering
180 GOSUB 4000 : REM Move the ovals to a new random position
190 GOSUB 2000 : REM Draw the ovals with changing colors
200 GOSUB 3000 : REM Pause between moves
210 GOSUB 5000 : REM Update the color scheme for the next iteration
220 GOSUB 1000 : REM Clear the screen for the next position
230 NEXT STEPS
999 GOTO 10 : REM Loop back to the beginning for continuous run
1000 REM Clear the Screen Routine
1010 DZOP "C",16
1020 DZOP "P",0,0
1030 DZOP "R",255,255
1040 RETURN
2000 REM Ovals Drawing Routine Using Pre-calculated Points
2010 DZOP "C",OC : REM Set color for horizontal oval
2020 FOR I = 0 TO 62
2030 X = XC + HX(I) : Y = YC + HY(I)
2040 IF X >= 0 AND X <= 255 AND Y >= 0 AND Y <= 255 THEN DZOP "P",X,Y : DZOP "D"
2050 NEXT I
2060 DZOP "C",MC : REM Set color for tilted right oval
2070 FOR I = 0 TO 62
2080 X = XC + RX(I) : Y = YC + RY(I)
2090 IF X >= 0 AND X <= 255 AND Y >= 0 AND Y <= 255 THEN DZOP "P",X,Y : DZOP "D"
2100 NEXT I
2110 DZOP "C",CC : REM Set color for tilted left oval
2120 FOR I = 0 TO 62
2130 X = XC + LX(I) : Y = YC + LY(I)
2140 IF X >= 0 AND X <= 255 AND Y >= 0 AND Y <= 255 THEN DZOP "P",X,Y : DZOP "D"
2150 NEXT I
2160 RETURN
3000 REM Pause Routine
3010 FOR PAUSE = 1 TO 300 : NEXT PAUSE : REM Short pause
3020 RETURN
4000 REM Move the Ovals to a New Random Position
4010 XC = INT(RND(1)*160) + 48 : YC = INT(RND(1)*160) + 48 : REM Random position
 within screen bounds
4020 RETURN
5000 REM Update the Ovals Color Scheme
5010 OC = OC + 1 : IF OC > 23 THEN OC = 17
5020 MC = MC + 1 : IF MC > 23 THEN MC = 17
5030 CC = CC + 1 : IF CC > 23 THEN CC = 17
5040 REM Ensure all colors are different
5050 IF MC = OC THEN MC = MC + 1 : IF MC > 23 THEN MC = 17
5060 IF CC = OC OR CC = MC THEN CC = CC + 1 : IF CC > 23 THEN CC = 17
5070 RETURN
6000 REM Pre-calculate Horizontal Oval (70 x 40)
6010 FOR I = 0 TO 62
6020 T = I * (2 * PI) / 62
6030 HX(I) = 70 * COS(T) : HY(I) = 40 * SIN(T)
6040 NEXT I
6050 RETURN
6100 REM Pre-calculate Tilted Right Oval (70 x 40, 55 degrees right)
6110 FOR I = 0 TO 62
6120 T = I * (2 * PI) / 62
6130 RX(I) = (70 * COS(T) * COS(55 * PI / 180)) - (40 * SIN(T) * SIN(55 * PI / 1
80))
6140 RY(I) = (70 * COS(T) * SIN(55 * PI / 180)) + (40 * SIN(T) * COS(55 * PI / 1
80))
6150 NEXT I
6160 RETURN
6200 REM Pre-calculate Tilted Left Oval (70 x 40, 55 degrees left)
6210 FOR I = 0 TO 62
6220 T = I * (2 * PI) / 62
6230 LX(I) = (70 * COS(T) * COS(-55 * PI / 180)) - (40 * SIN(T) * SIN(-55 * PI /
 180))
6240 LY(I) = (70 * COS(T) * SIN(-55 * PI / 180)) + (40 * SIN(T) * COS(-55 * PI /
 180))
6250 NEXT I
6260 RETURN
9999 REM End of Program
10000 GOTO 10
