aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-10 16:30:14 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-10 16:30:14 +0100
commit911c87fe6ac0d0bedf1844d00801b7cf393dda41 (patch)
tree1bcec9f8b95dba07245c4d461b224be8bd7aa152
parenta981a42a7378ed51155590215557e52553031272 (diff)
moved if statement
-rw-r--r--game/missile/MissileScript.cpp19
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) {