aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-11-17 18:45:46 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-11-17 18:45:46 +0100
commitb1c82f914f18457f9a30791b01896ea40832c2d3 (patch)
tree6c70f8336fb408f05a7e1816369008a2954065d0 /src/crepe/system
parent9885c58817912125506de3b3555f3dc6206e0e6a (diff)
bounce
Diffstat (limited to 'src/crepe/system')
-rw-r--r--src/crepe/system/CollisionSystem.cpp8
1 files changed, 7 insertions, 1 deletions
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<std::pair<CollisionSystem::CollidedInfoStor,CollisionSystem::CollidedInfoStor>> CollisionSystem::check_collisions(const std::vector<std::reference_wrapper<BoxCollider>>& boxcolliders, const std::vector<std::reference_wrapper<CircleCollider>>& circlecolliders) {