Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 14, 2012, 10:03:54 PM (13 years ago)
Author:
jo
Message:

Almost playable :-) Two obvious bugs are remaining concerning rotating a brick and collision detection.

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

Legend:

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

    r9087 r9089  
    2525 *      Johannes Ritz
    2626 *
    27  *BUG a) double stone model (@ brick's location the stone's model is duplicated. Why does the brick have a model attached to it.)
    28  *BUG b) the brick is set the wrong way after a (brick-brick) collision, if the brick was turned
     27 *
     28 *BUG b) the falling brick is set the wrong way after a (brick-brick) collision, if the falling brick was turned
    2929 *BUG c) destroying the old stones causes segfault -> WeakPointer as solution ?
    30  *BUG
     30 *BUG d) wrong collision detection: sometimes stones "bounce off"
     31 *BUG e) multiple rows are not cleared in one round
    3132 *
    3233 *TASK a) give points for winning
     
    3536 *TASK d) save the highscore
    3637 *TASK e) eye candy
     38 *TASK f) increasing speed
    3739 */
    3840
     
    181183        for(std::vector<TetrisStone*>::const_reverse_iterator it = this->stones_.rbegin(); it != this->stones_.rend(); ++it)
    182184        {
    183             if(this->activeBrick_->contains(*it))
     185            if(this->activeBrick_->contains(*it))//skip the moving brick' stones
    184186                continue;
    185187            //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount());
     
    187189            //!< Saves the position of the currentStone
    188190
     191            //filter out cases where the falling stone is already below a steady stone
     192            if(position.y < currentStonePosition.y - this->center_->getStoneSize()/2.0f)
     193                continue;
    189194            if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize()))
    190195            {
     
    274279    {
    275280        this->activeBrick_->setVelocity(Vector3::ZERO);
     281        if(this->activeBrick_ != NULL)
     282        {
     283            this->player_->stopControl();
     284        }
     285
    276286        this->cleanup();
    277287
     
    343353
    344354        // Apply the stone template to the stone.
    345         brick->addTemplate(this->center_->getStoneTemplate()); // TODO: find error concerning the cameras
     355        brick->addTemplate(this->center_->getBrickTemplate());
    346356
    347357        // Attach the brick to the Centerpoint and set the position of the brick to be at the top middle.
     
    386396    {
    387397        unsigned int correctPosition = 0;
    388                 orxout()<< "clear full rows ************ " <<endl;
    389398        unsigned int stonesPerRow = 0;
    390399        for (unsigned int row = 0; row < this->center_->getHeight(); row++)
     
    395404                correctPosition = static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize());
    396405                if(correctPosition == row)
    397                         stonesPerRow++;
    398                 if(stonesPerRow == this->center_->getWidth())
    399                     {orxout()<< "CANDIDATE FOUND in row " << row <<endl; clearRow(row);}
     406                {
     407                    stonesPerRow++;
     408                    if(stonesPerRow == this->center_->getWidth())
     409                    {
     410                        clearRow(row);
     411                        this->playerScored(this->player_);
     412                    }
     413                }
     414
    400415            }
    401416
     
    404419
    405420    void Tetris::clearRow(unsigned int row)
    406     {//std::vector<int>::iterator it = v.begin()
     421    {// clear the full row
    407422        for(std::vector<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
    408423        {
    409424            if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
    410                 (*it)->setPosition(Vector3(-10,-10,0));
     425                (*it)->setPosition(Vector3(-50,-50,100));
    411426                //{(*it)->destroy(); this->stones_.erase(it); orxout()<< "destroy row "<<endl;}//experimental
    412427        }
    413         for(std::vector<TetrisStone*>::const_reverse_iterator it2 = this->stones_.rbegin(); it2 != this->stones_.rend(); ++it2)
    414         {
    415             /*if(static_cast<unsigned int>(((*it2)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
    416                 (*it2)->setPosition((*it2)->getPosition()-Vector3(0,1,0));//*/
     428      // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
     429        for(std::vector<TetrisStone*>::iterator it2 = this->stones_.begin(); it2 != this->stones_.end(); ++it2)
     430        {
     431            if(static_cast<unsigned int>(((*it2)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
     432                (*it2)->setPosition((*it2)->getPosition()-Vector3(0,10,0));
    417433        }
    418434
  • code/branches/pCuts/src/modules/tetris/TetrisBrick.h

    r9085 r9089  
    101101            Timer rotationTimer_; ///!< This timer is used to filter out multiple rotation inputs.
    102102            Tetris* tetris_; //<! The Tetris class is responsible to initialize this value.
    103            // TetrisCenterpoint* center_;
    104103
    105104    };
Note: See TracChangeset for help on using the changeset viewer.