diff options
-rw-r--r-- | game/missile/MissileScript.cpp | 19 |
1 files 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<Animator>(); auto sprites = this->get_components<Sprite>(); - 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<AudioSource>().back().get(); @@ -73,16 +74,16 @@ void MissileScript::fixed_update(crepe::duration_t dt) { const auto & cam = this->get_components_by_name<Transform>("camera").front().get(); const auto & velocity = this->get_component<Rigidbody>().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) { |