Classic Computer Magazine Archive ANTIC VOL. 5, NO. 7 / NOVEMBER 1986



Public domain classic meets mouse

At school, you probably played some version of Hangman during class-at least until the teacher caught you at it. Remember that game where you tried to guess words, one letter at a time, before your wrong guesses "hung" a stick-figure man? A thinly disguised version of Hangman is popular on television today-under the name "Wheel of Fortune."

Now you can play Hangman on your Atari 520ST. Type in Listing 1, HANGMAN.BAS, and SAVE a copy to disk before you RUN it.

NOTE: We recommend that you type in the program with a word processor (I use 1ST-Word) and then LOAD the resulting text file into ST BASIC. We have found this to be a lot easier than struggling with the bare-bones editor included with the current version of ST BASIC. For example, if you insist on using the ST BASIC editor for this particular listing, you will lose all of the indentations we included to help set off the loops.


When you RUN the program, it will first full and clear the output window, then place two rectangles and fill patterns on the screen. Titles are printed, scores and averages appear. Finally you see a series of dashes which represent the unknown word, and the alphabet is displayed at the bottom of the screen.

Using the mouse, click the letter of the alphabet that is your guess. The letter will turn red to show it has been selected. (Remember, we told you this listing works only on STs with color monitors.) The program checks for a match-up with any letters from the unknown word. If a match is found, the unknown word is updated on screen with the correctly guessed letter, and the loop continues.

If you're out of
guesses, you'll hear
12 boops. If you're
right, 12 happy dings
chime out.

If you run out of guesses, you'll hear 12 boops and the correct word will appear. The next word for guessing appears on the screen and the game continues. But if you manage to guess the correct word, 12 happy dings chime out, your score is increased, and the next word is displayed.


Lines 1000-1050 contain the title of the program. Lines 1060-1150 comprise the entire MAIN loop of the game, which first INITLALIZEs the game, then while not finished, it will gosub Hangman. Eventually you decide that the game will be finished by clicking the right-hand mouse button.

Lines 1170-1300 contain the loop for Hangman itself. INITLALIZE sets playing to TRUE so Hangman will start the first time through. The first call inside the loop is a gemsys() call to GRAFMKSTATE, which returns the position of the mouse and the state of the mouse buttons. The current mouse location gets put into PLACE and the mouse button state gets put into MOUSE. The following logic determines if the mouse is in a playable position-If INRANGE and GOODPRESS-and if so calls MAKEAGUESS.


Lines 1330-1460 consist of MAKEAGUESS, which determines if the letter pointed to and clicked on matches any of the letters in the unknown word. If so, CORRECT is called, otherwise BADGUESS is called and we start with the next letter. However, if all of the guesses are used up, we RESTART the program, and branch back to the top.

Lines 1640-1770 make up WORD-GET, which is the routine to select a new word to randomly pull out of WORDSDATUM, which starts at line 2450. Right now there are 182 words in the WORDSDATUM table. You can substitute your own words or put in a different amount of words. But if you do change the total number of words in the table, be sure to put the new number in place of number 183 in line 1650.


RESTART contains information needed to re-start another game. When the previous game is finished, it makes a call here to reset variables and re-draw the screen. INITLALIZE contains the information we need to start the game from power-up. Starting at line 2400 is BOXDATUM, which contains the rectangle coordinates.

Paul Pratt and Stephen Everman of Hayward, California have written an ST Mastermind-type game that will appear in a future issue. They are currently working on a "Star Trek" game for the ST Resource!

Listing HANGMAN.BAS Download

Yes, that s right, a Hangman game in ST BASIC. In coming months, ST Resource will be publishing other ST conversions of classic public domain software. What better way to demonstrate a wide variety of programming effects on the ST? We plan to publish only ST Classics that are enhanced to take advantage of the ST's outstanding graphics and friendly GEM interface For example we like the way this Hangman makes selections with the mouse pointer and is a nice, clean example of GEM programming standards. However, please note that the current program only works with color monitors-ANTIC ED