void TetrisBoard::timerEvent(QTimerEvent *event){ if (event->timerId() == timer.timerId()) { if(!tetris.isPaused()){ if(lineDownTimeoutEnabled)tetris.timeoutElapsed(); timer.start(tetris.getTimeoutTime(), this); if(!invisible)refreshGUI(); } } else if (event->timerId() == borisTimer.timerId()) { if(tetris.hasStarted() && !tetris.isGameOver() && !tetris.isPaused() && borisIsPlaying){ boris.tick(); if(!invisible)refreshGUI(); } if (!tetris.hasStarted() && autoPlay){ start(); } } else { QFrame::timerEvent(event); } if(tetris.isGameOver() && !gameOver){ gameOver = true; onGameOver(); if (autoPlay && !(autoStopEnabled && gamesPlayed >= autoStopGames)){ start(); } } }
void LDZGameLayer::gameEnd(float high){ if (high>0) { Sprite* mark = Sprite::createWithSpriteFrameName("endline.png"); mark->setPosition(_mapSize.width/2, high); this->addChild(mark); } if (_mainC->getPositionY() > _upLimit->getPositionY() ) { onGameOver(false); }else if( _mainC->getPositionY() < _downLimit->getPositionY()){ onGameOver(true); }else{ CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("pass.wav"); onGamePass(); } }
//Checks if game is over and handles the result void Game::OnLoop() { bool emptyCells = haveEmptyCells(); //If playing against computer and it is AI turn and there are still empty grid cells if (!roundOver && gameType == 1 && currentPlayer == 1 && emptyCells) { aiMove(); } checkForWin(); if (!roundOver && emptyCells) { return; } //No empty cells left, check for win or draw onGameOver(); };