aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-11-17 19:04:33 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-11-17 19:04:33 +0100
commited04aa321fd390c45eff1fee03e73e6513c6b978 (patch)
tree767f1db1eda5a4dddecac21d704d214a3e26cf8d /src/crepe
parentb1c82f914f18457f9a30791b01896ea40832c2d3 (diff)
improved bounce
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/system/CollisionSystem.cpp7
1 files changed, 6 insertions, 1 deletions
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};