Skip Navigation LinksLunarLanderfromSmallBasicComputerGamesbyDavidAhl

Lunar LEM Rocket

 

This game in its many different versions and names (LUNAR, LEM, ROCKET) is by far and away the single most popular computer game. It exists in versions that start you anywhere from 500 feet to 200 miles above the moon or other planets, too. Some allow the control of directional stabilization rockets and/or the retro rocket.   

 

The three versions presented here represent the most popular of the many variations. In most versions of this game, the temptation is to slow up too soon and then have no fuel left for the lower part of the journey. This, of course, is disastrous (as you will find out when you land your own capsule)! 

 

LUNAR was originally written in FOCAL by Jim Storer while a student at Lexington High School and subsequently converted to BASIC by David Ahl.  It was then coverted to Microsoft Small Basic in 2010 by Philip Conrod. In this program, you set the burn rate of the retro rockets (pounds of fuel per second) every 10 seconds and attempt to achieve a soft landing on the moon. 200 Ib/sec really puts the brakes on, and 0 Ib/sec is free fall. Ignition occurs at 8 Ib/sec, so do not use burn rates between 1 and 7 Ib/sec. To make the landing more of a challenge and more closely approximate the real Apollo LEM capsule, you should make the available fuel at the start (N) equal to 16,000 Ib, and the weight of the capsule (M) equal to 32,500 Ib in these lines:

 

M=33000

N=16500

 

LEM was written by William Labaree of Alexandria, Virginia.  This is the most comprehensive of the three versions and permits you to control the time interval of firing, the thrust, and the attitude angle. It also allows you to work in the metric or English system of measurement. The instructions in the program dialog are very complete, so you shouldn't have any trouble.

 

ROCKET was written by Eric Peters at DEC.  In this version, you start 500 feet above the lunar surface and control the burn rate in 1-second bursts. Each unit of fuel slows your descent by 1 ft/sec. The maximum thrust of your engine is 30 f/sec/sec.

 

 

 

Code Listing (Small Basic File: lunar.sb):

 

TextWindow.CursorLeft = 33

TextWindow.WriteLine("LUNAR")

TextWindow.CursorLeft = 15

TextWindow.WriteLine("BIBLEBYTE BOOKS, MAPLE VALLEY, WASHINGTON")

TextWindow.WriteLine("")

TextWindow.WriteLine("")

TextWindow.WriteLine("")

TextWindow.WriteLine("THIS IS A COMPUTER SIMULATION OF AN APOLLO LUNAR")

TextWindow.WriteLine("LANDING CAPSULE.")

TextWindow.WriteLine("")

TextWindow.WriteLine("")

TextWindow.WriteLine("THE ON-BOARD COMPUTER HAS FAILED (IT WAS MADE BY")

TextWindow.WriteLine("XEROX) SO YOU HAVE TO LAND THE CAPSULE MANUALLY.")

LN70:

TextWindow.WriteLine("")

TextWindow.WriteLine("SET BURN RATE OF RETRO ROCKETS TO ANY VALUE BETWEEN")

TextWindow.WriteLine("0 (FREE FALL) AND 200 (MAXIMUM BURN) POUNDS PER SECOND.")

TextWindow.WriteLine("SET NEW BURN RATE EVERY 10 SECONDS.")

TextWindow.WriteLine("")

TextWindow.WriteLine("CAPSULE WEIGHT 32,500 LBS; FUEL WEIGHT 16,500 LBS.")

TextWindow.WriteLine("")

TextWindow.WriteLine("")

TextWindow.WriteLine("")

TextWindow.WriteLine("GOOD LUCK")

L=0

TextWindow.WriteLine("")

TextWindow.WriteLine("SEC    MI + FT     MPH      LB FUEL     BURN RATE")

TextWindow.WriteLine("")

A=120

V=1

M=33000

N=16500

G=.001

Z=1.8

LN150:

TextWindow.CursorLeft = 0

TextWindow.Write(math.Floor(L))

TextWindow.CursorLeft = 7

TextWindow.Write(Math.Floor(A))

TextWindow.CursorLeft = 12

TextWindow.Write(Math.Floor(5280*(A-Math.Floor(A))))

TextWindow.CursorLeft = 19

TextWindow.Write(Math.Floor(3600*V))

TextWindow.CursorLeft = 28

TextWindow.Write(math.Floor(M-N))

TextWindow.CursorLeft = 40

TextWindow.Write("? ")

K = TextWindow.ReadNumber()

T=10

LN160:

If M-N<0.001 Then

  Goto LN240

EndIf

If T<0.001 Then

  Goto LN150

EndIf

S=T

If M>=N+S*K Then

  Goto LN200

EndIf

S=(M-N)/K

LN200:

Sub420()

If I<=0 Then

  Goto LN340

EndIf

If V<=0 Then

  Goto LN230

EndIf

If J<0 Then

  Goto LN370

EndIf

LN230:

Sub330()

Goto LN160

LN240:

TextWindow.WriteLine("FUEL OUT AT "+Math.Floor(L)+" SECONDS")

S=(-V+Math.SquareRoot(V*V+2*A*G))/G

V=V+G*S

L=L+S

LN260:

W=3600*V

TextWindow.WriteLine("ON MOON AT "+math.Floor(L)+" SECONDS - IMPACT VELOCITY "+math.Floor(W)+" MPH")

If W<=1.2 Then

TextWindow.WriteLine("PERFECT LANDING!")

Goto LN440

EndIf

If W<=10 Then

TextWindow.WriteLine("GOOD LANDING (COULD BE BETTER)")

Goto LN440

EndIf

If W>60 Then

  Goto LN300

EndIf

TextWindow.WriteLine("CRAFT DAMAGE... YOU'RE STRANDED HERE UNTIL A RESCUE")

TextWindow.WriteLine("PARTY ARRIVES. HOPE YOU HAVE ENOUGH OXYGEN!")

Goto LN440

LN300:

TextWindow.WriteLine("SORRY THERE NERE NO SURVIVORS. YOU BLOW IT!")

TextWindow.WriteLine("IN FACT, YOU BLASTED A NEW LUNAR CRATER "+Math.Floor(W*.227)+" FEET DEEP!")

Goto LN440

Sub Sub330

L=L+S

T=T-S

M=M-S*K

A=I

V=J

EndSub

LN340:

If S<.005 Then

  Goto LN260

EndIf

D=V+Math.SquareRoot(V*V+2*A*(G-Z*K/M))

S=2*A/D

Sub420()

Sub330()

Goto LN340

LN370:

W=(1-M*G/(Z*K))/2

S=M*V/(Z*K*(W+Math.SquareRoot(W*W+V/Z)))+.05

Sub420()

If I<=0 Then

  Goto LN340

EndIf

sub330()

If J>0 Then

  Goto LN160

EndIf

If V>0 Then

  Goto LN370

EndIf

Goto LN160

Sub Sub420

Q=S*K/M

J=V+G*S+Z*(-Q-Q*Q/2-Q*Q*Q/3-Q*Q*Q*Q/4-Q*Q*Q*Q*Q/5)

I=A-G*S*S/2-V*S+Z*S*(Q/2+Q*Q/6+Q*Q*Q/12+Q*Q*Q*Q/20+Q*Q*Q*Q*Q/30)

EndSub

LN440:

TextWindow.WriteLine("")

TextWindow.WriteLine("")

TextWindow.WriteLine("")

TextWindow.WriteLine("TRY AGAIN?? ")

Goto LN70

 

 

 

CLICK ON THE ICON BELOW TO FIND MORE GAMES IN THE NEW "BASIC COMPUTER GAMES - SMALL BASIC EDITION"