Les blocs de gravité ne sont activables qu'une fois
This commit is contained in:
parent
608304f3d5
commit
3d74160669
|
@ -14,6 +14,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GravityDirection gravity_direction;
|
GravityDirection gravity_direction;
|
||||||
|
bool used;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
const unsigned int GravityBlock::TYPE_ID = 3;
|
const unsigned int GravityBlock::TYPE_ID = 3;
|
||||||
|
|
||||||
GravityBlock::GravityBlock() : Block() {}
|
GravityBlock::GravityBlock() : Block(), used(false) {}
|
||||||
GravityBlock::~GravityBlock() {}
|
GravityBlock::~GravityBlock() {}
|
||||||
|
|
||||||
Object::Ptr GravityBlock::clone() const {
|
Object::Ptr GravityBlock::clone() const {
|
||||||
|
@ -37,11 +37,17 @@ void GravityBlock::prepareDraw(ResourceManager& resources) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GravityBlock::activate(Game& game, Object::Ptr object) {
|
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);
|
Block::activate(game, object);
|
||||||
|
|
||||||
// lorsque le bloc est activé, il transmet son
|
// lorsque le bloc est activé, il transmet son
|
||||||
// sens de gravité au niveau
|
// sens de gravité au niveau
|
||||||
game.setGravityDirection(gravity_direction);
|
game.setGravityDirection(gravity_direction);
|
||||||
|
used = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GravityBlock::getTypeId() const {
|
unsigned int GravityBlock::getTypeId() const {
|
||||||
|
|
Loading…
Reference in New Issue