[Orxonox-commit 3892] r8566 - code/branches/presentation/src/modules/tetris
dafrick at orxonox.net
dafrick at orxonox.net
Tue May 24 22:12:42 CEST 2011
Author: dafrick
Date: 2011-05-24 22:12:42 +0200 (Tue, 24 May 2011)
New Revision: 8566
Modified:
code/branches/presentation/src/modules/tetris/Tetris.cc
code/branches/presentation/src/modules/tetris/Tetris.h
code/branches/presentation/src/modules/tetris/TetrisStone.cc
Log:
Fixing another bug.
Modified: code/branches/presentation/src/modules/tetris/Tetris.cc
===================================================================
--- code/branches/presentation/src/modules/tetris/Tetris.cc 2011-05-24 19:59:01 UTC (rev 8565)
+++ code/branches/presentation/src/modules/tetris/Tetris.cc 2011-05-24 20:12:42 UTC (rev 8566)
@@ -105,16 +105,14 @@
}
}
- std::pair<bool, TetrisStone*> Tetris::isValidMove(TetrisStone* stone, const Vector3& position)
+ bool Tetris::isValidMove(TetrisStone* stone, const Vector3& position)
{
assert(stone);
- std::pair<bool, TetrisStone*> valid = std::pair<bool, TetrisStone*>(true, NULL);
-
if(position.x < this->center_->getStoneSize()/2.0) //!< If the stone touches the left edge of the level
- valid.first = false;
+ return false;
else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level
- valid.first = false;
+ return false;
for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
{
@@ -123,17 +121,11 @@
const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
- if((position.x == currentStonePosition.x) && (position.y == currentStonePosition.y))
- {
- stone->setVelocity(Vector3::ZERO);
- this->createStone();
- this->startStone();
- valid.first = false;
- return valid;
- }// This case applies if the stones overlap completely
+ if((position.x == currentStonePosition.x) && abs(position.y-currentStonePosition.y) < this->center_->getStoneSize())
+ return false;
}
- return valid;
+ return true;
}
std::pair<bool, TetrisStone*> Tetris::isValidStonePosition(TetrisStone* stone, const Vector3& position)
Modified: code/branches/presentation/src/modules/tetris/Tetris.h
===================================================================
--- code/branches/presentation/src/modules/tetris/Tetris.h 2011-05-24 19:59:01 UTC (rev 8565)
+++ code/branches/presentation/src/modules/tetris/Tetris.h 2011-05-24 20:12:42 UTC (rev 8566)
@@ -68,7 +68,7 @@
PlayerInfo* getPlayer(void) const; //!< Get the player.
- std::pair<bool, TetrisStone*> isValidMove(TetrisStone* stone, const Vector3& position);
+ bool isValidMove(TetrisStone* stone, const Vector3& position);
protected:
virtual void spawnPlayersIfRequested(); //!< Spawns player.
Modified: code/branches/presentation/src/modules/tetris/TetrisStone.cc
===================================================================
--- code/branches/presentation/src/modules/tetris/TetrisStone.cc 2011-05-24 19:59:01 UTC (rev 8565)
+++ code/branches/presentation/src/modules/tetris/TetrisStone.cc 2011-05-24 20:12:42 UTC (rev 8566)
@@ -81,10 +81,9 @@
{
const Vector3& position = this->getPosition();
Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
- if(!this->tetris_->isValidMove(this, newPos).first)
+ if(!this->tetris_->isValidMove(this, newPos))
return;
- //this->previousPosition_ = position;
this->setPosition(newPos);
this->delay_ = true;
this->delayTimer_.startTimer();
More information about the Orxonox-commit
mailing list