From bc858a05d27888351d9d161c92a012ca8e6d9d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Wed, 30 Mar 2016 23:17:01 +0200 Subject: [PATCH] Fusion de collision_data et collision --- include/collision.hpp | 18 +++++++++++++++++- include/collision_data.hpp | 22 ---------------------- include/object.hpp | 2 +- src/collision.cpp | 4 +++- src/object.cpp | 1 - 5 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 include/collision_data.hpp diff --git a/include/collision.hpp b/include/collision.hpp index 8963358..f068ca7 100644 --- a/include/collision.hpp +++ b/include/collision.hpp @@ -1,7 +1,23 @@ #ifndef __PTF_COLLISION_HPP__ #define __PTF_COLLISION_HPP__ -#include "collision_data.hpp" +#include + +class Object; + +/** + * Structure qui retient des informations + * sur les collisions + */ +struct CollisionData { + sf::Vector2f normal; + float depth; + + Object& objA; + Object& objB; + + CollisionData(Object& objA, Object& objB); +}; /** * Détermine les informations sur la collision diff --git a/include/collision_data.hpp b/include/collision_data.hpp deleted file mode 100644 index 9eea386..0000000 --- a/include/collision_data.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __PTF_COLLISION_DATA_HPP__ -#define __PTF_COLLISION_DATA_HPP__ - -#include - -class Object; - -/** - * Structure qui retient des informations sur les - * collisions - */ -struct CollisionData { - sf::Vector2f normal; - float depth; - - Object& objA; - Object& objB; - - CollisionData(Object& objA, Object& objB) : objA(objA), objB(objB) {} -}; - -#endif diff --git a/include/object.hpp b/include/object.hpp index 21a13ed..e58bc69 100644 --- a/include/object.hpp +++ b/include/object.hpp @@ -3,7 +3,7 @@ #include #include -#include "collision_data.hpp" +#include "collision.hpp" #include "manager.hpp" #include "resource_manager.hpp" diff --git a/src/collision.cpp b/src/collision.cpp index e86faa0..df61fa8 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -1,5 +1,4 @@ #include "collision.hpp" -#include "collision_data.hpp" #include "player.hpp" #include "block.hpp" #include "object.hpp" @@ -195,6 +194,9 @@ std::map< {std::make_pair(Block::TYPE_ID, Block::TYPE_ID), blockToBlock} }; +CollisionData::CollisionData(Object& objA, Object& objB) : + objA(objA), objB(objB) {} + bool getCollisionData(CollisionData& data) { return collision_map[std::make_pair( data.objA.getTypeId(), diff --git a/src/object.cpp b/src/object.cpp index 3043df2..18645fb 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -1,7 +1,6 @@ #include "object.hpp" #include "constants.hpp" #include "collision.hpp" -#include "collision_data.hpp" Object::Object(float x, float y) : acceleration(0, 0), velocity(0, 0), position(x, y),