Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Ivysaur

Pages: [1]
1
System / Thread gets put to sleep . How can i avoid that ?
« on: February 12, 2015, 10:12:00 pm »
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 .

Pages: [1]
anything