diff options
Diffstat (limited to 'game/player/PlayerEndScript.cpp')
-rw-r--r-- | game/player/PlayerEndScript.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/game/player/PlayerEndScript.cpp b/game/player/PlayerEndScript.cpp index e04fb9d..62fd350 100644 --- a/game/player/PlayerEndScript.cpp +++ b/game/player/PlayerEndScript.cpp @@ -1,6 +1,7 @@ #include "PlayerEndScript.h" #include "../Config.h" +#include "../Events.h" #include "manager/LoopTimerManager.h" #include <crepe/api/Animator.h> @@ -61,7 +62,9 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) { rb_player.data.angular_velocity = 0; rb_player.data.elasticity_coefficient = 0; - rb_player.data.linear_velocity = vec2(PLAYER_SPEED * dt, 0); + if (rb_player.data.linear_velocity.x != 0) { + rb_player.data.linear_velocity = vec2(PLAYER_SPEED * dt, 0); + } rb_player.data.linear_velocity_coefficient = vec2(0.5, 0.5); rb_camera.data.linear_velocity_coefficient = vec2(0.5, 0.5); for (Animator & anim : anim_player) { @@ -89,7 +92,12 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) { jump++; } - return true; + if (rb_player.data.linear_velocity.x < 5 && jump == 3) { + this->trigger_event<EndGameEvent>(); + jump++; + } + + return false; } return false; |