Change quit to destroying

This commit is contained in:
SeanOMik 2021-11-20 00:06:50 -05:00
parent 32f83fa67b
commit 7408206107
No known key found for this signature in database
GPG Key ID: CA09E5BE1F32728A
3 changed files with 10 additions and 5 deletions

View File

@ -50,7 +50,12 @@ public:
ParticleEmitter() : Super(texture, sf::Vector2f(350, 350), .5f, 5, 900, se::Range2f(-25, 25, -25, 25), 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, se::particle::ParticleAttributes{std::chrono::milliseconds(500), sf::Vector2f(.1f, .1f), 5,
sf::Vector2f(2, 2)}, particle_properties, emitter_properties) { 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); texture.setSmooth(true);
particle_properties.emplace_back(std::make_unique<se::particle::RandomVelocityParticleProperty>(se::Range2f(-1.5f, 1.5f, -1.5f, 1.5f))); particle_properties.emplace_back(std::make_unique<se::particle::RandomVelocityParticleProperty>(se::Range2f(-1.5f, 1.5f, -1.5f, 1.5f)));

View File

@ -18,12 +18,12 @@ namespace simpleengine {
public: public:
explicit AsyncEvent(sf::RenderWindow* window = nullptr) : simpleengine::Event(window) { explicit AsyncEvent(sf::RenderWindow* window = nullptr) : simpleengine::Event(window) {
update_thread = std::thread( [this]() { update_thread = std::thread( [this]() {
while (!quit) { while (!destroying) {
std::unique_lock<std::mutex> unique_lock(mutex); std::unique_lock<std::mutex> unique_lock(mutex);
cond_var.wait(unique_lock); cond_var.wait(unique_lock);
// After waiting check if we're quiting and if we need to stop this thread. // 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); AsyncUpdate(tick_delta_time);
} }
@ -31,7 +31,7 @@ namespace simpleengine {
} }
virtual ~AsyncEvent() { virtual ~AsyncEvent() {
quit = true; destroying = true;
// Notify the async updating thread that we're quiting. // Notify the async updating thread that we're quiting.
{ {

View File

@ -21,7 +21,7 @@ namespace simpleengine {
entity->Update(delta_time); entity->Update(delta_time);
if (entity->IsDestroying()) { if (entity->IsDestroying()) {
quit = true; destroying = true;
} }
} }