Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ThrowBack Friday: "TARGET"
#1
Another Blast from the past! A three dimensional "shooter" text based. Attempt to hit a target in 3d space. (circa. 1975)

Code: (Select All)
0 REM ********************************** TARGET **************************************
1 REM In this program, you are firing a weapon from a spaceship in 3-dimensional space.
2 REM Your ship, the Starship Enterprise, is located at the origin (0,0,0) of a set of
4 REM x,y,z coordinates. You will be told the approximate location of the target in
6 REM 3-dimensional rectangular coordinates, the approximate angular deviation from
8 REM the x and z axes in both radius and degrees, and the approximate distance to the
10 REM target. Given this information, you then proceed to shoot at the target.
12 REM A shot within 20 kilometers of the target destroys it. After each shot, you are
14 REM given information as to the position of the explosion of your shot and a somewhat
16 REM improved estimate of the location of the target. Fortunately, this is just
18 REM practice and the target doesn't shoot back. After you have attained proficiency,
20 REM you ought to be able to destroy a target in 3 or 4 shots. However, attaining
22 REM proficiency might take awhile!
23 REM *******************************************************************************

25 REM Original Program Author
27 REM H. David Crockett
29 REM Fort Worth, TX 76133

90 PI = _PI 'added to define PI to maintain program originality

100 R = 1: R1 = 57.296: RANDOMIZE TIMER
110 PRINT "You are the weapons officer on the star ship Enterprise"
120 PRINT "and this is a test to see how accurate a shot you"
130 PRINT "are in a Three-Dimensional range. You will be told"
140 PRINT "the radian offset for the X and Z axes, the location"
150 PRINT "of the target in three-dimensional rectangular coordinates,"
160 PRINT "the approximate number of degrees from the X and Z"
170 PRINT "axes, and the approximate distance to the target."
180 PRINT "You will then proceed to shoot at the target until it is "
190 PRINT "destroyed!": PRINT: PRINT "Good Luck!!": PRINT: PRINT
220 A = RND * 2 * PI: B = RND * 2 * PI: Q = INT(A * R1): W = INT(B * R1)
260 PRINT "Radians from X axis ="; A; "  From Z axis ="; B
270 PRINT "Approx degrees from X axis ="; Q; "    From Z axis ="; W
280 P = 100000 * RND + RND: X = SIN(B) * COS(A) * P: Y = SIN(B) * SIN(aa) * P: z = COS(B) + R '??? scan is damaged at end of line looks like R though
340 PRINT "Target sighted: Approx Coordinates X="; X; "  Y="; Y; "  Z="; z
345 R = R + 1: IF R > 5 THEN GOTO 390
350 ON R GOTO 355, 360, 365, 370, 375
355 P3 = INT(P * .05) * 20: GOTO 390
360 P3 = INT(P * .1) * 10: GOTO 390
365 P3 = INT(P * .5) * 2: GOTO 390
370 P3 = INT(P) * 20: GOTO 390
375 P3 = P
390 PRINT "    Estimated Distance="; P3
400 INPUT "Input angle deviation from X, Deviation from Z, Distance"; A1, B1, P2
410 prinit: IF P2 < 20 THEN PRINT "YOU BLEW YOURSELF UP!!!": GOTO 580
420 A1 = A1 / R1: B1 = B1 / R1: PRINT "Radians from X axis="; A1; "  From Z axis ="; B1
480 X1 = P2 * SIN(B1) * COS(A1): Y1 = P2 * SIN(B1) * sn(A1): Z1 = P2 * COS(B1)
510 D = ((X1 - X) ^ 2 + (Y1 - Y) ^ 2 + (Z1 - z) ^ 2) ^ (1 / 2)
520 IF D > 20 THEN GOTO 670
530 PRINT: PRINT " * * * HIT * * *    Target is NON-FUNCTIONAL": PRINT
550 PRINT "Distance of explosion from target was"; D; "Kilometers"
570 PRINT: PRINT "Mission Accomplished in"; R; " shots."
580 R = 0: FOR I = 1 TO 5: PRINT: NEXT I: PRINT "Next Target....": PRINT: GOTO 220
670 x2 = X1 - X: y2 = Y1 - Y: z2 = Z1 - z: IF x2 < 0 THEN 730
710 PRINT "Shot in front of target"; x2; " Kilometers.": GOTO 780
730 PRINT "Shot Behind target"; -x2; " Kilometers."
740 IF y2 < 0 THEN 770
750 PRINT "Shot to LEFT of target"; y2; " Kilometers.": GOTO 780
770 PRINT "Shot to RIGHT of target"; -y2; " Kilometers."
780 IF z2 > 0 THEN 810
790 PRINT "Shot Above target"; z2; " Kilometers.": GOTO 820
810 PRINT "Shot Below target"; -z2; " Kilometers."
820 PRINT "Approx position of Explosion:  X="; X1; "  Y="; Y1; "  Z="; Z1
830 PRINT "  Distance from target ="; D: PRINT: PRINT: PRINT: GOTO 345
999 END
Reply




Users browsing this thread: 1 Guest(s)