コード例 #1
0
ファイル: MainLoop.cpp プロジェクト: akasakariki/stg
int CMainLoop::mainloop(void)
{
	if(debug_1==0)
	{
		setGameMode(GMODE_LOAD);//
		debug_1=1;
	}
	switch(gmode)
	{
		case GMODE_TITLE://タイトル画面
			title();
			break;

		case GMODE_LOAD:
			load();
			break;

		case GMODE_BODY://ゲーム本体
			body();
			break;

		case GMODE_CONFIG:
			config();
			break;

		case GMODE_GAMEOVER:
			gameover();
			break;

		case GMODE_END:
			end();
			break;
	}
	return 0;
}
コード例 #2
0
ファイル: gameframe.cpp プロジェクト: jpleau/sudoqu
void GameFrame::newBoard(std::vector<int> &g, std::vector<int> &b, GameMode m) {
    focused = -1;
    given = g;
    board = b;
    active = true;
    gameOver = false;
    mode = m;
    notes.clear();
    playersFocus.clear();
    emit setGameMode(mode);
    repaint();
}
コード例 #3
0
void Application::handleMouseEvents(){
	if(leftMouseButton){
		if(createGameButton->isPressed()){
			setGameMode(1);
		}
		else if(joinGameButton->isPressed()){
			setGameMode(2);
		}
		else if(versusButton->isPressed()){
			setGameMode(3);
		}
		else if(botGameButton->isPressed()){
			setGameMode(4);
		}
		else if(exitGameButton->isPressed()){
			this->isRunning = false;
		}
	}
	botGameButton->setPressed(false);
	versusButton->setPressed(false);
	createGameButton->setPressed(false);
	joinGameButton->setPressed(false);
	exitGameButton->setPressed(false);
}
コード例 #4
0
ファイル: TicTac.cpp プロジェクト: TAGC/TicTac
TicTac::TicTac()
:board(0)
{	
	setGameMode();
	setupBoard();
}
コード例 #5
0
/*
 * Executes a command given by the user
 *
 * @params: (command) - the command given by the user
 * @return: relevant exitcode
 */
