Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2011, 10:12:42 PM (13 years ago)
Author:
dafrick
Message:

Fixing another bug.

Location:
code/branches/presentation/src/modules/tetris
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/modules/tetris/Tetris.cc

    r8565 r8566  
    106106    }
    107107
    108     std::pair<bool, TetrisStone*> Tetris::isValidMove(TetrisStone* stone, const Vector3& position)
     108    bool Tetris::isValidMove(TetrisStone* stone, const Vector3& position)
    109109    {
    110110        assert(stone);
    111111
    112         std::pair<bool, TetrisStone*> valid = std::pair<bool, TetrisStone*>(true, NULL);
    113        
    114112        if(position.x < this->center_->getStoneSize()/2.0)  //!< If the stone touches the left edge of the level
    115             valid.first = false;
     113            return false;
    116114        else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level
    117             valid.first = false;
     115            return false;
    118116
    119117        for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
     
    124122            const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
    125123
    126             if((position.x == currentStonePosition.x) && (position.y == currentStonePosition.y))
    127             {
    128                 stone->setVelocity(Vector3::ZERO);
    129                 this->createStone();
    130                 this->startStone();
    131                 valid.first = false;
    132                 return valid;
    133             }// This case applies if the stones overlap completely
    134         }
    135 
    136         return valid;
     124            if((position.x == currentStonePosition.x) && abs(position.y-currentStonePosition.y) < this->center_->getStoneSize())
     125                return false;
     126        }
     127
     128        return true;
    137129    }
    138130
  • code/branches/presentation/src/modules/tetris/Tetris.h

    r8565 r8566  
    6969            PlayerInfo* getPlayer(void) const; //!< Get the player.
    7070
    71             std::pair<bool, TetrisStone*> isValidMove(TetrisStone* stone, const Vector3& position);
     71            bool isValidMove(TetrisStone* stone, const Vector3& position);
    7272
    7373        protected:
  • code/branches/presentation/src/modules/tetris/TetrisStone.cc

    r8564 r8566  
    8282            const Vector3& position = this->getPosition();
    8383            Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
    84             if(!this->tetris_->isValidMove(this, newPos).first)
     84            if(!this->tetris_->isValidMove(this, newPos))
    8585                return;
    8686
    87             //this->previousPosition_ = position;
    8887            this->setPosition(newPos);
    8988            this->delay_ = true;
Note: See TracChangeset for help on using the changeset viewer.