BATS

----

Here's a batty program for your 16K Spectrum from Colin Gooch of Ilminster.



In this program, you are a bat flying about trying to secure some moths for

your supper. Movement is made via the four "arrow" keys on the Spectrum, and

to make a catch you have to place the centre of the bat character directly

over the moth. Watch out though - the moth moves totally at random.



Because your bat cannot fly in bright light, the moth can escape you by

flying into the lighted window in the top left-hand corner of the screen. All

you have to do is trap the moth before it gets there! The game ends when you

have attempted to catch ten moths, although there is a bonus if you manage to

catch all ten.



Holy bat-catcher!



Initialisation of the graphics is done in lines 2230 and 2250. This leads

straight into the instruction page which is completed by lines 2300 to 3030.

This last section is not repeated when you play subsequent games after your

first.



The main program begins with line 50, which calls the subroutine to print the

screen display, followed by lines 90 to 120 which initialise the screen

co-ordinates for the bat and the moth. Lines 200 to 300 are a loop which

constantly moves the position of the moth, and if the right keys are pressed

this section of the program actually moves the bat.



The conditional statements for the moth make sure that it stays within the

screen area and also reverse its direction should it get too near to the

edge. The moth is moved 'dx' and 'dy' across and up the screen, but it is not

incremented on each pass of the loop. It is the RND value in lines 230 and

240 which look after this latter task, and it is this which gives the moth

its random movement.



The conditional statements for the bat read the keyboard, keep the bat on the

screen and also ensure that it will not move into the area of the window.

Line 320 detects a caught moth and moves on to the scoring section of the

program. Lines 330 to 350 detect the moth in the vicinity of the window, and

once there it is automatically drawn into the window, the moth's home score

is updated and a new moth appears down in the bottom right-hand are of the

screen.



Scoring is carried out from lines 370 and 520. This includes a "high score"

routine, and offers you a bonus "go" if you managed to catch ten moths out of

ten. This invitation comes courtesy of lines 530 to 580.



Flying tonight



The REM at line 20 indicates which lines need letters typed in the graphics

mode. Lines 250 and 260 use keyboard graphics and it is important that you

get four blanks at the end of each string.



Line 3400 looks the most complicated. However, if you decide that you don't

want to put a title or instructions in your listing, you could always rewrite

line 2400 to read:



2400 RETURN



and omit all from thereon.

