1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| namespace obstacle
{
class Obstacle : public Object
{
public:
virtual ~Obstacle(void) = 0 {}
virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const = 0
private:
friend class CollisionManager;
};
class ConvexObstacle:
public Obstacle
{
public:
ConvexObstacle();
/* AAARGHHH!!! SEMANTIQUE D'ENTITE !!! (*)
ConvexObstacle(ConvexObstacle &source);
*/
sf::IntRect GetBoundingBox() const;
~ConvexObstacle(){};
void draw(sf::RenderTarget &target, sf::RenderStates states) const {
// tiens, elle n'hérite vraiment pas d'une classe dérivée de sf::Drawable???
// bon, ben on la laisse "ne rien faire :D
}
};
class CircleObstacle :
public Obstacle, public sf::CircleShape
{
public:
CircleObstacle(int radius, sf::Vector2f position, sf::Color fill= sf::Color::White, int pointcount = 30); //(**)
/* AAARGHHH!!! SEMANTIQUE D'ENTITE !!! (*)
CircleObstacle(CircleObstacle &source);
*/
void draw(sf::RenderTarget &target, sf::RenderStates states) const{
sf::CircleShape::draw(target, states);
}
private:
friend class CollisionManager;
};
class RectangleObstacle :
public virtual Obstacle, public virtual sf::RectangleShape
{
public:
RectangleObstacle(sf::Vector2f size, sf::Vector2f position, sf::Color fill = sf::Color::White); //(**)
/* AAARGHHH!!! SEMANTIQUE D'ENTITE !!! (*)
RectangleObstacle(RectangleObstacle &source);
*/
~RectangleObstacle();
void draw(sf::RenderTarget &target, sf::RenderStates states) const{
sf::RectangleShape::draw(target, states);
}
private:
friend class CollisionManager;
};
}; |
Partager