-' Program to render animated DNA.\r
+' Program to render animated DNA as seen in the movies.\r
+'\r
' By Svjatoslav Agejenko.\r
' Email: svjatoslav@svjatoslav.eu\r
' Homepage: http://www.svjatoslav.eu\r
'\r
+' Changelog:\r
+' ?, Initial version\r
+' 2024, Improved program readability using AI\r
\r
-DEFINT A-Y\r
-\r
-DIM SHARED cx(1 TO 100)\r
-DIM SHARED cy(1 TO 100)\r
-DIM SHARED cz(1 TO 100)\r
-DIM SHARED cc(1 TO 100)\r
+DIM SHARED xCoordinates(1 TO 100)\r
+DIM SHARED yCoordinates(1 TO 100)\r
+DIM SHARED zCoordinates(1 TO 100)\r
+DIM SHARED colorCodes(1 TO 100)\r
\r
SCREEN 7, , , 1\r
-f = 0\r
\r
1:\r
b = 0\r
-zf = zf + 0.1\r
+rotationAngle = rotationAngle + 0.1\r
FOR a = 1 TO 20\r
b = b + 1\r
- cx(b) = SIN(a / 2 + zf) * 30 + 150\r
- cz(b) = SIN(a / 2 + zf + 1.6) * 2 + 2\r
- cy(b) = a * 8 + cz(b)\r
- cc(b) = 3\r
+ ' Calculate x-coordinate using sine function and add to array\r
+ xCoordinates(b) = SIN(a / 2 + rotationAngle) * 30 + 150\r
+ ' Calculate z-coordinate using sine function and add to array\r
+ zCoordinates(b) = SIN(a / 2 + rotationAngle + 1.6) * 2 + 2\r
+ ' Calculate y-coordinate by multiplying a with 8 and adding z-coordinate\r
+ yCoordinates(b) = a * 8 + zCoordinates(b)\r
+ ' Assign color code to the current point\r
+ colorCodes(b) = 3\r
\r
b = b + 1\r
- cx(b) = SIN(a / 2 + zf + 2.5) * 30 + 150\r
- cz(b) = SIN(a / 2 + zf + 1.6 + 2.5) * 2 + 2\r
- cy(b) = a * 8 + cz(b)\r
- cc(b) = 4\r
+ ' Calculate x-coordinate using sine function and add to array\r
+ xCoordinates(b) = SIN(a / 2 + rotationAngle + 2.5) * 30 + 150\r
+ ' Calculate z-coordinate using sine function and add to array\r
+ zCoordinates(b) = SIN(a / 2 + rotationAngle + 1.6 + 2.5) * 2 + 2\r
+ ' Calculate y-coordinate by multiplying a with 8 and adding z-coordinate\r
+ yCoordinates(b) = a * 8 + zCoordinates(b)\r
+ ' Assign color code to the current point\r
+ colorCodes(b) = 4\r
NEXT a\r
\r
+' Clear the screen\r
CLS\r
+\r
+' Draw lines and circles based on z-coordinate\r
FOR b = 0 TO 4\r
IF b = 1 THEN\r
FOR a = 1 TO 40 STEP 2\r
- LINE (cx(a), cy(a))-(cx(a + 1), cy(a + 1)), 15\r
+ ' Draw line between consecutive points\r
+ LINE (xCoordinates(a), yCoordinates(a))-(xCoordinates(a + 1), yCoordinates(a + 1)), 15\r
NEXT a\r
END IF\r
\r
FOR a = 1 TO 40\r
- IF cz(a) = b THEN\r
- CIRCLE (cx(a), cy(a)), b + 5, cc(a)\r
- PAINT (cx(a), cy(a)), cc(a)\r
- CIRCLE (cx(a), cy(a)), b + 5, 0\r
+ ' Check if the current z-coordinate matches the loop variable b\r
+ IF int(zCoordinates(a)) = b THEN\r
+ ' Draw circle with specified color code\r
+ CIRCLE (xCoordinates(a), yCoordinates(a)), b + 5, colorCodes(a)\r
+ PAINT (xCoordinates(a), yCoordinates(a)), colorCodes(a)\r
+ ' Draw an black outline of the circle\r
+ CIRCLE (xCoordinates(a), yCoordinates(a)), b + 5, 0\r
END IF\r
NEXT a\r
NEXT b\r
+\r
+' Copy the screen to buffer and clear the screen\r
PCOPY 0, 1\r
CLS\r
+\r
+' Check if any key is pressed\r
IF INKEY$ = "" THEN GOTO 1\r
+\r
+' End the program\r
SYSTEM\r