diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-12-13 20:42:44 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-12-13 20:42:44 +0100 |
commit | fea0c2f0f96e093962c5faf3643176e856b1e8f6 (patch) | |
tree | e2549acde74cb52d35fd9ff75a3c21b986c76fcf /src/crepe/system/CollisionSystem.cpp | |
parent | d5904cb53bb7cc3a33894cb30746433b724f5634 (diff) |
make format
Diffstat (limited to 'src/crepe/system/CollisionSystem.cpp')
-rw-r--r-- | src/crepe/system/CollisionSystem.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index 5c49983..ab9b1aa 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -193,13 +193,15 @@ CollisionSystem::collision_handler(CollisionInternal & data1, CollisionInternal } else if (resolution.x != 0) { resolution_direction = Direction::X_DIRECTION; //checks if the other velocity has a value and if this object moved - if (data1.rigidbody.data.linear_velocity.y != 0 && data1.rigidbody.data.linear_velocity.x != 0) + if (data1.rigidbody.data.linear_velocity.y != 0 + && data1.rigidbody.data.linear_velocity.x != 0) resolution.y = -data1.rigidbody.data.linear_velocity.y * (resolution.x / data1.rigidbody.data.linear_velocity.x); } else if (resolution.y != 0) { resolution_direction = Direction::Y_DIRECTION; //checks if the other velocity has a value and if this object moved - if (data1.rigidbody.data.linear_velocity.x != 0 && data1.rigidbody.data.linear_velocity.y != 0) + if (data1.rigidbody.data.linear_velocity.x != 0 + && data1.rigidbody.data.linear_velocity.y != 0) resolution.x = -data1.rigidbody.data.linear_velocity.x * (resolution.y / data1.rigidbody.data.linear_velocity.y); } @@ -319,13 +321,13 @@ void CollisionSystem::static_collision_handler(CollisionInfo & info) { switch (info.resolution_direction) { case Direction::BOTH: //bounce - if(info.this_rigidbody.data.elastisity_coefficient > 0){ + if (info.this_rigidbody.data.elastisity_coefficient > 0) { info.this_rigidbody.data.linear_velocity.y - = -info.this_rigidbody.data.linear_velocity.y - * info.this_rigidbody.data.elastisity_coefficient; - info.this_rigidbody.data.linear_velocity.x - = -info.this_rigidbody.data.linear_velocity.x - * info.this_rigidbody.data.elastisity_coefficient; + = -info.this_rigidbody.data.linear_velocity.y + * info.this_rigidbody.data.elastisity_coefficient; + info.this_rigidbody.data.linear_velocity.x + = -info.this_rigidbody.data.linear_velocity.x + * info.this_rigidbody.data.elastisity_coefficient; } //stop movement else { @@ -336,11 +338,11 @@ void CollisionSystem::static_collision_handler(CollisionInfo & info) { // Bounce if (info.this_rigidbody.data.elastisity_coefficient > 0) { info.this_rigidbody.data.linear_velocity.y - = -info.this_rigidbody.data.linear_velocity.y - * info.this_rigidbody.data.elastisity_coefficient; + = -info.this_rigidbody.data.linear_velocity.y + * info.this_rigidbody.data.elastisity_coefficient; } // Stop movement - else{ + else { info.this_rigidbody.data.linear_velocity.y = 0; info.this_transform.position.x -= info.resolution.x; } @@ -349,11 +351,11 @@ void CollisionSystem::static_collision_handler(CollisionInfo & info) { // Bounce if (info.this_rigidbody.data.elastisity_coefficient > 0) { info.this_rigidbody.data.linear_velocity.x - = -info.this_rigidbody.data.linear_velocity.x - * info.this_rigidbody.data.elastisity_coefficient; + = -info.this_rigidbody.data.linear_velocity.x + * info.this_rigidbody.data.elastisity_coefficient; } // Stop movement - else{ + else { info.this_rigidbody.data.linear_velocity.x = 0; info.this_transform.position.y -= info.resolution.y; } |