Hey guys so Im writting a text-based game and I wanted to split up the program and wait for some user responses so everything isn't spat out to the user at once leaving them too much to read and potentially turning them away from the game. My issue is that the compiler seems to be skipping one of the cin.get()'s I have
void createPlayer(Player *p)
{
std::string myName;
std::string myClass;
std::cout << "Character Creation Screen:\n"
<< "---------------------------\n";
std::cout << "I apoligize adventurer, I have yet to get you name. What would you like to be called?\n";
std::cout << "I would like to be called sir.";
std::cin >> myName;
p->setID(myName);
std::cout << "\nAnd what are you most interested in becoming adventurer?\n"
<< "\n1. Warrior\n"
<< "- Warriors focus on close combat with brutal and strong abilities while weilding with high HP.\n"
<< "Str: 10\nDef: 10\nRange: 2\nInt: 0\nHP: 250\n\n";
std::cin.get();
std::cout << "2. Mage\n"
<< "- Mages focus on a medium range with agressive and powerful abilities while wielding low HP.\n"
<< "Str: 0\nDef: 3\nRange: 5\nInt: 10\nHP: 100\n\n";
std::cin.get(); // wait for some response
std::cout << "3. Ranger\n"
<< "- Rangers focus on long range with quick and illusive abilities while wielding medium HP.\n"
<< "Str: 5\nDef: 5\nRange: 10\nInt: 0\nHP: 150\n";
//std::cin >> myClass;
p = nullptr;
}
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Character Creation Screen:
I apologize adventurer, I have yet to get you name. What would you like to be called?
I would like to be called sir. !![Waiting for player input here]!!
(I input my name "Brad")
And what are you most interested in becoming adventurer?
1. Warrior
- Warriors focus on close combat with brutal and strong abilities while weilding with high HP
Str: 10
Def: 10
Range: 2
Int: 0
HP: 250
[ Suppose to wait for player input here but continues onto explaining the mage class.
2. Mage
ect..
[Waits for player input here on the second std::cin.get();]