void Game::mousePressEvent(QMouseEvent *pe){ if(pe->buttons() == 1){ int x = pe->x()/50; int y = (500-pe->y())/50; if(arrayofpoints[x][y] != NULL){ if(activepoint != NULL) activepoint->active = 0; activepoint=arrayofpoints[x][y]; activepoint->active = 1; } else { if(activepoint != NULL){ ///////////////////////////////////////// if(movepoint(activepoint->x/50,activepoint->y/50,x,y)){ if(!checkarray()){ emit scoreChanged(); addpoint(); addpoint(); addpoint(); } checkarray(); emit scoreChanged(); } ///////////////////////////////////////// } } } if(pe->buttons() == 2){ if(activepoint){ activepoint->active = 0; activepoint = NULL; } } }
void GameWidget::shotTimeout() { bool paint = false; bool erase; TShots::iterator it = m_shots.begin(); while(it != m_shots.constEnd()) { erase = false; if (it->y < - 20) erase = true; else { int hitfactor = (it->level > 1)?100:1; TShips::iterator ship = m_ships.begin(); while (ship != m_ships.end()) { if (!ship->reg.intersects(it->reg)) { m_shotspreg += QRegion(ship->x, ship->y, 65, 65); m_ships.erase(ship); m_score += 10 * hitfactor; emit scoreChanged(m_score); m_shipTimeInt -= (float)4.9; if (it->level == 1) erase = true; break; // out of the ships search loop } ++ship; } if (m_bShowSoser && (!m_soserMask.intersects(it->reg))) { stopSoser(); m_shotspreg += QRegion(m_soserX, 0, m_soserX + SOSER_X_SIZE + 7, SOSER_Y_SIZE); m_score += 25 * hitfactor; emit scoreChanged(m_score); erase = true; } } it->moveUp(15); int x = it->x, y = it->y; paint = true; m_shotspreg += QRegion(x - 10, y - 10, 20, 35); if (erase) it = m_shots.erase(it); else ++it; } update(m_shotspreg); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setupSceneStateTransitions(); connect(&scene, SIGNAL(error(QString)), this, SLOT(handleError(QString))); connect(&scene, SIGNAL(warning(QString)), this, SLOT(handleWarning(QString))); connect(&scene, SIGNAL(notice(QString)), this, SLOT(handleNotice(QString))); connect(&score, SIGNAL(error(QString)), this, SLOT(handleError(QString))); connect(&score, SIGNAL(warning(QString)), this, SLOT(handleWarning(QString))); connect(&score, SIGNAL(notice(QString)), this, SLOT(handleNotice(QString))); connect(&scene, SIGNAL(userAction(UserAction)), &score, SLOT(userAction(UserAction))); connect(&score, SIGNAL(changed(ScoreChange)), &scene, SLOT(scoreChange(ScoreChange))); connect((ui->VoiceList), SIGNAL(userAction(UserAction)), &score, SLOT(userAction(UserAction))); connect(&score, SIGNAL(changed(ScoreChange)), (ui->VoiceList), SLOT(scoreChange(ScoreChange))); connect(ui->properSpinBox, SIGNAL(userAction(UserAction)), &score, SLOT(userAction(UserAction))); connect(&score, SIGNAL(changed(ScoreChange)), ui->properSpinBox, SLOT(scoreChanged(ScoreChange))); connect((ui->VoiceList), SIGNAL(voiceCheckedSignal(IdType,bool)), &scene, SLOT(voiceVisible(IdType,bool))); connect((ui->VoiceList), SIGNAL(voiceSelectedSignal(IdType)), &scene, SLOT(selectVoice(IdType))); ui->systemView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); ui->systemView->setScene(&scene); }
//game normal data accessor void DJGameUser::setScore( qint32 score ) { if ( m_score != score ) { m_score = score; emit scoreChanged( this ); } }
void DJGameUser::deltaScore( int delta ) { if ( delta ) { m_score += delta; emit scoreChanged( this ); } }
//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; }
//private void GameWindow::setGame(QSharedPointer<ReversiGame> game) { if (game.isNull()) return; //Force us to update the game's AI options this->handleAIOptionChange(this->options); this->ui->widget->setBoard(game->getBoard()); ReversiGame * raw = game.data(); connect(this->ui->widget, SIGNAL(cellClicked(BoardPos)), raw, SLOT(handleCellClicked(BoardPos))); connect(raw, SIGNAL(gameOver(CELL_STATE)), this, SLOT(handleGameOver(CELL_STATE))); this->game = game; connect(raw, SIGNAL(scoreChanged(quint16,quint16)), this, SLOT(handleCountChange(quint16,quint16))); }
///*** Run this such that there are 30 runs in a second, emulating frames ***/// void Game::timerEvent(QTimerEvent *event) { frameTimer++; score = player->getXP()*10; emit scoreChanged(score); if(!player->updatePlayer()) { gameOver = true; std::cout << "SNATHOEUSANOTH.\n"; repaint(); } for(int i=0;i<drones.size();i++) { drones.at(i)->updateEnemy(player->getLocation()); } for(int i=0;i<archers.size();i++) { archers.at(i)->updateEnemy(player->getLocation()); } checkCollision(); checkEnemyDeath(); spawnEnemies(); repaint(); }
void FrontServer::sendSignal(int rowId) { //QString temp; //temp.setNum(rowId); //QMessageBox::critical(0, "内部信号", "serve收到信号,显示球道号 " +temp + "\n\n"); emit scoreChanged(rowId); }
void KBlocksScene::addScore(int gameIndex, int lineCount) { if (!mSnapshotMode) { return; } maGameScoreList[gameIndex]->addScore(lineCount); emit scoreChanged(gameIndex, maGameScoreList[gameIndex]->getScorePoint(), maGameScoreList[gameIndex]->getLineCount(), maGameScoreList[gameIndex]->getGameLevel()); }
void KBounceGameWidget::newGame() { closeGame(); setCursor( m_vertical ? Qt::SizeVerCursor : Qt::SizeHorCursor ); m_level = 1; m_score = 0; emit levelChanged( m_level ); emit scoreChanged( m_score ); newLevel(); }
void ChessGame::emitLastMove() { int ply = m_moves.size() - 1; if (m_scores.contains(ply)) { int score = m_scores[ply]; if (score != MoveEvaluation::NULL_SCORE) emit scoreChanged(ply, score); } const auto& md = m_pgn->moves().last(); emit moveMade(md.move, md.moveString, md.comment); }
///*** If a player chooses to be an Assn, spawn it ***/// void Game::startAssassinGame() { player = new Assassin(); if (!gameStarted) { gameStarted = true; emit scoreChanged(score); emit levelChanged(level); gameOver = false; setMouseTracking(true); timerId = startTimer(33); spawnEnemies(); } }
void KBounceGameWidget::closeLevel() { m_bonus = 0; if ( m_board->filled() >= MIN_FILL_PERCENT ) { m_bonus = ( m_board->filled() - MIN_FILL_PERCENT ) * 2 * ( m_level + 5 ); } m_score += m_bonus; m_score += POINTS_FOR_LIFE * m_lives; emit scoreChanged( m_score ); m_clock->stop(); m_board->setPaused( true ); }
void TaskAnnotation::answerAnnotationTask(QList<int> answers){ int distance = 0; for(int i=0; i<5; i++){ int temp = abs(answers[i]-yValues[i]); distance += temp; } distance = 1000 - distance*5; if(distance > m_score) { m_score = distance*2; emit scoreChanged(m_score); } emit answeredChanged(false); }
void SpaceZombie::hit(float v1x, float v1y, float m1) { char msg[128]; sprintf(msg,"Before hit, direction: %f, %f", m_direction.x, m_direction.y); // CCLOG(msg); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("music/crash1.wav"); updateState2(); if(m_state2 == en_Floating) { float v2x = getSpeedX(); float v2y = getSpeedY(); m_direction.x = -m_direction.x; m_direction.y = -m_direction.y; m_speed = kZombieSpeedFlyAway; m_sprite->stopAllActions(); m_sprite->runAction(createFlyAwayAction()); m_state1 = en_ZombieFlyAway; scoreChanged(); sprintf(msg,"After hit, direction: %f, %f", m_direction.x, m_direction.y); //CCLOG(msg); } else if(m_state2 == en_InShield) { m_hp -= m1; if(m_hp <= 0) { m_facingLeft = v1x < 0 ? true : false; scoreChanged(); performDead(); } } }
int BaconDemo::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QFrame::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: scoreChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: levelChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: start(); break; case 3: pause(); break; case 4: showInstructions(); break; } _id -= 5; } return _id; }
int Game::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: scoreChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: levelChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: startTankGame(); break; case 3: startAssassinGame(); break; default: ; } _id -= 4; } return _id; }
void KBlocksScene::updateGame() { if (mSnapshotMode) { return; } QVarLengthArray<int, 16> removedLines(mGroupCount); int gameCount = mpGameLogic->updateGame(removedLines.data()); for (int i = 0; i < mGroupCount; i++) { if (removedLines[i] > 0) { if (maGameScoreList[i]->addScore(removedLines[i])) { int tmpLevel = maGameScoreList[i]->getGameLevel(); if (mTopGameLevel < tmpLevel) { mpGameLogic->levelUpGame(tmpLevel - mTopGameLevel); mTopGameLevel = tmpLevel; } } emit scoreChanged(i, maGameScoreList[i]->getScorePoint(), maGameScoreList[i]->getLineCount(), maGameScoreList[i]->getGameLevel()); } else if (removedLines[i] == -1) { maGroupList[i]->stopGame(); if (mGroupCount == 1) { QTimer::singleShot(500, this, &KBlocksScene::gameOverPlayer); emit isHighscore(0, maGameScoreList[0]->getScorePoint(), maGameScoreList[0]->getGameLevel()); } else { if (i == 0) { for (int j = 0; j < mGroupCount; j++) { maGroupList[j]->stopGame(); } QTimer::singleShot(500, this, &KBlocksScene::gameOverMultiLose); emit isHighscore(0, maGameScoreList[0]->getScorePoint(), maGameScoreList[0]->getGameLevel()); } else if (gameCount <= 1) { maGroupList[0]->stopGame(); QTimer::singleShot(500, this, &KBlocksScene::gameOverMultiWin); emit isHighscore(0, maGameScoreList[0]->getScorePoint(), maGameScoreList[0]->getGameLevel()); } } } } }
int MultBoard::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QFrame::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: scoreChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: levelChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: linesRemovedChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: start(); break; case 4: pause(); break; default: ; } _id -= 5; } return _id; }
//! [24] void TetrixBoard::removeFullLines() { int numFullLines = 0; for (int i = BoardHeight - 1; i >= 0; --i) { bool lineIsFull = true; for (int j = 0; j < BoardWidth; ++j) { if (shapeAt(j, i) == NoShape) { lineIsFull = false; break; } } if (lineIsFull) { //! [24] //! [25] ++numFullLines; for (int k = i; k < BoardHeight - 1; ++k) { for (int j = 0; j < BoardWidth; ++j) shapeAt(j, k) = shapeAt(j, k + 1); } //! [25] //! [26] for (int j = 0; j < BoardWidth; ++j) shapeAt(j, BoardHeight - 1) = NoShape; } //! [26] //! [27] } //! [27] //! [28] if (numFullLines > 0) { numLinesRemoved += numFullLines; score += 10 * numFullLines; emit linesRemovedChanged(numLinesRemoved); emit scoreChanged(score); timer.start(500, this); isWaitingAfterLine = true; curPiece.setShape(NoShape); update(); } //! [28] //! [29] }
//! [4] void TetrixBoard::start() { if (isPaused) return; isStarted = true; isWaitingAfterLine = false; numLinesRemoved = 0; numPiecesDropped = 0; score = 0; level = 1; clearBoard(); emit linesRemovedChanged(numLinesRemoved); emit scoreChanged(score); emit levelChanged(level); newPiece(); timer.start(timeoutTime(), this); }
/* When there is a timer event, this method automatically moves each Object, checks for collisions, and then calls the repaint() method */ void ZomZomAttack::timerEvent(QTimerEvent *event) { int px = player->getRect().x(); int py = player->getRect().y(); for (int i = 0; i < zomzom.size(); i++) zomzom[i]->autoMove(px, py); for (int i = 0; i < zBullets.size(); i++) { zBullets[i]->autoMove(px, py); if (zBullets[i]->isDone()) zBullets.erase(zBullets.begin() + i); } for (int i = 0; i < pBullets.size(); i++) { pBullets[i]->autoMove(px, py); if (pBullets[i]->isDone()) pBullets.erase(pBullets.begin() + i); } checkCollision(); repaint(); if (level == 1 && points > 500000) levelIncrease(); if (level == 2 && points > 1250000) levelIncrease(); if (level == 3 && points > 5000000) levelIncrease(); emit scoreChanged(points); emit healthChanged(health); emit levelChanged(level); }
//! [22] void TetrixBoard::pieceDropped(int dropHeight) { for (int i = 0; i < 4; ++i) { int x = curX + curPiece.x(i); int y = curY - curPiece.y(i); shapeAt(x, y) = curPiece.shape(); } ++numPiecesDropped; if (numPiecesDropped % 25 == 0) { ++level; timer.start(timeoutTime(), this); emit levelChanged(level); } score += dropHeight + 7; emit scoreChanged(score); removeFullLines(); if (!isWaitingAfterLine) newPiece(); //! [22] //! [23] }
void FrontClientSocket::readClient() { QDataStream in(this); in.setVersion(QDataStream::Qt_4_1); if (nextBlockSize == 0) { if (bytesAvailable() < sizeof(quint16)) return; //继承的socket类,所以可以直接用bytesAvailable() in >> nextBlockSize; } if (bytesAvailable() < nextBlockSize) return; in >> serviceFlag; in >> rowId; QString rowIdString, servString; rowIdString.setNum(rowId); servString.setNum(serviceFlag); quint16 totalPlayerCount16, currentPlayerNo16; quint16 turn16, score16; quint16 goodsTypeSize16, goodsId16, goodsCount16; qint16 bt16; bool openFlag = rowInfo.readInfo(rowId); if (!openFlag) { close(); return; } QString tempS; QSqlQuery sql; switch (serviceFlag) { case dataTransform::END_ONE: in >> totalPlayerCount16; if (totalPlayerCount16==0 || rowInfo.scoreInfo.size()<totalPlayerCount16) totalPlayerCount16 = rowInfo.scoreInfo.size(); for (int i=0; rowInfo.vipId!="" && i<totalPlayerCount16; i++) { int xCnt = 0; int hxCnt = 0; int score = rowInfo.scoreInfo[i].score[dataTransform::SCORE_SIZE-1]; for (int j=0; j<dataTransform::SCORE_SIZE; j++) { if (rowInfo.scoreInfo[i].str[j]=="X") xCnt++; if (rowInfo.scoreInfo[i].str[j]=="?\\") hxCnt++; } sql.prepare("INSERT INTO score_record VALUES (?, ?, ?, ?, ?);"); sql.addBindValue(rowInfo.vipId.toInt()); sql.addBindValue(QDateTime::currentDateTime().toString("yy-MM-dd hh:mm")); sql.addBindValue(score); sql.addBindValue(xCnt); sql.addBindValue(hxCnt); sql.exec(); //if (!sql.exec()) // qDebug() << "Insert vip history error " << sql.lastError().text(); } rowInfo.totalPlayerCount = totalPlayerCount16; if (rowInfo.totalPlayerCount<=rowInfo.restCount) rowInfo.restCount -= rowInfo.totalPlayerCount; else rowInfo.restCount = 0; //tempS.setNum(rowInfo.scoreInfo.size()); //QMessageBox::critical(0, "NULL", "总局数:" + tempS ); rowInfo.totalPlayerCount = 0; rowInfo.scoreInfo.clear(); rowInfo.currentPlayerNo = 0; rowInfo.writeInfo(rowId); if (rowInfo.restCount==0) { sentToClient(dataTransform::ANS_NO_DO_NOT_BEGIN, 0); emit endOne(rowId, 0); } else { sentToClient(dataTransform::ANS_YES_YOU_CAN_BEGIN, rowInfo.restCount); emit endOne(rowId, rowInfo.restCount); } break; case dataTransform::ROW_SCORE: in >> totalPlayerCount16 >> currentPlayerNo16; if (totalPlayerCount16==0 || currentPlayerNo16>=totalPlayerCount16) currentPlayerNo16 = 0; assert(totalPlayerCount16>=0); rowInfo.totalPlayerCount = totalPlayerCount16; rowInfo.currentPlayerNo = (currentPlayerNo16 < totalPlayerCount16 ? currentPlayerNo16 : 0); rowInfo.scoreInfo.resize(totalPlayerCount16); for (int i=0; i<rowInfo.totalPlayerCount; i++) { in >> turn16; rowInfo.scoreInfo[i].turn = turn16; for (int j=0; j<dataTransform::SCORE_SIZE; j++) { in >> score16 >> rowInfo.scoreInfo[i].str[j]; rowInfo.scoreInfo[i].score[j] = score16; if (rowInfo.scoreInfo[i].str[j]=="-") rowInfo.scoreInfo[i].str[j].clear(); } for (int j=0; j<dataTransform::BT_ROW_SIZE; j++) { for (int k=0; k<dataTransform::SCORE_SIZE; k++) { in >> bt16; rowInfo.scoreInfo[i].bt[j][k] = bt16; //qDebug() << "In bt " << j << " " << k << " " << rowInfo.scoreInfo[i].bt[j][k]; } } } if (rowInfo.restCount==0 && rowInfo.state=="占用") { rowInfo.state = "空闲"; } rowInfo.writeInfo(rowId); emit scoreChanged(int(rowId)); //QMessageBox::critical(0, "收到得分请求", "\n收到得分,写入文件,发出球道信息改变信号\n"); break; case dataTransform::CALL_GOODS: in >> goodsTypeSize16; assert(goodsTypeSize16>=0); rowInfo.buyGoodsInfo.goodsTypeSize = goodsTypeSize16; rowInfo.buyGoodsInfo.goodsId.resize(goodsTypeSize16); rowInfo.buyGoodsInfo.goodsCount.resize(goodsTypeSize16); for (int i=0; i<rowInfo.buyGoodsInfo.goodsTypeSize; i++) { in >> goodsId16; rowInfo.buyGoodsInfo.goodsId[i] = goodsId16; in >> goodsCount16; rowInfo.buyGoodsInfo.goodsCount[i] = goodsCount16; //qDebug() << "编号:" << goodsId16 << " 数量:" << goodsCount16; } rowInfo.writeInfo(rowId); emit buyGoodsChanged(int(rowId)); break; case dataTransform::CALL_SERVICE: QMessageBox::information(NULL, "新信息", "\n" + rowIdString + " 号球道呼叫\n"); emit callService(rowId); break; default: //QMessageBox::critical(NULL, "错误", "\n未识别信息\n" + servString + "\n\n"); //qDebug() << "Unknow information"; break; } //end switch quint32 temp; while (bytesAvailable()) { in >> temp; } close(); nextBlockSize = 0; }
void Controller::Player::awardPoints( std::size_t inPoints ) { mScore += inPoints; scoreChanged( mScore ); }
void Simulation::scoreChangedInternal() { const int objectPixels = info_.countPixels(object_.polygon()); pixelDifference_ = scoreCalculator_.pixels() - objectPixels; emit scoreChanged(); }
void HnModelItem::setScore(const int score) { m_score = score; emit scoreChanged(); }
void Snake::setScore(int amount) { score += amount; emit scoreChanged(); }