Computer Science Canada Need Help With Hangman Menu |
Author: | puventhar [ Fri Dec 10, 2010 4:31 pm ] | ||
Post subject: | Need Help With Hangman Menu | ||
What is it you are trying to achieve? <Replace all the <> with your answers/code and remove the <>> What is the problem you are having? <The menu of my game is kinda messed up. I have to press the play game button two times to go to the game procedure and also the buttons still show up while the game is running and it puts the word true at the start of the program for some reason.> Describe what you have tried to solve this problem <Answer Here> Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <import GUI View.Set ("offscreenonly") setscreen ("graphics") var font : int font := Font.New ("serif:6") var stopanimation : boolean := false procedure game stopanimation := true cls GUI.Refresh Draw.FillBox (0, 0, 640, 400, white) var word:string var userinput:string var counter : int := 0 put"Enter a word or sentence:" get word:* put"Try to guess a letter of the word:" get userinput:* % put "Enter ten words:" % for i : 1 .. 5 % get word (i) % end for % put "Enter a letter:" .. % get userinput for i : 1 .. 5 for j : 1 .. length (word (i)) if (word (i)(j) = userinput) then counter := counter + 1 end if end for if counter >= 1 then put word(i) else Draw.Oval(200,200,20,20,10) end if counter:=0 end for View.Update end game procedure controls end controls procedure grid for x : 10 .. maxx by 10 for y : 10 .. maxy by 10 drawdot (x, y, black) end for end for for x : 10 .. maxx by 20 Draw.Text (intstr (x), x - 3, maxy - 6, font, black) end for for y : 20 .. maxy by 20 Draw.Text (intstr (y), maxx - 12, y - 3, font, black) end for end grid grid process game1 loop exit when stopanimation = true if stopanimation = false then for i : -30 .. 30 exit when stopanimation=true Draw.FillBox (0, 0, 640, 400, brightgreen) var xincrease : int := 0 var font2 : int font2 := Font.New ("bankgothic md bt:40") var width : int := Font.Width ("Hangman", font2) var height, ascent, descent, internalLeading : int Font.Sizes (font2, height, ascent, descent, internalLeading) Draw.Text ("Hangman", 190, 350, font2, black) Draw.Box (190, 330 + descent, 190 + width, 330 + height, brightblue) Font.Free (font2) Draw.ThickLine (10, 10, 150, 10, 10, black) Draw.ThickLine (80, 10, 80, 340, 10, black) Draw.ThickLine (80, 340, 200, 340, 10, black) Draw.ThickLine (80, 290, 140, 340, 10, black) Draw.ThickLine (202, 340, 202 + i, 260, 5, black) delay (20) GUI.Refresh View.Update end for for decreasing i : 30 .. -30 exit when stopanimation=true Draw.FillBox (0, 0, 640, 400, brightgreen) var xincrease : int := 0 var font2 : int font2 := Font.New ("bankgothic md bt:40") var width : int := Font.Width ("Hangman", font2) var height, ascent, descent, internalLeading : int Font.Sizes (font2, height, ascent, descent, internalLeading) Draw.Text ("Hangman", 190, 350, font2, black) Draw.Box (190, 330 + descent, 190 + width, 330 + height, brightblue) Font.Free (font2) Draw.ThickLine (10, 10, 150, 10, 10, black) Draw.ThickLine (80, 10, 80, 340, 10, black) Draw.ThickLine (80, 340, 200, 340, 10, black) Draw.ThickLine (80, 290, 140, 340, 10, black) Draw.ThickLine (202, 340, 202 + i, 260, 5, black) delay (20) GUI.Refresh View.Update end for end if put stopanimation end loop end game1 if stopanimation = false then fork game1 end if if stopanimation=false then var playg : int := GUI.CreateButtonFull (282, 270, 0, "Play Game", game, 0, '^D', true) var control : int := GUI.CreateButtonFull (287, 180, 0, "Controls", controls, 0, '^D', true) var quitBtn : int := GUI.CreateButton (297, 100, 0, "Quit", GUI.Quit) end if loop exit when GUI.ProcessEvent end loop >
Please specify what version of Turing you are using <4.1.1> |