From 77831639d886381a37017956e6d8810c4048abaf Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sat, 26 Oct 2024 10:53:25 +0300 Subject: [PATCH] Using AI to improve code readability --- Graphics/Animations/orbiit.bas | 75 +++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/Graphics/Animations/orbiit.bas b/Graphics/Animations/orbiit.bas index 9993ef4..72cb61e 100755 --- a/Graphics/Animations/orbiit.bas +++ b/Graphics/Animations/orbiit.bas @@ -1,39 +1,66 @@ -' Svjatoslav Agejenko +' Projects animated particles in orbit around a central point. +' By Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu + +' Changelog: +' ?, Initial version +' 2024, Improved program readability using AI -DEFINT A-Y SCREEN 7, , , 1 RANDOMIZE TIMER -DIM SHARED zme(1 TO 100) -DIM SHARED zme1(1 TO 100) -DIM SHARED zme2(1 TO 100) - +' Declare shared arrays to store particles +DIM SHARED particleColor(1 TO 100) +DIM SHARED particleX(1 TO 100) +DIM SHARED particleAngle(1 TO 100) +' Initialize the arrays with random values FOR a = 1 TO 100 -zme2(a) = RND * 15 -zme1(a) = RND * 100 -zme(a) = RND * 100 + particleColor(a) = RND * 15 + particleX(a) = RND * 100 + particleAngle(a) = RND * 100 NEXT a + +' Main loop to draw the animated particles 1 CLS FOR a = 1 TO 50 -z2 = zme(a) -z1 = zme1(a) -c = zme2(a) -x = SIN(z2) * 25 -y = SIN(z1) * 20 -zb = (COS(z2) + 2) * 2 -x = x * zb -y = y * zb -CIRCLE (x + 160, y + 100), zb, c -PAINT (x + 160, y + 100), c -LINE (160, 100)-(x + 160, y + 100), c - -zme(a) = zme(a) + .1 + ' Get current segment data + currentColor = particleColor(a) + currentParticleX = particleX(a) + currentparticleAngle = particleAngle(a) + + ' Calculate the x and y coordinates for the current segment + xCoordinate = SIN(currentparticleAngle) * 25 + yCoordinate = SIN(currentParticleX) * 20 + + ' Scale the coordinates + scaleFactor = (COS(currentparticleAngle) + 2) * 2 + xCoordinate = xCoordinate * scaleFactor + yCoordinate = yCoordinate * scaleFactor + + ' Draw the current particle as a circle + CIRCLE (xCoordinate + 160, yCoordinate + 100), scaleFactor, currentColor + + ' Fill the inside of the circle with color + PAINT (xCoordinate + 160, yCoordinate + 100), currentColor + + ' Draw a line from the center to the current particle + LINE (160, 100)-(xCoordinate + 160, yCoordinate + 100), currentColor + + ' Rotate particle by small amount for next frame + particleAngle(a) = particleAngle(a) + .1 NEXT a + +' Copy screen buffer 0 to screen buffer 1 PCOPY 0, 1 + +' Check for user input and exit if any key is pressed IF INKEY$ <> "" THEN SYSTEM -SOUND 0, 1 -GOTO 1 +' Use sound function with inaudible 0 Hz but fixed delay to slow down animation +SOUND 0, 1 +' Go back to the main loop +GOTO 1 -- 2.20.1