Better code readability.
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 26 Jun 2025 13:55:13 +0000 (16:55 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 26 Jun 2025 13:55:13 +0000 (16:55 +0300)
2D GFX/Presentations/AI/AI demo.bas

index be9f839..138ecaa 100644 (file)
@@ -194,44 +194,43 @@ drawEdges:
 finishPolygon:\r
 END SUB\r
 \r
-\r
-SUB GetAngle (xOne, yOne, xTwo, yTwo, angleOutput)\r
+SUB GetAngle (point1X, point1Y, point2X, point2Y, angleBetween)\r
 '\r
-' Computes an angle in radians between two points (xOne,yOne) and (xTwo,yTwo).\r
-' The result is stored in angleOutput. Used for 2D rotation or orientation logic.\r
+' Calculates the angle between two 2D points in radians.\r
+' Used for rotation calculations in 3D rendering.\r
 '\r
-    IF yOne = yTwo THEN\r
-        IF xTwo > xOne THEN\r
-            angleOutput = globalPi / 2\r
+    IF point1Y = point2Y THEN\r
+        IF point2X > point1X THEN\r
+            angleBetween = globalPi / 2\r
         ELSE\r
-            angleOutput = globalPi * 1.5\r
+            angleBetween = globalPi * 1.5\r
         END IF\r
-        GOTO skipLogic\r
+        GOTO skipSpecialCases\r
     END IF\r
 \r
-    IF yTwo > yOne THEN\r
-        IF xTwo = xOne THEN\r
-            angleOutput = globalPi\r
-            GOTO skipLogic\r
+    IF point2Y > point1Y THEN\r
+        IF point2X = point1X THEN\r
+            angleBetween = globalPi\r
+            GOTO skipSpecialCases\r
         END IF\r
-        IF xTwo > xOne THEN\r
-            angleOutput = (globalPi * 1) - ATN((xTwo - xOne) / (yTwo - yOne))\r
+        IF point2X > point1X THEN\r
+            angleBetween = (globalPi * 1) - ATN((point2X - point1X) / (point2Y - point1Y))\r
         ELSE\r
-            angleOutput = globalPi + ATN((xOne - xTwo) / (yTwo - yOne))\r
+            angleBetween = globalPi + ATN((point1X - point2X) / (point2Y - point1Y))\r
         END IF\r
     ELSE\r
-        IF xTwo = xOne THEN\r
-            angleOutput = 0\r
-            GOTO skipLogic\r
+        IF point2X = point1X THEN\r
+            angleBetween = 0\r
+            GOTO skipSpecialCases\r
         END IF\r
-        IF xTwo > xOne THEN\r
-            angleOutput = ATN((xTwo - xOne) / (yOne - yTwo))\r
+        IF point2X > point1X THEN\r
+            angleBetween = ATN((point2X - point1X) / (point1Y - point2Y))\r
         ELSE\r
-            angleOutput = globalPi * 2 - ATN((xOne - xTwo) / (yOne - yTwo))\r
+            angleBetween = globalPi * 2 - ATN((point1X - point2X) / (point1Y - point2Y))\r
         END IF\r
     END IF\r
 \r
-skipLogic:\r
+skipSpecialCases:\r
 END SUB\r
 \r
 \r