From 3d74160669125f16dd69b07d0341155046ee5fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Sun, 17 Apr 2016 14:20:49 +0200 Subject: [PATCH] =?UTF-8?q?Les=20blocs=20de=20gravit=C3=A9=20ne=20sont=20a?= =?UTF-8?q?ctivables=20qu'une=20fois?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/gravity_block.hpp | 1 + src/gravity_block.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/gravity_block.hpp b/include/gravity_block.hpp index b9a79af..e6c3013 100644 --- a/include/gravity_block.hpp +++ b/include/gravity_block.hpp @@ -14,6 +14,7 @@ public: private: GravityDirection gravity_direction; + bool used; protected: /** diff --git a/src/gravity_block.cpp b/src/gravity_block.cpp index 585343e..f0cc5d3 100644 --- a/src/gravity_block.cpp +++ b/src/gravity_block.cpp @@ -4,7 +4,7 @@ const unsigned int GravityBlock::TYPE_ID = 3; -GravityBlock::GravityBlock() : Block() {} +GravityBlock::GravityBlock() : Block(), used(false) {} GravityBlock::~GravityBlock() {} Object::Ptr GravityBlock::clone() const { @@ -37,11 +37,17 @@ void GravityBlock::prepareDraw(ResourceManager& resources) { } void GravityBlock::activate(Game& game, Object::Ptr object) { + // on ne peut utiliser le bloc qu'une seule fois + if (used) { + return; + } + Block::activate(game, object); // lorsque le bloc est activé, il transmet son // sens de gravité au niveau game.setGravityDirection(gravity_direction); + used = true; } unsigned int GravityBlock::getTypeId() const {