Sinisterly
Hangman, the command line game.[C++] - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: C, C++, & Obj-C (https://sinister.ly/Forum-C-C-Obj-C)
+--- Thread: Hangman, the command line game.[C++] (/Thread-Hangman-the-command-line-game-C)

Pages: 1 2 3


RE: Gallows, the command line game.[C++] - Deque - 10-31-2013

The collection is actually done.
But I am willing to create a second one if we have enough games. Wink


RE: Gallows, the command line game.[C++] - Deque - 10-31-2013

The collection is actually done.
But I am willing to create a second one if we have enough games. Wink


RE: Gallows, the command line game.[C++] - Slarek - 10-31-2013

(10-31-2013, 07:57 PM)Deque Wrote: The collection is actually done.
But I am willing to create a second one if we have enough games. Wink

Yeah. I'm ready to contribute at least with this and i might make another game probably not in C/C++ unless it compulsory.


RE: Gallows, the command line game.[C++] - Slarek - 10-31-2013

(10-31-2013, 07:57 PM)Deque Wrote: The collection is actually done.
But I am willing to create a second one if we have enough games. Wink

Yeah. I'm ready to contribute at least with this and i might make another game probably not in C/C++ unless it compulsory.


RE: Gallows, the command line game.[C++] - Deque - 10-31-2013

You can submit your entry here: http://www.hackcommunity.com/Thread-Command-line-game-compilation-II


RE: Gallows, the command line game.[C++] - Deque - 10-31-2013

You can submit your entry here: http://www.hackcommunity.com/Thread-Command-line-game-compilation-II


RE: Hangman, the command line game.[C++] - Slarek - 11-03-2013

Code has been updated.
Graphics mode and menu added.


RE: Hangman, the command line game.[C++] - ArkPhaze - 11-03-2013

@Slarek - When drawing your hangman, be wary that '\' is the escape char. This line, you should have doubled those up, along with the other place where the arm is drawn:
Code:
"/( )\ |\n";

Into:
Code:
"/( )\\ |\n";

Other than that, you've got signed and unsigned comparisons going on:
Code:
int loc = word.find(letter);

When compared using the == operator with string::npos, which is an unsigned integral type. I'd just rewrite the definition of loc to be:
Code:
size_t loc = word.find(letter);

I got this though after playing once:
Code:
Good guess! Your word: paper It's correct! Unfortunately the word is: paper.

So where the output is supposed to be for winning the game, it appears to be executed code to output that I've lost as well.

The other bad thing though is that this is all within the main() function. C++ has classes and many other things available to it that could help break that down. There's not much to a hangman game, but perhaps some functions would help in this case. Smile


RE: Hangman, the command line game.[C++] - Slarek - 11-03-2013

@ArkPhaze
Thanks, this really helped. And I'll look into the matter.
I'm really not sure why i didn't make function, maybe I'll do it someday.
This is rather useless code snippet though