diff options
author | Max-001 <maxsmits21@kpnmail.nl> | 2025-01-06 11:11:25 +0100 |
---|---|---|
committer | Max-001 <maxsmits21@kpnmail.nl> | 2025-01-06 11:11:25 +0100 |
commit | 20ae1e9dc2043ef3c190f77dd5f9de74bcd533de (patch) | |
tree | e4f4789f242bd4e60f5eae7bd8cc0d233da5be2a /game/player/PlayerEndScript.cpp | |
parent | b31934cc6867be10e986a4bd4d0ab81dc91d56ec (diff) |
Added dt
Diffstat (limited to 'game/player/PlayerEndScript.cpp')
-rw-r--r-- | game/player/PlayerEndScript.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/game/player/PlayerEndScript.cpp b/game/player/PlayerEndScript.cpp index 4cd2cd0..e04fb9d 100644 --- a/game/player/PlayerEndScript.cpp +++ b/game/player/PlayerEndScript.cpp @@ -1,6 +1,7 @@ #include "PlayerEndScript.h" #include "../Config.h" +#include "manager/LoopTimerManager.h" #include <crepe/api/Animator.h> #include <crepe/api/BoxCollider.h> @@ -28,6 +29,8 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) { Rigidbody & rb_player = this->get_components_by_name<Rigidbody>("player").front(); Rigidbody & rb_camera = this->get_components_by_name<Rigidbody>("camera").front(); + float dt = this->get_loop_timer().get_fixed_delta_time().count(); + if (jump == 0) { int random_number = rand() % 4; for (Animator & anim : anim_player) { @@ -44,7 +47,7 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) { } if (jump == 0) { - rb_player.data.angular_velocity = 320; + rb_player.data.angular_velocity = 16000 * dt; rb_player.data.angular_velocity_coefficient = 0.7; jump++; } else if (jump == 1) { @@ -58,7 +61,7 @@ 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, 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) { |