Correction du comportement du bloc switch
This commit is contained in:
parent
13f32638af
commit
44ae6475e3
|
@ -17,6 +17,9 @@ protected:
|
||||||
*/
|
*/
|
||||||
static void init(std::ifstream& file, Object::Ptr object);
|
static void init(std::ifstream& file, Object::Ptr object);
|
||||||
|
|
||||||
|
public:
|
||||||
|
sf::Time last_activation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Identifiant unique du type "bloc changeur"
|
* Identifiant unique du type "bloc changeur"
|
||||||
|
|
Binary file not shown.
|
@ -18,8 +18,14 @@ void SwitchBlock::prepareDraw(ResourceManager& resources) {
|
||||||
void SwitchBlock::activate(Game& game, Object::Ptr object) {
|
void SwitchBlock::activate(Game& game, Object::Ptr object) {
|
||||||
Block::activate(game, object);
|
Block::activate(game, object);
|
||||||
|
|
||||||
// on échange la polarité de l'objet en contact
|
// on échange la polarité de l'objet en contact, si le dernier
|
||||||
if (object->getLastActivator().lock().get() != this) {
|
// objet touché par la balle n'est pas ce bloc et si un temps
|
||||||
|
// d'une seconde est passé
|
||||||
|
sf::Time current_time = game.getManager().getCurrentTime();
|
||||||
|
|
||||||
|
if (current_time - last_activation >= sf::seconds(1) &&
|
||||||
|
object->getLastActivator().lock() != shared_from_this()) {
|
||||||
|
last_activation = current_time;
|
||||||
object->setCharge(-object->getCharge());
|
object->setCharge(-object->getCharge());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue