Lunar Lander Game for C1P\SBII

Post Reply
lowrybt1
Posts: 212
Joined: Sun Mar 08, 2015 3:42 pm
Location: New York State

Lunar Lander Game for C1P\SBII

Post by lowrybt1 »

Hi All,

I'm posting here the code for a single-user game I wrote for the C1P: Lunar Lander (in the spirit of the great Atari video-arcade game). This was probably the most efficient program I ever wrote (in BASIC). I can't find the .wav file which I have somewhere -- am still looking for it. Please give it a try and if you like please share with fellow C1P\SB users.

The instructions... Load. Type Run...

When the program starts, the player is looking at a moonscape with a lunar lander positioned at the top left corner of the screen. After a few seconds, the lander will begin moving horizontally at a constant speed and vertically downward as gravity causes the vehicle to accelerate. You have a 1000 units of fuel to get the lander on the surface, level and with minimal downward speed, at one of the locations where the surface is flat, some of which are denoted by a score multiplier indicative of difficulty level.

To control your descent, press 1, 2, or 3 to burn fuel and create thrust. 1 is low thrust. 3 is high thrust. (My memory is rusty; there might be a 4th thrust level trigged by the 4 key). Thrust is generated only for as long the respective numeric key is depressed. You can pivot the lander to vector thrust and change speed and direction horizontally and vertically in 90-degree increments. The + and – keys are used to pivot the vehicle. If the lander hits a surface feature outside of a landing zone or hits the surface too hard, the game resets. The goal is to touch down with zero horizontal speed and very low vertical speed.

If the player doesn’t want to land on the lunar surface that initially appears, then pilot the lander over the mountain top on the top-right corner of the screen moving left-to-right. That will bring the lander into a new landscape with different landing zones.

Enjoy!!

