コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: bmael/DameGame
/**
 * @brief Instanciates and starts all listeners thread (chat, online players).
 * @pre The client have to be connected before to call this function.
 */
void MainWindow::startListeners()
{
    // Start a thread for listening server requests.
    _listener = new Listener(_player.socket, this);

    connect(_listener, SIGNAL(pseudoAlreadyExists(QString)), this, SLOT(pseudoAlreadyExists(QString)));

    connect(_listener, SIGNAL(addMsg(QString)), this, SLOT(addMsg(QString)));

    connect(_listener, SIGNAL(addPlayerToView(player)), this, SIGNAL(askAddPlayer(player)));
    connect(_listener, SIGNAL(removePlayerFromView(player)), this, SIGNAL(askRmPlayer(player)));

    connect(_listener,  SIGNAL(advisePlayerForGame(QString)), this, SLOT(adviseForGame(QString)));
    connect(_listener, SIGNAL(advisePlayerForAbortedGame(QString)), this, SLOT(adviseForAbortedGame(QString)));

    connect(_listener, SIGNAL(startGame()), this, SLOT(startGame()));

    connect(_listener, SIGNAL(clientBusy(player)), ui->rightMenuWidget, SIGNAL(askSetBusy(player)));
    connect(_listener, SIGNAL(clientFree(player)), ui->rightMenuWidget, SIGNAL(askSetFree(player)));

    connect(_listener, SIGNAL(setOpponent(player)), this, SLOT(setOpponent(player)));
    connect(_listener, SIGNAL(opponentQuit(player)), this, SLOT(opponentQuit(player)));

    connect(_listener, SIGNAL(receiveCheckerboard(checkerboard)), ui->checkerboardwidget, SLOT(receiveCheckerboard(checkerboard)));
    connect(_listener, SIGNAL(receiveWinner(player)), this, SLOT(displayWinner(player)));
}
コード例 #2
0
ファイル: GameScene.cpp プロジェクト: AIRIA/CreazyBomber
void GameScene::onTexturesLoaded()
{
    auto util = MapUtil::getInstance();
    BaseLayer::onTexturesLoaded();
    MapUtil::getInstance()->initMapSize();
    if(isShowTip()==false)
    {
        startGame();
    }
    else
    {
        /* 显示提示UI */
        auto wrapper = Node::create();
        auto tipBg = SPRITE("default.png");
        std::string tipName = util->getMapName()+".png";
        auto tip = SPRITE(tipName);
        wrapper->addChild(tipBg);
        wrapper->addChild(tip);
        wrapper->setPosition(VisibleRect::center());
        addChild(wrapper);
        wrapper->setScale(GameManager::getInstance()->getScaleFactor());
        wrapper->runAction(Sequence::create(DelayTime::create(3.0f),CallFunc::create([&,this,wrapper]()->void{
            startGame();
            wrapper->removeFromParent();
        }), NULL));
    }
   
    
    return;
}
コード例 #3
0
ファイル: Game.cpp プロジェクト: Aterwik111/PP
void Game::onEnter(int param) {
	gameState = 0;
	char path[TXT_FIELD_WIDTH];
	if (param == 0) {
		if (loadFromFile(DEFAULT_LABIRYNTH_NAME)) {
			startGame();
		}
		else {
			systemModule->dialog("Nie udalo sie wczytac domyslnego labiryntu!");
			systemModule->gotoLevel(&systemModule->menuLvl,0);
		}
	}
	else {		
		if (systemModule->textInputDialog("Prosze podac sciezke do pliku z labiryntem do wczytania", path)){
			if (loadFromFile(path)) { //sprobuj wczytac plik
				startGame();
			}
			else {
				systemModule->dialog("Nie udalo sie wczytac podanego labiryntu!");
				systemModule->gotoLevel(&systemModule->menuLvl, 0);
			}
		}
		else {
			systemModule->gotoLevel(&systemModule->menuLvl, 0);
		}
	}
}
コード例 #4
0
GameWidget::GameWidget(Scene *scene, QWidget *parent) :
    QGraphicsView(parent),
    m_scene(scene),
    m_timeLabel(this),
    m_checkpointRemainingLabel(this),
    m_paused(false),
    m_cameraScale(1.f),
    m_frameCount(0),
    m_timeBeforeStartLabel(this)
{
    if (!scene)
    {
        QMessageBox::information(nullptr, "Erreur (GameWidget)", "Aucune scène a afficher!", 0);
    }
    else if (!scene->loaded())
    {
        QMessageBox::information(nullptr, "Erreur (GameWidget)", "Le niveau n'a pas été chargé!", 0);
    }
    else
    {       
        this->setCursor(Qt::BlankCursor);

        //Placement du label du timer
        m_timeLabel.setGeometry(0,0,500,50);
        m_timeLabel.setStyleSheet("color: white;font: 24pt \"Leelawadee UI\";");

        //Placement du label du nombre de checkpoints restants
        m_checkpointRemainingLabel.setGeometry(parent->width()-250,0,250,50);
        m_checkpointRemainingLabel.setStyleSheet("color: white;font: 14pt \"Leelawadee UI\";");

        //Placement du label du affichant le temps avant le début de la partie
        m_timeBeforeStartLabel.setGeometry(350,250,100,100);
        m_timeBeforeStartLabel.setStyleSheet("font: 72pt \"Leelawadee UI\";");

        // prépare la scène pour l'affichage
        this->setScene(scene->graphicsScene());
        this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

        // réglages du clavier
        grabKeyboard();
        scene->setPlayerInput(&m_playerInput);

        // démarrage du timer de rafraichissement du jeu
        startTimer(sf::seconds(1/60.f).asMilliseconds());

        //Centrage de la caméra
        View view = m_scene->calcViewPoint();
        centerOn(view.position());

        //Démarrage du timer de début de course ( 3,2,1 -> Go)
        m_preStartTimer = new PreStartTimer(this);
        m_preStartTimer->startTimer();
        connect(m_preStartTimer,SIGNAL(startGame()),this,SLOT(startGame()));

    }
}
コード例 #5
0
ファイル: mainwindow.cpp プロジェクト: jsj2008/kdegames
void MainWindow::startGameDispatcher()
{
	if (sender() == m_newUntimedAct)
		startGame(KDiamond::UntimedGame);
	else if (sender() == m_newTimedAct)
		startGame(KDiamond::NormalGame);
	else
		//attention: this may also be used by KgDifficulty and the ctor
		startGame(Settings::untimed() ? KDiamond::UntimedGame : KDiamond::NormalGame);
}
コード例 #6
0
ファイル: main.cpp プロジェクト: NinjaTrappeur/pong-client
int main(int argc, char *argv[])
{
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    QApplication a(argc, argv);
    MainWindow w;
    Lobby lobby;
    QObject::connect(&lobby, SIGNAL(startGame(QString,qint16)), &w, SLOT(startGame(QString,qint16)));
    lobby.show();


    return a.exec();

}
コード例 #7
0
ファイル: GameManager.cpp プロジェクト: shadowpt/CastleBlast
	void GameManager::preOnMouse(int button, int state, int x, int y) 
	{
		if (!_gameMode) {
			if(x >= 265 && x <= 555 && y >= 270 && y <= 330)
				startGame(2);
		}
	}
