Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Fixing another bug.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.