1 GOTO140
2 C(2)=161:GOSUB 138:GOSUB 59:GOTO65
3 FOR E=1TO7:POKE A(E),32:NEXT:RETURN
4 FOR J=2 TO LEN(D$):POKE D+J,ASC(MID$(D$,J,1)):NEXT:POKE D+J,32:RETURN
5 D$=STR$(Z1):D=54231:GOSUB 4
6 IF Y<=0 THEN Y=0:W=W+1:Z4=1:FOR A=1TO8:POKE 54100+A,32:NEXT
7 D$=STR$(Y):D=54218:GOSUB 4
8 D$=STR$(Z):D=54198:GOSUB 4
9 D$=STR$(ABS(V)):D=54134:GOSUB 4
10 D$=STR$(ABS(W)):D=54166:GOSUB 4
11 IFY<75ANDZB=0THEN FORJ=1TO8:POKE54100+J,ASC(MID$(D1$,J,1)):NEXT:ZB=1
12 Z6=20:Z7=18:IF W<0 THEN Z6=16
13 IF W=0 THEN Z6=25
14 IF V<0 THEN Z7=22
15 IF V=0 THEN Z7=25
16 POKE 54171,Z6:POKE 54139,Z7:RETURN
17 POKEA(3),U:U1=C(3):C(3)=U:FORE=1TOT:IF ABS(H)=32THEN W=W+H/32:GOTO19
18 V=V+H
19 Y=Y-M:GOSUB 6:NEXT:RETURN
20 DATA 191,200,201,45,45,192,195,198,125,125,193,199,202,45,45,194,196
21 DATA 197,125,125,33,66,35,97,130,68,31,62,95,29,60,126
22 DATA 32,90,2,165,175,141,0,223,172,0,223,169,0,108,8,0,108,6,0,0
23 DATA 54196,110,54195,97,54194,109,54166,58,54165,116,54164,114,54217
24 DATA 108,54216,101,54215,117,54214,102,54198,58,54197,117,54218
25 DATA 58,54231,58,54230,101,54229,114,54228,111,54227,99,54226,115
26 DATA 54134,58,54133,122,54132,114,54130,104,54131,111,54162,118
27 DATA 54163,101,53793,143,53971,136
28 DATA 53434,192,53435,135,53436,191,53437,197,53441,143,53466,189
29 DATA 53473,143,53497,201,53505,143,53529,139,53537,143,53561,202
30 DATA 53569,143,53592,189,53601,143,53623,201,53633,143,53655,139
31 DATA 53665,143,53683,193,53687,202,53689,115,53697,143,53714,143
32 DATA 53716,135,53717,135,53718,135,53721,117,53729,143,53746,189
33 DATA 53748,50,53749,120,53753,114,53761,143,53777,201,53785,102
34 DATA 53809,202,53817,97,53825,143,53839,196,53840,195,53849,99
35 DATA 53857,143,53870,192,53871,193,53873,128,53881,101,53889,143
36 DATA 53904,191,53906,200,53913,49,53921,143,53938,199,53953,143
37 DATA 53985,143,54003,136,54017,143,54035,136,54036,53,54037,120
38 DATA 54049,143,54063,192,54064,135,54065,135,54066,135,54081,143
39 DATA 54095,201,54113,143,54120,193,54127,202,54145,143,54151,189
40 DATA 54153,197,54154,198,54157,196,54158,195,54180,135,54181,135
41 DATA 54182,135,54187,135,54188,135,53574,143,53724,136,53836,136
42 DATA 53475,198,53469,202,53437,201,53406,196,53500
43 DATA 189,53513,193,53512,193,53511,190,53510,191,53509,195,53508,197
44 DATA 53564,225,53546,194,53545,128,53544,198,53543,196,53531,224
45 DATA 53637,221,53627,222,53626,220,53606,201,53595,195,53594,221
46 DATA 53702,143,53692,136,53670,198,53669,220,53659,199,53638,223
47 DATA 53788,136,53773,193,53772,193,53766,201,53756,136,53734,143
48 DATA 53830,143,53819,195,53818,196,53805,201,53804,136,53798,199
49 DATA 53858,194,53850,225,53841,222,53840,196,53839,193,53837,199
50 DATA 53894,143,53882,194,53873,199,53870,191,53868,136,53862,143
51 DATA 53941,204,53937,139,53932,194,53926,143,53914,194,53905,201
52 DATA 53965,53,53964,225,53959,193,53958,143,53946,136,53942,222
53 DATA 53992,191,53978,225,53974,199,53973,140,53969,202,53993
54 DATA 135,54007,135,54005,140,54000,143,53995,135,53994,135,54008
55 DATA 135,54064,143,54041,120,54040,50,54037,202,54032,143,54009,135
56 DATA 54100,135,54099,135,54098,135,54097,191,54069,136
57 DATA 54152,114,54151,117,54150,115,53966,120
58 DATA 54158,50,54156,101,54155,99,54154,97,54153,102,53900,136
59 FOR E=1 TO 52:READ J,K:IF E>26 THEN POKE J,K
60 NEXT
61 FOR E=1 TO 184:READ J,K:IF SN AND E>83 THEN POKE J,K
62 IF NOT-SN AND E<84 THEN POKE J,K:IF E=83 THEN 64
63 NEXT
64 RESTORE:RETURN
65 FOR E= 1 TO 51:READ A:IF E>32 THEN POKE 585+(E-32),A
66 NEXT:RESTORE
67 B=0:V=1:W=0:Z=0:X=0:ZB=0:IF N THEN 69
68 Z1=0:Y=1000
69 GOSUB 5
70 A(1)=53349:A(2)=53381:A(3)=53413:A(4)=53414:A(5)=53412:A(6)=53444
71 A(7)=53446:P=0:POKE A(1),C(1):POKE A(2),C(2)
72 FOR E=3 TO 7:READ C:C(E)=C:POKE A(E),C:NEXT:RESTORE:POKE 54117,32
73 FOR E=1 TO 10000:NEXT
74 O=USR(191):IF O>247 OR O<239 THEN 92
75 R=2:Q=-1:P=P+1:IF O=247 THEN P=P-2:GOTO 80
76 IF P-1=3 THEN P=0
77 IF P>2 OR P=0 THEN Q=1
78 E=P/2:IF E<>INT(E) THEN R=1
79 GOTO 83
80 IF P=-1 THEN P=3
81 IF P<2 THEN Q=1
82 E=P/2:IF E=INT(E) THEN R=1
83 J=P*5+1:Z=Z+1:FOR E=1 TO 20:READ C:IF E<J OR E>J+4 THEN 85
84 C(E-(J-3))=C
85 NEXT:S=1:IF R=2 THEN S=7
86 FOR E=1 TO 12:READ D:IF E<S THEN89
87 IF E>S+5 THEN 90
88 I=E-(S-2):B(I)=A(I)+D*Q
89 NEXT
90 B(1)=A(1):RESTORE:GOSUB 3:FOR E=1 TO 7:POKE B(E),C(E):A(E)=B(E):NEXT
91 Y=Y-2:GOSUB 6
92 T=USR(127):IF T>239 THEN 100
93 Z=Z+1:T=(T-127)/32:IF T=0 THEN T=1
94 IF T=3.5 THEN T=4
95 IF P/2=INT(P/2) THEN 98
96 H=-1:U=41:IF P=1 THEN H=1:U=40
97 M=4:GOSUB 17:GOTO 100
98 H=-32:U=31:IF P=2 THEN H=-H:U=29
99 Z2=1:M=6:GOSUB 17
100 X=X+1:IF X=4 THEN W=W+1:X=0:GOSUB 10
101 F=ABS(W)+ABS(V):IF F=0 THEN 120
102 Z3=0:G=32:IF W<0 THEN G=-G
103 FOR A=1 TO F:IF A>ABS(W) THEN G=V/ABS(V):Z3=1
104 IF A<=ABS(G) AND PEEK(A(6)+32)=135 THEN 128
105 E=PEEK(A(6)+G):K=PEEK(A(7)+G):L=PEEK(A(1)+G)
106 IF E<>C(5) AND E>46 OR L<>161 AND L>46 OR K>46 AND K<>C(4) THEN 124
107 IF Z3 THEN 111
108 M=PEEK(A(5)+G):N=PEEK(A(4)+G)
109 IF M<>C(3) AND M>46 OR N<>C(3) AND N>46 THEN 124
110 GOTO 112
111 J=PEEK(A(2)+G):IF J<>C(3) AND J<>226 AND J>46 THEN 124
112 GOSUB 3:FOR E=1 TO 7:A(E)=A(E)+G:POKE A(E),C(E):NEXT
113 IF B>0 THEN B=B-1:IF B=0 THEN 119
114 IF B>0 THEN 112
115 C=ABS(A(1)-53379)/32:D=ABS(A(1)-53403)/32
116 IF INT(C)<>C AND INT(D)<>D THEN 119
117 SN=SN+1:IF SN=2 THEN SN=0
118 GOSUB 138:GOSUB 59:GOSUB 5:B=9:GOTO 112
119 NEXT
120 IF C(3)=U THEN C(3)=U1:POKE A(3),C(3)
121 IF Z4 THEN 100
122 IF Z2 AND W<0 THEN W=1:X=0
123 Z2=0:GOSUB 10:GOTO 74
124 FOR E=1 TO 7:POKE A(E),42:NEXT:FOR E=1 TO 2000:NEXT:GOSUB 3:GOSUB 138
125 PRINT"Module Destroyed":PRINT"crater gap";ABS(W)+ABS(V)*.3;"mi."
126 FOR E= 1 TO 4000:NEXT:IF Y<>0 THEN E=1:GOSUB 138:GOSUB 59:GOTO 67
127 PRINT"Mission Cancelled":GOTO 137
128 GOSUB 138:Z8=50:IF W=2 THEN Z8=25
129 IF W>2 OR ABS(V)>1 THEN 124
130 ZA=2:IF PEEK(A(7)+2)=53 THEN ZA=5
131 IF A(7)>54063 THEN ZA=1
132 PRINT"Challenger has landed!!":PRINT"credits:";Z8*ZA
133 Z9=Z8*ZA/(Z+W+ABS(V))
134 PRINT"Lunar Aver:";INT(Z9)
135 Z1=Z8*ZA+Z1:FOR E=1 TO 4000:NEXT:IF Y>0 THEN E=1:GOSUB 138:GOSUB 59:GOTO 67
136 PRINT"Mission Complete"
137 FOR E=1 TO 2000:NEXT:END
138 J=PEEK(129):K=PEEK(130):POKE129,0:POKE130,212:D$=" ":FOR E=1 TO 7
139 D$=D$+D$+" ":NEXT:POKE 129,J:POKE 130,K:RETURN
140 FOR X=53248 TO 55295:POKE X,32:NEXT X:CLEAR
141 POKE 515,0:POKE 11,74:POKE 12,2:SN=0:D1$="Fuel low":C(1)=226:GOTO2
142 REM
C8PDF w. 48K, 2x 520 24K RAM boards and Glitchworks 64K board
OSI 567 Telephony board
Spare 8" drives
Klyball D-13
dave
Site Admin
Posts: 710
Joined: Tue Sep 09, 2008 5:24 am

Re: Lunar Lander Game for C1P\SBII

Post by dave »

Hi Tom,

Thanks for posting this! I hope to put this, and some other stuff, up on the site this weekend.

Dave
dave
Site Admin
Posts: 710
Joined: Tue Sep 09, 2008 5:24 am

Re: Lunar Lander Game for C1P\SBII

Post by dave »

Hi Tom,

Thanks for posting this! I hope to put this, and some other stuff, up on the site this weekend.

Dave
Post Reply