From 911c87fe6ac0d0bedf1844d00801b7cf393dda41 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 10 Jan 2025 16:30:14 +0100 Subject: moved if statement --- game/missile/MissileScript.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/game/missile/MissileScript.cpp b/game/missile/MissileScript.cpp index f87dd20..3aa4eb6 100644 --- a/game/missile/MissileScript.cpp +++ b/game/missile/MissileScript.cpp @@ -44,12 +44,13 @@ void MissileScript::activate() { auto anim = this->get_components(); auto sprites = this->get_components(); - anim[0].get().active = true; - anim[1].get().active = true; - anim[2].get().stop(); sprites[0].get().active = true; sprites[1].get().active = true; sprites[2].get().active = false; + + anim[0].get().active = true; + anim[1].get().active = true; + anim[2].get().stop(); } bool MissileScript::on_collision(const CollisionEvent & ev) { auto & explosion_sound = this->get_components().back().get(); @@ -73,16 +74,16 @@ void MissileScript::fixed_update(crepe::duration_t dt) { const auto & cam = this->get_components_by_name("camera").front().get(); const auto & velocity = this->get_component().data.linear_velocity; - - if (missile.position.x < (cam.position.x - VIEWPORT_X / 1.8)) { - this->kill_missile(); - return; - } - // check if animation is at the end if (explosion_anim.data.row == 7) { this->activate(); this->seeking_disabled = false; + return; + } + + if (missile.position.x < (cam.position.x - VIEWPORT_X / 1.8)) { + this->kill_missile(); + return; } if (this->seeking_disabled) { -- cgit v1.2.3