コード例 #1
0
ファイル: main.cpp プロジェクト: Jawsarn/3D-Pacman
int main(void)
{
	GameManager gm = GameManager();

	UserCMD userCMD;
	userCMD.deltaMousePosition = glm::vec2(0,0);
	gm.Initialize();
	while (true)
	{
		userCMD.keys.push_back(1);	
		userCMD.keys.push_back(3);
		userCMD.deltaMousePosition = glm::vec2(0,0);
		gm.Update(userCMD);
	}
	
}
コード例 #2
0
ファイル: run.cpp プロジェクト: carriercomm/gamedev-old
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show)
#endif
{
    // setup random generator from start
    srand((unsigned int)time(NULL));

    glfwInit();
    GameManager manager = GameManager();

    double current_time, old_time, dt, next_update;
    old_time = glfwGetTime();

    while(true) {
        current_time = glfwGetTime();
        dt = current_time - old_time;

        if (dt <= 0.0)
            continue;

        old_time = current_time;
        next_update = current_time + 1.0 / FRAMERATE;

        // printf("%f\n", 1.0 / dt);
        if (!manager.update(dt))
            break;
        manager.draw();

        glfwSwapBuffers();
        if (!glfwGetWindowParam(GLFW_OPENED))
            break;

        dt = next_update - glfwGetTime();
        if (dt > 0.0) {
            glfwSleep(dt);
        }
    }
    return 0;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: adrianhartanto0/AE2CPP
int main(int argc, const char * argv[]) {

    GameManager mg = GameManager();
    
//    unsigned int time = 0;
//    unsigned int curr_time;
    
    while(mg.isGameRunning()){
        
//        curr_time = SDL_GetTicks();
        mg.receiveInput();
        mg.update();
        mg.render();
//        time = cur;
        
//        time = curr_time;
        
    }
    
    mg.quit();

    return 0;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: DGh0st/Hexagon-Fort
int main()
{
	// window
	sf::RenderWindow window(sf::VideoMode((int) (780 * 1.5), (int) (565 * 1.5)), "Hexagon Fort", (sf::Style::Close | sf::Style::Titlebar));
	window.setFramerateLimit(30);
	window.setMouseCursorVisible(false);

	// cursor
	sf::Texture cursorTexture;
	if (!cursorTexture.loadFromFile("images/mouse_pointer.png")) {
		return -1; // failed to load mouse pointer image
	}
	sf::Sprite cursor(cursorTexture);
	cursor.setScale(0.175f, 0.175f);

	// Setup game manager and map
	if (!GameManager::loadNecessaryFiles()) {
		return -1; // failed to load files so terminate application
	}
	GameManager manager(window);
	int gameState = 0; // 0 = start screen, 1 = in-game, 2 = pause, 3 = gameover
	int winner = -1; // -1 = no winner, 0 = red team won, 1 = blue team won
	sf::Sprite gameMap(GameManager::gameMapTexture);
	gameMap.setScale(1.5f, 1.5f);

	// background music
	sf::Music backgroundMusic;
	if (!backgroundMusic.openFromFile("sounds/Failing_Defense.ogg")) {
		return -1; // could not find the Failing_Defense music
	}
	backgroundMusic.setLoop(true);
	backgroundMusic.setVolume(25);
	backgroundMusic.play();

	while (window.isOpen())
	{
		sf::Event event;
		while (window.pollEvent(event)) {
			if (event.type == sf::Event::Closed)
				window.close();
		}

		if (window.isOpen()) {
			if (gameState == 0) {
				if (manager.isOnStartButton((sf::Vector2f) sf::Mouse::getPosition(window)) && sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
					//manager = GameManager(window); do not need to do this as we already initialized GameManager object
					gameState = 1; // go to in game
					winner = -1; // no winner
					GameManager::areTimersViable = true;
				}
			}
			else if (gameState == 1) {
				manager.runGameManager(window, 20, 0.75f);
				if (manager.getBlueTeamHealth() <= 0) {
					gameState = 3; // go to game over!
					winner = 0; // red won
					GameManager::areTimersViable = false;
				}
				else if (manager.getRedTeamHealth() <= 0) {
					gameState = 3; // go to game over!
					winner = 1; // blue won
					GameManager::areTimersViable = false;
				}
				else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
					gameState = 2; // go to pause game
					backgroundMusic.pause();
					GameManager::areTimersViable = false;
				}
			}
			else if (gameState == 2) {
				if (sf::Mouse::isButtonPressed(sf::Mouse::Left) && sf::IntRect(window.getPosition(), (sf::Vector2i) window.getSize()).contains(sf::Mouse::getPosition(window)) || sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
					gameState = 1; // go to in game (continue game)
					backgroundMusic.play();
					GameManager::areTimersViable = true;
				}
			}
			else if (gameState == 3) {
				if (sf::Mouse::isButtonPressed(sf::Mouse::Left) && sf::IntRect(window.getPosition(), (sf::Vector2i) window.getSize()).contains(sf::Mouse::getPosition(window)) || sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
					manager = GameManager(window);
					gameState = 1; // go to in game (restart game)
					winner = -1; // no winner
					GameManager::areTimersViable = true;
				}
			}
		}

		window.clear();

		window.draw(gameMap); // background map texture
		manager.draw(window, gameState, winner);

		if (window.isOpen()) {
			cursor.setPosition((sf::Vector2f)sf::Mouse::getPosition(window));
			window.draw(cursor);
		}

		window.display();
	}

	return 0;
}
コード例 #5
0
ファイル: Game.cpp プロジェクト: andreffs18/CG-2015
bool ERROR_LOG = true;

bool COLISION_SPHERE = false;

float GLOBAL1 = 0.0f;
float GLOBAL2 = 0.0f;
float GLOBAL3 = 0.0f;
float GLOBAL4 = 0.0f;
float GLOBAL5 = 0.0f;
float GLOBAL6 = 0.0f;


// initialize global log object
Log logger = Log();
// initialize game manager
GameManager gm = GameManager();

//  ---------------------------------------------------------------- main()
int main(int argc, char * argv[]) {
    // initialise glut library
    glutInit(&argc, argv);
    // request a RGBA display mode, and we want single buffering
    glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
    // set the initial window size
    glutInitWindowSize(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
    // set the initial window position
    glutInitWindowPosition(WINDOW_X_POS, WINDOW_Y_POS);
    // create the window with properties defined before
    glutCreateWindow(WINDOW_NAME);
    // stops continuisly pressing keyboard
    glutIgnoreKeyRepeat(1);
コード例 #6
0
int main(int argc,char** argv)
{
	GameManager GM=GameManager();
	GM.init( argc, argv);
	return 0;
}