% Hangman Game
var area : array 0 .. 12 of string
var guessedword : string (12)
var letter : array 0 .. 7 of boolean
var letter1 : array 1 .. 7 of string (1)
var number, long : int
var word : array 1 .. 7 of string
var gfxwrong : int := 0
var letterchosen : boolean
var inwrd : array 1 .. 7 of string
put "Max letter's in a word is 10."
put "Use Lower Case. You have 7 Guesses"
delay (6000)
cls
put "Please enter 7 words."
put ""
for I : 1 .. 7
put "Please enter word ", I, ".", " :>" ..
get inwrd (I)
end for
cls
for I : 1 .. 7
put I, ".", inwrd (I)
end for
procedure outputhangman
put area (1), area (2), area (3), area (4),
area (5), area (6), area (7)
end outputhangman
procedure noose
drawline (350, 170, 350, 190, 4)
drawline (350, 190, 400, 190, 4)
drawline (400, 190, 400, 20, 4)
drawline (425, 20, 375, 20, 4)
end noose
procedure graphics
noose
% head
if gfxwrong = 1 then
drawarc (350, 150, 20, 20, 0, 360, 3)
end if
%neck
if gfxwrong = 2 then
drawarc (350, 150, 20, 20, 0, 360, 3)
drawline (350, 130, 350, 110, 3)
end if
%arm Right
if gfxwrong = 3 then
drawarc (350, 150, 20, 20, 0, 360, 3)
drawline (350, 130, 350, 110, 3)
drawline (350, 110, 360, 120, 3)
end if
%arm Left
if gfxwrong = 4 then
drawarc (350, 150, 20, 20, 0, 360, 3)
drawline (350, 130, 350, 110, 3)
drawline (350, 110, 360, 120, 3)
drawline (350, 110, 340, 120, 3)
end if
%chest
if gfxwrong = 5 then
drawarc (350, 150, 20, 20, 0, 360, 3)
drawline (350, 130, 350, 70, 3)
drawline (350, 110, 360, 120, 3)
drawline (350, 110, 340, 120, 3)
end if
%leg right
if gfxwrong = 6 then
drawarc (350, 150, 20, 20, 0, 360, 3)
drawline (350, 130, 350, 70, 3)
drawline (350, 110, 360, 120, 3)
drawline (350, 110, 340, 120, 3)
drawline (350, 70, 360, 60, 3)
end if
%leg left
if gfxwrong = 7 then
drawarc (350, 150, 20, 20, 0, 360, 3)
drawline (350, 130, 350, 70, 3)
drawline (350, 110, 360, 120, 3)
drawline (350, 110, 340, 120, 3)
drawline (350, 70, 360, 60, 3)
drawline (350, 70, 340, 60, 3)
end if
end graphics
procedure numbers
locate (6, 1)
put "There are ", long, " letters in the word."
end numbers
% initialization
word (1) := inwrd (1)
word (2) := inwrd (2)
word (3) := inwrd (3)
word (4) := inwrd (4)
word (5) := inwrd (5)
word (6) := inwrd (6)
word (7) := inwrd (7)
area (0) := " "
area (1) := " "
area (2) := " "
area (3) := " "
area (4) := " "
area (5) := " "
area (6) := " "
area (7) := " "
letter (0) := true
letter (1) := false
letter (2) := false
letter (3) := false
letter (4) := false
letter (5) := false
letter (6) := false
letterchosen := false
randomize
randint (number, 1, 7)
guessedword := word (number)
long := length (guessedword)
for times : 1 .. 7
letterchosen := false
cls
graphics
outputhangman
locate (2, 1)
for I : 1 .. long
put "_" ..
end for
locate (3, 1)
put "Enter a letter in lowercase. Do not press return."
put ""
numbers
locate (7, 1)
put "You have ", 8 - times, " guesses left."
getch (letter1 (times))
cls
for d : 1 .. long
if word (number) (d .. d) = letter1 (times) then
area (d) := letter1 (times)
letter (d) := true
letterchosen := true
cls
outputhangman
graphics
gfxwrong := gfxwrong + 0
end if
end for
if letterchosen = false then
locate (11, 1)
put "Sorry, wrong letter."
delay (500)
gfxwrong := gfxwrong + 1
graphics
end if
outputhangman
if letter (1) = true and letter (2) = true and letter (3) = true and
letter (4) = true and letter (5) = true and
letter (6) = true and letter (long) = true and letter (long - 1)
= true and letter (long - 2) = true and
letter (long - 3) = true and letter (long - 4) = true and
letter (long - 5) = true and letter (long - 6) = true then
exit
end if
graphics
end for
if letter (1) = true and letter (2) = true and letter (3) = true and
letter (4) = true and letter (5) = true and
letter (6) = true and letter (long) = true and letter (long - 1) =
true and letter (long - 2) = true and
letter (long - 3) = true and letter (long - 4) = true and
letter (long - 5) = true and letter (long - 6) = true then
cls
outputhangman
locate (12, 5)
put "Congratulations. You have won the game."
else
cls
put
"Sorry, you have run out of guesses. You lost the game. The word was, "
put word (number), "."
gfxwrong := 7
graphics
end if
% end of game
|