コード例 #1
0
int main(int argc, char *argv[]) {
    srand(time(0));

    if(!sysInit()) return 1;
    if(!sysLoadFiles()) return 1;

    gameModeInit();
    menuInit();
    gameTitle();

    while(!quit) {
        startTimer = SDL_GetTicks();

        sysInput();
        gameLogic();
        drawEverything();

        // Update the screen
        SDL_RenderPresent(renderer);
        
        // Limit the frame rate
        endTimer = SDL_GetTicks();
        deltaTimer = endTimer - startTimer;
        if(deltaTimer < (1000/FPS))
            SDL_Delay((1000/FPS)-deltaTimer);
    }
    blockCleanup();
    sysCleanup();
}
コード例 #2
0
ファイル: main.c プロジェクト: dorkster/espada2
int main(void) {
    srand(time(0));

    if(!sysInit()) return 1;
    if(!sysLoadFiles()) return 1;

    gameTitle();

    while(!quit) {
        startTimer = SDL_GetTicks();

        sysInput();
        gameLogic();
        drawEverything();

        // Update the screen
        if(SDL_Flip(screen) == -1) return 1;
        
        // Limit the frame rate
        endTimer = SDL_GetTicks();
        deltaTimer = endTimer - startTimer;
        if(deltaTimer < (1000/FPS))
            SDL_Delay((1000/FPS)-deltaTimer);
    }
    gameCleanup();
    sysCleanup();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: zeroxiii/CS1372_Assignments
void reset()
{
    //Reset game variables
    paddle[0].prow = PSTARTROW;
    paddle[0].pcol = PSTARTCOL;
    paddle[0].poldcol = 0;
    paddle[0].poldrow = 0;
    paddle[0].color = pcolor;
    brickCount = 0;
    ballCount = 0;

    //Reset Ball Struct
    for(i=0; i<NUM; i++)
    {
        theBalls[i].row = ROWSTART + rand()%20;
        theBalls[i].col = COLSTART + rand()%20;
        theBalls[i].size = SIZE;
        theBalls[i].rdelta = RDELSTART+rand()%2;
        theBalls[i].cdelta = CDELSTART+rand()%2;
        theBalls[i].oldrow = 0;
        theBalls[i].oldcol = 0;
        theBalls[i].visible = 1;
        theBalls[i].color = WHITE;
    }

    //Reset Brick Struct
    for(k=0; k<NUMBRICKS; k++)
    {
        theBricks[k].row = BSTARTROW;
        theBricks[k].col = BSTARTCOL + k*BWIDTH;
        theBricks[k].size = SIZE;
        theBricks[k].visible = 1;
        theBricks[k].color = rand()%32767;
    }

    //Reset game environment
    gameEnviroment(theBricks, paddle[0].color);

    //Display game title
    gameTitle();

    waitForVblank();
}
コード例 #4
0
QLayout*
GameSelectionWindow::createGameDisplayArea() {
	//  set up game choice widgets

	// maps to hold widgets, ensures alphabetical ordering
	QMap<QString, GameChoiceWidget*> learningGamesMap;
	QMap<QString, GameChoiceWidget*> dockingGamesMap;

	// add each available game to the appropriate list for display
	for (int i = 0; i < ms_gameControllerInstance->NUM_GAMES; ++i) {
		GameController::ExscitechGame game = (GameController::ExscitechGame) i;
		GameChoiceWidget* gameWidget = new GameChoiceWidget(game);

		if (!ms_gameControllerInstance->inOnlineMode()
				&& !GameInfoManager::gameHasOfflineMode(game)) {
			gameWidget->setEnabled(false);
		}

		QObject::connect(gameWidget, SIGNAL(gameChoiceSelected()), this,
				SLOT(handleGameSelection()));

		GameInfoManager::GameType gameType = GameInfoManager::getGameType(game);
		QString gameTitle(GameInfoManager::getGameTitle(game).c_str());
		if (gameType == GameInfoManager::LEARNING_GAME) {
			learningGamesMap.insert(gameTitle, gameWidget);
		} else if (gameType == GameInfoManager::JOB_SUBMIT_GAME) {
			dockingGamesMap.insert(gameTitle, gameWidget);
		}
	}

	// set up gui to hold game choice widgets

	// create layout for entire game selection area
	// area will consist of game type labels and lists of games in scroll panes
	QVBoxLayout* gameSelectionArea = new QVBoxLayout();

	// construct and add 'Learning Games' label
	QLabel* learningGameLabel = new QLabel(tr(ms_learningGamesTitle.c_str()));
	learningGameLabel->setFont(QFont("Times", 14, QFont::Bold));
	gameSelectionArea->addWidget(learningGameLabel, 0, Qt::AlignLeft);

	// construct scroll pane for list of learning games
	GameWidgetScrollArea* learningGamesScrollArea = new GameWidgetScrollArea(
			learningGamesMap);
	gameSelectionArea->addWidget(learningGamesScrollArea, 1);

	// add space between learning and job submit games
	gameSelectionArea->addSpacing(ms_gameListsGapSize);

	// construct and add 'Job Submit Games' label
	QLabel* dockingGameLabel = new QLabel(tr(ms_dockingGamesTitle.c_str()));
	dockingGameLabel->setFont(QFont("Times", 14, QFont::Bold));
	gameSelectionArea->addWidget(dockingGameLabel, 0, Qt::AlignLeft);

	// construct scroll pane for list of job submit games
	GameWidgetScrollArea* dockingGamesScrollArea = new GameWidgetScrollArea(
			dockingGamesMap);
	gameSelectionArea->addWidget(dockingGamesScrollArea, 1);

	return (gameSelectionArea);
}