Your Mission: Save The Fleet

Just you and your Spectrum can defend the fleet against
a rain of bombs in Susan Kennedy's program.


Save the Fleet puts you in charge of a gunsight with which you must aim and
shoot down the bombs that are dropping on your fleet of ships. The four arrow
keys (5,6,7,8) control the gunsight movement with the F key being used for
the fire button.

The bombs will appear randomly across the screen and at varying heights, thus
increasing the uncertainty during the total attack of 50 bombs. Scores in the
game are accumulated by intercepting the bomb; with a higher score, the
higher up the screen the bomb is hit. If you are too slow and a bomb hits a
ship then you lose 50 points.

In order to maximise the speed of gunsight movement whilst maintaining bomb
movement and to overcome the problem of the Spectrum screen layout, a few
interesting techniques have been employed.

The program leaves the gunsight movement loop approximately every 400 msec
by testing for a difference of 20 in the least significant time frame byte
from the time of the last bomb movement. This is less accurate than using all
three time frame bytes, but much faster, and the occasional quick movement of
the bomb is not noticeable in the overall effect.

The time that could be taken to detect a hit on one of the ships would be
slow if one had to search an array of screen locations. This problem is
neatly overcome by giving the ships a unique character attribute (41) and as
such a hit can be detected by simply checking the attribute of the next bomb
position. Once a hit has been established there is no longer the need to save
time and a search can be made to find which ship was hit.

This game is fairly simple in concept and is aimed at showing that by giving
thought to time saving an arcade game can be written in BASIC. However,
providing the time available to moving the gunsight is maintained, many
improvements could be made such as:
* Slow down bomb movement but increase the number of simultaneous bombs.
* Introduce graphic lines of fire from the ships.
* Introduce random explosive flashes on the screen aimed at confusing the player.

I recommend that you first type in and run lines 10-50, which set up the
user-defined graphics. This will aid you when typing in the graphic lines in
the rest of the program. The graphics are: A bomb, B gunsight, CDE ship, FGH
submarine, I explosion.


How it works
  10-50    set up user-defined graphics
  60       initialise best score and score
  80-90    POKE system variable to force CAPS lock
 110-160   set up array S with ship character
 170-210   initialise variables, INK black, PAPER cyan
 220-240   draw sea - Note: PRINT 32 spaces
 245-300   draw the ships - Note: INK 1, PAPER 5, no BRIGHT and no FLASH,
           give display character attribute 41 uniquely to the ships
 310-360   update scores and initialise target sight X,Y at screen centre
 370       compute random bomb start position
 395-480   input arrow key presses and move sight accordingly, ensuring
           sight stays within screen boundary
 490       GOTO 1000 if F(ire) key pressed
 510       GOTO 2000 if time to move bomb
1000-1040  check for bomb hit and adjust score accordingly
2000-2030  move bomb, accounting for any PAPER change
2040-2160  is ship hit? ie. bomb coincident with location of attribute 41,
           then search for which ship and explode it; subtract 50 from score
2200-2220  if sea bottom reached explode bomb and return to produce new bomb
3000-3030  end of game questions
4000-4060  bomb explosion subroutine


Variables
SC    current score
BSC   best score
S(5)  array of ship locations
T     current system time
T2    system time at last bomb move
X,Y   target sight screen position
C     bomb left count
X2,Y2 bomb screen position
A$    input key pressed

--
from Home Computing Weekly, 12th July 1983
