From 20d15c6df8ea48076410d156d409bc174983d051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Sat, 19 Mar 2016 15:33:31 +0100 Subject: [PATCH] Correction de la collision balle-balle --- src/ball.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ball.cpp b/src/ball.cpp index a2a17a3..f95b2bf 100644 --- a/src/ball.cpp +++ b/src/ball.cpp @@ -2,6 +2,7 @@ #include "block.hpp" #include "constants.hpp" #include +#include Ball::Ball(float x, float y) : Object(x, y), shape(10) { shape.setOrigin(sf::Vector2f(10, 10)); @@ -82,7 +83,7 @@ bool Ball::getCollisionInfo(Object& obj, sf::Vector2f& normal, float& depth) { } bool Ball::getCollisionInfo(Ball& obj, sf::Vector2f& normal, float& depth) { - sf::Vector2f dir = obj.getPosition() - getPosition(); + sf::Vector2f dir = getPosition() - obj.getPosition(); float squaredLength = dir.x * dir.x + dir.y * dir.y; // TODO: supprimer les valeurs magiques @@ -106,7 +107,7 @@ bool Ball::getCollisionInfo(Ball& obj, sf::Vector2f& normal, float& depth) { // TODO: supprimer les valeurs magiques // il y a eu collision - depth = 10 - length; + depth = 20 - length; normal = dir / length; return true; }