//private void ReversiGame::setBoard(QSharedPointer<ReversiBoard> nBoard) { if (nBoard.isNull()) return; ReversiBoard * raw = nBoard.data(); connect(raw, SIGNAL(moveMade(CELL_STATE,CELL_STATE)), this, SLOT(handleTurnTaken(CELL_STATE,CELL_STATE))); connect(raw, SIGNAL(moveMade(CELL_STATE,CELL_STATE)), this, SIGNAL(turnTaken(CELL_STATE,CELL_STATE))); connect(raw, SIGNAL(gameOver(CELL_STATE)), this, SLOT(handleGameOver(CELL_STATE))); connect(raw, SIGNAL(gameOver(CELL_STATE)), this, SIGNAL(gameOver(CELL_STATE))); connect(raw, SIGNAL(countChanged(quint16,quint16)), this, SLOT(handleScoreChanged(quint16,quint16))); connect(raw, SIGNAL(countChanged(quint16,quint16)), this, SIGNAL(scoreChanged(quint16,quint16))); this->board = nBoard; }
void Game::onTouchEnded(Touch* touch, Event* unused_event) { Point endTouch = touch->getLocation(); endX = beginX-endTouch.x; endY = beginY-endTouch.y; if (abs(endX) > abs(endY)) { if(endX + 5>0){ if (left()) { createCardNumber(); gameOver(); } }else { if (right()) { createCardNumber(); gameOver(); } } }else if (abs(endX)<abs(endY)){ if (endY+5>0) { if (down()) { createCardNumber(); gameOver(); } }else{ if (up()) { createCardNumber(); gameOver(); } } } }
void MainWindow::validateConnection() { if(ui->IPAddress->text().length() < 7) { QMessageBox msg; msg.setWindowTitle("Error"); msg.setText("Skřítek v počítači přenesl data IP adresy a zjistil, že je prázdná nebo neni úplná."); msg.setIcon(QMessageBox::Information); msg.exec(); return; } if(ui->ServerPort->text().length() < 1) { QMessageBox msg; msg.setWindowTitle("Error"); msg.setText("Skřítek v počítači přenesl data cílového portu a zjistil, že je port prázdný. Port je třeba vyplnit, aby věděl kam má doručit data"); msg.setIcon(QMessageBox::Information); msg.exec(); return; } Client* client = new Client(ui->IPAddress->text(), ui->ServerPort->text().toInt(), this); if(client->connectToServer()) { IP = ui->IPAddress->text(); port = ui->ServerPort->text().toInt(); ui->action_rejoin->setEnabled(true); connect(ui->action_rejoin, SIGNAL(triggered()), this, SLOT(rejoin())); connect(client, SIGNAL(error(QString)), this, SLOT(showError(QString))); // Say hello to server client->sendPacket(Hello, QString("Hello"), client->toData(47777)); setCentralWidget(NULL); if(surface) delete surface; surface = new Surface(client, this); setCentralWidget(surface); connect(this, SIGNAL(key(Qt::Key&)), surface, SLOT(keyPress(Qt::Key&))); connect(surface, SIGNAL(foodEaten()), this, SLOT(updateScore())); connect(surface, SIGNAL(gameOver()), this, SLOT(gameOver())); score = -1; updateScore(); }
Controller* PlayField::createController() { // The client or server will overwrite this default configuration when // the network messages are interchanged m_battle_ships_configuration = Settings::severalShips() ? BattleShipsConfiguration::defaultMultipleShipsConfiguration(Settings::adjacentShips()): BattleShipsConfiguration::defaultSingleShipsConfiguration(Settings::adjacentShips()); Controller* controller = new Controller(this, m_player, m_battle_ships_configuration); connect(controller, SIGNAL(gameOver(Sea::Player)), this, SLOT(gameOver(Sea::Player))); connect(controller, SIGNAL(restartRequested()), this, SLOT(restartRequested())); connect(controller, SIGNAL(compatibility(int)), this, SLOT(setCompatibility(int))); connect(controller, SIGNAL(nickChanged(int,QString)), this, SLOT(updateNick(int,QString))); connect(controller, SIGNAL(turnChanged(int)), this, SLOT(changeTurn(int))); connect(controller, SIGNAL(playerReady(int)), this, SLOT(playerReady(int))); connect(controller, SIGNAL(restartPlacingShips(Sea::Player)), this, SLOT(restartPlacingShips(Sea::Player))); connect(controller, SIGNAL(startPlacingShips(int)), this, SLOT(startPlacingShips())); return controller; }
void GameLayer::roleJumpDownLogic() { /** 1, 先判断是否到地面下了 2, 检测右边的碰撞 3, 检测下面的碰撞 **/ float roleY = mRole->getPositionY(); roleY -= getRoleYSpeed(); if (roleY < getGroundHeight()) { gameOver(); CCLOG("正在下降, 撞地了"); return; } BarPipe *willCollisionBar = getWillCollisionBar(); if (isCollisionWithBar(COLL_STATE_RIGHT, willCollisionBar)) { gameOver(); CCLOG("正在下降, 右边发生碰撞"); return; } if (isCollisionWithBar(COLL_STATE_BOTTOM, willCollisionBar)) { gameOver(); CCLOG("正在下降, 下边发生碰撞"); return; } mRole->setPositionY(roleY); setRoleYSpeed(getRoleYSpeed() + getRoleAccelerate()); }
bool SnakeLayer::testDie() { LineNode* n = static_cast<LineNode*>(*lineGroup->getChildren().rbegin()); Point end = n->getEnd(); if (!bounds.containsPoint(end)) { gameOver(); return true; } for (int i = 0; i < lineGroup->getChildrenCount(); i++) { LineNode* li = static_cast<LineNode*>(*(lineGroup->getChildren().begin() + i)); for (int j = 0; j < lineGroup->getChildrenCount(); j++) { if (abs((int) i - (int) j) <= 1) continue; LineNode* lj = static_cast<LineNode*>(*(lineGroup->getChildren().begin() + j)); if (linesIntersect( li->getStart(), li->getEnd(), lj->getStart(), lj->getEnd())) { gameOver(); return true; } } } return false; }
void World::update() { if (_playerBase == nullptr) { gameOver(); } else if (_playerTank == nullptr) { if (_playerLife > 0) { _playerLife--; Tank *tank = new Tank; tank->setPos(_spawnPos[0]); _playerTank = tank; _tankList.append(tank); } else { gameOver(); } } else if (_tankList.size() < 3) { if (_enemyLife > 0) { _enemyLife--; Tank *tank = new Tank; tank->setTeam(1); tank->setPos(_spawnPos[_tankList.size()]); tank->setAngle(2); _tankList.append(tank); } } if (_isVideo) { playVideo(); } else { moveBots(); } updateTanks(); moveBullets(); }
void KReversiView::setGame(KReversiGame *game) { // disconnect signals from previous game if they exist, // we are not interested in them anymore if (m_game) { disconnect(m_game, SIGNAL(boardChanged()), this, SLOT(updateBoard())); disconnect(m_game, SIGNAL(moveFinished()), this, SLOT(gameMoveFinished())); disconnect(m_game, SIGNAL(gameOver()), this, SLOT(gameOver())); disconnect(m_game, SIGNAL(whitePlayerCantMove()), this, SLOT(whitePlayerCantMove())); disconnect(m_game, SIGNAL(blackPlayerCantMove()), this, SLOT(blackPlayerCantMove())); delete m_game; } m_game = game; if (m_game) { connect(m_game, SIGNAL(boardChanged()), this, SLOT(updateBoard())); connect(m_game, SIGNAL(moveFinished()), this, SLOT(gameMoveFinished())); connect(m_game, SIGNAL(gameOver()), this, SLOT(gameOver())); connect(m_game, SIGNAL(whitePlayerCantMove()), this, SLOT(whitePlayerCantMove())); connect(m_game, SIGNAL(blackPlayerCantMove()), this, SLOT(blackPlayerCantMove())); m_game->setDelay(m_delay); } m_hint = KReversiMove(); updateBoard(); }
void PD_UI_DissBattle::incrementConfidence(float _value){ // Value > 0 means the player is attacking if(_value > 0) { // Factor in enemy's defense _value *= playerAttackMultiplier * playerComboMultiplier; playerComboMultiplier += playerComboIncrement; }else { _value *= enemyAttackMultiplier * enemyComboMultiplier; enemyComboMultiplier += enemyComboIncrement; } sweet::Event * e = new sweet::Event("confidence"); e->setFloatData("value", _value); eventManager->triggerEvent(e); confidence = confidence + _value > 100.f ? 100.f : confidence + _value < 0.f ? 0.f : confidence + _value; if(confidence <= 0){ // Check if out of lives if(lives.size() <= 0){ gameOver(false); }else{ lostLives.push_back(lives.back()); lives.pop_back(); lostLives.back()->background->mesh->replaceTextures(lifeTokensCrossed.at(lives.size())); confidence = 50.f; } } if(confidence >= 100){ gameOver(true); } }
void Game::dealGameResult(GameResult game_result) { switch (game_result) { case Game::Result_Success: LOGD(TAG,"------------------------------Result_Success-------------------"); gameArea->removeFromParentAndCleanup(true); gameArea = nullptr; if (step < 2){ if (step == 0){ starAtl->gotoFrameAndPlay(0, starEndFrame[0],false); } else { starAtl->gotoFrameAndPlay(starEndFrame[step - 1] + 1, starEndFrame[step], false); } step++; gameUIMgr->resetAll(); gameArea = GameArea::create(gameUIMgr, guanQiaName[step]); gameNode->addChild(gameArea, Game::ZORDER_AREA, Game::TAG_AREA); } else { //成功 step++; gameOver(true); } break; case Game::Result_Fail: LOGD(TAG, "------------------------------Result_Fail-------------------"); gameOver(false); break; default: break; } }
static void eventHandler(objectKey key, windowEvent *event) { int x = 0; int y = 0; // Check for window events. if (key == window) { // Check for window refresh if (event->type == EVENT_WINDOW_REFRESH) refreshWindow(); // Check for the window being closed else if (event->type == EVENT_WINDOW_CLOSE) windowGuiStop(); } // Only go through the array of buttons if the event was a mouse click else if (event->type == EVENT_MOUSE_LEFTUP) { for (x = 0; x < GRID_DIM; x++) { for (y = 0; y < GRID_DIM; y++) { if (key == gridButtons[x][y]) { // If this spot is empty, invoke the clickEmpties function if (mineField[x][y] == -1) { clickEmpties(x, y); } else { if (mineField[x][y] == 9) { gameOver(0); } else { uncover(x, y); if (numUncovered >= ((GRID_DIM * GRID_DIM) - NUM_MINES)) { gameOver(1); } } } return; } } } } }
MainWindow::MainWindow() { setCaption(tr("GA Bots " VERSION)); initActions(); initMenuBar(); initToolBar(); initStatusBar(); initGABotDoc(); initView(); ViewToolBar->setOn(true); ViewStatusBar->setOn(true); //ViewGame->setOn(true); connect(GABotDoc, SIGNAL(gameReady(bool)), this, SLOT(slotGameReady(bool))); connect(GABotDoc, SIGNAL(teamAScores()), View, SLOT(slotScoreA())); connect(GABotDoc, SIGNAL(teamBScores()), View, SLOT(slotScoreB())); connect(GABotDoc, SIGNAL(clearScores()), View, SLOT(slotClearScores())); connect(GABotDoc, SIGNAL(moveTeamA(Coordinate, Coordinate)), View, SLOT(slotMoveTeamA(Coordinate, Coordinate))); connect(GABotDoc, SIGNAL(moveTeamB(Coordinate, Coordinate)), View, SLOT(slotMoveTeamB(Coordinate, Coordinate))); connect(GABotDoc, SIGNAL(turnTeamA(Coordinate, Direction)), View, SLOT(slotTurnTeamA(Coordinate, Direction))); connect(GABotDoc, SIGNAL(turnTeamB(Coordinate, Direction)), View, SLOT(slotTurnTeamB(Coordinate, Direction))); connect(GABotDoc, SIGNAL(moveBall(Coordinate,Coordinate)), View, SLOT(slotMoveBall(Coordinate,Coordinate))); connect(GoGame, SIGNAL(activated()), this, SLOT(slotGoGame())); connect(GoGame, SIGNAL(activated()), GABotDoc, SLOT(slotStartTimer())); connect(StopGame, SIGNAL(activated()), GABotDoc, SLOT(slotStopTimer())); connect(StopGame, SIGNAL(activated()), this, SLOT(slotStopGame())); connect(View, SIGNAL(valueChanged(int)), this, SLOT(slotTickInterval(int))); connect(GABotDoc, SIGNAL(clearField()), View, SLOT(slotClearField())); connect(ResetScreen, SIGNAL(activated()), View, SLOT(slotClearField())); //not sure if we should clear the field whenever regenerating the team // connect(TeamAGenerate,SIGNAL(activated()), View, SLOT(slotClearField())); // connect(TeamBGenerate,SIGNAL(activated()), View, SLOT(slotClearField())); connect(GABotDoc, SIGNAL(gameOver()), View, SLOT(slotClearField())); connect(GABotDoc, SIGNAL(gameOver()), View, SLOT(slotClearScores())); connect(GABotDoc, SIGNAL(gameOver()), this, SLOT(slotGameOver())); }
void AIManager::Think(float time) { if (OgreTrip::level <= 5) { spawnAnimalCD = 3 - OgreTrip::level*0.2; spawnStoneCD = 5 - OgreTrip::level*0.4; } spawnAnimal(time); spawnStone(time); for (std::size_t i = 0; i < mFoodList.size(); i++ ) { if (mFoodList[i]->Think(time)) { delete mFoodList[i]; mFoodList.erase(mFoodList.begin()+i); } } for (int m = 0; m < animalNum; m++) { for (std::size_t i = 0; i < mAnimalList[m].size(); i++ ) { if (mAnimalList[m][i]->Think(time)) { gameOver(); break; } if (mAnimalList[m][i]->getPosition().z < World::getSingleton()->getCarNode()->getPosition().z -100) { delete mAnimalList[m][i]; mAnimalList[m].erase(mAnimalList[m].begin()+i); } } } for (std::size_t i = 0; i < mStoneList.size(); i++ ) { if (mStoneList[i]->Think(time)) { gameOver(); break; } if (mStoneList[i]->getPosition().z < World::getSingleton()->getCarNode()->getPosition().z -100) { delete mStoneList[i]; mStoneList.erase(mStoneList.begin()+i); } } }
/***************************************************************************** Function: playGame Inputs: node for this board, plus player (to get to this board) Returns: nothing Description: play the game of TTT *****************************************************************************/ void playGame (NodeP node, char player) { int bestChild; /* which of the children to move to */ NodeP nextNode; /* the node for that child */ if (!gameOver(node)) { /* if we're not yet done */ printNode(node); /* print the board and scores */ printf("Next move by player %c\n", player); lookahead(node, player, DEPTH); /* construct the lookahead tree */ bestChild = bestMove(node, player); /* the best move for the player */ nextNode = node->offspring[bestChild]; /**** should free offspring of bestChild, plus all the other children */ MoveCount++; playGame(nextNode, opponent(player)); /* recurse */ } else { /* game is over */ printf("Final board is: \n"); printNode(node); } } /* end playGame */
void ofApp::updateEnemies( float dt ) { deque<ofPtr<DrawGame::CircleSprite> >::iterator itEnemy; for(itEnemy=Enemies.begin(); itEnemy!=Enemies.end(); itEnemy++) { ofPtr<DrawGame::CircleSprite> En = *itEnemy; bool bWhite = En->getbWhite(); if(!bWhite) { En->changeSize(dt*EnemyGrowthrate); En->changeRot(dt*90.0f); if(En->getSize()>100.0f) { HP -= HPBeatAmt2; if(HP<=0.0f) { eraseEnemy(itEnemy,"Beat2"); GameOverString = "You're Eaten!"; gameOver(); } break; } } else { En->changeSize(-dt*EnemyGrowthrate); En->changeRot(-dt*90.0f); } } }
//-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ if(!bGameRunning) { if(button==0) { pRetryBtn->dragged(x,y); } return; } MousePos = ofVec2f(x,y); if(0==button) { ofVec2f PosLast = pPlayer->getPosition(); ofVec2f PosNow = ofVec2f(x,y); float dist = PosNow.distance(PosLast); float sizePlayer = pPlayer->getSize(); float DeltaHP = -sizePlayer*dist*0.001f*HPDecSpd; HP += DeltaHP; if(HP<=0.0f) { GameOverString = "You're Exhausted!"; gameOver(); } pPlayer->moveTo(PosNow); } }
// ------------------------------------------------------------------------- // Strategy2005CL::emergencyStop // ------------------------------------------------------------------------- // Quand le match est arrete avant la fin par l'arret d'urgence // si on est arrete a presque 1 minute 30, c'est la fin du match // ------------------------------------------------------------------------- void Strategy2005CL::emergencyStop() { matchIsFinished_ = true; Move->stop(); if (Timer->time()>TIME_MATCH*0.9) { // fin du match normale gameOver(); } else { // on a arrete le robot avant la fin du match LOG_WARNING("EMERGENCY_STOP is pressed\n"); Lcd->print("EMERGENCY STOP"); Lcd->setLed(LCD_LED_GREEN, LCD_LED_OFF); Lcd->setLed(LCD_LED_RED, LCD_LED_BLINK); Log->stopMatch(); // unregister game over and emergency stop exceptions Events->registerCallback(EVENTS_EMERGENCY_STOP, this, NULL, ""); Events->registerCallback(EVENTS_GAME_OVER, this, NULL, ""); Events->registerCallback(EVENTS_TIMER_ALERT, this, NULL, ""); Move->emergencyStop(); MvtMgr->reset(); //IOMGR->emergencyStop(); Log->closeLogFile(); Sound->play(SOUND_ANORMAL_EMERGENCY_STOP, SND_PRIORITY_URGENT); sleep(2); if (menu("SophiaTeam is\nthe best team!")) { Sound->play(soundVictory_); } else { Sound->play(soundDefeat_); } } }
// ---------------------------------------------------------------------------- // Strategy2005CL::checkEndEvents // ---------------------------------------------------------------------------- // Execute les commandes en cas d'arret d'urgence, de fin de match // Retourne false si la strategy est terminee et qu'il faut retourner au menu // endEvt=true si l'evenement a ete catche // ---------------------------------------------------------------------------- bool Strategy2005CL::checkEndEvents() { if (matchIsFinished_) { return true; } #ifdef STOP_ON_EMERGENCY_STOP if (Events->isInWaitResult(EVENTS_EMERGENCY_STOP) || Events->check(EVENTS_EMERGENCY_STOP)) { emergencyStop(); return true; } else #endif if (Events->isInWaitResult(EVENTS_GAME_OVER) || Events->check(EVENTS_GAME_OVER)) { gameOver(); return true; } else if (Events->isInWaitResult(EVENTS_TIMER_ALERT) || Events->check(EVENTS_TIMER_ALERT)) { return timerAlert(); } else if (Events->isInWaitResult(EVENTS_USER_ABORT) || Events->check(EVENTS_USER_ABORT)) { return true; } return false; }
void MainWindow::onTimerTick() { Figure newFig = *cur_figure; newFig.setPosition(newFig.getPosition().x(), cur_figure->getPosition().y() + 1); if (m_cup.hasPlace(newFig)) { delete cur_figure; cur_figure = new Figure(newFig); } else { m_cup.putFigure(*cur_figure); m_score += m_cup.clearedLines() * 100 + (m_cup.clearedLines() > 0 ? 100 : 0); if (m_score >= NEXTLEVELSCORE) { m_score = 0; if (m_level < MAX_LEVEL) m_level++; else endGame(); init(); } delete cur_figure; cur_figure = new Figure(m_cup); if (m_cup.filled()) gameOver(); } draw(); }
void MainContentComponent::buttonClicked (Button *button) { if (button == &startButton) { removeChildComponent(&startButton); // String myString = (chooseMidi->getSelectedFile(1)).getFullPathName(); // std::cout<<myString<<std::endl; // myObstacle = new ObstacleComponent((myString.toStdString()).c_str()); // ypos = myObstacle->getInitialHeight()-35; processingAudio = new AudioProcess(myObstacle->getStartNote()+12); deviceManager.initialise( 1, 2, 0, true, String::empty, 0 ); deviceManager.addAudioCallback(processingAudio); gameStart(); } if (button == &stopButton) { gameOver(); } if (button == &restartButton) { removeAllChildren(); stopTimer(); reset(); gameStart(); } }
void MainContentComponent::collisionDetection() { if ( obsX < (0.15*winWidth + 80) ) { if ( ( curObsPos + 50 < ypos || (curObsPos -50) > ypos ) && curObsPos > 0 ){ //Within one semitone difference addAndMakeVisible(hitLabel); copterHits++; hitsDisplay = "Number of hits: "; hitsDisplay += copterHits; numHitsLabel.setText(hitsDisplay, dontSendNotification); } else if( curObsPos != -1 ){ removeChildComponent(&hitLabel); } } if(copterHits > 50) { gameOver(); } if( copterHits%10 == 0 && copterHits > 0 && (processingAudio->getTimeElapsed() - newlifeTime) > 1.0f){ newLife(); } }
void MainWindow::on_btnNext_clicked() { if(!solarSystem->setNextActive()) { gameOver(); } }
void main() { int i,j,boxidx; int driver=DETECT, mode=0; randomize(); //registerbgidriver(EGAVGA_driver); initgraph(&driver,&mode,""); xyz: do { menu(); init(); boxidx=random(7); FORCOLOR2=random(7)+1; for(j=0;j<4;j++) for(i=0;i<4;i++) box2[j][i]=BOX[boxidx][j][i]; do { getMessage(); dispatchMessage(); }while(!gameOver()); highscore(); OVER(); getch(); }while(1); }
int Game::run() { while ((level->getSpawnList().size() > 0 || monsters.size() > 0) || ((time - endTime) < 5)) { //cout << "time = " << time << " endTime = " << endTime << endl; //cout.precision(3); //cout << "t : " << time << " s\tpos : " << pos / blockSize << " block / " << pos << " pix" << endl; if (loop() == 0) // No more players return (1); if (gameOver()) return (2); // Loop time stabilization to REFRESH ms double targetTime = round(time * 1000 / REFRESH + 1) * REFRESH / 1000; sleep(static_cast<int>((targetTime - time) * 1000)); last = time; time = (now() - begin); pos = time * BLOCKS_PER_SECOND * blockSize; // Detect end of level if (!(level->getSpawnList().size() > 0 || monsters.size() > 0) && endTime < 0) { endTime = time; string t; t += CMD_NLVL; sendAll(t); } } return (0); }
void placeKey() { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { if (key.t[x*4+y] == 1) { if (key.r+x <=4) gameOver(); matrix[key.r+x][key.c+y] = 1; colorMatrix[key.r+x][key.c+y] = key.color; } } } checkForScore(); key.t = next.t; key.color = next.color; key.r = 0; key.c = 3; int nextType = qran_range(0,7); int *n; n = tetriminos[nextType]; next.t = n; next.color = colors[nextType]; drawMatrix(); setNextPiece(next); droppedYet = 0; }
void Game::handleGameConditions() { if(conditionTimer->Ticking()) { conditionTimer->tick(); if(conditionTimer->Condition()) { switch(curCondition) { case CONDITION_RESTART: restartGame(); break; case CONDITION_GAME_OVER: gameOver(); break; case CONDITION_NO_CONDITION: throw 0; //someone made a mistake break; } /*Reset everything*/ curCondition = CONDITION_NO_CONDITION; conditionTimer->stop(); conditionTimer->reset(); } } }
void GameLogic::setupNewComputers() { QRectF const scene = mView->sceneRect(); mAgent = new WorkStation(mGenerator, stations::hacker); mView->setItemToScene(mAgent); mAgent->setPos(scene.right() - 110, scene.center().y()); connect(this, SIGNAL(newWorkingDay()), mAgent, SLOT(dataTransfer())); mDevelopers = new WorkStation(mGenerator, stations::target); mView->setItemToScene(mDevelopers); mDevelopers->setPos(scene.left() + 10, scene.center().y() - scene.height() / 10); connect(mDevelopers, SIGNAL(secretDepartInfected()), this, SLOT(gameOver())); mUsersCount = (mGenerator->rand() % (maxUsers - minUsers + 1)) + minUsers; for (int i = 0; i < mUsersCount; i++) { WorkStation *newStation = new WorkStation(mGenerator); mView->setItemToScene(newStation); mUsers.append(newStation); connect(this, SIGNAL(newWorkingDay()), newStation, SLOT(dataTransfer())); // dbl click event filter doesnt work on graphicsview items connect(this, SIGNAL(energyChanged(bool)), newStation, SLOT(energyChange(bool))); connect(newStation, SIGNAL(updated()), this, SLOT(startReloadTime())); } trafficReloadTime = (mUsersCount < maxUsers / 2)? 2 : 1; }
void App::newGame() { if (_game) delete _game; _game = new HexdameGame(this); _gameView = new HexdameView(_game); connect(_game, SIGNAL(gameOver()), this, SLOT(gameOver())); setBlackPlayer(_blackCombo->currentIndex()); setWhitePlayer(_whiteCombo->currentIndex()); _mainwindow->setCentralWidget(_gameView); _game->startNextTurn(); }
void SinglePlayerView::onDataError( int code, const QString& description ) { showMsg( description ); emit gameOver(); QTimer::singleShot( 10, this, SLOT( hideLoading() ) ); qDebug() << "Loading error" << code << ":" << description; }
/* ** Handle events received (arrows, space, esc...). */ void Gui::handleEvents() { int key = wgetch(m_win); if (key == -1) throw (NibError("ncurses_wgetch", "fail")); while (m_state == ENABLE) { while (key != ESCAPE && m_nibbler.isActive()) { if (key == KEY_LEFT) m_nibbler.turn_left(); if (key == KEY_RIGHT) m_nibbler.turn_right(); key = 0; while ((key = wgetch(m_win)) != ESCAPE && key != ' ' && m_nibbler.isActive() && key != KEY_LEFT && key != KEY_RIGHT); if (key == ' ') m_nibbler.boost(); } if (key == ESCAPE) m_nibbler.disable(); if (gameOver(key) == true) m_state = DISABLE; } }