#include "block.hpp" #include "player.hpp" #include "constants.hpp" #include "resource_manager.hpp" Block::Block(float x, float y) : Object(x, y) { // 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(Constants::GRID / 2, Constants::GRID / 2)); } Block::~Block() {} void Block::draw(Manager& manager) { Object::draw(manager); // utilisation de la texture sprite.setTexture( manager.getResourceManager().getTexture("block.png") ); // coloration du bloc en fonction de sa charge if (getCharge() > 0) { sprite.setColor(sf::Color(180, 180, 255)); } else if (getCharge() < 0) { sprite.setColor(sf::Color(255, 180, 180)); } else { sprite.setColor(sf::Color::White); } sprite.setPosition(getPosition()); manager.getWindow().draw(sprite); } std::unique_ptr Block::getAABB() const { return std::make_unique( getPosition().x - Constants::GRID / 2, getPosition().y - Constants::GRID / 2, Constants::GRID, Constants::GRID ); } const unsigned int Block::TYPE_ID = 1; unsigned int Block::getTypeId() const { return TYPE_ID; }