Kaboomer by dagershman
A downloadable game
======================================================================
Ka-Boomer
2021 BASIC 10 Liner Submission
By David A. Gershman - @dagershman
======================================================================
Ka-Boomer is a game which pays homeage to the 'ol Atari 2600 game
"KaBoom!". The name variation, "Boomer", is proof this version was
written by an "older" person. :)
======================================================================
Submission Contents
======================================================================
kaboomer.txt : This info file.
kaboomer.d64 : Commodore d64 disk image for use with emulator.
kaboomer_sample_play.gif
: Animated .gif of a sample game load and play
typed_code_with_abbreviations.png
: Screenshot of the typed program showing 80chars/line
max. (Note: Line 1 has a typo of '[' instead of ':'
thanks to fat fingers on a Mac keyboard. The char
is inside a string so does not affect game play.
D64 image contains a corrected version of the
program.
======================================================================
Play Instructions
======================================================================
** Play Options **
Upon executing the program, the user is prompted for the "Time
Limit". This is the amount of seconds the user wishes to play. 30
seconds is a good value for first-time players.
The next prompt is the "Sparcity" of bombs ranging from .1 to .9. .1
is hardly any bombs and .9 is a bomb on virtually every line.
Once these values are entered, your "bucket" is put at the top of the
screen and play begins. Bombs start flowing up to your bucket which
you need to catch. Time does not start counting down until the screen
starts actually scrolling.
The object is to "catch" as many bombs as you can within the time
limit you provided.
** Bucket Movement **
The bucket can be moved by using numbers 1-6 with 1 being all the way
on the left and 6 being all the way on the right.
Alternatively, the user may use the joystick in port 2 to move the
bucket left or right.
The difference is the joystick moves the bucket in increments of 1
while the numbers put the bucket directly in a specific position.
Both methods may be used during game play.
** Game Completion **
After time is up, the screen clears except for the last line and you
are presented with the number of bombs you caught out of the total
number of bombs displayed. Finally, you are prompted to play again or
not.
======================================================================
Program Listing
======================================================================
0 a$=chr$(13):print"{clr}{white}"spc(15)"ka-boomer"a$a$"time limit(sec) :";:inputtl:print"spars"; 1 print"ity (.1-.9):";:inputf:p(0)=8:fori=1to6:p(i)=p(i-1)+24:next:y=56320:b=53248:z=0 2 fori=3072to3077:readx:pokei,x:next:fori=3078to3135:pokei,0:next:pokeb+39,1:poke2040,48 3 pokeb,p(1):pokeb+1,50:pokeb+21,1:j(4)=-1:j(8)=1:restore:print"{clr}{down}":pokeb+32,z:pokeb+33,z:g=0:i=1 4 j=(127-peek(y))and12:i=i+j(j):i=-(i>=1andi<=6)*i+-(i>6)*6+-(i<1):getn:ifntheni=n 5 pokeb,p(i):print"{white}{CBM-B}{red}";:x=int(rnd(ti)*18):ifpeek(214)<23thenti$="000000" 6 printspc(x+1);:if(rnd(0)<f)thenprint"{left}!";:s=s+1 7 printspc(17-x);:t=tl-int(ti/60):g=g-(peek(b+31)>0):print"{white}{RVSON}{CBM-B}{RVSOFF}{cyan} t:"t" pts:"g:ift>0then4 8 fori=1to22:print:nexti:print"{white}final score: "g"/"s:pokeb+21,0:print"play again [y/n]?"; 9 poke198,0:wait198,1:geta$:ifa$="y"thenclr:goto0:data127,255,254,255,0,255
======================================================================
Program Explanation
======================================================================
************
** Line 0 **
************
a$=chr$(13)
Typing this program in Linux and using VICE's /petcat/ tool allows
the use of certain terms, such as "{return}" to include carriage
returns in strings. However, when typing the program in the
emulator, there is no way to insert a carriage return in a string.
Instead I had to assign chr$(13) to a variable and then use the
variable in the string later.
print"{clr}{white}"spc(15)"ka-boomer"a$a$"time limit(sec) :";
Display the centered title and prompt the user for the time limit.
inputtl
Read in the time limit.
print"spars";
Maximizing character usage per line sometimes requires breaking up
strings into pieces on different lines. This is the first part of
the "Sparsity:..." prompt.
************
** Line 1 **
************
print"ity (.1-.9):";
Finish printing the "Sparsity..." prompt
inputf
Read in the sparsity factor.
p(0)=8
The p-array holds the bucket sprite's possible x-positions. I only
use positions 1-6 but initialize 0 to 8 in preparation of the next
'for' loop. In retrospect, I would need this if I initialize p(1)
and loop from 2 to 6 in the next part.
fori=1to6:p(i)=p(i-1)+24:next
Initialize the p-array to the bucket sprite's possible x-positions.
Later, I'll manipulate a variable which will be the index for the
array to position the bucket.
y=56320:b=53248:z=0
Prep for fewer chars later by setting some variables. 'y' is the
register for Joystick Port #2, 'b' is the start of the Spring VICII
addresses, and 'z' *was* used for screen/background colors. However,
I decided to keep both black and thus don't need 'z' either. :(
(Amazing what you find when you make this writeup at 11:30pm.)
************
** Line 2 **
************
fori=3072to3077:readx:pokei,x:next
Load first 6 bytes of sprite #0 to "draw" the bucket.
fori=3078to3135:pokei,0:next
Clear the rest of the sprite leaving just the bucket.
pokeb+39,1
Set sprite #0's color to white.
poke2040,48
Set sprite #0's pointer to the data.
************
** Line 3 **
************
pokeb,p(1)
Set sprite #0's x-coord to the left most position.
pokeb+1,50
Set sprite #0's y-coord.
pokeb+21,1
Turn on sprite #0.
j(4)=-1:j(8)=1
The joystick register will clear bit *values* 4 and 8 depending on
if pushed left or right, respectively. This sets the j-array
positions 4 and 8 to the increment adjustment values for the p-array
when setting the buckets new x-position.
restore
This line had space to reset the data in case the user will want to
play again on the same execution.
print"{clr}{down}"
Clear the screen in preparation for game play and move the cursor
down so the first bomb won't count as a collision (giving a point)
right away.
pokeb+32,z:pokeb+33,z
Set the border/background colors to black. Since I don't change
either during game play, this is why the 'z' variable is not needed
and I could have just hard coded 0 (or even period).
g=0
Initialize 'g' to 0 which will accumulate the number of bombs
"caught".
i=1
Initialize 'i' to 1 which will be used to index the p-array (the
bucket position 1-6).
************
** Line 4 **
************
j=(127-peek(y))and12
"peek(y)" is the current value of the Joystick #2 register.
Unfortunately, that registers is 127 by default (0111111) and
*clears* the bits when the joystick is moved in a direction. For
example, left would result in 0111011. Substracting from 127,
"flips the bits" to 1000100. ANDing with 12, masks out only the
bits for left and right movement. Thus 'j' is set to 4 if the
joystick is pressed left, or 8 if the joystick is pressed right. If
the joystick is not touched, the result in 0.
i=i+j(j)
Update the index for the p-array by the amount of the increment
pointed to by the Joystick movement. If 4 (left), j(4) is -1, so
the index variable 'i' is "moved left". If 8 (right), j(8) is 1, so
the index variable 'i' is "moved right". If the joystick is not
touched, 'j' will be 0 and j(0) is 0, so 'i' won't be changed.
i=-(i>=1andi<=6)*i+-(i>6)*6+-(i<1)
Adjusts the index variable, if necessary, to the p-array to ensure
its value stays between 1 and 6.
getn
Check to see if a number was pressed.
ifntheni=n
If so, then the index variable gets set to that. Thus, the keyboard
numbers get priority over the joystick, BUT does still allow either
methods for game play.
************
** Line 5 **
************
pokeb,p(i)
Once the appropriate x-position (index value) is determined, set
sprite #0's new position.
print"{white}{CBM-B}{red}";
Print the left border wall and set color for the bomb.
x=int(rnd(ti)*18)
Compute random position on the line for the bomb.
ifpeek(214)<23thenti$="000000"
Keep the clock at 0 until the screen is full of bombs and they start
to actually scroll.
************
** Line 6 **
************
printspc(x+1);
Space over to where the bomb MAY go. For now, print a space as if
the bomb WON'T be placed.
if(rnd(0)<f)thenprint"{left}!";
Get a random number between 0 and 1 and if it is less than the
factor the user requested, then move back 1 position and print the
bomb. Else, the bomb is skipped.
s=s+1
Remember, BASICv2 does *not* have an 'else'. So this portion is
only performed if the bomb was printed. So this variable, s, will
track the total number of bombs displayed so when the score is shown
at the end, we know how many total bombs were displayed.
************
** Line 7 **
************
printspc(17-x);
Finish printing the spaces of the line holding the (possible) bomb.
t=tl-int(ti/60)
Compute the remaining time of the game.
g=g-(peek(b+31)>0)
Increment player's score if the bucket sprite #0 collided with the
background (i.e. a bomb).
print"{white}{RVSON}{CBM-B}{RVSOFF}{cyan} t:"t" pts:"g
Display the right wall, time remaining, and current points.
ift>0then4
If there's still time in the game, go back and check the
joystick/keyboard again.
************
** Line 8 **
************
fori=1to22:print:nexti
Scroll the game up to clear the screen except the last line.
Another retrospect...don't need 'i' in "next i". :(
print"{white}final score: "g"/"s
Display the final score out of the total number of bombs.
pokeb+21,0
Turn off bucket sprite #0
print"play again [y/n]?";
Prompt the user if they want to play again.
************
** Line 9 **
************
poke198,0:wait198,1
Clear the keyboard buffer and wait for an answer to the "Play again"
question.
geta$:ifa$="y"thenclr:goto0
Get the answer and if 'y', then go play again. Final
retrospect..."clr" is left over from when I had a dim'd array at the
beginning. Without 'clr', I'd get a "redim" error when the user
wanted to play again. I ended up removing the dim'd array but
forgot to remove 'clr'. This line could have been shorter. :(
data127,255,254,255,0,255
Data for bucket sprite.
Status | Released |
Author | BASIC 10Liner |
Genre | Action |
Tags | 8-Bit, basic, basic10liner, Commodore 64 |
Install instructions
Emulator Usage/Loading/Execution
======================================================================
Kaboomer was developed on a Linux host using the VICE C64 Emulator
('x64' binary). To execute the program, it is presumed the
reader/user has knowledge of VICE and mounting of .d64 images.
To run the program, the reader/user must mount the provided .d64 file
using the VICE emulator running the "x64" binary.
After mounting the disk, issue the following commands:
load "*",8 <ENTER>
followed by
run <ENTER>
Leave a comment
Log in with itch.io to leave a comment.