コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: Yehtu/pd2-Angrybird
void MainWindow::tick()
{
    world->Step(1.0/60.0,6,2);
    scene->update();
    damageBarrier();
    killPig();
    scoreboard->setText(QString::number(score));
    if( killall == true )
    {
        bgm->stop();
        QString result;
        QTextStream(&result) << "LEVEL CLEARED ! " << " \n Your score : " << score << "\n\n  Play again ?";
        QMessageBox::StandardButton reply;
        reply = QMessageBox::question(this, " Congratulation ", result, QMessageBox::Yes | QMessageBox::No);
        if(reply == QMessageBox::No) exitGame(); //end game
        else restartGame();
    }
    if( num == -1 )
    {
        spdx = bird[0]->getLinearVelocity().x;
        spdy = bird[0]->getLinearVelocity().y;
        bound = bird[0]->getPosition().x;
        //std::cout << g << std::endl;
        if(( spdx == 0 && spdy == 0 )|| bound > 45 || bound < -5 )
        {
            bgm->stop();
            QString result;
            QTextStream(&result) << "Your score : " << score << "\n\n  Try again ?";
            QMessageBox::StandardButton reply;
            reply = QMessageBox::question(this, " Gameover ", result, QMessageBox::Yes | QMessageBox::No);
            if(reply == QMessageBox::No) exitGame(); //end game
            else restartGame();
        }
    }
}
コード例 #2
0
ファイル: SimonSays.cpp プロジェクト: threeheadedmonkey/simon
bool SimonSays::keyPressed( const OIS::KeyEvent &arg ) {
	bool ret = BaseApplication::keyPressed( arg );

	if (arg.key == KEY_START ) {
		if( !gameStarted ) {
			restartGame( true );
			gameStarted = true;
		}
		// (re-)starts the game
		if( turnEnded ) {
			restartGame( !correctOrder ); // if the order is correct, NO restart
		}
	} 

	if( !showMode && !turnEnded ) {
		if (arg.key == KEY_YELLOW) {
			Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
			playerNode->setPosition(0,20,0);
		} else if (arg.key == KEY_RED) {
			Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
			playerNode->setPosition(65,20,0);
		} else if (arg.key == KEY_BLUE) {
			Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
			playerNode->setPosition(0,20,65);
		} else if (arg.key == KEY_GREEN) {
			Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
			playerNode->setPosition(65,20,65);
		}

		// check key after moving the player
		if( playerOrder.size() > 0 ) {
			if( !checkKey(arg.key) ) {
				mSceneMgr->getLight("yellowSpot")->setVisible( false );
				mSceneMgr->getLight("redSpot")->setVisible( false );
				mSceneMgr->getLight("blueSpot")->setVisible( false );
				mSceneMgr->getLight("greenSpot")->setVisible( false );
				mSceneMgr->setAmbientLight(Ogre::ColourValue(1,0.2,0.2));
			};
		} 
		
		if( playerOrder.size() < 1 ) {
			mSceneMgr->getLight("yellowSpot")->setVisible( false );
			mSceneMgr->getLight("redSpot")->setVisible( false );
			mSceneMgr->getLight("blueSpot")->setVisible( false );
			mSceneMgr->getLight("greenSpot")->setVisible( false );
			mSceneMgr->getEntity("Player")->setVisible( false );
			mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2,1,0.2));
		}

	} // eof !showMode

	return ret;
}
コード例 #3
0
ファイル: widget.cpp プロジェクト: johann-bauer/psychoCards
void Widget::keyPressEvent ( QKeyEvent * event ) {
   int col = event->key() - 48;
   if( col >= 1 && col <=3)
      mixCards( col );
   else if(event->key() == Qt::Key_R )
      restartGame();
}
コード例 #4
0
ファイル: Game.cpp プロジェクト: CaterHatterPillar/PACMANIA
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();
		}
	}
}
コード例 #5
0
ファイル: mainwindow.cpp プロジェクト: zhaorui/8Puzzle
void MainWindow::createActions()
{
    openPict = new QAction(tr("&Open..."),this);
    openPict->setShortcut(QKeySequence::Open);
    openPict->setStatusTip(tr("use user-defined picture as game's background."));
    connect(openPict,SIGNAL(triggered()),this,SLOT(newBackground()));

    newGame = new QAction(tr("&New Game"),this);
    newGame->setShortcut(QKeySequence::New);
    connect(newGame,SIGNAL(triggered()),this,SLOT(restartGame()));

    nextStep = new QAction(tr("Next"),this);
    nextStep->setIcon(QIcon(":/icons/next.JPG"));
    nextStep->setToolTip(tr("The next best move"));
    connect(nextStep,SIGNAL(triggered()),this,SLOT(solveNextMove()));

    autoComplete = new QAction(tr("Auto"),this);
    autoComplete->setIcon(QIcon(":/icons/auto.JPG"));
    autoComplete->setToolTip(tr("complete puzzle with computer"));
    connect(autoComplete,SIGNAL(triggered()),this,SLOT(solvePuzzle()));

    configState = new QAction(tr("Set State"),this);
    configState->setIcon(QIcon(":/icons/set.jpg"));
    connect(configState,SIGNAL(triggered()),this,SLOT(showStateConfigDlg()));
}
コード例 #6
0
ファイル: moc_cannon.cpp プロジェクト: satazor/univ-aca-mips
bool CannonField::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0:
        setAngle((int)static_QUType_int.get(_o+1));
        break;
    case 1:
        setForce((int)static_QUType_int.get(_o+1));
        break;
    case 2:
        shoot();
        break;
    case 3:
        newTarget();
        break;
    case 4:
        setGameOver();
        break;
    case 5:
        restartGame();
        break;
    case 6:
        moveShot();
        break;
    default:
        return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
