コード例 #1
0
ファイル: main.cpp プロジェクト: rogueflynn/openglgame
/************************************************
			update() 
	All update logic goes in this function.
	update will keep track of the status and
	location of the player and tiles.
*************************************************/
void update(int data) {
	if(gameActive) {
		background.Scroll();
		//Calculates the frame rate
		previousTime = currentTime;
		currentTime = (float)glutGet(GLUT_ELAPSED_TIME);
		deltaTime = (currentTime - previousTime);

		enemyCollision();							//Check if the player has collided with an enemy
		playerMove(deltaTime);						//Move the player
		if (enemies.size() < 7 && enemyCount != 48)
			loadEnemies();

		if (enemies.size() == 1 && enemyCount == 48 && killCount < 20)
			cleanUp();

		/* KILL COUNT FOR LEVEL ! only */
		if (player[0]->lives <0) {
			fadeStarted = true;
			cleanUp();
		}
		if(enemies.size() == 1 && enemyCount == 48 && killCount >= 20) {
			killCount = 0;
			fadeStarted = true;
			cleanUp();
		}
	}
	//cout << "X: " <<  player[0]->getX() << " Y:" << player[0]->getY() << "\n";		
	glutPostRedisplay();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: lahagemann/digdug
void renderScene(bool miniMapOption)
{
    light.makeLight();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // limpar o depth buffer

    glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	if(miniMapOption)
        miniMapCam.setMiniMapCam();
    else
        cam.updateCam(game_map.player);

	loadPlayer();
	loadEnemies();
	loadIsland();
    glBindTexture(type, texture);
	renderSea();

	if(!PlaySound("Sounds\\56_Rocket_Tower_Takeover.wav", NULL, SND_ASYNC|SND_FILENAME|SND_LOOP|SND_NOSTOP ))
        PlaySound("Sounds\\56_Rocket_Tower_Takeover.wav", NULL, SND_ASYNC|SND_FILENAME|SND_LOOP|SND_NOSTOP );
}