Hey guys, I need your help on this one. I'm writing a text RPG game. Basically after creating your character you can either click 1 to play or click 2 to edit your character. If you click 1 its ok, the game plays well. However I can't make it return to the beginning of character creation if you click 2.
I think I should use return statement, but I can't make it work.
I would put the game in its own function and your character creation in its own function. Then in your if statement at the bottom, just call the appropriate function. I would use a switch statement instead of an if statement.
Hey again, when I try putting char creation screen into it's own function, it keeps saying that 175 char_create undeclared (first use this function). Here's the beginning of character create function:
1 2 3 4 5 6 7 8 9 10 11 12
case'P':
case'p':
int char_create()
cout << "Please type in your character's name:" << endl;
cout << "\n";
cin >> name;
Sleep (1000);
system("CLS");
break;
}
Here's the second part:
1 2 3 4 5 6 7 8 9 10 11
switch ( c )
{
case 2: char_create()
break;
default:
cout << "Invalid choice" << endl;
break;
}
You need to revisit function syntax. Study my posting above, then look at your latest post. In the first posting, you shouldn't have your char_create() function in the middle of a case statement. Also, you need an opening curly brace.
In the second post, when you call the char_create() function, you need a semicolon after the right parentheses. It's better to put actions on a line by itself, IMHO: