-
Notifications
You must be signed in to change notification settings - Fork 0
/
lander2018.bas
executable file
·85 lines (82 loc) · 1.91 KB
/
lander2018.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#if 0
c++ -pipe -xc++ -fpermissive -w -o "${0%.*}".exe "$0" && ./"${0%.*}.exe" ; exit $?
#endif
#include "ptsvubas.cc"
/*
original from:
http://ioccc.org/1990/LANDER.BAS
removed lines:
10 REM Lunar Lander
20 REM By Diomidis Spinellis
1000 REM Initialise
2000 REM Print values
3000 REM User input
4000 REM Detachment
4500 REM Delay
*/
BEGINBASIC(int,main,())
30 PRINT "You aboard the Lunar Lander about to leave the spacecraft.";
60 GOSUB 4000;
70 GOSUB 1000;
80 GOSUB 2000;
90 GOSUB 3000;
100 LET H = H - V;
110 LET V = ((V + G) * 10 - U * 2) / 10;
120 LET F = F - U;
130 IF H > 0 THEN 80;
135 LET H = 0;
140 GOSUB 2000;
150 IF V > 5 THEN 200;
160 PRINT "Congratulations! This was a very good landing.";
170 GOSUB 5000;
180 GOTO 10;
200 PRINT "You have crashed.";
210 GOTO 170;
1010 LET V = 70;
1020 LET F = 500;
1030 LET H = 1000;
1040 LET G = 2;
1050 RETURN;
2010 PRINT " Meter readings";
2015 PRINT " --------------";
2020 PRINT "Fuel (gal):";
2030 PRINT F;
2040 GOSUB 2100 + 100 * (H != 0);
2050 PRINT V;
2060 PRINT "Height (m):";
2070 PRINT H;
2080 RETURN;
2100 PRINT "Landing velocity (m/sec):";
2110 RETURN;
2200 PRINT "Velocity (m/sec):";
2210 RETURN;
3005 IF F == 0 THEN 3070;
3010 PRINT "How much fuel will you use?";
3020 INPUT U;
3025 IF U < 0 THEN 3090;
3030 IF U <= F THEN 3060;
3040 PRINT "Sorry, you have not got that much fuel!";
3050 GOTO 3010;
3060 RETURN;
3070 LET U = 0;
3080 RETURN;
3090 PRINT "No cheating please! Fuel must be >= 0.";
3100 GOTO 3010;
4005 PRINT "Ready for detachment";
4007 PRINT "-- COUNTDOWN --";
4010 FOR I = 1 TO 11;
4020 PRINT 11 - I;
4025 GOSUB 4500;
4030 NEXT I;
4035 PRINT "You have left the spacecraft.";
4037 PRINT "Try to land with velocity less than 5 m/sec.";
4040 RETURN;
4510 FOR J = 1 TO 500;
4520 NEXT J;
4530 RETURN;
5000 PRINT "Do you want to play again? (0 = no, 1 = yes)";
5010 INPUT Y;
5020 IF Y == 0 THEN 5040;
5030 RETURN;
5040 PRINT "Have a nice day.";
ENDBASIC