[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
|
|
Problem DescriptionHangman #1 is the traditional game of Hangman. One player, the hangman chooses a word kept secret from the other player, the convict. The convict guesses letters in the unknown word - he gets to see each correct guess placed wherever it occurs in the secret word. Each incorrect guess adds another piece to the gallows and an effigy of the hanging convict. If he completes the word before the picture is complete, he goes free. Otherwise, the convict is the big loser. Background & TechniquesThis game provides the framework for a future version with computer play. Here we'll define the basic drawing strategy, an array of 9 TPiece objects defining the gallows and hanging man. A TList component is an ideal place to keep a list of objects - HangManList is a TList containing the parts of the drawing in the order that they should be drawn. Initially we get a "secret" word from the hangman - The passwordchar property is optionally used to hide the word from prying eyes as it is being entered - the same technique used in password dialogs. Then the "convict" makes letter guesses until he wins (completes the secret word) or loses (completes the drawing). The CheckALetter procedure takes the convict's guess and either fills in the correct letter or draws one more piece and then checks if the letter was a winning or losing move. A simple ShowMessage call displays winning or losing messages. Running/Exploring the Program
Suggestions for Further Explorations
Modified: May 15, 2018
|
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 2000-2018, Gary Darby All rights reserved. |