2016-03-08 21:49:52 +00:00
|
|
|
#include "block.hpp"
|
2016-03-08 16:46:33 +00:00
|
|
|
|
2016-03-14 20:11:09 +00:00
|
|
|
Block::Block(float x, float y) : Object(x, y), shape(sf::Vector2f(Block::GRID, Block::GRID)) {
|
|
|
|
shape.setOrigin(sf::Vector2f(Block::GRID / 2, Block::GRID / 2));
|
|
|
|
}
|
|
|
|
|
2016-03-08 17:07:34 +00:00
|
|
|
void Block::draw(sf::RenderWindow& window) {
|
2016-03-12 13:15:27 +00:00
|
|
|
// chargement de la texture de test
|
2016-03-12 22:15:03 +00:00
|
|
|
if (!texture.loadFromFile("./res/block.png")) {
|
2016-03-12 13:15:27 +00:00
|
|
|
// erreur
|
2016-03-12 10:22:10 +00:00
|
|
|
}
|
2016-03-12 13:15:27 +00:00
|
|
|
|
|
|
|
shape.setTexture(&texture);
|
2016-03-12 10:22:10 +00:00
|
|
|
|
2016-03-11 15:15:27 +00:00
|
|
|
if (charge > 0) {
|
2016-03-12 22:15:03 +00:00
|
|
|
shape.setFillColor(sf::Color(180, 180, 255));
|
2016-03-11 15:15:27 +00:00
|
|
|
} else if (charge < 0) {
|
2016-03-12 22:15:03 +00:00
|
|
|
shape.setFillColor(sf::Color(255, 180, 180));
|
2016-03-11 15:15:27 +00:00
|
|
|
} else {
|
2016-03-12 22:15:03 +00:00
|
|
|
shape.setFillColor(sf::Color::White);
|
2016-03-11 15:15:27 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 14:16:46 +00:00
|
|
|
shape.setPosition(position);
|
2016-03-10 21:16:07 +00:00
|
|
|
window.draw(shape);
|
2016-03-08 17:07:34 +00:00
|
|
|
}
|
2016-03-08 18:50:55 +00:00
|
|
|
|
2016-03-13 16:03:56 +00:00
|
|
|
void Block::update(EngineState& state) {
|
2016-03-08 18:50:55 +00:00
|
|
|
// rien à mettre à jour
|
|
|
|
}
|
2016-03-13 18:07:35 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
));
|
|
|
|
}
|
2016-03-14 20:11:09 +00:00
|
|
|
|
|
|
|
unsigned int Block::getLayer() {
|
|
|
|
return 0;
|
|
|
|
}
|