void CChildView::OnTimer(UINT_PTR nIDEvent) { // TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다. tick++; if(tick2 > 0) tick2++; if(tick3 > 0) tick3++; static bool first = true; static int swt = 0; if(gameStart) { if(first) { OnHelpHowtoplay(); first = false; } if(tick%10 == 0) { if(!game->moveShapeDown()) { //PlaySound(MAKEINTRESOURCE(IDR_WAVE_DOWN), AfxGetInstanceHandle(),SND_RESOURCE | SND_ASYNC); game->madeLinePreClear(); swt = 1; } } if(swt == 1) { swt = 2; tick2 = 1; } if(swt == 2 && tick2 == 7) { game->madeLineClear(); tick2 = 0; swt = 0; // 게임 오버 if(!game->startNext()) { reStart(); } // 레벨 업 if(game->levelUp()) { KillTimer(0); //PlaySound(MAKEINTRESOURCE(IDR_WAVE_LEVELUP), AfxGetInstanceHandle(),SND_RESOURCE | SND_ASYNC); SetTimer(0,downSpeed[game->getDifficulty()][game->getSpeedLevel()],NULL); } } if(swt2 == 1) { swt2 = 2; tick3 = 1; } if(swt2 == 2 && tick3 == 7) { game->skillZ(); tick3 = 0; swt2 = 0; } } Invalidate(); CWnd::OnTimer(nIDEvent); }
hero::hero() { reStart(); init(); setCenter(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_server(new NetworkServer(this)), m_ipList(), m_bgm(this) { ui->setupUi(this); m_bgm.setMedia(QUrl::fromLocalFile("./Music/thestonemasons.wav")); m_bgm.setVolume(50); m_bgm.play(); connect(&m_bgm, SIGNAL(stateChanged(QMediaPlayer::State)), &m_bgm, SLOT(play())); setFixedSize(width(), height()); m_gobang = new Gobang(this); m_startMenu = new StartMenu(this); m_waitWidget = new waitWidget(this); setCursor(QCursor(QPixmap(":/Pic/arrows.png"), 1, 1)); m_gobang->hide(); m_waitWidget->hide(); m_startMenu->show(); currentWidget = m_startMenu; m_server->listen(); m_server->getIP(); m_waitWidget->ui->ipLabel->setText("您的IP是:" + m_server->Sadress); m_timer.setInterval(1000); currentState = m_server->readWriteSocket->state(); m_time1.setInterval(200); m_time1.start(); connect(&m_time1, SIGNAL(timeout()), this, SLOT(checkState())); m_timer.start(); connect(&m_timer, SIGNAL(timeout()), this, SLOT(checkUnactive())); connect(m_startMenu->ui->startServer, SIGNAL(clicked()), this, SLOT(setWaiting())); connect(m_startMenu->ui->startServer, SIGNAL(clicked()), m_gobang, SLOT(setHost())); connect(m_startMenu->ui->startServer, SIGNAL(clicked()), m_server, SLOT(closeListen())); connect(m_startMenu->ui->startServer, SIGNAL(clicked()), m_server, SLOT(initServer())); connect(m_startMenu->ui->startClient, SIGNAL(clicked()), this, SLOT(connectHost())); connect(m_startMenu->ui->startClient, SIGNAL(clicked()), m_server, SLOT(closeListen())); connect(m_waitWidget->ui->ok, SIGNAL(clicked()), this, SLOT(broadcast())); connect(m_waitWidget->ui->ok, SIGNAL(clicked()), m_waitWidget->ui->setBox, SLOT(hide())); connect(m_waitWidget->ui->ok, SIGNAL(clicked()), m_waitWidget->ui->waitLabel, SLOT(show())); connect(m_waitWidget->ui->back, SIGNAL(clicked()), m_server, SLOT(closeWrite())); connect(m_waitWidget->ui->back, SIGNAL(clicked()), m_server, SLOT(listen())); connect(m_waitWidget->ui->back, SIGNAL(clicked()), this, SLOT(setStart())); connect(m_gobang, SIGNAL(sendSignal(int, Step)), m_server, SLOT(sendMessage(int, Step))); connect(m_server, SIGNAL(setPieces(Step)), m_gobang, SLOT(setPieces(const Step&))); connect(m_server, SIGNAL(findPlayer(QString)), this, SLOT(findPlayer(QString))); connect(m_server, SIGNAL(changeCamp(int)), m_gobang, SLOT(changeCamp(int))); connect(m_server, SIGNAL(recall(int)), m_gobang, SLOT(recallDone(int))); connect(m_server, SIGNAL(reStart()), m_gobang, SLOT(reStart())); connect(m_server, SIGNAL(agreeRecall()), m_gobang, SLOT(on_recall())); connect(m_server, SIGNAL(askForRecall()), m_gobang, SLOT(forRecall())); connect(m_server, SIGNAL(agreeExit()), this, SLOT(setStart())); connect(m_server, SIGNAL(agreeExit()), m_gobang, SLOT(on_exit())); connect(m_server, SIGNAL(refuse()), m_gobang, SLOT(on_refuse())); connect(m_server, SIGNAL(agreeExit()), m_server, SLOT(listen())); connect(m_server, SIGNAL(askForExit()), m_gobang, SLOT(forExit())); connect(m_server, SIGNAL(changeState(int, int, int)), m_gobang, SLOT(changeCurrentState(int, int, int))); connect(m_server->listenSocket, SIGNAL(newConnection()), this, SLOT(setGobang())); connect(m_server->listenSocket, SIGNAL(newConnection()), m_server, SLOT(closeWrite())); connect(m_server->listenSocket, SIGNAL(newConnection()), m_server, SLOT(closeListen())); }
void CChildView::OnGameNew() { reStart(); }