' * * * * * * * * * * * * * * ' * LunarLander * ' * * ' * Written by Vince Long * ' * December 2003 * ' * * * * * * * * * * * * * * SCREEN 12 RANDOMIZE TIMER DIM a$(1000) 'GOTO MenuReentry GOTO Menu ' * * * * * * * * * * * * * * * * * * * * * * ' * Initialize System Variables and Settings ' * * * * * * * * * * * * * * * * * * * * * * Start: CLS RESTORE sx = 320: sy = 20 vthrust = -1 hthrust = 0 decay = 0 zone = 0 ast1x = 1: ast1y = 120 ast2x = 1: ast2y = 80 ast2Start = 0 GOSUB GetRandom GOSUB DrawShip GOSUB DrawPanel GOSUB DrawTerrain ' * * * * * * * * * * * * * * * * * * * * * * ' * Start Game Play Here ' * * * * * * * * * * * * * * * * * * * * * * DO IF ast1 = 1 THEN LINE (ast1x - 3, ast1y - 3)-(ast1x + 3, ast1y + 3), 0, BF P = INT(2 * RND(1) + 1) IF P = 2 THEN P = -1 ast1y = ast1y + P ast1x = ast1x + 6 IF ast1x > 320 THEN ast2Start = 1 IF POINT(ast1x, ast1y) <> 0 THEN GOTO Crash CIRCLE (ast1x, ast1y), 3, 8 PAINT (ast1x, ast1y), 8, 8 IF ast1x > 632 THEN LINE (ast1x - 3, ast1y - 3)-(ast1x + 3, ast1y + 3), 0, BF ast1 = 0 ast1x = 1 END IF ELSE ast1 = 1 END IF IF ast2Start = 1 THEN IF ast2 = 1 THEN LINE (ast2x - 3, ast2y - 3)-(ast2x + 3, ast2y + 3), 0, BF P = INT(2 * RND(1) + 1) IF P = 2 THEN P = -1 ast2y = ast2y + P ast2x = ast2x + 6 IF POINT(ast2x, ast2y) <> 0 THEN GOTO Crash CIRCLE (ast2x, ast2y), 3, 8 PAINT (ast2x, ast2y), 8, 8 IF ast2x > 632 THEN LINE (ast2x - 3, ast2y - 3)-(ast2x + 3, ast2y + 3), 0, BF ast2 = 0 ast2x = 1 END IF ELSE ast2 = 1 END IF END IF I$ = INKEY$ IF I$ <> "" THEN IF I$ = CHR$(0) + "H" THEN vthrust = vthrust - 1 IF I$ = CHR$(0) + "K" THEN hthrust = hthrust - 1 IF I$ = CHR$(0) + "M" THEN hthrust = hthrust + 1 IF I$ = CHR$(0) + "P" THEN vthrust = vthrust + 1 IF vthrust > 0 THEN vthrust = 0 IF vthrust < -8 THEN vthrust = -8 IF hthrust < -8 THEN hthrust = -8 IF hthrust > 8 THEN hthrust = 8 END IF t = TIMER DO LOOP WHILE TIMER < t + .2 IF fuel < 1 THEN vthrust = 0 hthrust = 0 END IF oldsx = sx: oldsy = sy sx = sx + hthrust decaydelay = decaydelay + 1 IF vthrust < 0 AND decay > 0 AND decaydelay > 5 THEN decaydelay = 0 decay = decay - 1 END IF IF vthrust = 0 THEN delay = delay + 1 IF vthrust = 0 AND delay > 5 THEN decay = decay + 1 IF decay > 8 THEN decay = 8 delay = 0 END IF IF vthrust = 0 THEN sy = sy + decay ELSEIF vthrust = -1 THEN sy = sy + decay ELSE sy = sy + vthrust + 1 + decay END IF IF fuel > 0 THEN fuel = fuel - ABS(hthrust) - ABS(vthrust) LOCATE 26, 11 PRINT " Horizontal Thrust: "; IF hthrust < 0 THEN PRINT "<= "; ABS(hthrust); " " IF hthrust > 0 THEN PRINT " "; ABS(hthrust); " =>" IF hthrust = 0 THEN PRINT " 0 " LOCATE 26, 41 PRINT " Vertical Thrust: "; IF vthrust < 0 THEN PRINT CHR$(24); " "; ABS(vthrust); " " IF vthrust > 0 THEN PRINT " "; ABS(vthrust); " "; CHR$(25) IF vthrust = 0 THEN PRINT " 0 " LOCATE 28, 11 PRINT " Rate of Descent: "; decay; " " LOCATE 28, 41 PRINT " Fuel = "; IF fuel > 99 AND fuel < 999 THEN PRINT " "; IF fuel > 9 AND fuel < 100 THEN PRINT " "; IF fuel < 10 THEN PRINT " "; PRINT fuel ' * * * * * * * * * * * * * * * * * * * * * * * * * '* Engage Automatic Crash Avoidance System (ACAS) * ' * * * * * * * * * * * * * * * * * * * * * * * * * IF ObstructDetect = 1 THEN ObstructCount = ObstructCount + 1 PLAY "T255L64O4CDEFGABO3CDEFGABO2CDEFGAB" IF ObstructCount MOD 2 = 0 THEN COLOR 14 ELSE COLOR 12 END IF LOCATE 29, 20 PRINT " Automatic Crash Avoidance System Engaged "; IF ObstructCount > 3 THEN ObstructCount = 0 ObstructDetect = 0 COLOR 8 LOCATE 29, 20 FOR CC = 1 TO 42: PRINT CHR$(219); : NEXT CC END IF fuel = fuel - 25 COLOR 15 END IF ' * * * * * * * * * * * * * * * * * * * * * * ' * Check for Obstruction ' * if true, engage ACAS ' * * * * * * * * * * * * * * * * * * * * * * IF decay < 3 AND POINT(sx - 6, sy + 12) = 6 THEN GOSUB BlockMove IF decay < 3 AND POINT(sx + 6, sy + 12) = 6 THEN GOSUB BlockMove GOSUB DrawShip ' * * * * * * * * * * * * * * * * * * * * * * ' * Check for Proper Landing ' * * * * * * * * * * * * * * * * * * * * * * IF POINT(sx + 6, sy + 13) = 14 AND POINT(sx + 6, sy + 13) = 14 AND decay < 3 AND ABS(hthrust) < 2 THEN vthrust = 0 hthrust = 0 GOSUB DrawShip COLOR 14 LOCATE 29, 10 PRINT " Landing Number "; zone; " successful."; IF zone < 6 THEN PRINT " Press any key to takeoff. "; COLOR 15 IF zone = 6 THEN GOTO Winner GOSUB DrawTerrain DO I$ = INKEY$ LOOP WHILE I$ = "" COLOR 8 LOCATE 29, 10 FOR CC = 1 TO 62: PRINT CHR$(219); : NEXT CC COLOR 15 hthrust = 0 vthrust = -2 END IF ' * * * * * * * * * * * * * * * * * * * * * * ' * Check for Landing in Wrong Zone ' * * * * * * * * * * * * * * * * * * * * * * IF POINT(sx + 6, sy + 13) = 14 AND POINT(sx + 6, sy + 13) = 5 AND decay < 3 AND ABS(hthrust) < 2 THEN vthrust = 0 hthrust = 0 GOSUB DrawShip COLOR 14 LOCATE 29, 16 PRINT " Wrong Landing Zone - Press any key to takeoff. "; COLOR 15 IF zone = 6 THEN GOTO Winner GOSUB DrawTerrain DO I$ = INKEY$ LOOP WHILE I$ = "" COLOR 8 LOCATE 29, 10 FOR CC = 1 TO 62: PRINT CHR$(219); : NEXT CC COLOR 15 hthrust = 0 vthrust = -2 END IF ' * * * * * * * * * * * * * * * * * * * * * * ' * Check for crashes ' * * * * * * * * * * * * * * * * * * * * * * IF POINT(sx + 6, sy + 13) = 14 AND POINT(sx + 6, sy + 13) = 14 AND decay > 2 THEN GOTO Crash END IF IF POINT(sx + 6, sy + 13) = 6 OR POINT(sx + 6, sy + 13) = 6 AND ABS(hthrust) > 2 THEN GOTO Crash END IF LOOP WHILE I$ <> CHR$(27) GOTO Menu DrawShip: LINE (oldsx - 6, oldsy - 9)-(oldsx + 6, oldsy + 12), 0, BF 'ConeHead LINE (sx - 4, sy - 4)-(sx + 4, sy - 4), 2 LINE (sx - 4, sy - 4)-(sx, sy - 8), 2 LINE (sx + 4, sy - 4)-(sx, sy - 8), 2 PAINT (sx, sy - 5), 2 'Body Stripes LINE (sx - 4, sy - 3)-(sx - 4, sy + 3), 1 LINE (sx - 3, sy - 3)-(sx - 3, sy + 3), 9 LINE (sx + 4, sy - 3)-(sx + 4, sy + 3), 1 LINE (sx + 3, sy - 3)-(sx + 3, sy + 3), 9 ' Main Body LINE (sx - 2, sy - 3)-(sx + 2, sy + 3), 3, BF ' Left Leg LINE (sx - 4, sy + 4)-(sx - 6, sy + 6), 10 LINE (sx - 6, sy + 7)-(sx - 6, sy + 12), 10 ' Right Leg LINE (sx + 4, sy + 4)-(sx + 6, sy + 6), 10 LINE (sx + 6, sy + 7)-(sx + 6, sy + 12), 10 ' DrawFire IF vthrust <> 0 OR hthrust <> 0 THEN LINE (sx - 3, sy + 4)-(sx, sy + 12), 14 LINE (sx + 3, sy + 4)-(sx, sy + 12), 14 LINE (sx - 2, sy + 4)-(sx, sy + 11), 12 LINE (sx + 2, sy + 4)-(sx, sy + 11), 12 LINE (sx - 2, sy + 4)-(sx + 2, sy + 4), 12 PAINT (sx, sy + 5), 12, 12 END IF RETURN DrawPanel: FOR y = 387 TO 389 LINE (1, y)-(640, y), 8 NEXT y LINE (1, 350)-(320, 380), 8 LINE (640, 350)-(320, 380), 8 LINE (1, 350)-(1, 387), 8 LINE (640, 350)-(640, 387), 8 PAINT (5, 375), 1, 8 LINE (20, 390)-(620, 470), 2, B PAINT (30, 410), 8, 2 LINE (1, 390)-(19, 470), 8, BF LINE (621, 390)-(640, 470), 8, BF RETURN ' * * * * * * * * * * * * * * * * ' * Draw the Terrain ' * * * * * * * * * * * * * * * * DrawTerrain: tx = 1: ty = 235 FOR I = 1 TO 6 LINE (tx, ty)-(x(I) - 1, y(I)), 6 LINE (x(I), y(I))-(x(I) + 18, y(I)), 6 tx = x(I) + 18: ty = y(I) NEXT I LINE (tx, ty)-(640, 235), 6 LINE (1, 235)-(1, 349), 6 LINE (1, 349)-(320, 379), 6 LINE (320, 379)-(640, 349), 6 LINE (640, 349)-(640, 235), 6 PAINT (320, 375), 6, 6 zone = zone + 1 FOR I = 1 TO 6 IF RZone(I) = zone THEN ZoneColor = 14 ELSE ZoneColor = 5 END IF LINE (x(I), y(I) - 1)-(x(I) + 18, y(I) - 1), ZoneColor LINE (x(I), y(I))-(x(I) + 18, y(I)), ZoneColor LINE (x(I), y(I) + 1)-(x(I) + 18, y(I) + 1), ZoneColor NEXT I RETURN ' * * * * * * * * * * * * * * * * ' * Crash Routine ' * * * * * * * * * * * * * * * * Crash: PLAY "T255L64MLO2BCADGEFEGDACBCADGEFEGDACB" FOR I = 1 TO 100 cx = INT((12 * RND(1) + 1) - 6) cy = INT((16 * RND(1) + 1) - 8) cKolor = INT(3 * RND(1) + 1) IF cKolor = 1 THEN cKolor = 14 ELSEIF cKolor = 2 THEN cKolor = 4 ELSE cKolor = 0 END IF PSET (cx + sx, cy + sy), cKolor NEXT I LINE (200, 100)-(440, 200), 14, B LINE (202, 102)-(438, 198), 9, B LINE (204, 104)-(436, 196), 11, B LINE (205, 105)-(435, 195), 0, BF LOCATE 8, 37 COLOR 12 PRINT " Mission " LOCATE 10, 36 PRINT " Fail! " LOCATE 12, 35 COLOR 14 PRINT " Press a Key " t = TIMER DO LOOP WHILE TIMER < t + 2 DO I$ = INKEY$ LOOP WHILE I$ = "" CLS GOTO MenuReentry RETURN BlockMove: sx = oldsx sy = oldsy - 1 GOSUB DrawShip vthrust = vthrust - 1 ObstructDetect = 1 RETURN ' * * * * * * * * * * * * * * * ' * Splash and Menu Screens ' * Start Here ' * * * * * * * * * * * * * * * Menu: CLS t = TIMER DO LOOP WHILE TIMER < t + 1 FOR I = 1 TO 3 IF I = 1 THEN sx = 160 IF I = 2 THEN sx = 480 IF I = 3 THEN sx = 320 FOR y = 480 TO 1 STEP -10 SOUND INT(RND * 1400) + 450, .1 sy = y vthrust = 1 GOSUB DrawShip oldsx = sx: oldsy = y t = TIMER DO LOOP WHILE TIMER < t + .05 NEXT y NEXT I LINE (oldsx - 6, oldsy - 9)-(oldsx + 6, oldsy + 12), 0, BF MenuReentry: CLS sx = 320 FOR y = 10 TO 50 SOUND INT(RND * 1400) + 450, .1 sy = y vthrust = 1 GOSUB DrawShip oldsx = sx: oldsy = y t = TIMER DO LOOP WHILE TIMER < t + .02 NEXT y LINE (200, 100)-(440, 200), 14, B LINE (202, 102)-(438, 198), 9, B LINE (204, 104)-(436, 196), 11, B LOCATE 8, 37 COLOR 12 PRINT "L U N A R" LOCATE 10, 36 PRINT "L A N D E R" LOCATE 12, 35 COLOR 14 PRINT "by Vince Long" FOR y = 51 TO 87 SOUND INT(RND * 1400) + 450, .1 sy = y vthrust = 1 GOSUB DrawShip oldsx = sx: oldsy = y t = TIMER DO LOOP WHILE TIMER < t + .02 NEXT y vthrust = 0 GOSUB DrawShip FOR I = 1 TO 10 'Art SOUND 1195 - 50 * I, .3 SOUND 1195 + 50 * I, .3 NEXT LOCATE 15, 35 COLOR 11 PRINT "System Menu" LOCATE 17, 28 COLOR 15 PRINT "1."; COLOR 3 PRINT " Operate the Lander" LOCATE 18, 28 COLOR 15 PRINT "2. "; COLOR 3 PRINT "Access the Operation Manual" LOCATE 19, 28 COLOR 15 PRINT "3. "; COLOR 3 PRINT "Exit the System" LOCATE 29, 1 PRINT "Beta 1.2"; GetSelection: LOCATE 21, 32 COLOR 11 PRINT "Make a Selection" DO I$ = INKEY$ LOOP WHILE I$ = "" PLAY "T255L64MLO4BAGFEDC 150 AND y(I) < 330 NEXT I ' ** Generate the Sequence ** FOR I = 1 TO 6: B(I) = 0: RZone(I) = 0: NEXT I FOR I = 1 TO 6 a = INT(6 * RND(1) + 1) IF B(a) = 0 THEN B(a) = 1 RZone(I) = a ELSE I = I - 1 END IF NEXT I RETURN ' * * * * * * * * * * * * * * * ' * Winner ' * * * * * * * * * * * * * * * Winner: LINE (180, 100)-(460, 300), 14, B LINE (182, 102)-(458, 298), 9, B LINE (184, 104)-(456, 296), 11, B LINE (185, 105)-(455, 295), 0, BF LOCATE 8, 37 COLOR 12 PRINT " Mission " LOCATE 10, 31 PRINT "Successful, "; rank$; "!" LOCATE 12, 35 IF rank$ = "Colonel" THEN COLOR 14 LOCATE 12, 31 PRINT "You have mastered the" LOCATE 13, 33 PRINT "The Lunar Lander" LOCATE 15, 30 COLOR 15 PRINT "Press any key to return" LOCATE 16, 33 PRINT "to the System Menu." DO I$ = INKEY$ LOOP WHILE I$ = "" GOTO MenuReentry ELSE COLOR 15 LOCATE 12, 27 PRINT "Press '1' to advance to the " LOCATE 13, 37 IF rank$ = "Lieutenant" THEN PRINT "Captain level" IF rank$ = "Captain" THEN PRINT "Colonel level" LOCATE 15, 27 PRINT "Press '2' to return" LOCATE 16, 37 PRINT "to the System Menu." DO I$ = INKEY$ LOOP WHILE I$ = "" IF rank$ = "Lieutenant" THEN rank$ = "Captain" fuel = 2000 GOTO Start ELSE rank$ = "Colonel" fuel = 1000 GOTO Start END IF GOTO Start END IF PRINT "Press" COLOR 14 PRINT " Press a Key " DO I$ = INKEY$ LOOP WHILE I$ = "" CLS GOTO MenuReentry ' * * * * * * * * * * * * * * * ' * Array data for X position ' * of landing zones ' * * * * * * * * * * * * * * * DATA 50,156,262,328,434,540 DATA "Lunar Lander - Operation Manual" DATA "" DATA "Section 1.0 - Overview" DATA "" DATA "In this simulation you will be flying our Model 45EY2 Lunar Lander in a " DATA "series of takeoffs and landings. You will control the craft by " DATA "adjusting its horizontal and vertical thrusters and complete your " DATA "assigned mission before exhausting the fuel supply. There are six " DATA "landing required to complete the mission. The sequence of landings is " DATA "determined randomly." DATA "" DATA "Section 2.0 - Controlling the Lander" DATA "" DATA "The Lander has horizontal thrusters that you will control with the " DATA "arrow keys on the keyboard. The left arrow key controls the right " DATA "thruster, moving the craft to the left. The right arrow controls the " DATA "left thruster and moves the craft to the right. You increase the " DATA "amount of thrust with each press of the key to a maximum thrust of 12 " DATA "units. To decrease the amount of thrust, press the opposite arrow key." DATA "" DATA "The vertical thruster works similarly to the horizontal thruster. " DATA "Every press of the up arrow increases your vertical thrust by one unit. " DATA "Pressing the down arrow decreases the thrust. A thrust of zero (0) " DATA "will allow gravity to pull the craft to the surface. A vertical thrust " DATA "of one (1) will cause the craft to float in equilibrium with the force " DATA "of gravity." DATA "" DATA "Section 3.0 - Landing the Lunar Lander" DATA "" DATA "The landing zone to which you are to guide the Lander will be " DATA "highlighted in yellow. Guide the craft above the zone and slowly " DATA "descend to its surface. In order to land successfully, your vertical " DATA "descent speed must be two (2) or less and your horizontal speed must be " DATA "one (1) or less. As soon as you have touched down, the Automated Touch" DATA "Down Shut Down System (ATDSDS) will engage, shutting down your" DATA "thrusters." DATA "" DATA "Once you have successfully touched down on the surface, takeoff again" DATA "and fly to the next landing zone, which will be highlighted in yellow." DATA "" DATA "You can land on one of the non-yellow landing zones but you will not" DATA "receive credit for this landing." DATA "" DATA "Section 4.0 - Obstructions and Crashes" DATA "" DATA "If your Lander hits the ground or a landing zone at a speed of two (2) " DATA "or less the Automated Crash Avoidance System (ACAS) will engage and " DATA "stabilize the craft, placing it in a vertical trajectory to clear " DATA "itself from the collision. Activation of this system will be indicated" DATA "on the control panel and an alarm will sound. A deduction of 25 fuel " DATA "units will occur whenever the ACAS is engaged." DATA "" DATA "Should the craft engage the ground at a speed above which the ACAS is " DATA "capable of handling, a crash will occur resulting in termination of the " DATA "mission." DATA "" DATA "Additionally, it will be necessary to avoid encounters with asteroids." DATA "There are many in your sector." DATA "" DATA "Section 5.0 - Fuel" DATA "" DATA "Prior to start of the mission your Lander is fuel with its maximun " DATA "capacity of fuel units. Operating thrusters deducts units from the " DATA "fuel stores as does engagement of the ACAS (see Section 4.0). When the " DATA "fuel stores are completed depleted the craft will revert to gravity " DATA "control." DATA "" DATA "* * * END OF MANUAL * * *"