Exemplo n.º 1
0
//=======================================================================
// Display Function
//=======================================================================
void Display(void)
{
	current_time = glutGet(GLUT_ELAPSED_TIME);

	if(current_time - previous_time > 15)
	{
		previous_time = current_time;

		elapsedTimeLastFrame =  current_time - lastFrame;

		glClear(GL_COLOR_BUFFER_BIT); 

		switch(GameState)	
		{
		case GAMEOVER:

			glColor3f(1.0, 0.0, 0.0);
			
			glLineWidth(20);
			renderText("GAME OVER", WIDTH/5, HEIGHT/2, 10);
			
			glLineWidth(1);
			DisplayScore();

			break;

		case GAMEPLAY:
		
			glColor3f(1.0, 1.0, 1.0);

			Ship(WIDTH/2, HEIGHT/2, shipRotation);

			EnemyList.Render(elapsedTimeLastFrame);
		
			glColor3f(1,0,0);
			bulletsList.Render(elapsedTimeLastFrame);

			if(fireLaser)
			Laser();
		
			DisplayScore();
			DisplayHints();
		
			CalculateFPS();
			DisplayFPS();
		
			break;
		}

		/* update animation */
		bulletsList.CheckCollision(&EnemyList);
		
		lastFrame = current_time;

	    glutSwapBuffers();

	}

	glutPostRedisplay();
}
Exemplo n.º 2
0
//=======================================================================
// Timer Function
//=======================================================================
void timer(int)
{
    /* update animation */
	CalculateFPS();
	
	bulletsList.CheckCollision(&EnemyList);

    glutPostRedisplay();
    glutTimerFunc(1000.f/60.f, timer, 0);
}