Archive for February, 2014

NOMAM Basic Ten-Liners 2014 Entry

Monday, February 24th, 2014

I’d like to introduce my entry, one evening work.

The game is known under  “Hanged Man” name.

The game is (well, was?) popular here in Poland among young children in schools, they play it on the lessons :D; It is usualy drawn on the paper sheet, two person game.

Rules:

One player (computer) writes down a space for letters (here – big dots), the other (you) tries to guess it letter by letter; every time the other person guesses wrong, the first draws another element to gallows and corpse; if she guesses right, the letter(s) is revealed. The game ends whenever the other person guesses the whole word, or the first finishes drawing gallows.

Words (in a number of 53) sucked from http://listofrandomwords.com/

Code review:Hanged

0

The first line will run only once; declarations of strings; change font generator to a half up (to get to semigraphics characters); Next the gallows data.

1

This is a begin of game loop. The first poke gives us space character :); next get random word from data and decode it.

2

Title, buffer reset and keyboard accidental key hit reset.

3

This is begin of the “fail” loop – we draw another element of gallows; and store the partially – guessed word.

4

When the all gallows are (is?) drawn (two dots in data in line 0) – you lost.

5

Wait for a key in a loop;  update the word with a letter just entered.

6

If we’ve guessed the whole word (no circles) – you win. If the word did not change, jump to the line which draws gallows, else next to

7

Next gallows element draw procedure.

8

Word draw procedure; iw w=0 returns immediately, else waits for 3 seconds.

9

This whole word draw procedure. Invoked at the end of game either you lost or win.

Tips’n Tricks:

  • I did not change the original font generator. The space “effect” is done by zeroing one of the colours (the orange one).
  • I have coded simultaneously under Atari800MacX using H6: device; I have edited source mainly in vim editor. That’s why lines are so long, the input buffer during “enter” command reaches 256 chars or so.
  • The game had 14 lines of code in original. I suspect it would be hard to shorten it to 8 or 9 lines  without code tricks.
  • The word coding is a simple “tr” command under unix. If words were nod encoded, it would be no fun :)
  • Words were taken from (as I wrote) http://listofrandomwords.com, I have discarded all of those I had not knew. So the meaningful (truly) went into the game.

Game ATR download :

Do not let me hang on!