-' Tank\r
-' made by Svjatoslav Agejenko\r
-' in 2000\r
-' H-Page: svjatoslav.eu\r
-' E-Mail: svjatoslav@svjatoslav.eu\r
- \r
-' Use keys to move around:\r
-' Left, Right, Up, Down look around\r
-' + move fovard\r
-' - move back\r
-' q quit\r
-' <space> - stop\r
-\r
-\r
-DECLARE SUB start ()\r
-DECLARE SUB savepos (x1%, y1%, x2%, y2%)\r
-DECLARE SUB teemaad ()\r
-DECLARE SUB setgus ()\r
-DECLARE SUB getgus ()\r
-DECLARE SUB getgus1 (x1%, y1%, x2%, y2%)\r
-DECLARE SUB kiri ()\r
-DECLARE SUB getcor ()\r
-DECLARE SUB mulcor ()\r
-DECLARE SUB nait3d ()\r
-DECLARE SUB calcsin ()\r
-DEFINT A-Y\r
-DIM SHARED xn(1000), yn(1000), czn(1000) ' original points\r
-DIM SHARED x(1000), y(1000), cz(1000) ' Rotated points\r
-DIM SHARED Xs1(1000), Ys1(1000), Xe1(1000), Ye1(1000) ' Old rotated points\r
-DIM SHARED pointers1(1000), pointers2(1000) ' Connected points\r
-DIM SHARED cosine&(360), sine&(360) ' SIN & COS table\r
-DIM SHARED np, nl\r
-\r
-DIM SHARED gusx(1 TO 1000)\r
-DIM SHARED gusy(1 TO 1000)\r
-DIM SHARED mitgus\r
-DIM SHARED smes\r
-\r
-\r
-DIM SHARED gusalgp ' segment\r
-DIM SHARED gusalgl\r
-DIM SHARED silalgp ' segment\r
-DIM SHARED silalgl\r
-\r
-DIM SHARED gusxp\r
-DIM SHARED myx, myy, myz\r
-DIM SHARED myxp, myyp, myzp\r
-\r
-DIM SHARED deg1, deg2, deg3\r
-DIM SHARED speed\r
-\r
-DIM SHARED ssu\r
-\r
-\r
-start\r
-\r
-nait3d\r
-\r
- \r
-\r
-\r
-DATA -10,-30,-20\r
-DATA 30,-30,-20\r
-DATA 30,-10,-20\r
-DATA -10,-10,-20\r
-\r
-DATA -10,-30,20\r
-DATA 30,-30,20\r
-DATA 30,-10,20\r
-DATA -10,-10,20\r
-\r
-DATA -10,-40,-15\r
-DATA 30,-40,-15\r
-DATA -10,-40,15\r
-DATA 30,-40,15\r
-\r
-DATA -20,-30,-15\r
-DATA -20,-30, 15\r
-\r
-DATA -70,-10,-50\r
-DATA 60,-10, -50\r
-DATA 70, 0, -50\r
-DATA 70, 20, -50\r
-DATA 60, 30, -50\r
-DATA -70,30, -50\r
-DATA -80,20, -50\r
-DATA -80, 0, -50\r
-\r
-DATA -70,-10,-30\r
-DATA 60,-10, -30\r
-DATA 70, 0, -30\r
-DATA 70, 20, -30\r
-DATA 60, 30, -30\r
-DATA -70,30, -30\r
-DATA -80,20, -30\r
-DATA -80, 0, -30\r
-\r
-DATA -70,-10, 50\r
-DATA 60,-10, 50\r
-DATA 70, 0, 50\r
-DATA 70, 20, 50\r
-DATA 60, 30, 50\r
-DATA -70,30, 50\r
-DATA -80,20, 50\r
-DATA -80, 0, 50\r
-\r
-DATA -70,-10, 30\r
-DATA 60,-10, 30\r
-DATA 70, 0, 30\r
-DATA 70, 20, 30\r
-DATA 60, 30, 30\r
-DATA -70,30, 30\r
-DATA -80,20, 30\r
-DATA -80, 0, 30\r
-\r
-DATA -50,-7,-30\r
-DATA 50,-7,-30\r
-DATA 50, 15,-30\r
-DATA -50, 15,-30\r
-\r
-DATA -50,-7, 30\r
-DATA 50,-7, 30\r
-DATA 50, 15,30\r
-DATA -50, 15,30\r
-\r
-DATA -20,-20,-5\r
-DATA -20,-20, 5\r
-DATA -20,-30, 5\r
-DATA -20,-30,-5\r
-\r
-DATA -100,-30,-5\r
-DATA -100,-30, 5\r
-DATA -100,-40, 5\r
-DATA -100,-40,-5\r
-\r
-DATA 999,999,999\r
-\r
-DATA 0,1\r
-DATA 1,2\r
-DATA 2,3\r
-DATA 3,0\r
-\r
-DATA 4,5\r
-DATA 5,6\r
-DATA 6,7\r
-DATA 7,4\r
- \r
-DATA 0,8\r
-DATA 1,9\r
-DATA 4,10\r
-DATA 5,11\r
-\r
-DATA 0,12\r
-DATA 4,13\r
-DATA 12,8\r
-DATA 13,10\r
-\r
-DATA 8,9\r
-DATA 10,11\r
-DATA 8,10\r
-DATA 9,11\r
-\r
-DATA 12,13\r
-DATA 12,3\r
-DATA 13,7\r
-DATA 3,7\r
-DATA 1,5\r
-DATA 2,6\r
-\r
-DATA 14,15\r
-DATA 15,16\r
-DATA 16,17\r
-DATA 17,18\r
-DATA 18,19\r
-DATA 19,20\r
-DATA 20,21\r
-DATA 21,14\r
-\r
-DATA 22,23\r
-DATA 23,24\r
-DATA 24,25\r
-DATA 25,26\r
-DATA 26,27\r
-DATA 27,28\r
-DATA 28,29\r
-DATA 29,22\r
-\r
-'DATA 14,22\r
-'DATA 15,23\r
-'DATA 16,24\r
-'DATA 17,25\r
-'DATA 18,26\r
-'DATA 19,27\r
-'DATA 20,28\r
-'DATA 21,29\r
-\r
-DATA 30,31\r
-DATA 31,32\r
-DATA 32,33\r
-DATA 33,34\r
-DATA 34,35\r
-DATA 35,36\r
-DATA 36,37\r
-DATA 37,30\r
-\r
-DATA 38,39\r
-DATA 39,40\r
-DATA 40,41\r
-DATA 41,42\r
-DATA 42,43\r
-DATA 43,44\r
-DATA 44,45\r
-DATA 45,38\r
-\r
-'DATA 30,38\r
-'DATA 31,39\r
-'DATA 32,40\r
-'DATA 33,41\r
-'DATA 34,42\r
-'DATA 35,43\r
-'DATA 36,44\r
-'DATA 37,45\r
-\r
-DATA 46,47\r
-DATA 47,48\r
-DATA 48,49\r
-DATA 49,46\r
-\r
-DATA 50,51\r
-DATA 51,52\r
-DATA 52,53\r
-DATA 53,50\r
-\r
-DATA 50,46\r
-DATA 51,47\r
-DATA 52,48\r
-DATA 53,49\r
-\r
-DATA 54,55\r
-DATA 55,56\r
-DATA 56,57\r
-DATA 57,54\r
-\r
-DATA 54,58\r
-DATA 55,59\r
-DATA 56,60\r
-DATA 57,61\r
-\r
-DATA 58,59\r
-DATA 59,60\r
-DATA 60,61\r
-DATA 61,58\r
-\r
-DATA 54,3\r
-DATA 55,7\r
-\r
-\r
-'DATA 62,63\r
-\r
-DATA 999, 999\r
-' S I L D\r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- ' parempoolsed k�epided\r
-DATA 100,0,100\r
-DATA 100,50,100\r
-\r
-DATA 50,0,100\r
-DATA 50,50,100\r
-\r
-DATA 0,0,100\r
-DATA 0,50,100\r
-\r
-DATA -50,0,100\r
-DATA -50,50,100\r
-\r
-DATA -100,0,100\r
-DATA -100,50,100\r
- ' 5\r
-DATA -150,0,100\r
-DATA -150,50,100\r
-\r
-DATA -200,0,100\r
-DATA -200,50,100\r
-\r
-DATA -250,0,100\r
-DATA -250,50,100\r
-\r
-DATA -300,0,100\r
-DATA -300,50,100\r
-\r
-DATA -350,0,100\r
-DATA -350,50,100\r
- ' 10\r
-\r
-DATA -400,0,100\r
-DATA -400,50,100\r
-\r
-DATA -450,0,100\r
-DATA -450,50,100\r
-\r
-DATA -500,0,100\r
-DATA -500,50,100\r
-\r
-DATA -550,0,100\r
-DATA -550,50,100\r
-\r
-DATA -600,0,100\r
-DATA -600,50,100\r
-\r
-DATA -650,0,100\r
-DATA -650,50,100\r
-\r
- ' vasak poolsed k�epided\r
-DATA 100,0,-100\r
-DATA 100,50,-100\r
-\r
-DATA 50,0,-100\r
-DATA 50,50,-100\r
-\r
-DATA 0,0,-100\r
-DATA 0,50,-100\r
-\r
-DATA -50,0,-100\r
-DATA -50,50,-100\r
-\r
-DATA -100,0,-100\r
-DATA -100,50,-100\r
- ' 5\r
-DATA -150,0,-100\r
-DATA -150,50,-100\r
-\r
-DATA -200,0,-100\r
-DATA -200,50,-100\r
-\r
-DATA -250,0,-100\r
-DATA -250,50,-100\r
-\r
-DATA -300,0,-100\r
-DATA -300,50,-100\r
-\r
-DATA -350,0,-100\r
-DATA -350,50,-100\r
- ' 10\r
-\r
-DATA -400,0,-100\r
-DATA -400,50,-100\r
-\r
-DATA -450,0,-100\r
-DATA -450,50,-100\r
-\r
-DATA -500,0,-100\r
-DATA -500,50,-100\r
-\r
-DATA -550,0,-100\r
-DATA -550,50,-100\r
-\r
-DATA -600,0,-100\r
-DATA -600,50,-100\r
-\r
-DATA -650,0,-100\r
-DATA -650,50,-100\r
- ' alumine joon\r
-DATA 100,75,-100\r
-DATA -650,75,-100\r
-\r
-DATA 100,75,100\r
-DATA -650,75,100\r
- ' kallas\r
-DATA 75,75,-100\r
-DATA 75,75,100\r
- 'parem\r
-DATA -50,200,-100\r
-DATA -50,200,100\r
-\r
-DATA 75,200,-190\r
-DATA 75,200, 190\r
- 'vasak\r
-DATA -525,200,-100\r
-DATA -525,200, 100\r
-\r
-DATA -600,200,-190\r
-DATA -600,200, 190\r
-\r
-\r
-\r
-\r
-DATA 999,999,999\r
-\r
- 'parempoolesd k�epided\r
-'DATA 0,1\r
-DATA 2,3\r
-DATA 4,5\r
-DATA 6,7\r
-DATA 8,9\r
-\r
-DATA 10,11\r
-DATA 12,13\r
-DATA 14,15\r
-DATA 16,17\r
-DATA 18,19\r
-\r
-DATA 20,21\r
-DATA 22,23\r
-DATA 24,25\r
-DATA 26,27\r
-DATA 28,29\r
-'DATA 30,31\r
-\r
- 'vasakpoolsed k�epided\r
-'DATA 32,33\r
-DATA 34,35\r
-DATA 36,37\r
-DATA 38,39\r
-DATA 40,41\r
-\r
-DATA 42,43\r
-DATA 44,45\r
-DATA 46,47\r
-DATA 48,49\r
-DATA 50,51\r
-\r
-DATA 52,53\r
-DATA 54,55\r
-DATA 56,57\r
-DATA 58,59\r
-DATA 60,61\r
-'DATA 62,63\r
- ' sild ise\r
-'DATA 0,30\r
-'DATA 1,31\r
-'DATA 32,62\r
-'DATA 33,63\r
-\r
-' pikad\r
-DATA 0,4\r
-DATA 4,8\r
-DATA 8,12\r
-DATA 12,16\r
-DATA 16,20\r
-DATA 20,24\r
-DATA 24,28\r
-DATA 28,30\r
-\r
-DATA 1,5\r
-DATA 5,9\r
-DATA 9,13\r
-DATA 13,17\r
-DATA 17,21\r
-DATA 21,25\r
-DATA 25,29\r
-DATA 29,31\r
-\r
-DATA 32,36\r
-DATA 36,40\r
-DATA 40,44\r
-DATA 44,48\r
-DATA 48,52\r
-DATA 52,56\r
-DATA 56,60\r
-DATA 60,62\r
-\r
-DATA 33,37\r
-DATA 37,41\r
-DATA 41,45\r
-DATA 45,49\r
-DATA 49,53\r
-DATA 53,57\r
-DATA 57,61\r
-DATA 61,63\r
-\r
-\r
-\r
-' l�pp\r
-\r
-DATA 1,33\r
-DATA 31,63\r
-\r
-DATA 64,65\r
-DATA 66,67\r
-DATA 64,66\r
-DATA 65,67\r
-\r
-DATA 0,66\r
-DATA 32,64\r
-DATA 30,67\r
-DATA 62,65\r
- ' kallas\r
-DATA 68,69\r
-DATA 70,71\r
-DATA 68,70\r
-DATA 69,71\r
-\r
-DATA 72,70\r
-DATA 72,68\r
-\r
-DATA 73,71\r
-DATA 73,69\r
- 'vasak\r
-DATA 74,76\r
-DATA 75,77\r
-DATA 74,75\r
-\r
-DATA 74,65\r
-DATA 76,65\r
-\r
-DATA 75,67\r
-DATA 77,67\r
-\r
-\r
-DATA 999, 999\r
-\r
-DEFINT Z\r
-SUB calcsin\r
-PRINT "Calculating SIN and COS data..."\r
-\r
-FOR a! = 0 TO 359 / 57.29577951# STEP 1 / 57.29577951#\r
- cosine&(a) = INT(.5 + COS(a!) * 1024)\r
- sine&(a) = INT(.5 + SIN(a!) * 1024)\r
- a = a + 1\r
-NEXT\r
-CLS\r
-END SUB\r
-\r
-DEFSNG Z\r
-SUB getcor\r
-FOR a = 0 TO 10000\r
- READ x(a), y(a), cz(a)\r
- IF x(a) = 999 THEN x(a) = 0: y(a) = 0: cz(a) = 0: GOTO 1\r
-NEXT\r
-1\r
-np = a\r
-FOR a = 0 TO 10000\r
- READ pointers1(a), pointers2(a)\r
- IF pointers1(a) = 999 THEN GOTO 2\r
-NEXT\r
-2\r
-nl = a\r
-\r
-gusalgp = np\r
-gusalgl = nl\r
-\r
-FOR a = 1 TO 48\r
-pointers1(nl) = np\r
-np = np + 1\r
-pointers2(nl) = np\r
-np = np + 1\r
-nl = nl + 1\r
-NEXT a\r
-\r
-\r
-\r
-END SUB\r
-\r
-DEFINT Z\r
-SUB getgus\r
-\r
-mitgus = 1\r
-getgus1 -70, -10, -80, 0\r
-getgus1 -80, 0, -80, 20\r
-getgus1 -80, 20, -70, 30\r
-getgus1 -70, 30, 60, 30\r
-getgus1 60, 30, 70, 20\r
-getgus1 70, 20, 70, 0\r
-getgus1 70, 0, 60, -10\r
-getgus1 60, -10, -70, -10\r
-'LOCATE 1, 1\r
-'PRINT mitgus\r
-'SLEEP\r
-\r
-\r
-END SUB\r
-\r
-DEFSNG Z\r
-SUB getgus1 (x1, y1, x2, y2)\r
-z1 = ABS(x1 - x2)\r
-z2 = ABS(y2 - y1)\r
-mi = SQR(z1 ^ 2 + z2 ^ 2) * 1.017142857#\r
-\r
-zxp = (x1 - x2) / mi\r
-zyp = (y2 - y1) / mi\r
-zx = x1\r
-zy = y1\r
-\r
-FOR a = 1 TO mi\r
-zx = zx - zxp\r
-zy = zy + zyp\r
-gusx(mitgus) = zx\r
-gusy(mitgus) = zy\r
-mitgus = mitgus + 1\r
-NEXT a\r
-\r
-END SUB\r
-\r
-DEFINT Z\r
-SUB moveright\r
-END SUB\r
-\r
-DEFSNG Z\r
-SUB nait3d\r
-\r
-DO\r
-\r
-setgus\r
-\r
- deg1 = deg1 + d1\r
- deg2 = deg2 + d2\r
- deg3 = deg3 + d3\r
-'LOCATE 1, 1\r
-'PRINT deg1, deg2, deg3, speed\r
- \r
- IF deg1 <= 0 THEN deg1 = deg1 + 360\r
- IF deg2 <= 0 THEN deg2 = deg2 + 360\r
- IF deg3 <= 0 THEN deg3 = deg3 + 360\r
- \r
- IF deg1 >= 360 THEN deg1 = deg1 - 360\r
- IF deg2 >= 360 THEN deg2 = deg2 - 360\r
- IF deg3 >= 360 THEN deg3 = deg3 - 360\r
-\r
- c1& = cosine&(deg1): s1& = sine&(deg1)\r
- c2& = cosine&(deg2): s2& = sine&(deg2)\r
- c3& = cosine&(deg3): S3& = sine&(deg3)\r
-\r
-myx = myx - (s1& * speed / 100)\r
-myy = myy - (c1& * speed / 100)\r
-myz = myz - (s2& * speed / 100)\r
-\r
-FOR a = 0 TO np - 1\r
-x1 = x(a) + myx\r
-y1 = y(a) + myz\r
-pz1 = cz(a) + myy\r
- \r
-x2 = (x1 * c1& - pz1 * s1&) \ 1024\r
-pz2 = (x1 * s1& + pz1 * c1&) \ 1024\r
- \r
-y2 = (y1 * c2& - pz2 * s2&) \ 1024\r
-pz3 = (y1 * s2& + pz2 * c2&) \ 1024\r
- \r
-x3 = (y2 * c3& - x2 * S3&) \ 1024\r
-y3 = (y2 * S3& + x2 * c3&) \ 1024\r
- \r
-IF pz3 > 10 THEN\r
-xn(a) = 320 + (x3 / pz3 * 500)\r
-yn(a) = 240 + (y3 / pz3 * 500)\r
-ELSE\r
-xn(a) = -1\r
-END IF\r
-\r
-\r
-NEXT\r
-\r
- \r
-FOR a1 = 0 TO nl - 1\r
-f1 = pointers1(a1)\r
-s1 = pointers2(a1)\r
- \r
-xn = xn(f1)\r
-yn = yn(f1)\r
- \r
-x1 = xn(s1)\r
-y1 = yn(s1)\r
- \r
-IF Xs1(a1) = -1 OR Xe1(a1) = -1 THEN ELSE LINE (Xs1(a1), Ys1(a1))-(Xe1(a1), Ye1(a1)), 0\r
-IF x1 = -1 OR xn = -1 THEN ELSE LINE (x1, y1)-(xn, yn), 15\r
-\r
-\r
-Xs1(a1) = x1: Ys1(a1) = y1\r
-Xe1(a1) = xn: Ye1(a1) = yn\r
-NEXT\r
- \r
-\r
-k$ = INKEY$\r
-IF k$ <> "" THEN\r
-\r
-SELECT CASE k$\r
-\r
-CASE CHR$(0) + "M"\r
-d1 = d1 - 1\r
-\r
-CASE CHR$(0) + "K"\r
-d1 = d1 + 1\r
-\r
-CASE CHR$(0) + "P"\r
-d2 = d2 + 1\r
-\r
-CASE CHR$(0) + "H"\r
-d2 = d2 - 1\r
-\r
-CASE "w"\r
-d3 = d3 - 1\r
-\r
-CASE "z"\r
-d3 = d3 + 1\r
-\r
-CASE "-"\r
-speed = speed - 1\r
-\r
-CASE "+"\r
-speed = speed + 1\r
-\r
-CASE " "\r
-d1 = 0\r
-d2 = 0\r
-d3 = 0\r
-speed = 0\r
-\r
-CASE CHR$(27)\r
-SYSTEM\r
-\r
-END SELECT\r
-k$ = ""\r
-END IF\r
-LOOP\r
-END SUB\r
-\r
-SUB setgus\r
-gusxp = gusxp + ssu\r
-smes = smes + ssu\r
-IF smes > 15 THEN smes = 1\r
-IF smes < 1 THEN smes = 15\r
-b = smes\r
-\r
-FOR a = gusalgp TO gusalgp + 48 STEP 2\r
-x(a) = gusx(b) - gusxp\r
-y(a) = gusy(b)\r
-cz(a) = 50\r
-x(a + 1) = gusx(b) - gusxp\r
-y(a + 1) = gusy(b)\r
-cz(a + 1) = 30\r
-b = b + 15\r
-NEXT a\r
-\r
-b = smes\r
-FOR a = gusalgp + 48 TO gusalgp + 94 STEP 2\r
-x(a) = gusx(b) - gusxp\r
-y(a) = gusy(b)\r
-cz(a) = -50\r
-x(a + 1) = gusx(b) - gusxp\r
-y(a + 1) = gusy(b)\r
-cz(a + 1) = -30\r
-b = b + 15\r
-NEXT a\r
-\r
-' maa\r
-FOR a = 0 TO 84\r
-x(a) = x(a) - ssu\r
-NEXT a\r
- \r
-IF x(84) > 0 THEN ssu = 1\r
-IF x(83) < -400 THEN ssu = -1\r
-\r
-\r
-\r
-\r
-END SUB\r
-\r
-SUB start\r
-SCREEN 12\r
-CLS\r
-speed = 0\r
-\r
-'deg1 = 270\r
-'deg2 = 0\r
-'deg3 = 90\r
-\r
-deg1 = 210\r
-deg2 = 20\r
-deg3 = 90\r
-\r
-smes = 1\r
-gusxp = 0\r
-\r
-myxp = 0\r
-myyp = 0\r
-myzp = 0\r
-myx = 0\r
-myy = -300\r
-myz = 100\r
-smes = 1\r
-\r
-ssu = 1\r
-\r
-calcsin\r
-\r
-getcor\r
-teemaad\r
-getgus\r
-\r
-\r
-END SUB\r
-\r
-SUB teemaad\r
-silalgl = nl\r
-np = np + 0\r
-silalgp = np\r
-\r
-5\r
-READ x(np), y(np), cz(np)\r
-IF x(np) = 999 THEN x(np) = 0: y(np) = 0: cz(np) = 0: GOTO 3\r
-np = np + 1\r
-GOTO 5\r
-\r
-3\r
-READ pointers1(nl), pointers2(nl)\r
-IF pointers1(nl) = 999 THEN GOTO 4\r
-pointers1(nl) = pointers1(nl) + silalgp\r
-pointers2(nl) = pointers2(nl) + silalgp\r
-nl = nl + 1\r
-GOTO 3\r
-4\r
-\r
-END SUB\r
-\r
+' Program to render animated 3D tank that drives back and forth on the 3D bridge.
+' User can fly around the tank and bridge.
+' By Svjatoslav Agejenko.
+' Email: svjatoslav@svjatoslav.eu
+' Homepage: http://www.svjatoslav.eu
+'
+' Changelog:
+' 2000, Initial version
+' 2024, Improved program readability using AI
+
+' Use keys to move around:
+' Left, Right, Up, Down look around
+' + move forward
+' - move back
+' q quit
+' <space> - stop
+
+DECLARE SUB start ()
+DECLARE SUB savepos (x1%, y1%, x2%, y2%)
+DECLARE SUB teemaad ()
+DECLARE SUB setgus ()
+DECLARE SUB getgus ()
+DECLARE SUB getgus1 (x1%, y1%, x2%, y2%)
+DECLARE SUB kiri ()
+DECLARE SUB getcor ()
+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 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
+DIM SHARED np, nl
+
+DIM SHARED gusx(1 TO 1000)
+DIM SHARED gusy(1 TO 1000)
+DIM SHARED mitgus
+DIM SHARED smes
+
+DIM SHARED gusalgp ' segment
+DIM SHARED gusalgl
+DIM SHARED silalgp ' segment
+DIM SHARED silalgl
+
+DIM SHARED gusxp
+DIM SHARED myx, myy, myz
+DIM SHARED myxp, myyp, myzp
+
+DIM SHARED deg1, deg2, deg3
+DIM SHARED speed
+
+DIM SHARED ssu
+
+start
+
+nait3d
+
+DATA -10,-30,-20
+DATA 30,-30,-20
+DATA 30,-10,-20
+DATA -10,-10,-20
+
+DATA -10,-30,20
+DATA 30,-30,20
+DATA 30,-10,20
+DATA -10,-10,20
+
+DATA -10,-40,-15
+DATA 30,-40,-15
+DATA -10,-40,15
+DATA 30,-40,15
+
+DATA -20,-30,-15
+DATA -20,-30, 15
+
+DATA -70,-10,-50
+DATA 60,-10, -50
+DATA 70, 0, -50
+DATA 70, 20, -50
+DATA 60, 30, -50
+DATA -70,30, -50
+DATA -80,20, -50
+DATA -80, 0, -50
+
+DATA -70,-10,-30
+DATA 60,-10, -30
+DATA 70, 0, -30
+DATA 70, 20, -30
+DATA 60, 30, -30
+DATA -70,30, -30
+DATA -80,20, -30
+DATA -80, 0, -30
+
+DATA -70,-10, 50
+DATA 60,-10, 50
+DATA 70, 0, 50
+DATA 70, 20, 50
+DATA 60, 30, 50
+DATA -70,30, 50
+DATA -80,20, 50
+DATA -80, 0, 50
+
+DATA -70,-10, 30
+DATA 60,-10, 30
+DATA 70, 0, 30
+DATA 70, 20, 30
+DATA 60, 30, 30
+DATA -70,30, 30
+DATA -80,20, 30
+DATA -80, 0, 30
+
+DATA -50,-7,-30
+DATA 50,-7,-30
+DATA 50, 15,-30
+DATA -50, 15,-30
+
+DATA -50,-7, 30
+DATA 50,-7, 30
+DATA 50, 15,30
+DATA -50, 15,30
+
+DATA -20,-20,-5
+DATA -20,-20, 5
+DATA -20,-30, 5
+DATA -20,-30,-5
+
+DATA -100,-30,-5
+DATA -100,-30, 5
+DATA -100,-40, 5
+DATA -100,-40,-5
+
+DATA 999,999,999
+
+DATA 0,1
+DATA 1,2
+DATA 2,3
+DATA 3,0
+
+DATA 4,5
+DATA 5,6
+DATA 6,7
+DATA 7,4
+
+DATA 0,8
+DATA 1,9
+DATA 4,10
+DATA 5,11
+
+DATA 0,12
+DATA 4,13
+DATA 12,8
+DATA 13,10
+
+DATA 8,9
+DATA 10,11
+DATA 8,10
+DATA 9,11
+
+DATA 12,13
+DATA 12,3
+DATA 13,7
+DATA 3,7
+DATA 1,5
+DATA 2,6
+
+DATA 14,15
+DATA 15,16
+DATA 16,17
+DATA 17,18
+DATA 18,19
+DATA 19,20
+DATA 20,21
+DATA 21,14
+
+DATA 22,23
+DATA 23,24
+DATA 24,25
+DATA 25,26
+DATA 26,27
+DATA 27,28
+DATA 28,29
+DATA 29,22
+
+'DATA 14,22
+'DATA 15,23
+'DATA 16,24
+'DATA 17,25
+'DATA 18,26
+'DATA 19,27
+'DATA 20,28
+'DATA 21,29
+
+DATA 30,31
+DATA 31,32
+DATA 32,33
+DATA 33,34
+DATA 34,35
+DATA 35,36
+DATA 36,37
+DATA 37,30
+
+DATA 38,39
+DATA 39,40
+DATA 40,41
+DATA 41,42
+DATA 42,43
+DATA 43,44
+DATA 44,45
+DATA 45,38
+
+'DATA 30,38
+'DATA 31,39
+'DATA 32,40
+'DATA 33,41
+'DATA 34,42
+'DATA 35,43
+'DATA 36,44
+'DATA 37,45
+
+DATA 46,47
+DATA 47,48
+DATA 48,49
+DATA 49,46
+
+DATA 50,51
+DATA 51,52
+DATA 52,53
+DATA 53,50
+
+DATA 50,46
+DATA 51,47
+DATA 52,48
+DATA 53,49
+
+DATA 54,55
+DATA 55,56
+DATA 56,57
+DATA 57,54
+
+DATA 54,58
+DATA 55,59
+DATA 56,60
+DATA 57,61
+
+DATA 58,59
+DATA 59,60
+DATA 60,61
+DATA 61,58
+
+DATA 54,3
+DATA 55,7
+
+'DATA 62,63
+
+DATA 999, 999
+' BRIDGE
+
+' right handlebars
+DATA 100,0,100
+DATA 100,50,100
+
+DATA 50,0,100
+DATA 50,50,100
+
+DATA 0,0,100
+DATA 0,50,100
+
+DATA -50,0,100
+DATA -50,50,100
+
+DATA -100,0,100
+DATA -100,50,100
+ ' 5
+DATA -150,0,100
+DATA -150,50,100
+
+DATA -200,0,100
+DATA -200,50,100
+
+DATA -250,0,100
+DATA -250,50,100
+
+DATA -300,0,100
+DATA -300,50,100
+
+DATA -350,0,100
+DATA -350,50,100
+ ' 10
+
+DATA -400,0,100
+DATA -400,50,100
+
+DATA -450,0,100
+DATA -450,50,100
+
+DATA -500,0,100
+DATA -500,50,100
+
+DATA -550,0,100
+DATA -550,50,100
+
+DATA -600,0,100
+DATA -600,50,100
+
+DATA -650,0,100
+DATA -650,50,100
+
+ ' left handlebars
+DATA 100,0,-100
+DATA 100,50,-100
+
+DATA 50,0,-100
+DATA 50,50,-100
+
+DATA 0,0,-100
+DATA 0,50,-100
+
+DATA -50,0,-100
+DATA -50,50,-100
+
+DATA -100,0,-100
+DATA -100,50,-100
+ ' 5
+DATA -150,0,-100
+DATA -150,50,-100
+
+DATA -200,0,-100
+DATA -200,50,-100
+
+DATA -250,0,-100
+DATA -250,50,-100
+
+DATA -300,0,-100
+DATA -300,50,-100
+
+DATA -350,0,-100
+DATA -350,50,-100
+ ' 10
+
+DATA -400,0,-100
+DATA -400,50,-100
+
+DATA -450,0,-100
+DATA -450,50,-100
+
+DATA -500,0,-100
+DATA -500,50,-100
+
+DATA -550,0,-100
+DATA -550,50,-100
+
+DATA -600,0,-100
+DATA -600,50,-100
+
+DATA -650,0,-100
+DATA -650,50,-100
+ ' alumine joon
+DATA 100,75,-100
+DATA -650,75,-100
+
+DATA 100,75,100
+DATA -650,75,100
+ ' kallas
+DATA 75,75,-100
+DATA 75,75,100
+ 'parem
+DATA -50,200,-100
+DATA -50,200,100
+
+DATA 75,200,-190
+DATA 75,200, 190
+ 'vasak
+DATA -525,200,-100
+DATA -525,200, 100
+
+DATA -600,200,-190
+DATA -600,200, 190
+
+'
+
+DATA 999,999,999
+
+ 'right handlebars
+'DATA 0,1
+DATA 2,3
+DATA 4,5
+DATA 6,7
+DATA 8,9
+
+DATA 10,11
+DATA 12,13
+DATA 14,15
+DATA 16,17
+DATA 18,19
+
+DATA 20,21
+DATA 22,23
+DATA 24,25
+DATA 26,27
+DATA 28,29
+'DATA 30,31
+
+ 'left handlebars
+'DATA 32,33
+DATA 34,35
+DATA 36,37
+DATA 38,39
+DATA 40,41
+
+DATA 42,43
+DATA 44,45
+DATA 46,47
+DATA 48,49
+DATA 50,51
+
+DATA 52,53
+DATA 54,55
+DATA 56,57
+DATA 58,59
+DATA 60,61
+'DATA 62,63
+ ' sild ise
+'DATA 0,30
+'DATA 1,31
+'DATA 32,62
+'DATA 33,63
+
+' pikad
+DATA 0,4
+DATA 4,8
+DATA 8,12
+DATA 12,16
+DATA 16,20
+DATA 20,24
+DATA 24,28
+DATA 28,30
+
+DATA 1,5
+DATA 5,9
+DATA 9,13
+DATA 13,17
+DATA 17,21
+DATA 21,25
+DATA 25,29
+DATA 29,31
+
+DATA 32,36
+DATA 36,40
+DATA 40,44
+DATA 44,48
+DATA 48,52
+DATA 52,56
+DATA 56,60
+DATA 60,62
+
+DATA 33,37
+DATA 37,41
+DATA 41,45
+DATA 45,49
+DATA 49,53
+DATA 53,57
+DATA 57,61
+DATA 61,63
+
+'
+
+' l�pp
+
+DATA 1,33
+DATA 31,63
+
+DATA 64,65
+DATA 66,67
+DATA 64,66
+DATA 65,67
+
+DATA 0,66
+DATA 32,64
+DATA 30,67
+DATA 62,65
+ ' kallas
+DATA 68,69
+DATA 70,71
+DATA 68,70
+DATA 69,71
+
+DATA 72,70
+DATA 72,68
+
+DATA 73,71
+DATA 73,69
+ 'vasak
+DATA 74,76
+DATA 75,77
+DATA 74,75
+
+DATA 74,65
+DATA 76,65
+
+DATA 75,67
+DATA 77,67
+
+'
+
+DATA 999, 999
+
+DEFINT Z
+SUB calcsin
+REM Calculating SIN and COS data...
+
+FOR a! = 0 TO 359 / 57.29577951# STEP 1 / 57.29577951#
+ cosine&(a) = INT(.5 + COS(a!) * 1024)
+ sine&(a) = INT(.5 + SIN(a!) * 1024)
+ a = a + 1
+NEXT
+CLS
+END SUB
+
+DEFSNG Z
+SUB getcor
+REM 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
+NEXT
+1
+np = a
+FOR a = 0 TO 10000
+ READ pointers1(a), pointers2(a)
+ IF pointers1(a) = 999 THEN GOTO 2
+NEXT
+2
+nl = a
+
+gusalgp = np
+gusalgl = nl
+
+REM Initializing connected points
+FOR a = 1 TO 48
+pointers1(nl) = np
+np = np + 1
+pointers2(nl) = np
+np = np + 1
+nl = nl + 1
+NEXT a
+
+END SUB
+
+DEFINT Z
+SUB getgus
+
+REM Initialize the number of segments
+mitgus = 1
+getgus1 -70, -10, -80, 0
+getgus1 -80, 0, -80, 20
+getgus1 -80, 20, -70, 30
+getgus1 -70, 30, 60, 30
+getgus1 60, 30, 70, 20
+getgus1 70, 20, 70, 0
+getgus1 70, 0, 60, -10
+getgus1 60, -10, -70, -10
+'LOCATE 1, 1
+'PRINT mitgus
+'SLEEP
+
+END SUB
+
+DEFSNG Z
+SUB getgus1 (x1%, y1%, x2%, y2%)
+REM Calculating points for a segment
+z1 = ABS(x1 - x2)
+z2 = ABS(y2 - y1)
+mi = SQR(z1 ^ 2 + z2 ^ 2) * 1.017142857#
+
+REM Calculating direction vectors
+zxp = (x1 - x2) / mi
+zyp = (y2 - y1) / mi
+zx = x1
+zy = y1
+
+FOR a = 1 TO mi
+ zx = zx - zxp
+ zy = zy + zyp
+ gusx(mitgus) = zx
+ gusy(mitgus) = zy
+ mitgus = mitgus + 1
+NEXT a
+
+END SUB
+
+
+
+DEFSNG Z
+SUB nait3d
+REM Main loop to render the scene
+DO
+
+ setgus
+
+ REM Updating rotation angles
+ deg1 = deg1 + d1
+ deg2 = deg2 + d2
+ deg3 = deg3 + d3
+
+ REM Normalizing angles
+ IF deg1 <= 0 THEN deg1 = deg1 + 360
+ IF deg2 <= 0 THEN deg2 = deg2 + 360
+ IF deg3 <= 0 THEN deg3 = deg3 + 360
+
+ IF deg1 >= 360 THEN deg1 = deg1 - 360
+ IF deg2 >= 360 THEN deg2 = deg2 - 360
+ IF deg3 >= 360 THEN deg3 = deg3 - 360
+
+ REM Calculating sine and cosine values
+ c1& = cosine&(deg1)
+ s1& = sine&(deg1)
+ c2& = cosine&(deg2)
+ s2& = sine&(deg2)
+ c3& = cosine&(deg3)
+ S3& = sine&(deg3)
+
+ REM Updating tank position
+ myx = myx - (s1& * speed / 100)
+ myy = myy - (c1& * speed / 100)
+ myz = myz - (s2& * speed / 100)
+
+ REM Rotating points
+ FOR a = 0 TO np - 1
+ x1 = x(a) + myx
+ y1 = y(a) + myz
+ pz1 = cz(a) + myy
+
+ REM Applying rotation matrix
+ x2 = (x1 * c1& - pz1 * s1&) \ 1024
+ pz2 = (x1 * s1& + pz1 * c1&) \ 1024
+
+ y2 = (y1 * c2& - pz2 * s2&) \ 1024
+ pz3 = (y1 * s2& + pz2 * c2&) \ 1024
+
+ x3 = (y2 * c3& - x2 * S3&) \ 1024
+ y3 = (y2 * S3& + x2 * c3&) \ 1024
+
+ REM Checking if point is within view
+ IF pz3 > 10 THEN
+ xn(a) = 320 + (x3 / pz3 * 500)
+ yn(a) = 240 + (y3 / pz3 * 500)
+ ELSE
+ xn(a) = -1
+ END IF
+ NEXT
+
+ REM Drawing lines between connected points
+ FOR a1 = 0 TO nl - 1
+ f1 = pointers1(a1)
+ s1 = pointers2(a1)
+
+ xn = xn(f1)
+ yn = yn(f1)
+
+ x1 = xn(s1)
+ y1 = yn(s1)
+
+ REM Drawing lines
+ IF Xs1(a1) = -1 OR Xe1(a1) = -1 THEN
+ ELSE
+ LINE (Xs1(a1), Ys1(a1))-(Xe1(a1), Ye1(a1)), 0
+ END IF
+
+ IF x1 = -1 OR xn = -1 THEN
+ ELSE
+ LINE (x1, y1)-(xn, yn), 15
+ END IF
+
+ REM Updating old rotated points
+ Xs1(a1) = x1
+ Ys1(a1) = y1
+
+ Xe1(a1) = xn
+ Ye1(a1) = yn
+ NEXT
+
+ REM Handling user input
+ k$ = INKEY$
+ IF k$ <> "" THEN
+
+ SELECT CASE k$
+
+ CASE CHR$(0) + "M"
+ d1 = d1 - 1
+
+ CASE CHR$(0) + "K"
+ d1 = d1 + 1
+
+ CASE CHR$(0) + "P"
+ d2 = d2 + 1
+
+ CASE CHR$(0) + "H"
+ d2 = d2 - 1
+
+ CASE "w"
+ d3 = d3 - 1
+
+ CASE "z"
+ d3 = d3 + 1
+
+ CASE "-"
+ speed = speed - 1
+
+ CASE "+"
+ speed = speed + 1
+
+ CASE " "
+ d1 = 0
+ d2 = 0
+ d3 = 0
+ speed = 0
+
+ CASE CHR$(27)
+ SYSTEM
+
+ END SELECT
+ k$ = ""
+ END IF
+LOOP
+END SUB
+
+SUB setgus
+REM Updating tank position
+gusxp = gusxp + ssu
+smes = smes + ssu
+IF smes > 15 THEN smes = 1
+IF smes < 1 THEN smes = 15
+b = smes
+
+FOR a = gusalgp TO gusalgp + 48 STEP 2
+ x(a) = gusx(b) - gusxp
+ y(a) = gusy(b)
+ cz(a) = 50
+ x(a + 1) = gusx(b) - gusxp
+ y(a + 1) = gusy(b)
+ cz(a + 1) = 30
+ b = b + 15
+NEXT a
+
+b = smes
+FOR a = gusalgp + 48 TO gusalgp + 94 STEP 2
+ x(a) = gusx(b) - gusxp
+ y(a) = gusy(b)
+ cz(a) = -50
+ x(a + 1) = gusx(b) - gusxp
+ y(a + 1) = gusy(b)
+ cz(a + 1) = -30
+ b = b + 15
+NEXT a
+
+REM Moving the tank
+FOR a = 0 TO 84
+ x(a) = x(a) - ssu
+NEXT a
+
+IF x(84) > 0 THEN ssu = 1
+IF x(83) < -400 THEN ssu = -1
+
+END SUB
+
+SUB start
+REM Initializing the program
+SCREEN 12
+CLS
+speed = 0
+
+'deg1 = 270
+'deg2 = 0
+'deg3 = 90
+
+deg1 = 210
+deg2 = 20
+deg3 = 90
+
+smes = 1
+gusxp = 0
+
+myxp = 0
+myyp = 0
+myzp = 0
+myx = 0
+myy = -300
+myz = 100
+smes = 1
+
+ssu = 1
+
+calcsin
+
+getcor
+teemaad
+getgus
+
+END SUB
+
+SUB teemaad
+REM Adding new points and connected points
+silalgl = nl
+np = np + 0
+silalgp = 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
+np = np + 1
+GOTO 5
+
+3
+READ pointers1(nl), pointers2(nl)
+IF pointers1(nl) = 999 THEN GOTO 4
+pointers1(nl) = pointers1(nl) + silalgp
+pointers2(nl) = pointers2(nl) + silalgp
+nl = nl + 1
+GOTO 3
+4
+
+END SUB