コード例 #8
0
bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
{
    assert(m_setup); // assert that the setup exists
    if (event->getType() == EVENT_TYPE_MESSAGE)
    {
        const NetworkString &data = event->data();
        assert(data.size()); // assert that data isn't empty
        uint8_t message_type = data[0];
        if (message_type == 0x03 ||
            message_type == 0x06)
            return false; // don't treat the event

        event->removeFront(1);
        Log::info("ClientLobbyRoomProtocol", "Asynchronous message of type %d", message_type);
        if (message_type == 0x01) // new player connected
            newPlayer(event);
        else if (message_type == 0x02) // player disconnected
            disconnectedPlayer(event);
        else if (message_type == 0x04) // start race
            startGame(event);
        else if (message_type == 0x05) // start selection phase
            startSelection(event);
        else if (message_type == 0x80) // connection refused
            connectionRefused(event);
        else if (message_type == 0x81) // connection accepted
            connectionAccepted(event);
        else if (message_type == 0x82) // kart selection refused
            kartSelectionRefused(event);
        else if (message_type == 0xc0) // vote for major mode
            playerMajorVote(event);
        else if (message_type == 0xc1) // vote for race count
            playerRaceCountVote(event);
        else if (message_type == 0xc2) // vote for minor mode
            playerMinorVote(event);
        else if (message_type == 0xc3) // vote for track
            playerTrackVote(event);
        else if (message_type == 0xc4) // vote for reversed mode
            playerReversedVote(event);
        else if (message_type == 0xc5) // vote for laps
            playerLapsVote(event);

        return true;
    } // message
    else if (event->getType() == EVENT_TYPE_CONNECTED)
    {
        return true;
    } // connection
    else if (event->getType() == EVENT_TYPE_DISCONNECTED) // means we left essentially
    {
        NetworkManager::getInstance()->removePeer(m_server);
        m_server = NULL;
        NetworkManager::getInstance()->disconnected();
        m_listener->requestTerminate(this);
        NetworkManager::getInstance()->reset();
        // probably the same as m_server
        NetworkManager::getInstance()->removePeer(event->getPeer());
        return true;
    } // disconnection
    return false;
}   // notifyEventAsynchronous
コード例 #9
0
ファイル: game.cpp プロジェクト: obono/ArduboyWorks
static void updateGameIssues(void)
{
    handleDPad();
    if (issue == COUNT_ISSUES && padX > 0) padX = 0;
    if (padX != 0 || padY != 0) {
        int tmp = issue + padX + padY * 5;
        if (tmp >= 0 && tmp <= COUNT_ISSUES + 4) {
            issue = min(tmp, COUNT_ISSUES);
            playSoundTick();
            isInvalid = true;
        }
    }
    if (arduboy.buttonDown(A_BUTTON)) {
        setSound(!arduboy.isAudioEnabled());
        playSoundClick();
        isInvalid = true;
    }
    if (arduboy.buttonDown(B_BUTTON)) {
        if (issue == COUNT_ISSUES) {
            state = STATE_LEAVE;
            playSoundClick();
        } else {
            startGame();
        }
    }
}
コード例 #10
0
ファイル: GroupGame.cpp プロジェクト: corecode/CuteCW
void GroupGame::play()
{
    clear();
    startGame();

    QModeStart startInfo(0, tr("Grouping Game"));
    QVBoxLayout *layout = startInfo.mainLayout();

    QFormLayout form;
    layout->addLayout(&form);

    QSpinBox groupLength;
    m_groupLengthSpinBox = &groupLength;
    groupLength.setValue(int(m_goodGuesses - m_badGuesses / GROUPLENGTH_WEIGHT));
    if (groupLength.value() < 1)
        groupLength.setValue(1);
    groupLength.setMaximum(m_WPM);
    form.addRow(tr("Starting Group Length:"), &groupLength);

    QSpinBox WPM;
    WPM.setValue(m_WPM);
    connect(&WPM, SIGNAL(valueChanged(int)), this, SLOT(limitLength(int)));
    form.addRow(tr("Starting WPM:"), &WPM);

    if (startInfo.exec() == QDialog::Accepted) {
        m_goodGuesses = GROUPLENGTH_WEIGHT * (groupLength.value() - 1);
        m_WPM = WPM.value();
        m_morse->createTones(m_WPM);
        startNextGroup();
    }
    m_groupLengthSpinBox = 0;
}
コード例 #11
0
ファイル: events.c プロジェクト: theronrabe/gameMachine
int main(int argc, char **argv) {
	//Graphics Stuff
	glutInit(&argc, argv);

	//Framework Stuff
	createHeadInst();
	startGame(argc, argv);
	glutKeyboardFunc(KeyDown);
	glutKeyboardUpFunc(KeyUp);
	glutMouseFunc(Mouse);
	glutTimerFunc(GAME.STEPTIME, Step, 0);
	glutDisplayFunc(Draw);
	glutTimerFunc(GAME.FRAMERATE, FPS, 0);
	glutPassiveMotionFunc(moveMouse);
	//glutIdleFunc(Draw);

	//Aaaaand... we're off!
	loadShaders("gameMachine/vertShader", "gameMachine/fragShader");
	glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH|GLUT_STENCIL);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glEnable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glutMainLoop();

	return 0;
}
コード例 #12
0
ファイル: window.cpp プロジェクト: huy10/GoBang
void Window::dealMenu(void)
{
	QMenuBar * MenuBar = new QMenuBar(this);
	QMenu * GameMenu = new QMenu(tr("GAME"), MenuBar);
	QMenu * HelpMenu = new QMenu(tr("Help"), MenuBar);

	QAction * StartGame = new QAction(tr("Start"), GameMenu);
	QAction * StopGame = new QAction(tr("End"), GameMenu);
	QAction * QuitGame = new QAction(tr("Quit"), GameMenu);
	GameMenu->addAction(StartGame);
	GameMenu->addAction(StopGame);
	GameMenu->addAction(QuitGame);
	MenuBar->addMenu(GameMenu);
	connect(StartGame, SIGNAL(triggered()), this, SLOT(startGame()));
	connect(StopGame, SIGNAL(triggered()), this, SLOT(stopGame()));
	connect(QuitGame, SIGNAL(triggered()), this, SLOT(close()));


	QAction * About = new QAction(tr("About"), HelpMenu);
	HelpMenu->addAction(About);
	MenuBar->addMenu(HelpMenu);
	connect(About, SIGNAL(triggered()), this, SLOT(showAbout()));


	setMenuBar(MenuBar);
}
コード例 #13
0
void Game::keyPressEvent(QKeyEvent *event) {
    switch (event->key()) {
    case Qt::Key_Left:
         snake->dir = Snake::LEFT;
       break;
    case Qt::Key_Right:
          snake->dir = Snake::RIGHT;
        break;
    case Qt::Key_Up:
          snake->dir = Snake::UP;
        break;
    case Qt::Key_Down:
          snake->dir = Snake::DOWN;
        break;
    case Qt::Key_P:
          pauseGame();
        break;
    case Qt::Key_Space:
          startGame();
        break;
    case Qt::Key_Escape:
          qApp->exit();
        break;
    default:
        QWidget::keyPressEvent(event);
    }
    repaint();
}
コード例 #14
0
ファイル: CMT.cpp プロジェクト: yzliang/vcmi
void startGameFromFile(const std::string &fname)
{
	StartInfo si;
	try //attempt retrieving start info from given file
	{
		if(!fname.size() || !boost::filesystem::exists(fname))
			throw std::runtime_error("Startfile \"" + fname + "\" does not exist!");

		CLoadFile out(fname);
		if(!out.sfile || !*out.sfile)
		{
			throw std::runtime_error("Cannot read from startfile \"" + fname + "\"!");
		}
		out >> si;
	}
	catch(std::exception &e)
	{
		logGlobal->errorStream() << "Failed to start from the file: " + fname << ". Error: " << e.what() 
			<< " Falling back to main menu.";
		GH.curInt = CGPreGame::create();
		return;
	}

	while(GH.topInt())
		GH.popIntTotally(GH.topInt());
	startGame(&si);
}
コード例 #15
0
ファイル: GamesScence.cpp プロジェクト: bluesky466/Tetris
void GamesScence::btRestartCallback(Ref* pSender,Widget::TouchEventType type)
{
	if(type == Widget::TouchEventType::ENDED)
	{
		startGame();
	}
}
コード例 #16
0
ファイル: gamescene.cpp プロジェクト: hellckt/DivineCraft
void GameScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    if(event->button()==Qt::LeftButton){
        if(!backPackBar->isShow() && !inOpWidget){
            if(!inSence){
                inSence=true;
                mouseLock();
                camera->bind();
                startGame();
            }
            else{
                emit removeBlock();
            }
        }
    }
    else if(event->button()==Qt::RightButton){
        if(!backPackBar->isShow() && !inOpWidget){
            if(inSence){
                emit addBlock();
            }
        }
    }
    else if(event->button() & Qt::MidButton){       //中间拾取
        if(!backPackBar->isShow()){
            if(inSence){
                //...获得已选中方块的属性并传给物品栏
                if(camera->getKeyPosition().y()>=0)
                    itemBar->midBlock(world->getBlockIndex(world->getBlock(camera->getKeyPosition())->getId()));
            }
        }
    }
    QGraphicsScene::mousePressEvent(event);
}
コード例 #17
0
ファイル: KBlocksWin.cpp プロジェクト: KDE/kblocks
void KBlocksWin::startGame()
{
    qsrand(time(0));
    mpGameLogic->setGameSeed(qrand());
    if (mpGameLogic->startGame(mGameCount)) {
        mpPlayManager->startGame();

        mpGameScene->createGameItemGroups(mGameCount, false);
        mpGameScene->startGame();

        int levelUpTime = 0;
        switch ((int) Kg::difficultyLevel()) {
        case KgDifficultyLevel::Medium:
            levelUpTime = 5;
            break;
        case KgDifficultyLevel::Hard:
            levelUpTime = 10;
            break;
        }
        mpGameLogic->levelUpGame(levelUpTime);

        Kg::difficulty()->setGameRunning(true);
    } else {
        stopGame();
        startGame();
    }

    mScore->setText(i18n("Points: %1 - Lines: %2 - Level: %3", 0, 0, 0));

    m_pauseAction->setEnabled(true);
    m_pauseAction->setChecked(false);
}
コード例 #18
0
ファイル: testApp.cpp プロジェクト: adamschoenemann/Pinball
//--------------------------------------------------------------
void testApp::keyPressed(int key){
	if(gameOver){
		gameOver = 0;
		gameEndsAt = ofGetElapsedTimeMillis() + gameDuration;
		circles.clear();
		lastTimeUsed = ofGetElapsedTimeMillis();
		startGame();
		return;
	}
	if(ofGetElapsedTimeMillis() - cooldown > lastTimeUsed){
		real str = 500.0f;
		Vector2 vec;
		if(key == 'a'){
			vec.x = -1;
		}
		if(key == 'w'){
			vec.y = -1;
		}
		if(key == 'd'){
			vec.x = 1;
		}
		if(key == 's'){
			vec.y = 1;
		}

		pball->setVelocity(pball->getVelocity() + vec * str);
		lastTimeUsed = ofGetElapsedTimeMillis();
	}
}
コード例 #19
0
ファイル: Game.cpp プロジェクト: Selfer/ICP-2015
void Game::showGameOverMenu(int player_id) {
    int n = scene->items().size();
    for(int i = 0; i < n; i++) {
        scene->items()[i]->setEnabled(false);
    }
    drawPanel(0, 0, 1024, 768, QColor(Qt::lightGray), 0.65);
    drawPanel(1024/2 - 200,200,400,400,QColor(Qt::darkGray), 0.85);
    QGraphicsTextItem *lbl_go_text = new LabelItem("Konec hry", 0, 0);
    lbl_go_text->setPos(scene->width()/2 - lbl_go_text->boundingRect().width()/2, 250);
    scene->addItem(lbl_go_text);
    QGraphicsTextItem *lbl_player_won = new LabelItem(QString("Vyhral hrac c. %1").arg(player_id), 0, 0);
    lbl_player_won->setPos(scene->width()/2 - lbl_player_won->boundingRect().width()/2, 275);
    scene->addItem(lbl_player_won);
    Button *restart_btn = new Button(QString("Hrat znovu"));
    int x = scene->width()/2 - restart_btn->boundingRect().width()/2;
    int y = 325;
    restart_btn->setPos(x, y);
    connect(restart_btn, SIGNAL(clicked()), this, SLOT(startGame()));
    scene->addItem(restart_btn);

    Button *back_to_menu_btn = new Button(QString("Vratit do menu"));
    x = scene->width()/2 - back_to_menu_btn->boundingRect().width()/2;
    y += 75;
    back_to_menu_btn->setPos(x, y);
    connect(back_to_menu_btn, SIGNAL(clicked()), this, SLOT(showMainMenu()));
    scene->addItem(back_to_menu_btn);

    Button *exit_btn = new Button(QString("Konec"));
    x = scene->width()/2 - exit_btn->boundingRect().width()/2;
    y += 75;
    exit_btn->setPos(x, y);
    connect(exit_btn, SIGNAL(clicked()), this, SLOT(close()));
    scene->addItem(exit_btn);
}
コード例 #20
0
ファイル: playfield.cpp プロジェクト: alasin/knavalbattle
void PlayField::restart(bool ask)
{
    Animator::instance()->restart();
    m_seaView->clear();
    startGame();
    m_controller->restart(ask);
}
コード例 #21
0
void Window::loadGame()
{
	// Load board
	QSettings settings;
	int seed = settings.value("Current/Seed", m_seed).toInt();
	int difficulty = settings.value("Current/Difficulty", m_difficulty).toInt();
	int algorithm = settings.value("Current/Algorithm", m_algorithm).toInt();
	QStringList moves = settings.value("Current/Moves").toStringList();
	if (settings.value("Current/Version").toInt() != 2) {
		moves.clear();
	}
	startGame(seed, difficulty, algorithm);

	// Load moves
	QRegExp parse("(-?\\d+)x(-?\\d+) to (-?\\d+)x(-?\\d+)");
	for (const QString& move : moves) {
		if (!parse.exactMatch(move)) {
			continue;
		}

		QPoint old_hole(parse.cap(1).toInt(), parse.cap(2).toInt());
		QPoint new_hole(parse.cap(3).toInt(), parse.cap(4).toInt());
		if (m_board->isPeg(old_hole) && m_board->isHole(new_hole)) {
			m_board->move(old_hole, new_hole);
		} else {
			qWarning("Invalid move: %dx%d to %dx%d", old_hole.x(), old_hole.y(), new_hole.x(), new_hole.y());
		}
	}
}
コード例 #22
0
void doStartButton() 
{
	if (g_state == STATE_PLAYING) {
		paused = !paused;
	} else if (g_state == STATE_GAMEOVER) {
		backToTitleScreen();
	} else if (g_state == STATE_TITLE) {

		if (g_menuState == MENU_DESCRIBE_LEVEL) {
			startGame();						
		} else if (g_menuState == MENU_PICK_LEVEL) {
			g_menuState = MENU_DESCRIBE_LEVEL;
		} else if (g_menuState == MENU_MAINMENU) {
			if (g_menuItem==0) {
				
				// Play
				g_menuState = MENU_PICK_LEVEL;
			} else if (g_menuItem==1) {
				// Hi Scores
				g_state = STATE_GAMEOVER;
			} else if (g_menuItem==2) {			
				// Help
				g_menuState = MENU_HELP;
			} else if (g_menuItem==3) {
				do_quit();
			}
		} else if (g_menuState == MENU_HELP ) {
			g_menuState = MENU_MAINMENU;
		}
	}	
}
コード例 #23
0
ファイル: ReadyCommand.cpp プロジェクト: ishigo974/rtype
        void        Ready::execute()
        {
            Component::Player*      player =
                _entity->getComponent<Component::Player>();
            Component::NetworkTCP*  network =
                _entity->getComponent<Component::NetworkTCP>();
            Component::Room*        room;

            if (player == nullptr || network == nullptr)
                throw std::runtime_error("Entity does not have a "
                                         "player/network component");
            if ((room = player->getRoom()) == nullptr
                || !room->setPlayerReadiness(*_entity, true))
                network->send(Server::responseKO);
            else
            {
                RType::Request         request(RType::Request::SE_CLIENTRDY);

                request.push<uint8_t>("player_id", room->getPlayerId(*_entity));
                network->send(Server::responseOK);
                room->broadcastTCP(request.toBuffer(), _entity);
                if (room->allReady())
                    startGame(room);
            }
        }
