Files
lttb/examples/lander.bas
T

49 lines
1.1 KiB
QBasic
Raw Normal View History

2026-06-13 12:05:25 +03:00
REM
REM --- Tiny BASIC Interpreter and Compiler Project
REM --- Lunar Lander Demonstration Game
REM
REM --- Released as Public Domain by Damian Gareth Walker 2019
REM --- Created: 15-Aug-2019
REM
REM --- Variables:
REM A: altitude
REM B: fuel to burn this turn
REM F: fuel remaining
REM T: time elapsed
REM V: velocity this turn
REM W: velocity next turn
REM --- Initialise the Program
50 LET A=1000
51 LET B=0
52 LET F=150
53 LET V=50
54 LET T=0
REM --- Main Loop
100 PRINT "Time:",T," Alt:",A," Velocity:",V," Fuel:",F," Thrust:",B
111 IF F>30 THEN PRINT "Thrust (0-30)?"
112 IF F<31 THEN PRINT "Thrust (0-",F,")?"
113 INPUT B
114 IF B>=0 THEN IF B<=30 THEN IF B<=F THEN GOTO 120
115 GOTO 111
120 LET W=V-B+5
121 LET F=F-B
122 LET A=A-(V+W)/2
123 LET V=W
124 LET T=T+1
125 IF A>0 THEN GOTO 100
REM --- End of Game
126 IF V<5 THEN GOTO 140
127 PRINT "You crashed!"
130 GOTO 160
140 IF A<0 THEN GOTO 150
141 PRINT "Perfect landing!"
142 GOTO 160
150 PRINT "Touchdown."
160 IF A<0 THEN LET A=0
165 PRINT "Time:",T," Alt:",A," Velocity:",V," Fuel:",F
170 END