Hangman help
Author |
Message |
Archpain
|
Posted: Fri Jan 21, 2011 11:17 am Post subject: Hangman help |
|
|
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?
<Answer Here>i HAVE A PORBLEM WITH MAKING THE HANGMAN AT THE END SAY YOU LOSE OR WIN IF THEY GET THE WORD RIGHT OR WRONG I ALSO NEED HELP MOVING THE POSITIONS LIKE R IS IN POSITION IN 3.
Describe what you have tried to solve this problem
<Answer Here>ui HAVE TRIED TO COMMENT OUT MANY THINGS BUT THAT FAILED I ALSO TRIED TO ADD A COUNTER
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
<Add your code here>
setscreen ("graphics:1000;650")
% var font3 : int % for a font to place numbers on the grid
% font3 := Font.New ("Arial:8:bold")
% var num : string % to change the x or y (of loops) to a string which font needs
%
% % to make the vertical lines of the grid
% for x : 0 .. maxx by 25
% drawline (x, 0, x, maxy, 29)
% num := intstr (x) % changing x to a string
% Font.Draw (num, x - 6, 0, font3, red)
% end for
%
% % to make the horizontal lines of the grid
% for y : 0 .. maxy by 25
% drawline (0, y, maxx, y, 29)
% num := intstr (y) % changing y to a string
% Font.Draw (num, 0, y - 6, font3, red)
% end for
% Getto
drawline (750, 100, 950, 100, 7) % the down line
drawline (800, 100, 800, 400, 7) % the up line
drawline (800, 400, 875, 400, 7) % the across line
drawline (875, 400, 875, 325, 7) % the holding hangman line
% Hangman
% drawoval (875, 306, 20, 20, 7) % Face
% drawline (875, 288, 875, 200, 7) %Neck
% drawline (875, 200, 850, 125, 7) %leg1
% drawline (875, 200, 900, 125, 7) %leg2
% drawline (875, 250, 825, 300, 7) %Hand1
% drawline (875, 250, 925, 300, 7) %Hand2
var font1, font2 : int % for a font to place numbers on the grid
font1 := Font.New ("Arial:14:bold")
font2 := Font.New ("Arial:72:bold")
proc line (x : int)
Draw.ThickLine (x, 400, x + 20, 400, 3, 12)
end line
const NUM := 10
var countrys : array 1 .. NUM of string := init ("RUSSIA", "ENGLAND", "FRANCE", "JAPAN", "NORWAY", "LUXEMBERG", "GERMANY", "NORTH KOREA", "SWEDEN", "SINGAPORE")
var num : int %to hold the number of the array
randint (num, 1, NUM ) % to get a random number
% Font.Draw (countrys (num), 10, 485, font1, 2) % output for testing
% Font.Draw (countrys (num) + " has " + intstr (length (countrys (num))) + " letters in it.", 10, 460, font1, 2) %output for testing
for i : 1 .. length (countrys (num )) * 25 by 25 % to output the number of lines for the letters of the randomly selected countrys
line (30 + i )
end for
var letter : string (1) := ""
var position : array 1 .. 7 of int := init (0, 0, 0, 0, 0, 0, 0)
var count := 0
var wrong := 0
var alpha : array 1 .. 26 of string (1) := init ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
var a := 1 % to keep track of a
for x : 28 .. 725 by 27
Font.Draw (alpha (a ), x, 12, font1, 10)
a := a + 1
end for
var x, y, btnNumber, btnUpDown, buttons : int % for using Mouse.ButtonWait
var nx, ny : int % for drawing procedure
loop
ny := 0
Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
if y > 0 and y < 27 then
ny := 12
if x > 695 then
nx := 695
letter := "Z"
elsif x > 668 then
nx := 668
letter := "Y"
elsif x > 641 then
nx := 641
letter := "X"
elsif x > 614 then
nx := 614
letter := "W"
elsif x > 587 then
nx := 587
letter := "V"
elsif x > 560 then
nx := 560
letter := "U"
elsif x > 533 then
nx := 533
letter := "T"
elsif x > 506 then
nx := 506
letter := "S"
elsif x > 479 then
nx := 479
letter := "R"
elsif x > 452 then
nx := 452
letter := "Q"
elsif x > 425 then
nx := 425
letter := "P"
elsif x > 398 then
nx := 398
letter := "O"
elsif x > 371 then
nx := 371
letter := "N"
elsif x > 344 then
nx := 344
letter := "M"
elsif x > 317 then
nx := 317
letter := "L"
elsif x > 290 then
nx := 290
letter := "K"
elsif x > 263 then
nx := 263
letter := "J"
elsif x > 236 then
nx := 236
letter := "I"
elsif x > 209 then
nx := 209
letter := "H"
elsif x > 182 then
nx := 182
letter := "G"
elsif x > 155 then
nx := 155
letter := "F"
elsif x > 128 then
nx := 128
letter := "E"
elsif x > 101 then
nx := 101
letter := "D"
elsif x > 74 then
nx := 74
letter := "C"
elsif x > 47 then
nx := 47
letter := "B"
elsif x > 20 then
nx := 20
letter := "A"
end if
else
put "please click on a letter"
end if
loop
drawfillbox (nx, ny, nx + 25, ny + 20, 5) % draws x at point clicked
exit when Mouse.ButtonMoved ("up")
end loop
for i : 1 .. length (countrys (num ))
if countrys (num ) (i ) = letter then
count := count + 1
position (count ) := i
end if
end for
if count = 0 then
wrong := wrong + 1
end if
if wrong = 1 then
drawoval (875, 306, 20, 20, 7) % Face
elsif wrong = 2 then
drawline (875, 288, 875, 200, 7) %Neck
elsif wrong = 3 then
drawline (875, 200, 850, 125, 7) %leg1
elsif wrong = 4 then
drawline (875, 200, 900, 125, 7) %leg2
elsif wrong = 5 then
drawline (875, 250, 825, 300, 7) %Hand1
elsif wrong = 6 then
drawline (875, 250, 925, 300, 7) %Hand2
end if
if count > 0 then
% Font.Draw ("Yes, " + countrys (num) + " has " + letter + " in it", 10, 360, font1, 2) % output for testing
% Font.Draw ("The first " + letter + " is in position " + intstr (position (1)), 10, 335, font1, 2) % output for testing
else
% Font.Draw ("There is no " + letter + " in " + countrys (num), 10, 360, font1, 2) % output for testing
end if
if count > 1 then
% Font.Draw (countrys (num) + " has more than one " + letter + " in it", 10, 310, font1, 2) % output for testing
var fonty : int := 285
for i : 1 .. 7
if position (i ) > 0 then
Font.Draw (letter + " is in position " + intstr (position (i )), 10, fonty, font1, 2) % output for testing
fonty := fonty - 25
else
exit
end if
end for
end if
if count > 0 then % put the letter on the correct line
var fonty : int := 403 % a little above the lines that were drawn earlier
for i : 1 .. 7
if position (i ) > 0 then
Font.Draw (letter, position (i ) * 25 + 7, fonty, font1, 2) % the x matches how the lines were drawn above with some tweaking
else
exit
end if
end for
end if
Mouse.ButtonWait ("up", nx, ny, btnNumber, btnUpDown )
count := 0
for i : 1 .. 7
position (i ) := 0
end for
end loop
% % the next section is to draw a number of lines standing for a word
% proc line (x : int)
% Draw.ThickLine (x, 400, x + 20, 400, 3, 12)
% end line
% const NUM := 10
% var countrys : array 1 .. NUM of string := init ("RUSSIA", "ENGLAND", "FRANCE", "JAPAN", "NORWAY", "LUXEMBERG", "GERMANY", "NORTH KOREA", "SWEDEN", "SINGAPORE")
% var num : int %to hold the number of the array
% randint (num, 1, NUM) % to get a random number
% Font.Draw (countrys (num), 10, 485, font1, 2) % output for testing
% Font.Draw (countrys (num) + " has " + intstr (length (countrys (num))) + " letters in it.", 10, 460, font1, 2) %output for testing
% for i : 1 .. length (countrys (num)) * 25 by 25 % to output the number of lines for the letters of the randomly selected countrys
% line (30 + i)
% end for
% var position : array 1 .. 7 of int := init (0, 0, 0, 0, 0, 0, 0)
% var count := 0
% for i : 1 .. length (countrys (num))
% if countrys (num) (i) = "E" then
% count := count + 1
% position (count) := i
% end if
% end for
if count > 0 then
Font.Draw ("Yes, " + countrys (num ) + " has E in it", 10, 360, font1, 2) % output for testing
Font.Draw ("The first E is in position " + intstr (position (1)), 10, 335, font1, 2) % output for testing
end if
if count > 1 then
Font.Draw (countrys (num ) + " has more than one E in it", 10, 310, font1, 2) % output for testing
var fonty : int := 285
for i : 1 .. 7
if position (i ) > 0 then
Font.Draw ("E is in position " + intstr (position (i )), 10, fonty, font1, 2) % output for testing
fonty := fonty - 25
else
exit
end if
end for
end if
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Fri Jan 21, 2011 11:53 am Post subject: RE:Hangman help |
|
|
Oh please god let ChromeOS become superpopular. |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Fri Jan 21, 2011 12:09 pm Post subject: Re: Hangman help |
|
|
Archpain @ Fri Jan 21, 2011 11:17 am wrote: i HAVE TRIED TO COMMENT OUT MANY THINGS BUT THAT FAILED
What was the idea behind that?
P.S. http://www.bash.org/?835030
Quote:
<Khassaki> HI EVERYBODY!!!!!!!!!!
<Judge-Mental> try pressing the the Caps Lock key
<Khassaki> O THANKS!!! ITS SO MUCH EASIER TO WRITE NOW!!!!!!!
<Judge-Mental> fuck me
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
RandomLetters
|
Posted: Fri Jan 21, 2011 1:23 pm Post subject: Re: RE:Hangman help |
|
|
Insectoid @ Fri Jan 21, 2011 11:53 am wrote: Oh please god let ChromeOS become superpopular.
lol what?
On the other hand, he got everything else right.
Think of the win/loss conditions for actual hangman, and how to implement them.
If you got every letter in the word, you win
If you got too many wrong letters, you lose. |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Fri Jan 21, 2011 2:39 pm Post subject: Re: RE:Hangman help |
|
|
Insectoid @ Fri Jan 21, 2011 11:53 am wrote: Oh please god let ChromeOS become superpopular.
This is in reference to the Chrome laptop not having a caps lock key. |
|
|
|
|
![](images/spacer.gif) |
|
|