From bc66ba7754dec9d6f907bc69730f211ae2215906 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Sun, 29 Dec 2024 12:15:10 +0100 Subject: Improved stop sprite --- game/player/PlayerEndScript.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/game/player/PlayerEndScript.cpp b/game/player/PlayerEndScript.cpp index 37b870c..80d3011 100644 --- a/game/player/PlayerEndScript.cpp +++ b/game/player/PlayerEndScript.cpp @@ -26,7 +26,7 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) { Rigidbody & rb_player = this->get_components_by_name("player").front(); Rigidbody & rb_camera = this->get_components_by_name("camera").front(); - if (jump == 0 || jump == 1) { + if (jump == 0) { int random_number = rand() % 4; for (Animator & anim : anim_player) { anim.active = false; @@ -35,14 +35,19 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) { anim.next_anim(); } } + } else if (jump == 1) { + for (Animator & anim : anim_player) { + anim.next_anim(); + } } if (jump == 0) { rb_player.data.angular_velocity = 320; rb_player.data.angular_velocity_coefficient = 0.7; jump++; - } else if (jump == 1 && transform_player.rotation > 65 - && transform_player.rotation < 115) { + } else if (jump == 1) { + jump++; + } else if (jump == 2) { rb_player.data.angular_velocity = 0; rb_player.data.elasticity_coefficient = 0; rb_player.data.linear_velocity = vec2(100, 0); @@ -52,6 +57,24 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) { anim.active = false; anim.set_anim(7); } + if (transform_player.rotation > 0 && transform_player.rotation < 90) { + // Do not call next_anim() + } else if (transform_player.rotation > 90 && transform_player.rotation < 180) { + for (Animator & anim : anim_player) { + anim.next_anim(); + } + } else if (transform_player.rotation > 180 && transform_player.rotation < 270) { + for (Animator & anim : anim_player) { + anim.next_anim(); + anim.next_anim(); + } + } else { + for (Animator & anim : anim_player) { + anim.next_anim(); + anim.next_anim(); + anim.next_anim(); + } + } jump++; } -- cgit v1.2.3