Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8733 turbocat 1
REM
2
    REM --- Tiny BASIC Interpreter and Compiler Project
3
    REM --- Lunar Lander Demonstration Game
4
    REM
5
    REM --- Released as Public Domain by Damian Gareth Walker 2019
6
    REM --- Created: 15-Aug-2019
7
    REM
8
 
9
    REM --- Variables:
10
    REM     A: altitude
11
    REM     B: fuel to burn this turn
12
    REM     F: fuel remaining
13
    REM     T: time elapsed
14
    REM     V: velocity this turn
15
    REM     W: velocity next turn
16
 
17
    REM --- Initialise the Program
18
    LET A=1000
19
    LET B=0
20
    LET F=150
21
    LET V=50
22
    LET T=0
23
 
24
    REM --- Main Loop
25
100 PRINT "Time:",T," Alt:",A," Velocity:",V," Fuel:",F," Thrust:",B
26
111 IF F>30 THEN PRINT "Thrust (0-30)?"
27
    IF F<31 THEN PRINT "Thrust (0-",F,")?"
28
    INPUT B
29
    IF B>=0 THEN IF B<=30 THEN IF B<=F THEN GOTO 120
30
    GOTO 111
31
120 LET W=V-B+5
32
    LET F=F-B
33
    LET A=A-(V+W)/2
34
    LET V=W
35
    LET T=T+1
36
    IF A>0 THEN GOTO 100
37
 
38
    REM --- End of Game
39
    IF V<5 THEN GOTO 140
40
    PRINT "You crashed!"
41
    GOTO 160
42
140 IF A<0 THEN GOTO 150
43
    PRINT "Perfect landing!"
44
    GOTO 160
45
150 PRINT "Touchdown."
46
160 IF A<0 THEN LET A=0
47
    PRINT "Time:",T," Alt:",A," Velocity:",V," Fuel:",F
48
    END