コード例 #7
0
ファイル: raksamp.cpp プロジェクト: mishannn/m0d_sa
void OrigRakClient::SendClientJoin(char *playerNick)
{
	restartGame();
	BYTE byteNameLen = (BYTE)strlen(playerNick);

	char *szVersion = "0.3.7";
	BYTE byteVerLen = (BYTE)strlen(szVersion);

	BYTE byteAuthBSLen = (BYTE)strlen(AUTH_BS);

	RakNet::BitStream bsSend;
	bsSend.Write(NETGAME_VERSION);
	bsSend.Write((BYTE)'\001');
	bsSend.Write(byteNameLen);
	bsSend.Write(playerNick, byteNameLen);

	bsSend.Write(set.challenge ^ NETGAME_VERSION);
	bsSend.Write(byteAuthBSLen);
	bsSend.Write(AUTH_BS, byteAuthBSLen);
	bsSend.Write(byteVerLen);
	bsSend.Write(szVersion, byteVerLen);
	bsSend.Write(set.challenge ^ NETGAME_VERSION);

	g_RakClient->RPC(RPC_ClientJoin, &bsSend, HIGH_PRIORITY, RELIABLE, 0, FALSE);
}
コード例 #8
0
ファイル: GameScene.cpp プロジェクト: nomadsinteractive/2048
bool GameScene::checkGameOver() {
    if (isGameOver()) {
        updateBestScore();

        auto gameOverLayer = LayerColor::create(Color4B(0, 0, 0, 220));

        const Point& visibleOrigin = Director::getInstance()->getVisibleOrigin();
        const Size& visibleSize = Director::getInstance()->getVisibleSize();
        const Point& center = Point(visibleOrigin.x + visibleSize.width / 2.0f,
                                    visibleOrigin.y + visibleSize.height / 2.0f);

        auto gameOverLabel = Label::createWithSystemFont("GAME OVER", "Consolas", 80);
        gameOverLabel->setColor(Color3B(255, 255, 0));
        gameOverLabel->setPosition(Point(center.x, center.y + 180.0f));
        gameOverLayer->addChild(gameOverLabel);

        char score[64];
        sprintf(score, "BEST  %d", mBestScoreCache);
        auto bestScoreLabel = Label::createWithSystemFont(score, "Consolas", 80);
        bestScoreLabel->setColor(Color3B(128, 0, 128));
        bestScoreLabel->setPosition(Point(center.x, center.y + 55.0f));
        gameOverLayer->addChild(bestScoreLabel);

        sprintf(score, "SCORE %d", mScore);
        auto scoreLabel = Label::createWithSystemFont(score, "Consolas", 80);
        scoreLabel->setColor(Color3B(80, 160, 100));
        scoreLabel->setPosition(Point(center.x, center.y - 55.0f));
        gameOverLayer->addChild(scoreLabel);

        MenuItemFont::setFontName("Consolas");
        MenuItemFont::setFontSize(80);
        auto menuItemRestart = MenuItemFont::create("RESTART",
                [gameOverLayer, this] (Ref* sender) {
            gameOverLayer->removeFromParent();
            restartGame();
        });
        auto menu = Menu::create(menuItemRestart, nullptr);
        menu->setColor(Color3B(0, 255, 255));
        menu->setPosition(Point(center.x, center.y - 180.0f));
        gameOverLayer->addChild(menu);

        getParent()->addChild(gameOverLayer, 1);

        // setup touch event listener for gameOverLayer, it does nothing but swallow the touch events
        auto touchListener = EventListenerTouchOneByOne::create();
        touchListener->setSwallowTouches(true);
        touchListener->onTouchBegan =
                [] (Touch* touch, Event* event) -> bool { return true; };
        touchListener->onTouchMoved = [] (Touch* touch, Event* event) {};
        touchListener->onTouchCancelled = [] (Touch* touch, Event* event) {};
        touchListener->onTouchEnded = [] (Touch* touch, Event* event) {};
        Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(
                touchListener, gameOverLayer);

        return true;
    }

    return false;
}
コード例 #9
0
void Board::Master()            //master game mode
{
    if(score!=0 || start.size()>153)        //everthing works the same as expert except bubbles are shot after 5 second
    {
        QMessageBox newMB;
        QAbstractButton *YES;
        YES=newMB.addButton(QMessageBox::Yes);
        newMB.addButton(QMessageBox::No);
        newMB.setText("The game will be reset");
        newMB.setInformativeText("Are You Sure You Want To Continue?");
        newMB.exec();
        if(newMB.clickedButton()==YES)
        {
            restartGame();
            timeleft=5000;
            chancesleft=3;
            turn->display(chancesleft);
            rbm->setChecked(true);
            timer=new QLCDNumber(4);

            timer->setSegmentStyle(QLCDNumber::Filled);

            layout->addWidget(timer);
            timer->display(timeleft);
            timerexists=1;
            rbn->setDown(false);
            rbe->setDown(false);
            rbm->setDown(true);
        }
        else
        {
            if(rbn->isDown())
                rbn->setChecked(true);
            if(rbe->isDown())
                rbe->setChecked(true);
            if(rbm->isDown())
                rbm->setChecked(true);
        }
    }
    else
    {
        chancesleft=3;
        timeleft=5000;
        turn->display(chancesleft);
        rbm->setChecked(true);

        timer=new QLCDNumber(4);
        timer->setSegmentStyle(QLCDNumber::Filled);

        layout->addWidget(timer);
        timer->display(timeleft);
        timerexists=1;
        rbn->setDown(false);
        rbe->setDown(false);
        rbm->setDown(true);
    }
}
コード例 #10
0
ファイル: widget.cpp プロジェクト: duventj/qarte
void Widget::keyPressEvent ( QKeyEvent * event ) {
   int col = event->key() - 48;
   if( col >= 1 && col <= MAX_CARDS)
   {if(!chg.contains(conventionCarte(&joueur.main, col)))
	 { chg.push_back(conventionCarte(&joueur.main, col));
	   }
   }
   else if(event->key() == Qt::Key_R )
      restartGame();
}
コード例 #11
0
MainWindow::MainWindow(QWidget *parent)
    :QMainWindow(parent)
    ,ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->actionRestart_game, SIGNAL(triggered()), this, SLOT(restartGame()));
    connect(ui->actionShow_tip, SIGNAL(triggered()), this, SLOT(showTip()));
    connect(ui->actionStart_new_game, SIGNAL(triggered()), this, SLOT(startNewGame()));
    connect(ui->openGLWidget, SIGNAL(resizeParent(QSize)), this, SLOT(customResize(QSize)));
}
コード例 #12
0
ファイル: settingwidget.cpp プロジェクト: RodgerNO1/AI
void SettingWidget::on_OkBt(){
    Widget::FloyNum=num_box->itemText(num_box->currentIndex()).toInt();
    Widget::Ng_Num=ng_box->itemText(ng_box->currentIndex()).toInt();
    Widget::MaxSpeed=maxspeed_box->itemText(maxspeed_box->currentIndex()).toInt();
    Widget::BounceSpeed=bspeed_box->itemText(bspeed_box->currentIndex()).toInt();
    Widget::RevDist=revdist_box->itemText(revdist_box->currentIndex()).toInt();
    Widget::Sleep=time_box->itemText(time_box->currentIndex()).toInt();

    emit restartGame();
}
コード例 #13
0
ファイル: game.cpp プロジェクト: glebb/Spoony
void Game::onDie()
{
    //TODO: Exercise 4 //Optional
    global_lives--;

    if (global_lives == 0)
        restartGame();
    else
        resetLevel();
}
コード例 #14
0
ファイル: WorldMap.cpp プロジェクト: Easihh/laughing-avenger
void WorldMap::updateDeathScreen(sf::Event& event){
	if (event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::W){
		gameOverSelectorIndex++;
		if (gameOverSelectorIndex > 1)
			gameOverSelectorIndex = 0;
	}
	if (event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Q){
		if (gameOverSelectorIndex == 0)
			restartGame();
	}
}
コード例 #15
0
ファイル: Game.cpp プロジェクト: asalahli/Bombardier
void Game::run() {
    mClock.restart();
//    getWindow().setMouseCursorVisible(false);
    while (getWindow().isOpen())
    {
        sf::Event event;
        while (getWindow().pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                getWindow().close();
            else if (!mGameOver && event.type == sf::Event::MouseButtonPressed) {
                sf::Vector2i pos(event.mouseButton.x, event.mouseButton.y);
                sf::Vector2f coords = getWindow().mapPixelToCoords(pos);
                mCurrentScreen->onMouseDown(coords, event.mouseButton.button);
            }
            else if (mGameOver && event.type == sf::Event::MouseButtonPressed) {
                if (event.mouseButton.button == sf::Mouse::Left) {
                    restartGame();
                }
            }
            else if (!mGameOver && event.type == sf::Event::MouseMoved) {
                sf::Vector2i pos(event.mouseMove.x, event.mouseMove.y);
                sf::Vector2f coords = getWindow().mapPixelToCoords(pos);
                mCurrentScreen->onMouseMove(coords);
            }
            else if (!mGameOver && event.type == sf::Event::KeyPressed) {
                mCurrentScreen->onKeyDown(event.key.code);
            }
            else if (event.type == sf::Event::LostFocus) {
                mCurrentScreen->pause();
            }
            else if (event.type == sf::Event::GainedFocus) {
                mCurrentScreen->resume();
            }
        }

        int ms;
        for ( ;; ) {
            ms = mClock.getElapsedTime().asMilliseconds();
            if (ms >= getConfig().updateDelay) break;
            sf::sleep(sf::milliseconds(5));
        }
        mClock.restart();

        if (!mGameOver)
            mCurrentScreen->update(ms/1000.0);

        getWindow().clear();
        mCurrentScreen->draw();
        getWindow().display();
    }
}
コード例 #16
0
ファイル: GameWindow.cpp プロジェクト: wwong412/pic10c
void GameWindow::startNewGame(){

    popUpWindow = new QWidget;
    QPushButton *newGameButton = new QPushButton("NEW GAME");
    QPushButton *quitButton = new QPushButton("QUIT");
    QObject::connect(quitButton, SIGNAL(pressed()), this, SLOT(closeGame()));
    QObject::connect(newGameButton, SIGNAL(pressed()), this, SLOT(restartGame()));
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(newGameButton);
    layout->addWidget(quitButton);
    popUpWindow->setFixedSize(100,100);


}void GameWindow::startGame(int level, int difficulty){
コード例 #17
0
ファイル: kmahjongg.cpp プロジェクト: KDE/kmahjongg
void KMahjongg::setupKAction()
{
    KStandardGameAction::gameNew(this, SLOT(startNewGame()), actionCollection());
    KStandardGameAction::load(this, SLOT(loadGame()), actionCollection());
    KStandardGameAction::save(this, SLOT(saveGame()), actionCollection());
    KStandardGameAction::quit(this, SLOT(close()), actionCollection());
    KStandardGameAction::restart(this, SLOT(restartGame()), actionCollection());

    QAction * newNumGame = actionCollection()->addAction(QStringLiteral("game_new_numeric"));
    newNumGame->setText(i18n("New Numbered Game..."));
    connect(newNumGame, &QAction::triggered, this, &KMahjongg::startNewNumeric);

    QAction * action = KStandardGameAction::hint(m_gameView, SLOT(helpMove()), this);
    actionCollection()->addAction(action->objectName(), action);

    QAction * shuffle = actionCollection()->addAction(QStringLiteral("move_shuffle"));
    shuffle->setText(i18n("Shu&ffle"));
    shuffle->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
    connect(shuffle, &QAction::triggered, m_gameView, &GameView::shuffle);

    QAction * angleccw = actionCollection()->addAction(QStringLiteral("view_angleccw"));
    angleccw->setText(i18n("Rotate View Counterclockwise"));
    angleccw->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-left")));
    actionCollection()->setDefaultShortcut(angleccw, Qt::Key_F);
    connect(angleccw, &QAction::triggered, m_gameView, &GameView::angleSwitchCCW);

    QAction * anglecw = actionCollection()->addAction(QStringLiteral("view_anglecw"));
    anglecw->setText(i18n("Rotate View Clockwise"));
    anglecw->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-right")));
    actionCollection()->setDefaultShortcut(anglecw, Qt::Key_G);
    connect(anglecw, &QAction::triggered, m_gameView, &GameView::angleSwitchCW);

    m_demoAction = KStandardGameAction::demo(this, SLOT(demoMode()), actionCollection());

    KStandardGameAction::highscores(this, SLOT(showHighscores()), actionCollection());
    m_pauseAction = KStandardGameAction::pause(this, SLOT(pause()), actionCollection());

    // move
    m_undoAction = KStandardGameAction::undo(this, SLOT(undo()), actionCollection());
    m_redoAction = KStandardGameAction::redo(this, SLOT(redo()), actionCollection());

    // edit
    QAction * boardEdit = actionCollection()->addAction(QStringLiteral("game_board_editor"));
    boardEdit->setText(i18n("&Board Editor"));
    connect(boardEdit, &QAction::triggered, this, &KMahjongg::slotBoardEditor);

    // settings
    KStandardAction::preferences(this, SLOT(showSettings()), actionCollection());
    setupGUI(qApp->desktop()->availableGeometry().size() * 0.7);
}
コード例 #18
0
void Board::Novice()        //novice mode
{
    if(score!=0 || start.size()>153)
    {
        QMessageBox newMB;
        QAbstractButton *YES;
        YES=newMB.addButton(QMessageBox::Yes);
        newMB.addButton(QMessageBox::No);
        newMB.setText("The game will be reset");            //displays warning message is score is not 0 or bubble has been shot
        newMB.setInformativeText("Are You Sure You Want To Continue?");
        newMB.exec();
        if(newMB.clickedButton()==YES)              //if yes is clicked, changes mode
        {
            layout->removeWidget(timer);

            restartGame();
            chancesleft=5;
            turn->display(chancesleft);
            rbn->setChecked(true);
            rbm->setDown(false);
            rbe->setDown(false);
            rbn->setDown(true);
            timerexists=0;
            timeleft=5000;
        }
        else            //reverts mode to one it was just at
        {
            if(rbn->isDown())
                rbn->setChecked(true);
            if(rbe->isDown())
                rbe->setChecked(true);
            if(rbm->isDown())
                rbm->setChecked(true);
        }
    }
    else            //changes game mode
    {
        layout->removeWidget(timer);

        chancesleft=5;
        timeleft=5000;
        timerexists=0;
        turn->display(chancesleft);
        rbm->setDown(false);
        rbe->setDown(false);
        rbn->setDown(true);
    }

}
コード例 #19
0
void Board::Expert()        //expert game mode
{
    if(score!=0 || start.size()>153)        //everything works the same as in novice except chances left is 3
    {
        QMessageBox newMB;
        QAbstractButton *YES;
        YES=newMB.addButton(QMessageBox::Yes);
        newMB.addButton(QMessageBox::No);
        newMB.setText("The game will be reset");
        newMB.setInformativeText("Are You Sure You Want To Continue?");
        newMB.exec();
        if(newMB.clickedButton()==YES)
        {
            layout->removeWidget(timer);

            restartGame();
            chancesleft=3;
            turn->display(chancesleft);
            rbe->setChecked(true);
            timerexists=0;
            rbn->setDown(false);
            rbm->setDown(false);
            rbe->setDown(true);
            timeleft=5000;
        }
        else
        {
            if(rbn->isDown())
                rbn->setChecked(true);
            if(rbe->isDown())
                rbe->setChecked(true);
            if(rbm->isDown())
                rbm->setChecked(true);
        }
    }
    else
    {
        layout->removeWidget(timer);

        chancesleft=3;
        timeleft=5000;
        timerexists=0;
        turn->display(chancesleft);
        rbn->setDown(false);
        rbm->setDown(false);
        rbe->setDown(true);
    }
}
コード例 #20
0
ファイル: ringworld_logic.cpp プロジェクト: TomFrost/scummvm
void RingworldGame::processEvent(Event &event) {
	if (event.eventType == EVENT_KEYPRESS) {
		switch (event.kbd.keycode) {
		case Common::KEYCODE_F1:
			// F1 - Help
			MessageDialog::show(HELP_MSG, OK_BTN_STRING);
			break;

		case Common::KEYCODE_F2: {
			// F2 - Sound Options
			ConfigDialog *dlg = new ConfigDialog();
			dlg->runModal();
			delete dlg;
			_globals->_soundManager.syncSounds();
			_globals->_events.setCursorFromFlag();
			break;
		}

		case Common::KEYCODE_F3:
			// F3 - Quit
			quitGame();
			event.handled = false;
			break;

		case Common::KEYCODE_F4:
			// F4 - Restart
			restartGame();
			_globals->_events.setCursorFromFlag();
			break;

		case Common::KEYCODE_F7:
			// F7 - Restore
			restoreGame();
			_globals->_events.setCursorFromFlag();
			break;

		case Common::KEYCODE_F10:
			// F10 - Pause
			GfxDialog::setPalette();
			MessageDialog::show(GAME_PAUSED_MSG, OK_BTN_STRING);
			_globals->_events.setCursorFromFlag();
			break;

		default:
			break;
		}
	}
}
コード例 #21
0
ファイル: ringworld2_logic.cpp プロジェクト: rkmarvin/scummvm
void Ringworld2Game::processEvent(Event &event) {
	if (event.eventType == EVENT_KEYPRESS) {
		switch (event.kbd.keycode) {
		case Common::KEYCODE_F1:
			// F1 - Help
			HelpDialog::show();
			break;

		case Common::KEYCODE_F2:
			// F2 - Sound Options
			SoundDialog::execute();
			break;

		case Common::KEYCODE_F3:
			// F3 - Quit
			quitGame();
			event.handled = false;
			break;

		case Common::KEYCODE_F4:
			// F4 - Restart
			restartGame();
			g_globals->_events.setCursorFromFlag();
			break;

		case Common::KEYCODE_F7:
			// F7 - Restore
			restoreGame();
			g_globals->_events.setCursorFromFlag();
			break;

		case Common::KEYCODE_F8:
			// F8 - Credits
			warning("TODO: Show Credits");
			break;

		case Common::KEYCODE_F10:
			// F10 - Pause
			GfxDialog::setPalette();
			MessageDialog::show(GAME_PAUSED_MSG, OK_BTN_STRING);
			g_globals->_events.setCursorFromFlag();
			break;

		default:
			break;
		}
	}
}
コード例 #22
0
ファイル: mainwindow.cpp プロジェクト: kaajo/Wcc2048
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent) ,
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    gameBoard = new QGameBoard(this);
    setCentralWidget(gameBoard);

    connect(ui->actionConnect, SIGNAL(triggered(bool)), this, SLOT(connects(bool)));
    connect(ui->actionRestart, SIGNAL(triggered()), this, SLOT(restartGame()));
    connect(&fifo, SIGNAL(pointsReady(std::vector<glm::vec2>)), this, SLOT(handlePoints(std::vector<glm::vec2>)));

    lastWasEmpty = true;
    l = r = u = d = 0.0f;
    timer = new (QTime);
}
コード例 #23
0
ファイル: widget.cpp プロジェクト: duventj/qarte
void Widget::endOfGame( void ) 
{
  clean_cards();
  calcul_qualite_main(&joueur);
  qDebug () << "Qualite main :" << joueur.qualite ;
  while( nbElementsPaquet(&joueur.main) > 0 )
  {
    popMain(&joueur,0, &jeu);
  }
//  echangeCellule ( &joueur.main,0, &jeu );
//  pushPaquet(&jeu, popPaquet(&joueur.main));
  qDebug () << "endOfGame - nbelements:" << nbElementsPaquet(&joueur.main) ;
/*  while (!chg.isEmpty()) 
	 { chg.removeLast();}*/
  restartGame();
}
コード例 #24
0
ファイル: main.cpp プロジェクト: quandrei/DragonCity
//this method is used in order to perform certain actions based on events
void handleInput()
{
    if( event.type == SDL_KEYDOWN )
    {
		if (smaug.alive && gameStarted)
			smaug.shoot(event.key.keysym.sym, &mySounds); //handles smaug's shooting
		
		mainLight.handleInput(event.key.keysym.sym);

		switch( event.key.keysym.sym )
		{
			case SDLK_RETURN:
				if (!gameStarted)
				{
					gameStarted = true;
					mySounds.startMusic(1);
				}
				else if (gameOver || gameWon)
				{
					restartGame();
				}
				break;
			case SDLK_F1:
				if(!rLight && gameStarted)
				{		
					rLight = true;
					mySounds.startMusic(0);
				}
				else
				{
					rLight = false;
					mySounds.startMusic(1);
				}
				break;
			case SDLK_p:
				if(cam == 0 && gameStarted)	
					cam = 1;
				else			
					cam = 0;	
				break;
			case SDLK_ESCAPE:
				SDL_Quit();
				exit(1);
				break;
		}
	}
}
コード例 #25
0
ファイル: kmahjongg.cpp プロジェクト: KDE/kmahjongg
void KMahjongg::noMovesAvailable()
{
    m_gameTimer->pause();
    updateState(GameState::Stuck);

    int answer = KMessageBox::questionYesNoCancel(
        this,
        i18n("Game Over: You have no moves left."),
        i18n("Game Over"),
        KGuiItem(i18n("New Game"), QIcon(actionCollection()->action(KStandardGameAction::name(KStandardGameAction::New))->icon())),
        KGuiItem(i18n("Restart"), QIcon(actionCollection()->action(KStandardGameAction::name(KStandardGameAction::Restart))->icon())));
    if (answer == KMessageBox::Yes) {
        startNewGame();
    } else if (answer == KMessageBox::No) {
        restartGame();
    }
}
コード例 #26
0
void FastQSPWindow::linkClicked(const QUrl &url) {
  if(url.toString().contains("interaction"))
  {
    replaceHTML = true;
    newImage = "";
  }
  qDebug() << "Link clicked" << url.toString();
  if (url.toString().startsWith(QLatin1String("exec:"), Qt::CaseInsensitive)) {
    QString execStr;
    execStr = url.toString().remove(0, 5).trimmed().replace("%22", "\"");
    QSPExecString(execStr.toStdWString().c_str(), true);
  } else if (url.toString().startsWith(QLatin1String("obj:"),
                                       Qt::CaseInsensitive)) {
    bool ok = false;
    int number = 0;
    number = url.toString().remove(0, 4).trimmed().toInt(&ok);
    if (!ok) {
      qCritical() << "Unknown link format" << url.toString();
      return;
    }
    QSPSetSelObjectIndex(number, true);
  } else if (url.path() == QLatin1String("/api/closemsg")) {
    builder.hideMessage();
  } else if (url.toString().toLower() == QLatin1String("restart")) {
    restartGame();
  } else if (url.host() == QLatin1String("qspgame.local")) {
    QString path = url.path();
    path.remove(0, 1);
//    qDebug() << path;
    bool ok = false;
    int number;
    number = path.toUInt(&ok);
    if (ok) {
      QSPSetSelActionIndex(number - 1, true);
      QSPExecuteSelActionCode(true);
    } else {
      qWarning() << QLatin1String("Bad link path:") << path;
    }
  } else if (url.scheme() == QLatin1String("http") ||
             url.scheme() == QLatin1String("mailto")) {
    QDesktopServices::openUrl(url);
  } else {
    qWarning() << QLatin1String("Bad link:") << url.toString();
  }
  loadPage();
}
コード例 #27
0
ファイル: game.cpp プロジェクト: tomtom7/tictactoe
//Handles keyboard input
void Game::OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode) {

	//If s was pressed then restart the game
	if (sym == SDLK_s ) { 
		restartGame();
	} 

	//key 1 & 2 are handled only when in menu
	if (gameType != 0) {
		return;
	}
	if (sym == SDLK_1) {
		gameType = 1;
	}
	if (sym == SDLK_2) {
		gameType = 2;
	}
}
コード例 #28
0
ファイル: GameWindow.cpp プロジェクト: wwong412/pic10c
void GameWindow::userWon(){
    timer->stop();
    popUpWindow = new QWidget();
    QLabel *label = new QLabel("Congratulations!! YOU WON!! ");
    QVBoxLayout *layout = new QVBoxLayout;
    QVBoxLayout *buttonlayout = new QVBoxLayout;
    QPushButton *closebutton = new QPushButton("Exit");
    QPushButton *againbutton = new QPushButton("Play Again");
    QObject::connect(closebutton, SIGNAL(pressed()), this, SLOT(closeGame()));
    QObject::connect(againbutton, SIGNAL(pressed()), this, SLOT(restartGame()));
    layout->addWidget(label);
    buttonlayout->addWidget(closebutton);
    buttonlayout->addWidget(againbutton);
    layout->addLayout(buttonlayout);
    popUpWindow->setLayout(layout);
    popUpWindow->setFixedSize(300,300);
    popUpWindow->show();
}
コード例 #29
0
ファイル: widget.cpp プロジェクト: duventj/qarte
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
//menu
    QPushButton *quit = new QPushButton(tr("Quit"));
    quit->setFont(QFont("Times", 18, QFont::Bold));
    connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
    ui->menu->addWidget(quit, 0, 0);
