Adding 2 player mode with custom isogram

Hey there. I’ve recently finished section 2 and fancied messing around with the game. I’ve seen a bunch of people who added more words and difficult levels in their version. I wanted to set up a multiplayer aspect. Game asks if there are one or two players. Then if there are two players the game asks player one to input the word for player 2 to get. I feel like I gotten close to getting my code to work but I’ve hit a wall. As it stands when you select two player it doesn’t give the user the opportunity to input a word and changes hidden word an empty string.

FString GetCustomWord()
	std::cout << "Enter an isogram (lower case) for Player 2. Then give them control.\n";
	FString responce = "";
	std::getline(std::cin, responce);
	std::cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
	return BCGame.MyHiddenWord = responce;

std::getline(std::cin, responce);

with simply
std::cin >> responce;

The reason? std::getline reads the line end ‘\n’ left in the input stream by your previous std::cin >> Response code and immediately returns.

1 Like

Privacy & Terms