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 - Kookies

Pages: [1]
1
System / Re: Threads are Freezing my Window
« on: April 30, 2021, 04:11:31 pm »
So where should I create it?

2
System / Threads are Freezing my Window
« on: April 29, 2021, 05:07:53 pm »
This is a function I'm using to spawn enemies, and I'm using sf::sleep to add a delay.
void spawn()
{
        sleep(seconds(2));
        if (count1 % 20 && count1 != 0)
        {
                enemies.push_back(Enemy(true, 500.0, 25.0, 50.0, 50.0, Color::Red));
        }
        else
        {
                enemies.push_back(Enemy(false, 100.0, 15.0, 50.0, 50.0, Color::White));
        }
        count1++;
}
I launch the thread from here:
Thread spawning(&spawn);
        spawning.launch();
But for some reason, the sleep in the thread affects my main loop and causes it to update every two seconds.

Pages: [1]
anything