Computer Science Canada need hangman turing game assistance |
Author: | sards8 [ Wed Jun 17, 2009 7:02 am ] |
Post subject: | need hangman turing game assistance |
By:Josh Cirone %variables for the program% var found := true var choice, letter : string var font1 : int var wrongLetter := 0 font1 := Font.New ("tahoma:20") cls loop %draws the hangmans head% drawfilloval (400, 240, 20, 20, black) %draws the body% Draw.ThickLine (400, 220, 400, 130, 5, black) %draws the left arm% Draw.ThickLine (400, 200, 350, 120, 5, black) %draws the right arm% Draw.ThickLine (400, 200, 450, 120, 5, black) %draws the right leg% Draw.ThickLine (400, 130, maxx div 3 * 2, 50, 5, black) %draws the left leg% Draw.ThickLine (400, 130, maxx div 5 * 3, 50, 5, black) put "Do you want to play hangman?" put "Yes" put "No" get choice if choice = "Yes" or choice = "YES" or choice = "yes" then cls %different catergories of the hangman% put "Choose a Category" put "1. Animals" put "2. Music" put "3. cars" put "Enter 1,2,3 then press 'Enter'" %enter a number and goes to the hangman game screen% get choice cls case choice of label "1" : cls %draws the answer lines$ put "Animals" Draw.Line (500, 100, 500, 280, black) Draw.Line (400, 280, 500, 280, black) Draw.Line (400, 260, 400, 280, black) Draw.Line (20, 100, 50, 100, black) Draw.Line (60, 100, 90, 100, black) Draw.Line (100, 100, 130, 100, black) Draw.Line (140, 100, 170, 100, black) Draw.Line (180, 100, 210, 100, black) %draws the answer lines$ label "2" : cls put "music" Draw.Line (500, 100, 500, 280, black) Draw.Line (400, 280, 500, 280, black) Draw.Line (400, 260, 400, 280, black) Draw.Line (20, 100, 50, 100, black) Draw.Line (60, 100, 90, 100, black) Draw.Line (100, 100, 130, 100, black) Draw.Line (140, 100, 170, 100, black) Draw.Line (180, 100, 210, 100, black) %draws the answer lines$ label "3" : cls put "cars" Draw.Line (500, 100, 500, 280, black) Draw.Line (400, 280, 500, 280, black) Draw.Line (400, 260, 400, 280, black) Draw.Line (20, 100, 50, 100, black) Draw.Line (60, 100, 90, 100, black) Draw.Line (100, 100, 130, 100, black) Draw.Line (140, 100, 170, 100, black) Draw.Line (180, 100, 210, 100, black) %if the person types no then it restarts the program if choice = "No" or choice = "NO" or choice = "no" then cls quit else cls %exits the choice if clicked yes% end if exit when choice = "Yes" or choice = "YES" or choice = "yes" end case end if loop locate (1, 1) put "Guess a letter" get letter for i : 1 .. 20 %draws the letters of the answer% if letter = "r" or letter = "R" then Font.Draw (letter, 20, 100, font1, 12) elsif letter = "h" or letter = "H" then Font.Draw (letter, 60, 100, font1, 12) elsif letter = "i" or letter = "I" then Font.Draw (letter, 100, 100, font1, 12) elsif letter = "n" or letter = "N" then Font.Draw (letter, 140, 100, font1, 12) elsif letter = "o" or letter = "O" then Font.Draw (letter, 180, 100, font1, 12) else %if letter is wrong draws the head% wrongLetter += 1 if wrongLetter = 1 then drawfilloval (400, 240, 20, 20, black) %if letter is wrong it draws the body elsif wrongLetter = 2 then Draw.ThickLine (400, 220, 400, 130, 5, black) % if letter is wrong it draws the arm elsif wrongLetter = 3 then Draw.ThickLine (400, 200, 450, 120, 5, black) %if letter is wrong it draws the arm elsif wrongLetter = 4 then Draw.ThickLine (400, 200, 350, 120, 5, black) % if letter is wrong it draws the leg elsif wrongLetter = 5 then Draw.ThickLine (400, 130, maxx div 3 * 2, 50, 5, black) % if letter is wrong it draws the leg elsif wrongLetter = 6 then Draw.ThickLine (400, 130, maxx div 5 * 3, 50, 5, black) end if locate (1, 1) put "Guess a letter" get letter for i1 : 1 .. 20 %draws the letters of the answer% if letter = "m" or letter = "M" then Font.Draw (letter, 20, 100, font1, 12) elsif letter = "e" or letter = "E" then Font.Draw (letter, 60, 100, font1, 12) elsif letter = "t" or letter = "T" then Font.Draw (letter, 100, 100, font1, 12) elsif letter = "a" or letter = "A" then Font.Draw (letter, 140, 100, font1, 12) elsif letter = "l" or letter = "L" then Font.Draw (letter, 180, 100, font1, 12) end if %if letter is wrong draws the head% wrongLetter += 1 if wrongLetter = 1 then drawfilloval (400, 240, 20, 20, black) %if letter is wrong it draws the body elsif wrongLetter = 2 then Draw.ThickLine (400, 220, 400, 130, 5, black) % if letter is wrong it draws the arm elsif wrongLetter = 3 then Draw.ThickLine (400, 200, 450, 120, 5, black) %if letter is wrong it draws the arm elsif wrongLetter = 4 then Draw.ThickLine (400, 200, 350, 120, 5, black) % if letter is wrong it draws the leg elsif wrongLetter = 5 then Draw.ThickLine (400, 130, maxx div 3 * 2, 50, 5, black) % if letter is wrong it draws the leg elsif wrongLetter = 6 then Draw.ThickLine (400, 130, maxx div 5 * 3, 50, 5, black) end if %end loop locate (1, 1) put "Guess a letter" get letter for i2 : 1 .. 20 %draws the letters of the answer% if letter = "l" or letter = "L" then Font.Draw (letter, 20, 100, font1, 12) elsif letter = "e" or letter = "E" then Font.Draw (letter, 60, 100, font1, 12) elsif letter = "x" or letter = "X" then Font.Draw (letter, 100, 100, font1, 12) elsif letter = "u" or letter = "U" then Font.Draw (letter, 140, 100, font1, 12) elsif letter = "s" or letter = "S" then Font.Draw (letter, 180, 100, font1, 12) end if %if letter is wrong draws the head% wrongLetter += 1 if wrongLetter = 1 then drawfilloval (400, 240, 20, 20, black) %if letter is wrong it draws the body elsif wrongLetter = 2 then Draw.ThickLine (400, 220, 400, 130, 5, black) % if letter is wrong it draws the arm elsif wrongLetter = 3 then Draw.ThickLine (400, 200, 450, 120, 5, black) %if letter is wrong it draws the arm elsif wrongLetter = 4 then Draw.ThickLine (400, 200, 350, 120, 5, black) % if letter is wrong it draws the leg elsif wrongLetter = 5 then Draw.ThickLine (400, 130, maxx div 3 * 2, 50, 5, black) % if letter is wrong it draws the leg elsif wrongLetter = 6 then Draw.ThickLine (400, 130, maxx div 5 * 3, 50, 5, black) end if end for end for end if end for end loop end loop if someone could help me with this when i enter the letters sometimes it doesnt show up and it fills in random letters i dont know what is wrong with it if someone could help that would be great |
Author: | Nai [ Thu Jun 18, 2009 3:09 pm ] |
Post subject: | RE:need hangman turing game assistance |
The way you have it, the user's choice doesn't matter. If the user picks animals the program is still going to be checking for "lexus" even though it should only be checking for "rhino". Try making a variable that changes with the user's choice and then only check for a word if the user has picked the category. |