From 710f4da55dbd7d962683448c555610e98c7481dd Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sun, 27 Oct 2024 15:59:24 +0200 Subject: [PATCH] Refactoring code for better readability --- Graphics/3D/tank1.bas | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Graphics/3D/tank1.bas b/Graphics/3D/tank1.bas index 22246a8..6b34f9f 100755 --- a/Graphics/3D/tank1.bas +++ b/Graphics/3D/tank1.bas @@ -29,8 +29,8 @@ DECLARE SUB mulcor () DECLARE SUB nait3d () DECLARE SUB calcsin () DEFINT A-Y -DIM SHARED xn(1000), yn(1000), czn(1000) ' original points -DIM SHARED x(1000), y(1000), cz(1000) ' Rotated points +DIM SHARED xn(1000), yn(1000), czn(1000) ' points transformed to on-screen coordinates +DIM SHARED pointX(1000), pointY(1000), pointZ(1000) ' points in 3D space DIM SHARED Xs1(1000), Ys1(1000), Xe1(1000), Ye1(1000) ' Old rotated points DIM SHARED pointers1(1000), pointers2(1000) ' Connected points DIM SHARED cosine&(360), sine&(360) ' SIN & COS table @@ -497,8 +497,8 @@ DEFSNG Z SUB getcor ' Loading original points and connected points FOR a = 0 TO 10000 - READ x(a), y(a), cz(a) - IF x(a) = 999 THEN x(a) = 0: y(a) = 0: cz(a) = 0: GOTO 1 + READ pointX(a), pointY(a), pointZ(a) + IF pointX(a) = 999 THEN pointX(a) = 0: pointY(a) = 0: pointZ(a) = 0: GOTO 1 NEXT 1 np = a @@ -600,9 +600,9 @@ DO ' Rotating points FOR a = 0 TO np - 1 - x1 = x(a) + myx - y1 = y(a) + myz - pz1 = cz(a) + myy + x1 = pointX(a) + myx + y1 = pointY(a) + myz + pz1 = pointZ(a) + myy ' Applying rotation matrix x2 = (x1 * c1& - pz1 * s1&) \ 1024 @@ -707,33 +707,33 @@ IF smes < 1 THEN smes = 15 b = smes FOR a = TracksBeginp TO TracksBeginp + 48 STEP 2 - x(a) = Tracksx(b) - Tracksxp - y(a) = Tracksy(b) - cz(a) = 50 - x(a + 1) = Tracksx(b) - Tracksxp - y(a + 1) = Tracksy(b) - cz(a + 1) = 30 + pointX(a) = Tracksx(b) - Tracksxp + pointY(a) = Tracksy(b) + pointZ(a) = 50 + pointX(a + 1) = Tracksx(b) - Tracksxp + pointY(a + 1) = Tracksy(b) + pointZ(a + 1) = 30 b = b + 15 NEXT a b = smes FOR a = TracksBeginp + 48 TO TracksBeginp + 94 STEP 2 - x(a) = Tracksx(b) - Tracksxp - y(a) = Tracksy(b) - cz(a) = -50 - x(a + 1) = Tracksx(b) - Tracksxp - y(a + 1) = Tracksy(b) - cz(a + 1) = -30 + pointX(a) = Tracksx(b) - Tracksxp + pointY(a) = Tracksy(b) + pointZ(a) = -50 + pointX(a + 1) = Tracksx(b) - Tracksxp + pointY(a + 1) = Tracksy(b) + pointZ(a + 1) = -30 b = b + 15 NEXT a REM Moving the tank FOR a = 0 TO 84 - x(a) = x(a) - ssu + pointX(a) = pointX(a) - ssu NEXT a -IF x(84) > 0 THEN ssu = 1 -IF x(83) < -400 THEN ssu = -1 +IF pointX(84) > 0 THEN ssu = 1 +IF pointX(83) < -400 THEN ssu = -1 END SUB @@ -775,8 +775,8 @@ np = np + 0 BridgeBeginp = np 5 -READ x(np), y(np), cz(np) -IF x(np) = 999 THEN x(np) = 0: y(np) = 0: cz(np) = 0: GOTO 3 +READ pointX(np), pointY(np), pointZ(np) +IF pointX(np) = 999 THEN pointX(np) = 0: pointY(np) = 0: pointZ(np) = 0: GOTO 3 np = np + 1 GOTO 5 -- 2.20.1