----------------------------------- we64 Sun Jan 25, 2004 3:36 pm Hangman Game ----------------------------------- %Text Select %By Tony Zhang setscreen ("graphics:1000;650") var x, y, nx, button, letter : int := 0 var colo : int := 9 var letters1 : array 1 .. 10 of string := init ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J") var letters2 : array 1 .. 10 of string := init ("K", "L", "M", "N", "O", "P", "Q", "R", "S", "T") var letters3 : array 1 .. 6 of string := init ("U", "V", "W", "X", "Y", "Z") var words : array 1 .. 15 of string := init ("computer", "speaker", "program", "video", "cat", "dog", "tiger", "driver", "soccer", "radio", "music", "science", "math", "basketball", "chess") var random, counter, right : int := 0 var word, choice, let : string := "" colourback (71) cls process won choice := "n" for w : 1 .. 100 Draw.Text ("YaY, You won!", maxx div 2 - 100, maxy div 2, Font.New ("serif:24:bold"), Rand.Int (1, 100)) delay (100) exit when choice not= "n" end for end won process lost choice := "n" for l : 1 .. 100 Draw.Text ("You Lost!", maxx div 2 - 50, maxy div 2 - 50, Font.New ("serif:24:bold"), Rand.Int (155, 200)) Draw.Text ("The word was:", maxx div 2 - 150, maxy div 2, Font.New ("serif:24:bold"), Rand.Int (155, 200)) Draw.Text (words (random), maxx div 2 + 60, maxy div 2, Font.New ("serif:24:bold"), Rand.Int (155, 200)) delay (100) exit when choice not= "n" end for end lost loop %Title Draw.Text ("Welcome to Tony's Hangman Game", maxx div 2 - 150, maxy - 20, Font.New ("serif:16:bold"), 40) %Question locate (3, 1) put "Please choose letters from the alphabets" %Hang drawfillbox (640, 170, 660, 410, 112) %post drawfillbox (660, 390, 760, 410, 112) drawfillbox (600, 160, 800, 180, 115) %ground drawfillbox (730, 390, 740, 358, 114) %wire drawarc (735, 345, 13, 13, 0, 360, 114) %Random Words and Dashes randint (random, 1, 15) var dash : array 1 .. length (words (random)) of string for a : 1 .. length (words (random)) dash (a) := "_" end for %Keyboard for a : 1 .. 10 %First Row drawbox (90 + nx, 250, 140 + nx, 300, black) drawfillbox (95 + nx, 255, 135 + nx, 295, grey) Draw.Text (letters1 (a), 105 + nx, 260, Font.New ("serif:22:bold"), 56) %Second Row drawbox (90 + nx, 200, 140 + nx, 250, black) drawfillbox (95 + nx, 205, 135 + nx, 245, grey) Draw.Text (letters2 (a), 105 + nx, 210, Font.New ("serif:22:bold"), 56) %Third Row if nx >= 100 and nx = 95 and x = 255 and y = 145 and x = 255 and y = 195 and x = 255 and y = 245 and x = 255 and y = 295 and x = 255 and y = 345 and x = 255 and y = 395 and x = 255 and y = 445 and x = 255 and y = 495 and x = 255 and y = 545 and x = 255 and y = 95 and x = 205 and y = 145 and x = 205 and y = 195 and x = 205 and y = 245 and x = 205 and y = 295 and x = 205 and y = 345 and x = 205 and y = 395 and x = 205 and y = 445 and x = 205 and y = 495 and x = 205 and y = 545 and x = 205 and y = 195 and x = 155 and y = 245 and x = 155 and y = 295 and x = 155 and y = 345 and x = 155 and y = 395 and x = 155 and y = 445 and x = 155 and y 95 end if end loop %Wrong Letter if index (words (random), let) = 0 then counter += 1 end if %Hangman face if counter = 1 then drawfilloval (735, 355, 15, 15, 89) elsif counter = 2 then drawfilloval (728, 357, 3, 3, black) % left eye elsif counter = 3 then drawfilloval (742, 357, 3, 3, black) %right eye elsif counter = 4 then drawarc (735, 345, 5, 5, 20, 160, black) %mouth %Hangman body elsif counter = 5 then drawline (735, 340, 735, 280, black) Draw.Text ("Help me please!", 795, 330, Font.New ("serif:16:bold"), 40) elsif counter = 6 then drawline (735, 310, 765, 340, black) %right arm Draw.Text ("Help me please!", 795, 330, Font.New ("serif:16:bold"), 71) Draw.Text ("Help me!", 795, 330, Font.New ("serif:16:bold"), 40) elsif counter = 7 then drawline (735, 310, 705, 340, black) %left arm elsif counter = 8 then drawline (735, 280, 765, 250, black) %right leg Draw.Text ("Help me!", 795, 330, Font.New ("serif:16:bold"), 71) Draw.Text ("Help! Help!", 795, 330, Font.New ("serif:16:bold"), 40) elsif counter = 9 then drawline (735, 280, 705, 250, black) %left leg end if %Right letter for a : 1 .. length (words (random)) if let = words (random) (a) then dash (a) := let end if end for locate (8, 15) for a : 1 .. length (words (random)) put dash (a) : 3, " " .. end for for a : 1 .. length (words (random)) right := right + index (dash (a), "_") end for %Exits exit when right = 0 right := 0 exit when counter = 9 end loop %Play again delay (1000) cls Draw.Text ("Would you like to play again?", maxx div 2 - 130, maxy - 100, Font.New ("serif:16:bold"), 56) drawbox (maxx div 2 - 100, maxy - 250, maxx div 2, maxy - 200, black) drawfillbox (maxx div 2 - 95, maxy - 245, maxx div 2 - 5, maxy - 205, grey) Draw.Text ("Yes", maxx div 2 - 75, maxy - 235, Font.New ("serif:24:bold"), black) drawbox (maxx div 2 + 100, maxy - 250, maxx div 2, maxy - 200, black) drawfillbox (maxx div 2 + 95, maxy - 245, maxx div 2 + 5, maxy - 205, grey) Draw.Text ("No", maxx div 2 + 30, maxy - 235, Font.New ("serif:24:bold"), black) %Choice if counter = 9 then fork lost loop if Mouse.ButtonMoved ("down") then var buttonnumber, buttonupdown : int Mouse.ButtonWait ("down", x, y, buttonnumber, buttonupdown) if x >= maxx div 2 - 95 and x = maxy - 245 and y = maxx div 2 - 95 and x = maxy - 245 and y