int executeCommand(char* command){
	char str[64];
	sscanf(command, "%s", str);
	if (str_equals(str, "quit")){
		exit(0);
	}	
	if (state == SETTINGS){
		if (str_equals(str, "game_mode")){
			return setGameMode(command);
		}
		if (str_equals(str, "difficulty")){
			return setDifficulty(command);
		}
		if (str_equals(str, "user_color")){
			return setUserColor(command);
		}
		if (str_equals(str, "load")){
			return loadGameByCommand(command);
		}
		if (str_equals(str, "clear")){
			Board_clear(&board);
			PieceCounter_reset(counter);
			return 0;
		}
		if (str_equals(str, "next_player")){
			return setFirstPlayer(command);
		}
		if (str_equals(str, "rm")){
			return removePiece(command);
		}
		if (str_equals(str, "set")){
			return setPiece(command);
		}
		if (str_equals(str, "print")){
			display();
			return 0;
		}
		if (str_equals(str, "start")){
			if(PieceCounter_kingIsMissing(counter)){
				return -7;
			}	
			turn = first;
			state = GAME;
			return 2; //special value to break the humanTurn loop so the initial board will always be checked for immediate loss or tie conditions
		}
	}
	else{
		if (str_equals(str, "get_moves")){
			return printMovesOfPiece(command);
		}
		if (str_equals(str, "move")){
			return movePiece(command);
		}
		if (str_equals(str, "castle")){
			return castleRook(command);
		}
		if (str_equals(str, "get_best_moves")){
			return printBestMoves(command);
		}
		if (str_equals(str, "get_score")){
			return printMoveValue(command);
		}	
		if (str_equals(str,"save")){
			return saveGameByCommand(command);
		}
	}
	return -1;
}
コード例 #6
0
void startScreen() {
    scenario->resetScenario();
    gfxeng->setMenuBG();
    setMenu(new StartMenu());
    setGameMode(GAME_MENU);
}
コード例 #7
0
ファイル: gamescene.cpp プロジェクト: dragly/nanoparticles
GameScene::GameScene(GameView *parent) :
    QGraphicsScene(parent),
    m_level(1),
    m_highestLevel(1),
    m_gameState(GameRunning),
    m_dt(0),
    firstStep(true),
    m_selectedType(ParticlePositive),
    m_isSlowMotionEnabled(false),
    currentTime(0),
    lastFrameTime(0),
    frameNumber(0),
    dtSum(0)
{
    qRegisterMetaType<GameScene::GameMode>("GameMode");
    qRegisterMetaType<GameScene::GameState>("GameState");
#ifdef OS_IS_ANDROID
    qDebug() << "Force syncing settings";
    settings.sync();
#endif
    if(isDemo()) {
        qDebug() << "This is the demo version";
    } else {
        qDebug() << "This is the full version";
    }

    setSelectedType(ParticlePositive);

    // load images
    selectionImage = QImage(":/images/selection-overlay.png");
    positiveImage = QImage(":/images/particle-positive.png");
    negativeImage = QImage(":/images/particle-negative.png");
    neutralImage = QImage(":/images/particle-neutral.png");
    playerImage = QImage(":/images/particle-player.png");
    playerOverchargedImage = QImage(":/images/particle-player-overcharged.png");
    glowingImage = QImage(":/images/particle-glowing.png");
    enemyImage = QImage(":/images/particle-enemy.png");
    slowMotionImage = QImage(":/images/particle-slow-motion.png");
    repellentImage = QImage(":/images/particle-repellent.png");
    transferImage = QImage(":/images/particle-transfer.png");

    setSceneRect(0, 0, 854, 480); // TODO: just for init, should be chosen by the platform
    setItemIndexMethod(QGraphicsScene::NoIndex);

    // Background image
    QPixmap backgroundPixmap(":/images/background.png");
    backgroundImage = this->addPixmap(backgroundPixmap);

    // Main menu
    QDeclarativeEngine *engine = new QDeclarativeEngine;
//#ifdef OS_IS_ANDROID
//    QDeclarativeComponent mainMenuComponent(engine, QUrl(adjustPath("assets:/qml/MainMenu.qml")));
//#else
    QDeclarativeComponent mainMenuComponent(engine, QUrl("qrc:/qml/MainMenu.qml"));
//#endif
    engine->rootContext()->setContextProperty("contextGameScene", this);
    mainMenu = qobject_cast<QGraphicsObject *>(mainMenuComponent.create());
    qDebug() << "Component errors:\n" << mainMenuComponent.errors();
    qDebug() << "End component errors";
    // Connect the QML back to this class
    addItem(mainMenu);
    mainMenu->setZValue(1000);
    m_specialParticles = new QList<int>;

#ifdef OS_IS_HARMATTAN
    mainMenu->setProperty("exit.visible", false);
#endif


#ifdef OS_IS_SYMBIAN
    qreal screenWidth = QApplication::desktop()->screenGeometry().width();
    qreal screenHeight = QApplication::desktop()->screenGeometry().height();
    if(screenWidth  > screenHeight) { // Symbian hack
        mainMenu->setProperty("width", screenWidth);
        mainMenu->setProperty("height", screenHeight);
    } else {
        mainMenu->setProperty("width", screenHeight);
        mainMenu->setProperty("height", screenWidth);
    }
#endif

    // set up timer
    levelTimer = new QTimer(this);
    levelTimer->setInterval(1000);
    connect(levelTimer, SIGNAL(timeout()), SLOT(updateLevelTime()));

    // Set up animations
    timeFactorAnimation = new QPropertyAnimation(this, "timeFactor");
    qDebug() << "Highest level is" << m_level;

    setGameState(GameStarted);

    // just init all in the resize() function
    resized();

    // Start level and start timers
    //    startLevel(level());

    connect(&advanceTimer, SIGNAL(timeout()), SLOT(advance()));
    advanceTimer.start(10);
    time.start();
    qDebug() << "Timers started!";

    // dashboard button
#if (defined(OS_IS_DESKTOP_LINUX) || defined(Q_OS_WIN32) || defined(Q_OS_MAC) || defined(Q_WS_MAEMO_5))
    qDebug() << "Show dashboard button";
    mainMenu->setProperty("dashboardButtonVisible", true);
#else
    qDebug() << "Don't show dashboard button";
    mainMenu->setProperty("dashboardButtonVisible", false);
#endif

    // load settings
    setGameMode((GameMode)settings.value("gameMode", ModeClassic).toInt());
}