Change quit to destroying
This commit is contained in:
parent
32f83fa67b
commit
7408206107
|
@ -50,7 +50,12 @@ public:
|
|||
ParticleEmitter() : Super(texture, sf::Vector2f(350, 350), .5f, 5, 900, se::Range2f(-25, 25, -25, 25),
|
||||
se::particle::ParticleAttributes{std::chrono::milliseconds(500), sf::Vector2f(.1f, .1f), 5,
|
||||
sf::Vector2f(2, 2)}, particle_properties, emitter_properties) {
|
||||
texture.loadFromFile("particle.png"); // The particle I tested with was 5x5 pixels
|
||||
// The particle I tested with was 5x5 pixels
|
||||
if (!texture.loadFromFile("particle.png")) {
|
||||
std::cerr << "Failed to load particle.png!" << std::endl;
|
||||
throw std::runtime_error("Failed to load particle.png");
|
||||
}
|
||||
|
||||
texture.setSmooth(true);
|
||||
|
||||
particle_properties.emplace_back(std::make_unique<se::particle::RandomVelocityParticleProperty>(se::Range2f(-1.5f, 1.5f, -1.5f, 1.5f)));
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace simpleengine {
|
|||
public:
|
||||
explicit AsyncEvent(sf::RenderWindow* window = nullptr) : simpleengine::Event(window) {
|
||||
update_thread = std::thread( [this]() {
|
||||
while (!quit) {
|
||||
while (!destroying) {
|
||||
std::unique_lock<std::mutex> unique_lock(mutex);
|
||||
cond_var.wait(unique_lock);
|
||||
|
||||
// After waiting check if we're quiting and if we need to stop this thread.
|
||||
if (quit) break;
|
||||
if (destroying) break;
|
||||
|
||||
AsyncUpdate(tick_delta_time);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace simpleengine {
|
|||
}
|
||||
|
||||
virtual ~AsyncEvent() {
|
||||
quit = true;
|
||||
destroying = true;
|
||||
|
||||
// Notify the async updating thread that we're quiting.
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace simpleengine {
|
|||
entity->Update(delta_time);
|
||||
|
||||
if (entity->IsDestroying()) {
|
||||
quit = true;
|
||||
destroying = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue