Meteor Storm (C64) by Sioban
A downloadable game
11th Edition of BASIC 10 Liner Contest (2022)
---------------------------------------------
Game title: Meteor Storm
8-bit computer: C64
Language: Commodore 64 BASIC V2
Category: PUR-80
Sub-category: ACTION (shoot 'em up)
Author: Sioban©2022
*** I agree the program can be immediately published.
╔════════════════════════╗ ║************************║ ║***** METEOR STORM *****║ ║************************║ ╚════════════════════════╝
Year 2332. Planet Vulcan B is threatened by a swarm of meteorites coming from the deep space. As the flag officer of Starfleet you are tasked with preventing meteorites from impacting your planet and thus saving it from destruction.
You have a super cannon at your disposal that you can orient in the different directions of arrival of the meteors. Once in position, you have only one shot per meteor. But be careful, as the level increases the number of meteors and their speed also increase so you should choose which one to shoot down first!
┌────────────────┐ │Running the game│ └────────────────┘
After some initialization, in few seconds you are ready to save your small planet from the swarm of meteors!
"R" key to move the cannon around the planet,
[spacebar] to launch the rocket.
Remember...you have only one life.
Good luck!
┌────────────────┐ │Code explanation│ └────────────────┘
Variable description
---------------------------------------------------------------
#name #description
A variable used to read DATA (increment value)
B() Number of possible positions for each direction of meteor
B$ string used to read DATA (memory locations)
C number of meteors on the screen (+1)
D increment for the movement of meteor
E() flag: start movement for each meteor
F variable for cannon position
G flag and position index for rocket
K variable for ASCII code of key pressed
L game level
L$ constant string "LEVEL:"
M() index of the position for each meteor
O$ constant string "GAME OVER"
P() starting direction for each meteor
Q(i,j) memory locations for meteor positions according to direction 'i' and index of position 'j'
R screen border color address
S score
S$ constant string "SCORE:"
V SID volume address
Z constant variable for ASCII code 32
FN P(x) return a random number between 0 and x
FN Y(x) return M(x),if M(x)>=0; 0,otherwise
>>>[line0]:
L=-1 initialize variable for level number
D=.1 initial increment for the meteor movement
R=53280 address for border color
V=54296 address for SID volume
READ B$ read DATA string of line 6
O$="GAME OVER" self-explanatory string
DIM Q(8,18) matrix of meteor positions: (direction, position)
POKER,0:POKER+1,0 set the border and background color to black
FORI=0TO7 cycle for the 8 directions
>>>[line1]:
Q(I,0)=VAL(MID$(B$,1+I*4,4)) first position for each direction is read directly from the B$ string
(4 characters)
READ A,B(I) read the increment of the position and the number of positions
for each direction
FORJ=1TOB(I):Q(I,J)=Q(I,J-1)+A:NEXTJ,I for each direction, it calculates all the screen memory locations
(by increment)and save them into the matrix Q.The calculation is made
from the outside towards the center of the screen
(memory location $05F3(#1523))
Z=32 assign to variable Z the ASCII code for <space>
>>>[line2]:
PRINT"{CLR}": POKE1523,160 clear the screen and place a "solid square" in the center of the screen
( note: {CLR}=[SHIFT]+[CLR/HOME] )
DEF FN P(X) = INT(RND(.)*X) define function: get a random number between 0 and X-1
DEF FN Y(X) = -(M(X)>=0)*M(X) define function: get M(X) if M(X)>=0, otherwise 0
G=0 initialize firing flag
L$ = "LEVEL: self-explanatory string
>>>[line3]:
POKE Q(P(C),FN Y(C)),Z delete character at position Q()
IF E(C)=0 THEN P(C)=FN P(8) choose a random direction for the c-th meteor (only the first time)
M(C) = FN P(4) - 4 index of the starting position for the c-th meteor (between -4 and -1)
E(C) = 1 enable the movement of the meteor
S$="{HOME}SCORE: string for display the score
( note: {HOME}=[CLR/HOME] )
>>>[line4]:
M(C)=M(C)+D increment the position of the c-th meteor
IF M(C)>=0 THEN POKE Q(P(C),M(C)),42 if the position of the meteor is in the visible area
then visualize it (42 is the ASCII character for '*')
IF M(C)>=B(P(C)) THEN PRINT SPC(255)O$:END if the meteor hits the planet...GAME OVER
(meteor position is greater than max allowed)
>>>[line5]:
POKE Q(F,G),Z delete the last rocket position
POKE Q(F, B(F)),90 display the cannon
K=0 initialize variable for get char
GET K$: IF K$ THEN K=ASC(K$) if character pressed,its ASCII code in K
IF K=Z AND G=0 THEN G=B(F) if [spacebar] pressed and it was not already firing,
get the direction of the cannon
>>>[line6]:
IF K=82 AND G=0 THEN POKE Q(F,B(F)),Z if "R" pressed and it was not already firing,
clear the last position of the cannon
F=-(F<7)*(F+1) if f<7 then f=f+1 otherwise f=0 (totally 8 positions)
DATA"10721083109415422015200319911504 data string for memory locations (each of 4 digits)
for the 8 starting corners
>>>[line7]:
IF G THEN G=G-1:POKE Q(F,G),46 if the cannon fired, move the rocket in new position
IF F=P(C) AND M(C)>=G THEN POKE Q(F,G),Z destroy meteor if there is a collision with rocket
G=0:E(C)=0:S=S+100 enable cannon again, reset meteor position, increment score
GOTO 9 jump to line 9
>>>[line8]:
PRINT S$ S TAB(Z) L$ INT(L+1) print score and level at the top of the screen
C=-(C<L)*(C+1) if C<L increase by one the number of meteors on the screen
GOTO 3 repeat the cycle
DATA 41,10,40,10,39,10,-1,18,-41,11,-40,11 pairs of values: the increment for each direction
and the total number of positions
>>>[line9]:
POKE R,2 border color red
FOR T=0 TO 8:POKE V,FN P(15):NEXT random volumes to get sound effect
D=D+.025 meteor movement faster
L=L+.1 increase game level
POKE R,0 border color again black
GOTO 8 jump to line 8
DATA -39,11,1,18 pairs of values: the increment for each direction
and the total number of positions
Status | Released |
Author | BASIC 10Liner |
Install instructions
┌────────────────┐ │Loading the game│ └────────────────┘
Recommended C64 Emulator: VICE
or any emulator that handles *.d64 files.
Start VICE emulator (with standard settings:speed, sound,etc.)
Mount the .d64 file using the 'attach disk image' > 'Drive 8' command from File menu.
Type LOAD"*",8 then press the [Return] key.
When finished loading, type RUN and press [Return].
Leave a comment
Log in with itch.io to leave a comment.