From ed04aa321fd390c45eff1fee03e73e6513c6b978 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Sun, 17 Nov 2024 19:04:33 +0100 Subject: improved bounce --- src/crepe/system/CollisionSystem.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/crepe/system') diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index 8377823..3c6f22e 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -153,7 +153,12 @@ void CollisionSystem::static_collision_handler(CollisionInfo& info){ std::cout << "INFO: x:" << info.first.transform.position.x << "y:" << info.first.transform.position.y << std::endl; info.first.transform.position += info.move_back_value; if(info.first.rigidbody.data.bounce) { - info.first.rigidbody.data.linear_velocity = -info.first.rigidbody.data.linear_velocity * info.first.rigidbody.data.bouncie_factor; + if(info.move_back_value.x != 0) { + info.first.rigidbody.data.linear_velocity.x = -info.first.rigidbody.data.linear_velocity.x * info.first.rigidbody.data.bouncie_factor; + } + if(info.move_back_value.y != 0) { + info.first.rigidbody.data.linear_velocity.y = -info.first.rigidbody.data.linear_velocity.y * info.first.rigidbody.data.bouncie_factor; + } } else { info.first.rigidbody.data.linear_velocity = {0,0}; -- cgit v1.2.3