diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-11-20 20:50:48 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-11-20 20:50:48 +0100 |
commit | faa9adb84ad3f675587b52fba79cf44b7bdd2034 (patch) | |
tree | bb99f14b30a4292789da8efa858551af93fd0994 /src/crepe | |
parent | 6808307cf65a4b686621f08a58effecc0a9c6bb8 (diff) |
added unit tests for dynamic box box collision
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/system/CollisionSystem.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index 2132b0d..b23e779 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -91,9 +91,11 @@ void CollisionSystem::collision_handler(CollidedInfoStor& data1,CollidedInfoStor move_back_direction = Direction::BOTH; } else if (move_back.x != 0) { move_back_direction = Direction::X_DIRECTION; + if(data1.rigidbody.data.linear_velocity.y != 0) move_back.y = data1.rigidbody.data.linear_velocity.y * (move_back.x/data1.rigidbody.data.linear_velocity.x); } else if (move_back.y != 0) { move_back_direction = Direction::Y_DIRECTION; + if(data1.rigidbody.data.linear_velocity.x != 0) move_back.x = data1.rigidbody.data.linear_velocity.x * (move_back.y/data1.rigidbody.data.linear_velocity.y); } @@ -341,13 +343,8 @@ bool CollisionSystem::check_circle_circle_collision(const CircleCollider& circle } Vector2 CollisionSystem::current_position(const Collider& collider, const Transform& transform, const Rigidbody& rigidbody) { - // Function to convert degrees to radians - auto degrees_to_radians = [](double degrees) { - return degrees * (M_PI / 180.0); - }; - // Get the rotation in radians - double radians1 = degrees_to_radians(transform.rotation); + double radians1 = transform.rotation * (M_PI / 180.0); // Calculate total offset with scale Vector2 total_offset = (rigidbody.data.offset + collider.offset) * transform.scale; |