1000 DIM PLOT$(42):BACK$=CHR$(24)
1010 PRINT CHR$(21)
1020 CLS:PRINT @(10,20),"Do you want instructions ?";
1030 LINE INPUT INS$
1040 IF ANS$ = "Q" THEN PRINT CHR$(21): RUN "MENU"
1050 IF INS$="NO" OR INS$="N" THEN GOSUB 2700:PRINT:GOTO 2430
1060 IF INS$<>"YES" AND INS$<>"Y" THEN GOTO 1020
1070 CLS
1080 GOSUB 2700
1090 PRINT @(9,13),"You are landing a spaceship on an unknown planet and have";
1100 PRINT @(10,13),"taken over manual control ";H;" feet above a good";
1110 PRINT @(11,13),"landing spot with a downward velocity of ";V;" ft/sec,";
1120 PRINT @(12,13),"and ";F;" units of fuel remaining.";
1130 PRINT @(18,13),
1140 GOSUB 2660
1150 PRINT @(2,13),"The following rules govern your spacecraft:";
1160 PRINT @(5,13),"  (1) After each second, the height, velocity, and";
1170 PRINT @(6,13)," remaining fuel will be printed, along with a";
1180 PRINT @(7,13)," plot of the spacecraft height above the";
1190 PRINT @(8,13)," planet's surface";
1200 PRINT @(10,13),"  (2) At the right side of the plot, the symbol ':'";
1210 PRINT @(11,13)," will be typed.  At this point, supply the";
1220 PRINT @(12,13)," number of units of fuel to be burned in";
1230 PRINT @(13,13)," the next second.  Each unit of fuel slows";
1240 PRINT @(14,13)," your descent by 1 ft/sec.";
1250 PRINT @(16,13)," The maximum thrust of your descent engine";
1260 PRINT @(17,13)," is 50 units of fuel/sec or 50 ft/sec/sec.";
1270 PRINT @(20,13),
1280 GOSUB 2660
1290 PRINT @(3,13),"  (4) When you make contact with the planet's surface,"
1300 PRINT @(4,13)," your descent engine will automatically cut";
1310 PRINT @(5,13)," off and you will be given a report of your";
1320 PRINT @(6,13)," landing speed and remaining fuel.";
1330 PRINT @(8,13),"  (5) If you run out of fuel, the ':' will no longer";
1340 PRINT @(9,13)," be typed out, and the report will automatically";
1350 PRINT @(10,13)," be given each second until you hit the surface";
1360 PRINT @(11,13)," of the planet.";
1365 PRINT @(13,16),STRING$(42,"-");
1370 PRINT @(14,16),"A velocity of 5 or less will win the game.";
1375 PRINT @(15,16),STRING$(42,"-");
1380 PRINT @(20,13),
1390 GOSUB 2660
1400 PRINT @(3,18),"List of variables and symbols used;";
1410 PRINT @(5,18)," T = Elapsed time (Sec):";
1420 PRINT @(6,18)," H = Height above the planet's surface (ft):";
1430 PRINT @(7,18)," V = Downward velocity (ft/sec):";
1440 PRINT @(8,18)," F = Remaining units of fuel:";
1450 PRINT @(9,18)," : = Units of fuel to be burned during the";
1460 PRINT @(10,18),"     next second  (Supplied by the user):";
1470 PRINT @(11,18)," ";CHR$(240);"   Represents your warship:";
1480 PRINT @(16,23),"The manuevers will now begin...";
1490 PRINT @(18,25),"G O O D   L U C K ! ! !";
1500 PRINT @(20,20),
1510 GOSUB 2660
1520 CLS
1530 IF INS$="YES" OR INS$="Y" THEN INS$="N" ELSE GOSUB 2700
1540 CLS
1550 PRINT "Time  Height  Vel.  Fuel";
1560 PRINT SPACE$(16);
1570 PRINT "Plot of height"
1580 GRAV=G
1590 TIME=0
1600 SHIP$= CHR$(240)
1610 SHIPALT=H
1620 SHIPVEL=V
1630 SHIPFUEL=F
1640 SHIPPLOT=41
1650 FOR I=2 TO 40
1660 PLOT$(I)=" "
1670 NEXT I
1680 PLOT$(1)="*"
1690 PLOT$(41)=SHIP$
1700 PLOT$(42)="*"
1710 INITALT=SHIPALT
1720 PRINT SPACE$(1);
1730 PRINT USING "##";TIME;:PRINT SPACE$(1);
1740 PRINT USING "#####.##";SHIPALT;:PRINT SPACE$(1);
1750 PRINT USING "####";INT(SHIPVEL);:PRINT SPACE$(1);
1760 IF SHIPFUEL = 0 THEN PRINT " No-fuel  ";
1770 IF SHIPFUEL > 0 THEN PRINT USING "#####";SHIPFUEL;:PRINT SPACE$(5);
1780 FOR I=1 TO 42
1790 PRINT PLOT$(I);
1800 NEXT I
1810 IF SHIPFUEL=0 THEN SOUND 1,0: PRINT:SHIPBURN=0:GOTO 1890
1820 PRINT ":";
1830 LINE INPUT SHIPBURN$
1840 IF SHIPBURN$ = "Q" THEN PRINT CHR$(21):RUN "MENU"
1850 SHIPBURN = VAL(SHIPBURN$)
1860 SHIPBURN=INT(SHIPBURN)
1870 IF SHIPBURN<0 OR SHIPBURN>50 THEN GOSUB 2500:GOTO 1830
1880 IF SHIPBURN>SHIPFUEL THEN SHIPBURN=SHIPFUEL
1890 ACC=GRAV-SHIPBURN
1900 VEL=ACC+SHIPVEL
1910 ALT=SHIPALT-SHIPVEL-.5*ACC
1920 IF ALT>0 THEN GOTO 2020
1930 IF ACC=0 THEN TIMEX=SHIPALT/SHIPVEL:GOTO 1990
1940 X=2*ACC*SHIPALT+SHIPVEL*SHIPVEL
1950 GOSUB 2580
1960 TIMEX=(SQRT-SHIPVEL)/ACC
1970 VEL=ACC*TIMEX+SHIPVEL
1980 IF VEL<0 THEN GOTO 2020
1990 IMPACT=1
2000 TIME=TIME+TIMEX
2010 GOTO 2050
2020 IMPACT=0
2030 SHIPALT=ALT
2040 TIME=TIME+1
2050 SHIPFUEL=SHIPFUEL-SHIPBURN
2060 SHIPVEL=VEL
2070 IF IMPACT=1 THEN GOTO 2160
2080 SHIPPLOT=INT(SHIPALT*39/INITALT+2.5)
2090 IF SHIPPLOT<=1 THEN SHIPPLOT=2
2100 IF SHIPPLOT<=41 THEN SHIP$=CHR$(240)ELSE SHIPPLOT=41:SHIP$=" "
2110 FOR I=2 TO 41
2120 PLOT$(I)=" "
2130 NEXT I
2140 PLOT$(SHIPPLOT)=SHIP$
2150 GOTO 1720
2160 VEL=INT(SHIPVEL)
2170 PRINT STRING$(79,CHR$(95))
2180 IF VEL=0 THEN PRINT "Perfect landing!":GOTO 2270
2190 IF VEL = 1 THEN PRINT "Good landing!!":GOTO 2270
2200 IF VEL<=2 THEN PRINT "Slightly bumpy landing.":GOTO 2270
2210 IF VEL<=4 THEN PRINT "Very bumpy landing.":GOTO 2270
2220 IF VEL<=5 THEN PRINT "Crunch!! -- You barely made it!":GOTO 2270
2230 IF VEL<=25 THEN PRINT "Appropriate condolences will be sent to your family.":GOTO 2270
2240 IF VEL<=50 THEN PRINT "Excessive impact velocity has destroyed the":PRINT "structural integrity of your ship... No air left!"
2250 IF VEL >50 THEN PRINT "That flash of light visible from the Earth"
2260 IF VEL >50 THEN PRINT "was your spacecraft vaporizing on impact..."
2270 PRINT STRING$(79,CHR$(95))
2280 PRINT "Final velocity; ";VEL;" ft/sec."
2290 PRINT "Fuel remaining; ";SHIPFUEL;" units."
2300 PRINT
2310 IF VEL<=5 THEN PRINT "Congratulations... The general sends his compliments." ELSE PRINT "You have been court martialed."
2320 PRINT : SOUND 7,0
2330 PRINT "Do you want to try again ?";
2340 LINE INPUT ANS$
2350 IF ANS$ = "Q" THEN PRINT CHR$(21): RUN "MENU"
2360 IF ANS$="NO" OR ANS$="N" THEN CLS:PRINT CHR$(21):RUN "MENU"
2370 IF ANS$<>"YES" AND ANS$<>"Y" THEN GOTO 2330
2380 PRINT "Same initial conditions ?";
2390 INPUT ANS$
2400 IF ANS$ = "Q" THEN PRINT CHR$(21):RUN "MENU"
2410 IF ANS$="YES" OR ANS$="Y" THEN:G=GSAV:H=HSAV:V=VSAV:F=FSAV:GOTO 1540
2420 IF ANS$<>"NO" AND ANS$<>"N" THEN GOTO 2380
2430 PRINT "Do you wish to choose initial conditions ?";
2440 LINE INPUT ANS$
2450 IF ANS$ = "Q" THEN PRINT CHR$(21):RUN "MENU"
2460 IF ANS$="NO" OR ANS$="N" THEN GOTO 1520
2470 IF ANS$<>"YES" AND ANS$<>"Y" THEN GOTO 2430
2480 GOSUB 2750
2490 GOTO 1540
2500 FOR I=1 TO 10
2510 PRINT BACK$;
2520 NEXT I
2530 PRINT SPACE$(9);
2540 FOR I=1 TO 9
2550 PRINT BACK$;
2560 NEXT I
2570 RETURN
2580 IF X=0 THEN SQRT=0:RETURN
2590 IF X<1 THEN X1=2*X ELSE X1=X/2
2600 X2=.5*(X/X1+X1)
2610 D=X2-X1
2620 IF D<0 THEN D=-D
2630 IF D>.0001 THEN X1=X2:GOTO 2600
2640 SQRT=X2
2650 RETURN
2660 PRINT SPACE$(23); "Press <ENTER> to continue.";
2670 LINE INPUT Z$
2680 CLS
2690 RETURN
2700 G=.25*(20+RND(121))
2710 V=30+RND(31)
2720 H=V*(15+RND(6))
2730 GOSUB 2970
2740 RETURN
2750 PRINT "Gravitational acceleration constant (5-35): ";
2760 INPUT ANS$
2770 IF ANS$ = "Q" THEN PRINT CHR$(21): RUN "MENU"
2780 ANS = VAL(ANS$)
2790 IF ANS<5 OR ANS>35 THEN GOTO 2750
2800 G=ANS
2810 PRINT "Initial velocity (30-60): ";
2820 INPUT ANS$
2830 IF ANS$ = "Q" THEN PRINT CHR$(21):RUN "MENU"
2840 ANS = VAL(ANS$)
2850 IF ANS<30 OR ANS>60 THEN GOTO 2810
2860 V=ANS
2870 HT1=15*INT(V)
2880 HT2=20*INT(V)
2890 PRINT "Initial altitude (";HT1;"-";HT2;"): ";
2900 INPUT ANS$
2910 IF ANS$ = "Q" THEN PRINT CHR$(21): RUN "MENU"
2920 ANS = VAL(ANS$)
2930 IF ANS<HT1 OR ANS>HT2 THEN GOTO 2890
2940 H=ANS
2950 GOSUB 2970
2960 RETURN
2970 F=10*(1+INT(7*(2*H*G/V+V)/100))
2980 GSAV=G:HSAV=H:VSAV=V:FSAV=F:RETURN
2990 END
