I was programming my Game until i found a Problem with Threads .
By the Way i got all my Functions and Variables in one Class (Besides the main) .
int main()
{
Game Game1; //Create an Instance of the Game and initialise it
sf::Thread THGetKeyInput(&Game::GetKeyInput,&Game1);
THGetKeyInput.launch(); //Create and launch the Thread which Function takes Events from the
//Main Window and puts them in bools in the Game1 Instance
Game1.menu(); //Start the actuall Game . Here is the Problem
}
What apparently happens is that the call of Function Game1.menu puts the main Function to sleep .
And because THGetKeyInput is a part of the main Function it gets put to sleep too .
Is there any solution to this Problem while still just creating and running a Thread once ?
I've tried to make a Thread for both Functions and adding while() to the main Function but then
the Game1.menu Function seems to be unable to draw Sprites in the Window .
If the Problem is something else pls tell me .