%HANG THE MAN
var word : array 1 .. 12 of string := init ("photosynthesis", "dictionary", "language", "obstreperous", "zeitgeist", "ersatz", "dour", "serendipity", "sycophant", "lucre", "introspection",
"etymologically")
var chars, random, count, space : int := 0
var letter : string
colourback (91)
cls
%begging
locate (1, 1)
put "please enter a letter"
%base graphic
locate (5, 1)
drawbox (300, 200, 400, 210, 4)
drawbox (345, 210, 355, 320, 4)
drawbox (355, 318, 435, 310, 4)
%random words
randint (random, 1, 12)
var dash : array 1 .. length (word (random)) of string
for a : 1 .. length (word (random))
dash (a) := "_"
end for
%word
loop
locate (2, 5)
%draw dash
for a : 1 .. length (word (random))
put dash (a) : 3, " " ..
end for
%chech for letters
loop
locate (4, 1)
put "" : 10
locate (4, 1)
get letter
if length (letter) > 1 then
locate (20, 1)
put " "
end if
exit when length (letter) = 1
end loop
if index (word (random), letter) >= 0 then
locate (14, 5 + chars)
put letter
chars := chars + 2
end if
count := count + 1
%graphics
%head
if count > 1 then
drawline (432, 310, 432, 290, 7)
end if
if count > 2 then
Draw.Oval (432, 280, 10, 10, 1)
end if
if count > 3 then
drawoval (428, 282, 2, 2, 7)
end if
if count > 4 then
drawoval (436, 282, 2, 2, 7)
end if
if count > 5 then
drawline (430, 275, 434, 275, 7)
end if
%body parts
if count > 6 then
drawline (432, 270, 432, 240, 1)
end if
if count > 7 then
drawline (432, 240, 418, 220, 1)
end if
if count > 8 then
drawline (432, 240, 446, 220, 1)
end if
if count > 9 then
drawline (432, 255, 422, 265, 1)
end if
if count > 10 then
drawline (432, 255, 442, 265, 1)
end if
put letter
space := 3
for b : 1 .. length (word (random))
if letter = word (random) (b) then
dash (b) := letter
end if
end for
%win condition
%lose condition
if count = 12 then
cls
var font : int
font := Font.New ("serif:20")
Draw.Text ("YOU LOSE", maxx div 2 - 60, maxy div 2, font, red)
Font.Free (font)
put word (random)
exit when count = 12
end if
end loop
|