Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2011, 10:17:10 PM (14 years ago)
Author:
dafrick
Message:

Some simplification.

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

Legend:

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

    r8566 r8567  
    9191        if(this->activeStone_ != NULL)
    9292        {
    93             std::pair<bool, TetrisStone*> valid = this->isValidStonePosition(this->activeStone_, this->activeStone_->getPosition());
    94             if(!valid.first)
     93            if(!this->isValidStonePosition(this->activeStone_, this->activeStone_->getPosition()))
    9594            {
    9695                this->activeStone_->setVelocity(Vector3::ZERO);
    97                 if(valid.second != NULL)
    98                 {
    99                     Vector3 position = Vector3(this->activeStone_->getPosition().x, valid.second->getPosition().y+this->center_->getStoneSize(), this->activeStone_->getPosition().z);
    100                     this->activeStone_->setPosition(position);
    101                 }
    10296                this->createStone();
    10397                this->startStone();
     
    129123    }
    130124
    131     std::pair<bool, TetrisStone*> Tetris::isValidStonePosition(TetrisStone* stone, const Vector3& position)
     125    bool Tetris::isValidStonePosition(TetrisStone* stone, const Vector3& position)
    132126    {
    133127        assert(stone);
    134128
    135         std::pair<bool, TetrisStone*> valid = std::pair<bool, TetrisStone*>(true, NULL);
    136 
    137129        if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level
    138130        {
    139             valid.first = false;
    140131            stone->setPosition(Vector3(stone->getPosition().x, this->center_->getStoneSize()/2.0, stone->getPosition().z));
     132            return false;
    141133        }
    142134
     
    150142            if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize()))
    151143            {
    152                 valid.first = false;
    153                 valid.second = *it;
    154                 return valid;
     144                this->activeStone_->setPosition(Vector3(this->activeStone_->getPosition().x, currentStonePosition.y+this->center_->getStoneSize(), this->activeStone_->getPosition().z));
     145                return false;
    155146            }// This case applies if the stones overlap partially vertically
    156147        }
    157148
    158         return valid;
     149        return true;
    159150    }
    160151
  • code/branches/presentation/src/modules/tetris/Tetris.h

    r8566 r8567  
    7878            void createStone(void);
    7979            void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
    80             std::pair<bool, TetrisStone*> isValidStonePosition(TetrisStone* stone, const Vector3& position);
     80            bool isValidStonePosition(TetrisStone* stone, const Vector3& position);
    8181           
    8282            PlayerInfo* player_;
Note: See TracChangeset for help on using the changeset viewer.