Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9330


Ignore:
Timestamp:
Jul 22, 2012, 7:23:51 PM (12 years ago)
Author:
landauf
Message:

added deterministic stop criterion to end tetris match (independent of time)

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

Legend:

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

    r9329 r9330  
    7474
    7575        this->player_ = NULL;
    76         this->endGameCriteria_ = 0.0f;
    7776        this->setHUDTemplate("TetrisHUD");
    7877        this->futureBrick_ = 0;
     
    117116        if((this->activeBrick_ != NULL)&&(!this->hasEnded()))
    118117        {
    119             this->endGameCriteria_ += dt;
    120118            if(!this->isValidBrickPosition(this->activeBrick_))
    121119            {
     
    125123                this->activeBrick_->releaseStones(this->center_);
    126124                this->findFullRows();
    127                 if(this->endGameCriteria_ < 0.1f) //end game if two bricks are created within a 0.1s interval.
    128                     this->end();
    129                 else
    130                     this->startBrick();
    131                 this->endGameCriteria_ = 0.0f;
     125                this->startBrick();
    132126            }
    133127        }
     
    378372        // create a new future brick
    379373        this->createBrick();
     374
     375        // check if the new brick is in a valid position, otherwise end the game
     376        if (!this->isValidBrickPosition(this->activeBrick_))
     377            this->end();
    380378    }
    381379
  • code/branches/presentation2012merge/src/modules/tetris/Tetris.h

    r9329 r9330  
    9797
    9898            Timer starttimer_; //!< A timer to delay the start of the game.
    99             float endGameCriteria_; //<! Works as a timer which is resetted, whenever a brick is created.
    10099    };
    101100}
Note: See TracChangeset for help on using the changeset viewer.