Im Magazin „8000 PLUS" wurde im Main 1989 der folgende Artikel abgedruckt.
(Im Juni 1989 erfolgte eine Korrektur)
Das bekannte Spiel Schiffe versenken als BASIC-Programm

BATTLESHIPS

by M A Owen
Remember when, if you managed to get the back of a school book boxed and the ships positioned without being flicked round the ear with chalk, you could have had a fine old game of battleships?
With the PCW version of this classic diversion your Armada consists of three vessels: one submarine, one boat and a cruiser. In the first section of the game you are asked to place your fleet on an eight by eight grid using the ENTER, PASTE and arrow keys. The screen then clears and two grids appear. The left one shows your positions while the right remains blank and represents the computer's board; it's choices remain hidden from you.
Battle is joined by the use of the cursor keys for navigation and the ENTER key to bomb. You can see where moves have been made, asterisks appear on the grids, while the sound of battle is signalled via the PCW's blood curdling bleep.
The game is simple in use but rather limited in some aspects. For example the ships are only represented by their initial letters, S, B and C. Also the computer will allow you to position one ship upon another. As it stands however, the program is no mean achievment.

The beginning of the fray after your ships are selected. Re-defining the characters would be good.
A good example of the use of DATA to cut down on tedious toing and froing within a program is given in line 110. You can see this in action when you are asked to place your ships. Instead of three lines asking for the respective names; Submarine, Cruiser and Boat, the single DATA line is used and read three times during the FOR......NEXT loop which also begins on line 110.
Another usage of DATA is made within the loop which begins on line 450 and ends with line 520. Here the numbers given are the codes returned by the ENTER, PASTE and cursor keys enabling the PCW to see where you are and allowing you to blatt the machine into submission.
If you wish to fiddle with the program, and why not, there is always the possibility of livening up the graphics. The Pac Man upgrade program in the March issue (30) shows how this can be done. You might like to add an exit routine; allow yourself to change your choice of position or slow the computer's response time down, all relatively simple alterations.
This section prepares the escape codes and sets up the user defined functions. Note the READ in line 70 refers to DATA in line 120.
The placing of your flotilla occurs here. Note the referral to the subroutine In line 360.
The begining of the fight. The computer also gets to place its ships.
The height of battle and the victor is declared.
The grid(s) are set up here. This section is often referred to by the program. Note the use of CHRS(134), CHR$(130) etc. which, when printed, give the grid graphics.
The asterisks and ships are placed here. If you type TRON before running the program you will see a great deal of line 450!
Checking for your key presses with the INKEY$ in line 550. The sighting arrows are also placed here. CHR$(12) is the horizontal arrow by the way.
This stops you from placing a ship of the grid or from bombing the same square twice.
[Korrigiertes BASIC-Listing]

Battleships Correction
(whoops! mode)

Last month's Battleships program was savaged by Gremlins (who normally stick with RAF). The following corrections apply to lines 620 and 630:
620 PRINT FN c$(26+gx,21-
   2*y);CHRS(154)+es$+CHR$(12);FN
   c$(26+gx+4*x,21);"^":GOTO 550
630 a$="":IF (x>(9-s(p,e)) AND f=1) OR (y>(9-
   s(p,e)) AND f=2) THEN a$="error":RETURN
Sorry about that.

HTML-Bearbeitung von Werner Cirsovius
Dezember 2014
© 8000 PLUS