Fusion de collision_data et collision

This commit is contained in:
Mattéo Delabre 2016-03-30 23:17:01 +02:00
parent aba30eefcd
commit bc858a05d2
5 changed files with 21 additions and 26 deletions

View File

@ -1,7 +1,23 @@
#ifndef __PTF_COLLISION_HPP__ #ifndef __PTF_COLLISION_HPP__
#define __PTF_COLLISION_HPP__ #define __PTF_COLLISION_HPP__
#include "collision_data.hpp" #include <SFML/Graphics.hpp>
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 * Détermine les informations sur la collision

View File

@ -1,22 +0,0 @@
#ifndef __PTF_COLLISION_DATA_HPP__
#define __PTF_COLLISION_DATA_HPP__
#include <SFML/Graphics.hpp>
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

View File

@ -3,7 +3,7 @@
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
#include <memory> #include <memory>
#include "collision_data.hpp" #include "collision.hpp"
#include "manager.hpp" #include "manager.hpp"
#include "resource_manager.hpp" #include "resource_manager.hpp"

View File

@ -1,5 +1,4 @@
#include "collision.hpp" #include "collision.hpp"
#include "collision_data.hpp"
#include "player.hpp" #include "player.hpp"
#include "block.hpp" #include "block.hpp"
#include "object.hpp" #include "object.hpp"
@ -195,6 +194,9 @@ std::map<
{std::make_pair(Block::TYPE_ID, Block::TYPE_ID), blockToBlock} {std::make_pair(Block::TYPE_ID, Block::TYPE_ID), blockToBlock}
}; };
CollisionData::CollisionData(Object& objA, Object& objB) :
objA(objA), objB(objB) {}
bool getCollisionData(CollisionData& data) { bool getCollisionData(CollisionData& data) {
return collision_map[std::make_pair( return collision_map[std::make_pair(
data.objA.getTypeId(), data.objA.getTypeId(),

View File

@ -1,7 +1,6 @@
#include "object.hpp" #include "object.hpp"
#include "constants.hpp" #include "constants.hpp"
#include "collision.hpp" #include "collision.hpp"
#include "collision_data.hpp"
Object::Object(float x, float y) : Object::Object(float x, float y) :
acceleration(0, 0), velocity(0, 0), position(x, y), acceleration(0, 0), velocity(0, 0), position(x, y),