From b1c82f914f18457f9a30791b01896ea40832c2d3 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Sun, 17 Nov 2024 18:45:46 +0100 Subject: bounce --- src/crepe/system/CollisionSystem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/crepe/system') diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index 4b74e67..8377823 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -152,7 +152,13 @@ void CollisionSystem::call_collision_handler(CollidedInfoStor& data1,CollidedInf 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; - info.first.rigidbody.data.linear_velocity = {0,0}; + if(info.first.rigidbody.data.bounce) { + info.first.rigidbody.data.linear_velocity = -info.first.rigidbody.data.linear_velocity * info.first.rigidbody.data.bouncie_factor; + } + else { + info.first.rigidbody.data.linear_velocity = {0,0}; + } + } std::vector> CollisionSystem::check_collisions(const std::vector>& boxcolliders, const std::vector>& circlecolliders) { -- cgit v1.2.3