// I am new to C++ and can not seem to get the falling man to output to the screen. Any help would be greatly appreciated.
#include <iostream>
#include <windows.h>
using namespace std;
void DrawBar(char guess);
int main()
{
char solution[8]; //holds solution
char blank[8]; //holds "*"'s for unsolved letters
int counter = 0; //general-use counter
int right = 0; //1 = right guess, 0 = wrong guess.
char guess;
cout<<"Enter phrase 8 chars or less."<<endl;
cin.getline(solution, 8);
int puzzLength = strlen(solution); //finds lengtrh of puzzle, stores INT value to puzzlength
//convert puzzle to full uppercase
for (counter = 0; counter < puzzLength; counter++){
solution[counter] = toupper(solution[counter]);
}
//done converting
strcpy_s(blank, solution); //copy solution to the 'blank' array
for (counter = 0; counter < puzzLength; counter++) { //converts characters to _'s to represent blanks
if (isalnum(solution[counter])) blank[counter] = '_';
else blank[counter] = solution[counter];
} //closes for loop
while (strcmp(solution, blank)) { //play game until the 'blank' puzzle becomes the 'right' answer
cout<<endl<<"Solution phrase is: "<<solution<<"."<<endl;
cout<<"The current 'blank' puzzle is: "<<blank<<"."<<endl;
cout<<"Enter a guess."<<endl;
cin>>guess;
guess = toupper(guess);
//cbeck guess!
for (counter = 0; counter <= puzzLength; counter++) {
if (guess == solution[counter]) {
blank[counter] = guess; //fill in the puzzle with the letter
}
} //close loop, done checking guess
} //game is over.
cout<<"Winner!";
cin.get();
return 0;
}
//DrawBar(guess); //Draw the hanging bar at end of game
//They lost if they are here so tell them the answer.
//cout<<"The word was : "<<Words[Word]<<endl<<endl;
// This will Draw the hanging bar according to the state
void DrawBar(char guess)
{
if(guess==5)
{
cout<<endl<<endl
<<" +--------+ "<<endl
<<" | 0 "<<endl
<<" | /|\\ "<<endl
<<" | / \\ "<<endl
<<" | "<<endl
<<" | AAHHH!!! "<<endl
<<" ============"<<endl<<endl;
Sleep(500); // Message Sleep for 1 second
cout<<endl<<endl
<<" +--------+ "<<endl
<<" | "<<endl
<<" | 0 "<<endl
<<" | /|\\ "<<endl
<<" | / \\ "<<endl
<<" | AAHHH!!! "<<endl
<<" ============"<<endl<<endl;
Sleep(500); // Message Sleep for 1 second
cout<<endl<<endl
<<" +--------+ "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | 0 "<<endl
<<" | /|\\ "<<endl
<<" | AAHHH!!! "<<endl
<<" ============"<<endl<<endl;
Sleep(500); // Message Sleep for 1 second
cout<<endl<<endl
<<" +--------+ "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | 0 "<<endl
<<" | AAHHH!!! "<<endl
<<" ============"<<endl<<endl;
Sleep(500); // Message Sleep for 1 second
cout<<endl<<endl
<<" +--------+ "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | AAHHH!!! "<<endl
<<" ============"<<endl<<endl;
}
else if(guess==4)
{
cout<<endl<<endl
<<" +---------+ "<<endl
<<" | \\0 "<<endl
<<" | |\\ "<<endl
<<" | / \\ "<<endl
<<" | "<<endl
<<" | "<<endl
<<" ============="<<endl<<endl;
}
else if(guess==3)
{
cout<<endl<<endl
<<" +----------+ "<<endl
<<" | \\0/ "<<endl
<<" | | "<<endl
<<" | / \\ "<<endl
<<" | "<<endl
<<" | "<<endl
<<" ============="<<endl<<endl;
}
else if(guess==2)
{
cout<<endl<<endl
<<" +-----------+ "<<endl
<<" | 0_:__: "<<endl
<<" | \\ "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | "<<endl
<<" ============="<<endl<<endl;
}
else if(guess==1)
{
cout<<endl<<endl
<<" +-----------+ "<<endl
<<" | 0_:__: "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | "<<endl
<<" | "<<endl
<<" ============="<<endl<<endl;
}
}