skizzle/src/block.cpp

34 lines
791 B
C++
Raw Normal View History

2016-03-08 21:49:52 +00:00
#include "block.hpp"
2016-03-08 16:46:33 +00:00
void Block::draw(sf::RenderWindow& window) {
2016-03-12 13:15:27 +00:00
// chargement de la texture de test
if (!texture.loadFromFile("./res/block.png")) {
2016-03-12 13:15:27 +00:00
// erreur
}
2016-03-12 13:15:27 +00:00
shape.setTexture(&texture);
if (charge > 0) {
shape.setFillColor(sf::Color(180, 180, 255));
} else if (charge < 0) {
shape.setFillColor(sf::Color(255, 180, 180));
} else {
shape.setFillColor(sf::Color::White);
}
shape.setPosition(position);
2016-03-10 21:16:07 +00:00
window.draw(shape);
}
void Block::update(EngineState& state) {
// rien à mettre à jour
}
std::unique_ptr<sf::FloatRect> Block::getAABB() {
return std::unique_ptr<sf::FloatRect>(new sf::FloatRect(
position.x - Block::GRID / 2,
position.y - Block::GRID / 2,
Block::GRID, Block::GRID
));
}