Classic Computer Magazine Archive ANTIC VOL. 7, NO. 5 / SEPTEMBER 1988

ST Resource
By MARVIN JENKINS

GEM Battleship

Ahoy there Captain GFA

GEM Battleship
I didn't think I was asking for too much, just to play against my ST in a GEM-based Battleship program with graphics representing the ships instead of squares. But I had no luck finding such a game so-thanks to GFA BASIC-I programmed GEM Battleship myself.

The main part of the program is the logic which launches the missiles. First it has the computer fire randomly until it hits one of your ships. Then it concentrates on sinking that particular ship. I tried to make the computer guess what was the size of the ship it hit, and whether the ship was positioned horizontally or vertically, just as a person would. After the ship is sunk, the computer starts firing randomly again until it sniffs out another ship. This continues until all of either your ships or the computer's ships are sunk.

I drew the ships with my favorite drawing program. It was easy to load the picture file containing the ships by using the Get and Put commands to display them on-screen, but the program would be dependent on the picture file. This wouldn't do, so I got around it by writing a utility program that reads the picture file, cuts out the ships using the Get command, then writes the data file to disk for each ship. After all the data files were created, I used the Merge option in GFA BASIC to merge them into my program. After this, the rest of the program was fairly easy

GEM Battleship works only in low resolution, so a color monitor is required. Antic Disk owners will find a standalone version (no GFA BASIC required) of the program, SHIPCOMB.PRG on Side B of this month's Antic Disk. See the disk's ST Help file for information about how to transfer the program to a 3 1/2 inch disk.

GETTING STARTED
Type in Listing 1, SHIPCOMB.BAS, and Save a copy before you Run it. When Run, GEM Battleship will prompt you to enter your name and press [RETURN]. Be patient for a moment while the program initializes.

When you see the menu, go to Option and click on Start. The grids are displayed and the pointer becomes a hand. Now you're ready to place your ships-in the left grid only, please. The right-hand grid is where the computer places its ships. Using the hand icon, place your ships horizontally by clicking the left mouse button or vertically by clicking the right mouse button. The ship length is checked from right to left and from top to bottom.

Your ships and their lengths are:

Destroyer     2 squares

U-boat 3 squares
Tanker 3 squares
Battleship 4 squares
Carrier 5 squares

The program won't let you put a ship in an area too small to hold it. The length of a ship is equal to the number of hits required to sink it. When you're done placng your ships, the hand icon changes back to the pointer icon. You're ready to do battle.

Move the pointer to the right-hand grid and click the left mouse button on a likely square. The computer will immediately fire at your target. Hits are represented by a red square on the computer's right-hand grid and a red dot on your left grid. Blue is a miss. Sunken ships are displayed at the bottom of each grid. The object is to sink all the computer's ships before it sinks yours. If the computer wins, it will display the locations of its remaining ships.

You can start a new game any time by clicking on Start. If you need help while playing, you can use the Help option.


Texan Marvin Jenkins is a student at ITT Technical Institute and has owned Atari computers since 1981.

Listing 1: SHIPCOMB.BAS Download

On Disk: SHIPCOMB.PRG Download