//scene tapis
    scene = new QGraphicsScene(0,0,700,450);
     connect(scene, SIGNAL(selectionChanged()), this, SLOT(selection()));
    ui->graphicsView->setScene( scene );
    ui->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
//menu jeu playgame
    QPushButton *Cancel = new QPushButton(tr("Cancel"));
    Cancel->setFont(QFont("Times", 18, QFont::Bold));
    connect(Cancel, SIGNAL(clicked()), this, SLOT(recup_cards()));
    ui->playgame->addWidget(Cancel, 0, 0);

    LCDRange *mise = new LCDRange;
    ui->playgame->addWidget(mise, 0, 1);

    QPushButton *OK = new QPushButton(tr("OK"));
    OK->setFont(QFont("Times", 18, QFont::Bold));
    connect(OK, SIGNAL(clicked()), this, SLOT(change_cards()));
    ui->playgame->addWidget(OK, 0, 2);

// compte du joueur
    initJoueur(&joueur);

//lancement
    createHelp();
 
    initPaquet(&jeu);
    this->createCards();
    creerJeu(&jeu);  /* cree un jeu de 52 carte (complet) */
    melangerPaquet(&jeu);
    restartGame();

}
コード例 #30
0
// ---------------------------------------------------------
void KMahjongg::setupKAction()
{
    // game
    KStdGameAction::gameNew(this, SLOT(newGame()), actionCollection());
    KStdGameAction::load(this, SLOT(loadGame()), actionCollection());
    KStdGameAction::save(this, SLOT(saveGame()), actionCollection());
    KStdGameAction::quit(this, SLOT(close()), actionCollection());
    KStdGameAction::restart(this, SLOT(restartGame()), actionCollection());
    new KAction(i18n("New Numbered Game..."), "newnum", 0, this, SLOT(startNewNumeric()), actionCollection(), "game_new_numeric");
    new KAction(i18n("Open Th&eme..."), 0, this, SLOT(openTheme()), actionCollection(), "game_open_theme");
    new KAction(i18n("Open &Tileset..."), 0, this, SLOT(openTileset()), actionCollection(), "game_open_tileset");
    new KAction(i18n("Open &Background..."), 0, this, SLOT(openBackground()), actionCollection(), "game_open_background");
    new KAction(i18n("Open La&yout..."), 0, this, SLOT(openLayout()), actionCollection(), "game_open_layout");
    new KAction(i18n("Sa&ve Theme..."), 0, this, SLOT(saveTheme()), actionCollection(), "game_save_theme");
    // originally "file" ends here
    KStdGameAction::hint(bw, SLOT(helpMove()), actionCollection());
    new KAction(i18n("Shu&ffle"), "reload", 0, bw, SLOT(shuffle()), actionCollection(), "move_shuffle");
    demoAction = KStdGameAction::demo(this, SLOT(demoMode()), actionCollection());
    showMatchingTilesAction = new KToggleAction(i18n("Show &Matching Tiles"), 0, this, SLOT(showMatchingTiles()), actionCollection(), "options_show_matching_tiles");
    showMatchingTilesAction->setCheckedState(i18n("Hide &Matching Tiles"));
    showMatchingTilesAction->setChecked(Prefs::showMatchingTiles());
    bw->setShowMatch( Prefs::showMatchingTiles() );
    KStdGameAction::highscores(this, SLOT(showHighscores()), actionCollection());
    pauseAction = KStdGameAction::pause(this, SLOT(pause()), actionCollection());

    // TODO: store the background ; open on startup
    // TODO: same about layout
    // TODO: same about theme

    // move
    undoAction = KStdGameAction::undo(this, SLOT(undo()), actionCollection());
    redoAction = KStdGameAction::redo(this, SLOT(redo()), actionCollection());

    // edit
    new KAction(i18n("&Board Editor"), 0, this, SLOT(slotBoardEditor()), actionCollection(), "edit_board_editor");

    // settings
    KStdAction::preferences(this, SLOT(showSettings()), actionCollection());
    
    setupGUI();
}