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.


Messages - Ivysaur

Pages: [1]
1
System / Re: Thread gets put to sleep . How can i avoid that ?
« on: February 13, 2015, 07:54:22 am »
And if you still want to use threads you should use std::thread.
Maybe i'll get to that later . My Compiler just doesn't support it and changing to a different one will put me in the same Struggles i had when trying to install SDL on Dev-C++ .

2
System / Re: Thread gets put to sleep . How can i avoid that ?
« on: February 13, 2015, 07:52:19 am »
Threads are not unstable. They just add a level of complexity that is rarely needed. In most case, you can make a whole game with only one thread without a problem. I really don't see why you use thread for this.
If you don't wanna help . Then just stfu .

Programming is not something that you need to do this or this way . Instead you can use many different Ways to achieve your Goal . And if you don't understand my Way of programming then don't question it out . If you think Threads are too complex Then fine . Just don't say that others shouldn't use them . Because it's not your decision .

3
System / Re: Thread gets put to sleep . How can i avoid that ?
« on: February 12, 2015, 10:51:30 pm »
First question that comes to mind is; why on earth are you even bothering with threads?

If "Game1.menu()" puts the program (the whole program, not just the main thread) to sleep, you should already know why since you wrote it. Besides, you didn't even show us the code of the function, so how would we know what it does?

And I have to ask again - why threads?
Why shouldn't i use threads ? Are they really that unstable or should i just use as less as possible ?

By the way Game1.menu just displays some Sprites and checks for the bools that are being modified by THGetKeyInput . The Problem here is that THGetKeyInput get's put to sleep because it's local in the main Function which waits until Game1.menu returns and therefor those bools will always be false .

4
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]