コード例 #24
0
ファイル: Game.cpp プロジェクト: amarocolas/Game
//--------------------------------------------------------------
void Game::keyReleased(int key) 
{    
    if (key == 'p') startGame();
    if (key == 'r') toggleState();
    
    if (!locked)
    {
        //players keyboards extra controls
        switch(key)
        { 
            case OF_KEY_UP: playerList[0].applyImpulse(); break;
			case OF_KEY_DOWN: playerList[0].setDirection(0); break;
            case OF_KEY_LEFT: playerList[0].setDirectionIncrement(-1); break;
			case OF_KEY_RIGHT: playerList[0].setDirectionIncrement(1); break;
            
            case 'w': playerList[1].applyImpulse(); break;
            case 's': playerList[1].setDirection(0); break;
            case 'a': playerList[1].setDirectionIncrement(-1); break;
            case 'd': playerList[1].setDirectionIncrement(1); break;
            
            case 'y': playerList[2].applyImpulse(); break;
            case 'h': playerList[2].setDirection(0); break;
            case 'g': playerList[2].setDirectionIncrement(-1); break;
            case 'j': playerList[2].setDirectionIncrement(1); break;
            
            case 'Y': playerList[3].applyImpulse(); break;
            case 'H': playerList[3].setDirection(0); break;
            case 'G': playerList[3].setDirectionIncrement(-1); break;
            case 'J': playerList[3].setDirectionIncrement(1); break;
        }
    }
}
コード例 #25
0
ファイル: main.c プロジェクト: cnsoft/librgs
void onKeyPress(int keyCode) {

	if(titleScreen->visible == 1) {
		titleScreenKeyPress(keyCode);
		return;
	}

	if(helpScreen->visible == 1) {
		helpScreen->visible = 0;
		startGame();
		return;
	}
	
	if(gameoverScreen->visible == 1) {
		if(gameoverkeylock == 0) {
			gameoverScreen->visible = 0;
			titleScreen->visible = 1;
		}
		return;
	}

	if(aboutScreen->visible == 1) {
		hideIntro();
		return;
	}

	if(	hiscoreScreen->visible == 1) {
			hiscoreScreen->visible = 0;
			titleScreen->visible = 1;
			return;
	}
	
	
	gameScreenKeyPress(keyCode);
}
コード例 #26
0
ファイル: 猜测游戏.cpp プロジェクト: alannet/example
void guessGame::play()
{
    startGame();
    showGuess();
    while(playMore())
        showGuess();
}
コード例 #27
0
void showMenu()
{
	int selectMenu = 0;

	while (1)
	{
		printf("** Bulls And Cows **\n");
		printf("  [1] Start Game\n");
		printf("  [2] Exit Game\n");

		printf(" [] select Number : ");
		scanf("%d", &selectMenu);
		clearEnter();

		switch (selectMenu)
		{
			case 1:
				startGame();
				break;
			case 2:
				exitGame();
				exit(0);
				break;
			default:
				printf("[Error] Invalid value selected!\n");
				showMenu();
				break;
		}
	}
}
コード例 #28
0
ファイル: mainwindow.cpp プロジェクト: ArtChecnokov/conway
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    currentColor(QColor("#000")),
    game(new GameWidget(this))
{
    ui->setupUi(this);

    QPixmap icon(16, 16);
    icon.fill(currentColor);
    ui->colorButton->setIcon( QIcon(icon) );

    connect(ui->startButton, SIGNAL(clicked()), game,SLOT(startGame()));
    connect(ui->stopButton, SIGNAL(clicked()), game,SLOT(stopGame()));
    connect(ui->clearButton, SIGNAL(clicked()), game,SLOT(clear()));
    connect(ui->iterInterval, SIGNAL(valueChanged(int)), game, SLOT(setInterval(int)));
    connect(ui->cellsControl, SIGNAL(valueChanged(int)), game, SLOT(setCellNumber(int)));
    connect(ui->colorButton, SIGNAL(clicked()), this, SLOT(selectMasterColor()));

    connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveGame()));
    connect(ui->loadButton, SIGNAL(clicked()), this, SLOT(loadGame()));

    ui->mainLayout->setStretchFactor(ui->gameLayout, 8);
    ui->mainLayout->setStretchFactor(ui->setLayout, 2);
    ui->gameLayout->addWidget(game);
}
コード例 #29
0
void BaseGame::toggleState() {
	
	if(state==STATE_PLAYING) changeState(STATE_GAMEOVER);
	else startGame(); 


}
コード例 #30
0
// main menu
void startMenu()
{
	int menuNum=0;
	char key;
	system("cls");
	setWindowSize();
	startImage();

	while(1)
	{
		Sleep(200);
		if(kbhit())
		{
			key=getch();
			if(key=='1'||key=='2'||key=='3')
				break;
		}
	}
	if(key=='1')
	{
		startGame();
		return;
	}
	else if (key=='2')
	{
		showRank();
		Sleep(2000);
		startMenu();
		return;
	}else if(key=='3')
		exit;
	
	return;
}