diff --git a/include/level.hpp b/include/level.hpp index 0fe1423..c39262b 100644 --- a/include/level.hpp +++ b/include/level.hpp @@ -163,9 +163,11 @@ public: const std::vector& getPlayers() const; /** - * Ajoute un nouvel objet + * Ajoute un nouvel objet. Retourne l'objet + * si il a bien été ajouté, ou nullptr si l'ajout + * a été bloqué */ - void addObject(Object::Ptr object); + Object::Ptr addObject(Object::Ptr object); /** * Supprime l'objet donné diff --git a/src/block.cpp b/src/block.cpp index f167b2e..98d6af8 100644 --- a/src/block.cpp +++ b/src/block.cpp @@ -7,10 +7,6 @@ const unsigned int Block::TYPE_ID = 2; Block::Block() : Object() { - // par défaut, les blocs ne sont pas déplaçables et ont - // donc une masse infinie, représentée par 0 - setMass(0.f); - // déplacement de l'origine au centre du bloc sprite.setOrigin(sf::Vector2f(23, 23)); select_sprite.setOrigin(sf::Vector2f(23, 23)); diff --git a/src/game.cpp b/src/game.cpp index 95e20fc..c302c42 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1,5 +1,4 @@ #include -#include #include "game.hpp" #include "player.hpp" #include "constants.hpp" diff --git a/src/manager.cpp b/src/manager.cpp index 05ddb5e..cb5900e 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1,4 +1,3 @@ -#include #include "manager.hpp" const unsigned int Manager::FPS = 60; diff --git a/src/object.cpp b/src/object.cpp index 8c44d45..8077e6b 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -2,11 +2,10 @@ #include "level.hpp" #include "constants.hpp" #include "collision.hpp" -#include #include const unsigned int Object::PROP_MASS = 1; -const float DEFAULT_MASS = 1.f; +const float DEFAULT_MASS = 0.f; const unsigned int Object::PROP_CHARGE = 2; const float DEFAULT_CHARGE = 0.f; const unsigned int Object::PROP_RESTITUTION = 3; @@ -338,9 +337,6 @@ float Object::getMassInvert() const { } void Object::setMass(float set_mass) { - if (getTypeId() == 1){ - std::cout << "Change mass player from " << mass << " to " << set_mass << std::endl; - } mass = set_mass; inv_mass = -1.f; } diff --git a/src/widget_toolbar.cpp b/src/widget_toolbar.cpp index 59162f7..7e69c91 100644 --- a/src/widget_toolbar.cpp +++ b/src/widget_toolbar.cpp @@ -37,7 +37,9 @@ Object::Ptr WidgetToolbar::createMovableBlock() { } Object::Ptr WidgetToolbar::createPlayer() { - return Object::Ptr(new Player); + Object::Ptr player = Object::Ptr(new Player); + player->setMass(1.f); + return player; } Object::Ptr WidgetToolbar::createGravityBlock(GravityDirection direction) {