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(); } }
MainWindow::MainWindow(QApplication *a, QHostAddress ip, quint16 port, QByteArray l, QString skin, double mouseSensitivity, QObject *parent) : QObject(parent) { app = a; repaintTimer = new QTimer; repaintTimer->setInterval(16); stopBot = false; widget = new DrawGl(app, skin, mouseSensitivity); widget->legacy = this; widget->setMinimumHeight(480); widget->setMinimumWidth(640); login = l; qDebug() << "connecting to " + ip.toString() + ":" + QString::number(port); input = new NetworkClass(ip, port, QString::fromLocal8Bit(login)); QObject::connect(repaintTimer, SIGNAL(timeout()), widget, SLOT(repaint())); QObject::connect(input, SIGNAL(gameStart()), this, SLOT(gameStart())); QObject::connect(input, SIGNAL(connectionFailed()), this, SLOT(connectionFailed())); QObject::connect(input, SIGNAL(successConnection()), this, SLOT(connectedSuccess())); QObject::connect(widget, SIGNAL(runCommand(QString)), input, SLOT(runCommand(QString))); QObject::connect(widget, SIGNAL(destroyed()), this, SLOT(legalStop())); ctrlPressed = false; finished = false; widget->a = input; repaintTimer->start(); input->start(); thread = new CalculationThread(widget, input); for (int i = 0; i < 100; i++) for (int j = 0; j < 100; j++) for (int k = 0; k < 100; k++) progress[i][j][k] = false; }
int teamAbout(void) { int i; HWND hwnd = GetForegroundWindow(); SetWindowTextA(hwnd, "离散数学实验室 - 团队信息"); loginui(); printf("\n\n"); printf("\t\t\t\t 程序作者\n\n\t\t\t\t 张博强\n\n\t\t\t辽宁工程技术大学 软件学院 15级9班\n\n\t\t\t\t "); //printf("\t\t\t\t 团队信息\n\n\t\t\t 张博强、李昕、范守峰、王妍\n\n\t\t\t辽宁工程技术大学 软件学院 15级9班\n\n\t\t\t\t "); printf("\n\t\t\t\t 指导老师\n\n\t\t\t\t 冯永安\n\n"); printf("\n\n"); printf("\n\t本软件在最终发布前对功能进行了测试,确保功能都尽量准确执行,但由\n\t于团队水平和开发经验有限,错误和疏漏在所难免,还望各位不吝赐教。\n"); printf("\n\t\t\t\t\t\t\t "); printf(DATENOW); i = 1; while (_getch() == ' ') { i++; if (i > 7) { gameStart(); break; } } return 1000; }
void BattleController::onEnter(void) { Layer::onEnter(); loadRes(); scheduleUpdate(); gameStart(); }
StartWindow::StartWindow(QWidget *parent) : QWidget(parent) { // get the size of the monitor being used. monitor = new QDesktopWidget(); int screenHeight = monitor->geometry().height(); int screenWidth = monitor->geometry().width(); //set the main game window size according to the monitor window. // setFixedSize(screenWidth-(screenWidth*.55),screenHeight-(screenHeight*.1)); int windowHeight = this->size().height(); int windowWidth = this->size().width(); // setGeometry((screenWidth - windowWidth) / 2,(screenHeight - windowHeight) / 2,windowWidth,windowHeight); backGround = new QPixmap(":/Images/startbackground.png"); backGroundLabel = new QLabel(); int w = backGroundLabel->width(); int h = backGroundLabel->height(); backGroundLabel->setPixmap(backGround->scaled(w,h,Qt::KeepAspectRatio)); startButton = new QPushButton("Start"); boxLayout = new QVBoxLayout(); boxLayout->addWidget(backGroundLabel); boxLayout->addWidget(startButton); QObject::connect(startButton,SIGNAL(clicked()),this,SLOT(gameStart())); setLayout(boxLayout); setWindowTitle("TETRIS"); //setGeometry(372,35,0,0); //setFixedSize(620,650); }
void Menu::handleStartPushed() { int checked = 0; foreach(QCheckBox* i, *cards) checked += i -> isChecked(); if(checked == 8) emit gameStart(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { i = 0; win_width = 440; win_height = 600; floor_height = win_height/4; this->setFixedSize(win_width,win_height); //視窗大小 this->setWindowIcon(QIcon(":/Image/bird1.png")); this->setWindowTitle("Qt FlappyBird"); //創建水管 for(int i=0;i<pipeCount;i++) pipe[i]=new OBSTACLE(this); //創建鳥 birds=new ROLE(this); floor=new FLOOR(this); //創建數字 Number=new number(this); //遊戲初始模式 gameRedy(); //遊戲開始 gameStart(); Number->setnum(0); fgm = new easyMusic("musicFile/fly2_cut.wav", 50, 0); fgm2 = new easyMusic("musicFile/money_cut.wav", 100, 0); fgm3 = new easyMusic("musicFile/hit.wav", 50, 0); }
int upx::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: addHostGroup(); break; case 1: updateHostGroup(); break; case 2: delHostGroup(); break; case 3: addHost(); break; case 4: delHost(); break; case 5: groupClicked((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 6: saveSettings(); break; case 7: saveLog2File(); break; case 8: addGame(); break; case 9: updateGame(); break; case 10: deleteGame(); break; case 11: calcGigest(); break; case 12: gameRefresh(); break; case 13: addGameHost(); break; case 14: deleteGameHost(); break; case 15: gameStop(); break; case 16: gameStart(); break; case 17: diffGameFiles(); break; case 18: syncGameFiles(); break; case 19: selectGamePath(); break; case 20: selectGameItem(); break; default: ; } _id -= 21; } return _id; }
Client::Client() { connect(this,SIGNAL(readyRead()),this,SLOT(readMessage())); connect(logic,SIGNAL(gameStart()),this,SIGNAL(readyToStart())); connect(logic,SIGNAL(sendCommand(QString)),this,SLOT(sendMessage(QString))); connect(this,SIGNAL(getMessage(QString)),logic,SLOT(getCommand(QString))); logic->setClient(this); }
void MainWindow::keyPressEvent(QKeyEvent *event) { // 在這裡設定按下鍵盤要觸發的功能 if (gamemod == lose) { if (birdTimer->isActive()) birdTimer->stop(); gameRedy(); gameStart(); Number->setnum(0); } if (gamemod == pause) gameStart(); if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Space){ fgm->stop(); fgm->play(); birdup(); } if (event->key() == Qt::Key_Down) gamePause(); }
void MainWindow::mousePressEvent(QMouseEvent *event) { // 在這裡設定按下滑鼠要觸發的功能 if (gamemod == lose) { if (birdTimer->isActive()) birdTimer->stop(); gameRedy(); gameStart(); Number->setnum(0); } if (gamemod == pause) gameStart(); if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) { fgm->stop(); fgm->play(); birdup(); } }
void main(void) { time_t t1, t2; time(&t1); gameStart(); time(&t2); printf("かかった時間は%.0f秒です\n", difftime(t2, t1)); }
void BackgroundEngine::roleRandom() { for(int i=0;i<playerSum;i++){ playerList[i]=setRole(roles[i],this,queue[i].digitValue(),queue[i+playerSum].digitValue()); coder.roleNotice(queue[i].digitValue(),roles[i]); } seatPostarrange(); gameStart(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setStyleSheet("background-color: white;"); for (int i=0; i<10; i++) { for (int j=0; j<10; j++) { b[i][j]= new Blank(i,j,this); connect(b[i][j], SIGNAL(Click(int,int)), this, SLOT(button_clicked(int, int))); connect(b[i][j], SIGNAL(finishMove()), this, SLOT(zeroVanish())); } } gameStart(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { win_width = 380; win_height = 450; this->setFixedSize(win_width,win_height); //視窗大小 this->setWindowIcon(QIcon(":/Image/bird1.png")); this->setWindowTitle("Qt FlappyBird"); //創建水管 for(int i=0;i<pipeCount;i++) pipe[i]=new OBSTACLE(this); //創建鳥 birds=new ROLE(this); //遊戲初始模式 gameRedy(); //遊戲開始 gameStart(); }
MyRoom::MyRoom(Server *server):QObject() { backEngine = new BackgroundEngine(); testUI = new TestUIex(NULL); this->serverModule = server; engineThr = new MyThread; backEngine->moveToThread(engineThr); engineThr->start(); //connect(backEngine,SIGNAL(askForActSIG(QList<CardEntity*>,int)),testUI,SLOT(actSLOT(QList<CardEntity*>,int))); //connect(backEngine,SIGNAL(askForReply(QList<CardEntity*>,QString,int)),testUI,SLOT(replySLOT(QList<CardEntity*>,QString,int))); //connect(backEngine,SIGNAL(askForHeal(int,int)),testUI,SLOT(healSLOT(int,int))); connect(backEngine,SIGNAL(toInforDisplay(QString)),testUI,SLOT(toDisplay(QString))); connect(serverModule,SIGNAL(seatArrangeSIG()),backEngine,SLOT(seatArrange())); connect(serverModule,SIGNAL(seatPrearrangeSIG(int,int,QString)),backEngine,SLOT(seatPrearrange(int,int,QString))); connect(this->serverModule,SIGNAL(toDisplay(QString)),this->testUI,SLOT(toDisplay(QString))); connect(backEngine,SIGNAL(sendMessageSIG(int,QString)),this->serverModule,SLOT(sendMessage(int,QString))); connect(&coder,SIGNAL(sendMessage(int,QString)),this->serverModule,SLOT(sendMessage(int,QString))); switch(serverModule->getRoleStrategy()) { case 0: connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine,SLOT(roleRandom())); break; case 1: connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine,SLOT(role3Pick1())); connect(serverModule,SIGNAL(role3Pick1ReplySIG(int,int)),backEngine,SLOT(role3Pick1Reply(int,int))); connect(serverModule,SIGNAL(gameStartSIG()),this->backEngine,SLOT(gameStart())); connect(this->serverModule,SIGNAL(roleNoticeSIG()),backEngine,SLOT(seatPostarrange())); break; case 2: connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine, SLOT(BP())); } // emit this->serverModule->toDisplayPublic("server IP:" + this->serverModule->serverAddress().toString()); emit this->serverModule->toDisplayPublic("server port:" + QString::number(this->serverModule->serverPort())); }
void gameInitialize(uint32_t screenWidth, uint32_t screenHeight) { if (gGame) return; Profile profile("Game initialize"); remoteDebugStart(platformDeviceName()); gGame = new Game(); gGame->clock = new Clock(); clockStart(gGame->clock); gGame->sensor = new SensorState(); gGame->screen = new Screen(); gGame->screen->width = screenWidth; gGame->screen->height = screenHeight; gGame->fps = 60; RLOGI("%s", "Initializing Game!"); gGame->L = luaCoreCreate(); if(hasStarted) gameRestart(); else gameStart(); }
void MainWindow::on_reset_clicked() { gameStart(); }
void Referee::slotRead() { QDataStream in(messengerOfTheGods); in.setVersion(QDataStream::Qt_4_0); if (messageSize == 0) { if ((int) messengerOfTheGods->bytesAvailable() < (int) sizeof(quint16)) return; quint16 size; in >> size; messageSize = (int) size; } if ((int) messengerOfTheGods->bytesAvailable() < (int) messageSize) return; // Here we have received a complete message bool lastPacket = false; do { quint16 id; in >> id; int code = (int) id; qreal a, b; quint16 color; switch (code) { case HERMES_GAME_START: Q_EMIT gameStart(); break; case HERMES_DETECTION_START: Q_EMIT detectionStart(); break; case HERMES_GAME_OVER: Q_EMIT gameOver(); break; case HERMES_A_B: in >> a; in >> b; Q_EMIT abValues((double) a, (double) b); break; case HERMES_TEAMCOLOR: in >> color; Q_EMIT trueColorOfTeam((TeamColor) color); break; case HERMES_STOP_MOVEMENT: Q_EMIT stopMovement(); break; default: messengerOfTheGods->readAll(); break; } if (!in.atEnd()) { lastPacket = false; if ((int) messengerOfTheGods->bytesAvailable() < (int) sizeof(quint16)) { messengerOfTheGods->readAll(); lastPacket = true; } else { quint16 size; in >> size; messageSize = (int) size; } } else { lastPacket = true; } } while (!lastPacket);
//Displays the menu of the game void Application::menu() { if (gWindow == NULL) { //Start up SDL and create window if (!init()) { printf("Failed to initialize!\n"); } } menuBackgroundSound = Mix_LoadMUS("sounds/menu_background.mp3"); Mix_PlayMusic(menuBackgroundSound, 10); LTexture menuBackgroundTexture; int start = 0; //------------BUTTONS------------ loadButtonMedia(); //--------------TEXT LOADING--------- loadText(); SDL_Color textColor = { 0x00, 0xCC, 0xFF }; //-------------BUTTON SET POS & BACKGROUND---------- menuBackgroundTexture.loadFromFile("img/menu.png", gRenderer); lastTenGamesManager.createBlankFile(); std::fstream gameFile("previousGames.txt", std::ios::out | std::ios::in); //Main loop flag bool quit = false; isMusicOn = true; //Event handler SDL_Event e; const int screenTicksPF = 1000 / screenFPS; Timer fpsTimer, capTimer; fpsTimer.start(); //While application is running while (!quit) { capTimer.start(); //Handle events on queue while (SDL_PollEvent(&e) != 0) { //User requests quit if (e.type == SDL_QUIT || e.key.keysym.sym == SDLK_ESCAPE || exitButton->handleEvent(&e)) { quit = true; gameFile.close(); } else if (onMusicButton->handleEvent(&e)) { checkMusic(); } else if (startButton->handleEvent(&e) && gameData.getPlayerBet() > 0) { moneyManager.setCredit(gameData.getStartCredit()); startTimeTemp = SDL_GetTicks(); this->deposit = 0; depositNum->loadFromRenderedText(std::to_string(this->deposit), textColor, *gRenderer); int chosenCar = chooseCar(gRenderer); if (chosenCar != 0) { gameStart(gameFile, chosenCar); } else { continue;//if escape is pressed returns to main loop } if (isMusicOn) { Mix_PlayMusic(menuBackgroundSound, 10); } moneyManager.setCredit(gameData.getStartCredit()); betNum->loadFromRenderedText(std::to_string((int)gameData.getPlayerBet()), textColor, *gRenderer); creditNumber->loadFromRenderedText(std::to_string((int)gameData.getStartCredit()), textColor, *gRenderer); } else if (instructionsButton->handleEvent(&e)) { instructionsScreen(); } else if (lastTenGamesButton->handleEvent(&e)) { lastTenGamesScreen(gameFile); } else if (addDepositButton->handleEvent(&e)) { moneyManager.addDeposit(this->deposit); depositNum->loadFromRenderedText(std::to_string(deposit), textColor, *gRenderer); } else if (removeDepositButton->handleEvent(&e)) { moneyManager.removeDeposit(this->deposit); depositNum->loadFromRenderedText(std::to_string(deposit), textColor, *gRenderer); } else if (makeDepositButton->handleEvent(&e)) { double startCredit = gameData.getStartCredit(); moneyManager.makeDeposit(startCredit, this->deposit); gameData.setStartCredit(startCredit); creditNumber->loadFromRenderedText(std::to_string((int)gameData.getStartCredit()), textColor, *gRenderer); depositNum->loadFromRenderedText(std::to_string(this->deposit), textColor, *gRenderer); } else if (addBetButton->handleEvent(&e)) { double playerBet = gameData.getPlayerBet(); moneyManager.makeBet(gameData.getStartCredit(), playerBet); gameData.setPlayerBet(playerBet); betNum->loadFromRenderedText(std::to_string((int)gameData.getPlayerBet()), textColor, *gRenderer); } else if (removeBetButton->handleEvent(&e)) { double playerBet = gameData.getPlayerBet(); moneyManager.removeBet(playerBet); gameData.setPlayerBet(playerBet); betNum->loadFromRenderedText(std::to_string((int)gameData.getPlayerBet()), textColor, *gRenderer); } } //--------------CLEAR SCREEN----------- SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF); SDL_RenderClear(gRenderer); menuBackgroundTexture.render(*gRenderer, 0, 0); renderMenuTextures(); if (gameData.getStartCredit() != 0) { creditText->render(*gRenderer, 50, 50); creditNumber->render(*gRenderer, 220, 50); } else { blinkingEffect(start); start++; } //------------- UPDATE SCREEN---------------- SDL_RenderPresent(gRenderer); int frameTicks = capTimer.getTicks(); if (frameTicks < screenTicksPF) { SDL_Delay(screenTicksPF - frameTicks); } } }
// slot for loading a map file void Board::topTen() { gameStart(); //calls gamestart qDebug("clicked Top 10"); }
// Do the initialization tasks. This is where all the buttons are created void Board::init() { layout = new QVBoxLayout; // Create a vertical layout for a column of buttons QLabel *status =new QLabel(" Score"); QLabel *status2 = new QLabel(" Chances Left"); QLabel *Name =new QLabel(" Player Name"); layout->addWidget(Name); QPushButton *b = new QPushButton(tr("Restart")); // create a button for restarting the game connect(b, SIGNAL(clicked()), this, SLOT(restartGame())); // connect restart button to restartGame function layout->addWidget(b); // add the restart button to the button row b = new QPushButton(tr("Top 10")); // Create a button for showing top 10 high scores connect(b, SIGNAL(clicked()), this, SLOT(topTen())); // connect this button to high score function layout->addWidget(b); // Add it to the row of buttons b = new QPushButton(tr("Help")); //Creat a button for showing helpful instructions connect(b, SIGNAL(clicked()), this, SLOT(help())); //connect this button to help function layout->addWidget(b); //add it to the row of buttons QVBoxLayout *vbox = new QVBoxLayout; rbn = new QRadioButton(tr("Novice")); connect(rbn, SIGNAL(clicked()), this, SLOT(Novice())); rbn->setCheckable(true); rbn->setChecked(true); rbn->setDown(true); vbox->addWidget(rbn); // Add it to the row of buttons rbe = new QRadioButton(tr("Expert")); connect(rbe, SIGNAL(clicked()), this, SLOT(Expert())); rbe->setCheckable(true); vbox->addWidget(rbe); // Add it to the row of buttons rbm = new QRadioButton(tr("Master")); connect(rbm, SIGNAL(clicked()), this, SLOT(Master())); rbm->setCheckable(true); vbox->addWidget(rbm); // Add it to the row of buttons QGroupBox *bg = new QGroupBox(tr("Game Mode")); bg->setLayout(vbox); layout->addWidget(bg); QWidget *window = new QWidget; // create a window to whold the row of buttons window->setLayout(layout); // add the row of buttons to this window window->move(W+2*T,0); // position it at the right edge this->scene()->addWidget(window); // add the button window to the scene layout->addWidget(status2); turn=new QLCDNumber(1); //creates QLCDNumber to hold remaining shots turn->setSegmentStyle(QLCDNumber::Filled); layout->addWidget(turn); turn->display(5); layout->addWidget(status); //adds text label to say score showscore=new QLCDNumber(10); //creates QLCDNumber to show score showscore->setSegmentStyle(QLCDNumber::Filled); layout->addWidget(showscore); //adds a box to display the score showscore->display(0); //sets the score showtimer=new QLabel(" Time Left (ms)"); //label to say time left layout->addWidget(showtimer); int y=Bubble::R*17+2; for(int i=0; i<9; i++) //draws 9 rows of random coloured bubbles { int x=Bubble::R+3; if(i%2==0) x+=Bubble::R; for(int p=0; p<17; p++) // draws 17 column of random coloured bubbles { start.append(new Bubble(random(rand1),shootAngle)); start.last()->setParentItem(this); start.last()->setPos(x,y); x+=Bubble::R*2; } y-=Bubble::R*2; } first=random(first); //gives first a new random colour next=random(next); //gives next a new random colour FirstandSecond.append(new Bubble(first,shootAngle)); //adds new bubble to be shot next FirstandSecond.back()->setParentItem(this); FirstandSecond.back()->setPos(W/2,H); FirstandSecond.append(new Bubble(next,shootAngle)); //adds new bubble to be shot after that FirstandSecond.back()->setParentItem(this); FirstandSecond.back()->setPos(W+Bubble::R*4,H-Bubble::R*8); gameStart(); // calls function to diplay ten highest scores }