Starship (C64) by Kevin Prosser
A downloadable game
Starship:
The Starship game is very much like the Lunar Lander game that was in the instruction manual for the C-64. The object is to safely land your Starship Lunar Lander on the moon. The space bar is your engine fire control and the cursors fire the left and right lateral thrusters. You must maneuver the lander to a safe landing site between the large boulders on the surface. Good luck and remember you have limited fuel.
Program listing (Spaces added for clarity, remove all spaces and abbreviate all commands to fit in 80 columns)
0 V=53248: FOR I=1 TO 14: READ X,Y: POKE V+X,Y: NEXT: FOR X=832 TO 1022: POKEX,0: NEXT: PRINT"{HOME}";
V is start of Sprite memory. The first FOR loop loads pairs of data into X,Y variables. The first value of the data pair is the memory location offset from V and the second is the data to be loaded into that memory location. Most of the data is sprite control register data but all the data needed except the sprite shape is loaded here.
The second for loop on this line is used to clear the sprite memory in case it is not already clear.
1 PRINT"{BLACK}X<....<<<<<<<<<.r....Rx@@B.Bxphxpxhxphphhhh@";: F=60: X=80: Y=X: data2,64,3,97,21
Print Starship and flame sprite data to screen in black font so it is not visible. Once this is printed to the screen, the screen memory will hold a series of bytes beginning at 1024 that define what the starship and flame will look like. The data, starting at 1024, will be:
Starship sprite data first:
24,60,126,126,126,126,60,60,60,60,60,60,60,60,60,126,255,255,255,255,24
24 is loaded by printing the character X to the screen,
60 is the < sign,
126 is the upper left square (TAB V on the VICE emulator),
255 is the left leaning double checker symbol which is the reverse video right leaning double check symbol. (On the VICE emulator this is made by printing the RVS ON, then TAB B, then RVS OFF). On the Vice RVS on is CTRL 9, RVS OFF is CTRL 0
Exhaust sprite data is the second half of the print line:
0,0,66,126,66, 24,16,8, 24,16,24, 8,24, 16,8,16,8,8,8,8,0,
16 is made with the P,
8 is the H,
0 is the @ symbol,
66 is the vertical line symbol (Shift B)
2 FOR I=0 TO 41: POKE 832+I*3,PEEK(1024+I): NEXT: PRINT".S": FOR T=0 TO 30: POKE 1984+T,98
This FOR loop copies the sprite data from screen to the sprite memory area.
The second FOR loop is the loop for printing the ground and obstacles. 1984 is the first character of the last line of screen memory and 98 is the screen code for a horizontal line representing the ground.
3 POKE 1944+T,32-70*(RND(0)<.5): NEXT: data3,-51208,13,-51207,14,32,,33,,39,1,40,8,23,,29
The pokes to 1944 are for the obstacles which are randomly selected. 32 is a space, 32+70 is a checkered box that represents the obstacles.
Note the double commas are short hand for ,0, which saves a character
4 PRINT"{WHITE}{HOME}FUEL:";INT(F);"{CURSER BACK}{SPACE}": POKEV,X: POKEV+1,Y: data0,16,,28,,27,,
This line moves cursor to top of screen and prints in white the fuel remaining and pokes the starship sprite X/Y location with the current X/Y
5 GETA$: I=-2*(A$="{CURSOR LEFT}")-3*(A$=”{CURSOR DOWN}”)-3*(A$="{CURSOR RIGHT}")-(A$="{SPACE}"): C=(PEEK(V+31)AND1)AND(Y>100):
This line gets the player’s input. Allowable inputs are left and right cursor and space bar for thrust. The space bar auto repeats so it can be held for continuous thrust. Either cursor down or cursor left counts as a cursor left. This feature is for actual commodore 64s that have left and right cursor on the same key. The down cursor works the same as left cursor so that the shift key is not needed.
C is collision detect between the starship sprite and background.
Z$ is a temp variable to hold the first half of the results string (landed!, Crashed, or nothing)
6 S=0.1*(I=2 AND H>-2)-0.1*(I=3 AND H<2): T=1*(I=1): F=F-ABS(S)+T: IF F<0 THEN F=0:T=0:S=0
S is the sideways acceleration (or thrust). Fuel available is reduced a small amount for side thrust. Horizontal velocity is limited to 2 in order to make game more playable.
T is vertical Thrust.
F is Fuel and is decreased if side or vertical thrust is used.
If fuel is zero, side acceleration is set to zero.
7 U=U+0.3+T: Y=Y+U: H=H+S: X=X+H: X=X+235*(X>255)-235*(X<20): D=(C AND(U+2*ABS(H)>2))
U is vertical velocity and it is always acted upon by lunar gravity (0.3) and any vertical thrust (T)
Y position is updated based on vertical position Y and vertical velocity.
H is horizontal velocity and it is affected only by side thrust (S).
X position is updated based on horizontal velocity (H) and wrapped around screen if too high or low
D is the “died” flag and is set true if a collision occurs (C is true) and if velocities are too high (U and H)
8 POKE V+2,X-16-(S<0)+(S>0): POKE V+3,Y-17*(T<0)-5*(S>0)-5*(S<0): D=D+(C AND(Y<222))
V+2 is the flame sprite horizontal position. This is normally hidden behind the starship sprite and is offset a bit in X because only one third of each sprite is used. The vertical position and horizontal position of the flame sprite is also offset to allow different portions of the sprite to peek out behind the starship to represent side thrust of vertical thrust.
The died flag D is further defined by a Y value <222 which means an obstacle was hit vice the ground
9 G$="LANDED!CRASHED ":T=15+7*(D>0)+14*(D=0 AND C=1): PRINT MID$(G$,T,7):IF C=0 GOTO 4
G$ is the results string. The remainder of this line determines which part of that string is printed to the screen. If all is well and game is still in play, spaces are printed, otherwise “CRASHED” or “LANDED!” are printed and the game exits.
If you would like to use a joystick instead of the keyboard, Line 5 can be changed as follows
5 J=28 AND PEEK(56321):I=-(J=12)-2*(J=24)-3*(J=20):C=(PEEK(V+31) AND 1) AND(Y>100)
Published | 8 days ago |
Status | Released |
Author | BASIC 10Liner |
Genre | Action |
Tags | 10liner, 8-Bit, basic, Commodore 64 |
Install instructions
To play:
LOAD”STARSHIP”,8 <RETURN>
RUN <RETURN>
Comments
Log in with itch.io to leave a comment.
Landed with 37 fuel! Hard but fun game!
Cool!