From 62013124abb9c219f2d4f5475fd8c958761b4986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Mon, 28 Mar 2016 20:02:23 +0200 Subject: [PATCH] Constructeurs virtuels --- include/block.hpp | 1 + include/object.hpp | 1 + include/player.hpp | 1 + src/block.cpp | 4 ++++ src/game.cpp | 4 ++-- src/object.cpp | 2 ++ src/player.cpp | 4 ++++ src/view.cpp | 3 +++ 8 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/view.cpp diff --git a/include/block.hpp b/include/block.hpp index 78d5b7b..139efc3 100644 --- a/include/block.hpp +++ b/include/block.hpp @@ -10,6 +10,7 @@ private: public: Block(float x, float y); + virtual ~Block(); /** * Dessin du bloc dans la fenêtre donnée diff --git a/include/object.hpp b/include/object.hpp index a462b17..7edfdac 100644 --- a/include/object.hpp +++ b/include/object.hpp @@ -32,6 +32,7 @@ protected: public: Object(float x, float y); + virtual ~Object(); /** * Dessine l'objet dans la fenêtre donnée diff --git a/include/player.hpp b/include/player.hpp index 37298be..ec9697b 100644 --- a/include/player.hpp +++ b/include/player.hpp @@ -17,6 +17,7 @@ protected: public: Player(float x, float y); + virtual ~Player(); /** * Dessine la balle dans la fenêtre donnée diff --git a/src/block.cpp b/src/block.cpp index 8387b14..165e56e 100644 --- a/src/block.cpp +++ b/src/block.cpp @@ -12,6 +12,10 @@ Block::Block(float x, float y) : Object(x, y) { sprite.setOrigin(sf::Vector2f(Constants::GRID / 2, Constants::GRID / 2)); } +Block::~Block() { + Object::~Object(); +} + void Block::draw(Manager& manager) { Object::draw(manager); diff --git a/src/game.cpp b/src/game.cpp index 9551e80..5ce979b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1,10 +1,9 @@ #include "game.hpp" #include "constants.hpp" +#include "player.hpp" #include #include -#include "player.hpp" - Game::Game() : accumulator(0.f) { if (!music.openFromFile("./res/music_lvl1.wav")) { // erreur @@ -18,6 +17,7 @@ Game::Game() : accumulator(0.f) { } Game::~Game() { + View::~View(); clear(); } diff --git a/src/object.cpp b/src/object.cpp index 9178c8c..102c36c 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -15,6 +15,8 @@ Object::Object(float x, float y) : dynamic_friction(0.2f), layer(Constants::DEFAULT_LAYER) {} +Object::~Object() {} + sf::Vector2f Object::getForces( const Manager& manager, const std::vector& objects ) const { diff --git a/src/player.cpp b/src/player.cpp index f40e75f..fb82215 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -9,6 +9,10 @@ Player::Player(float x, float y) : Object(x, y) { sprite.setOrigin(sf::Vector2f(getRadius(), getRadius())); } +Player::~Player() { + Object::~Object(); +} + sf::Vector2f Player::getForces(const Manager& manager, const std::vector& objects) const { sf::Vector2f forces = Object::getForces(manager, objects); diff --git a/src/view.cpp b/src/view.cpp new file mode 100644 index 0000000..ef2a8f7 --- /dev/null +++ b/src/view.cpp @@ -0,0 +1,3 @@ +#include "view.hpp" + +View::~View() {}