Пример #1
0
void
MyWindow::Render()
{
	m_bg->Draw();

	for (int i = 0; i < NUM_ICONS; i++)
		m_icons[i]->Draw();
}
Пример #2
0
//Called to update the display
void DisplayFunc()
{
	float current_time = float(glutGet(GLUT_ELAPSED_TIME)) / 1000.0f;

	glEnable(GL_CULL_FACE);
	glEnable(GL_NORMALIZE);
	glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glViewport(0, 0, window.size.x, window.size.y);
	background.Draw(window.size);
	Window::time = (window.paused ? window.time_last_pause_began : current_time) - window.total_time_paused;

	//Draw the current scene!
	switch(Window::currentScene){
	case 0:
		scene1.Draw(Window::time);
		break;
	
	case 1:
		scene2.Draw(Window::time);
		break;

	case 2:
		scene3.Draw(Window::scene3rotation, Window::time);
		break;

	case 3:
		scene4.Draw(Window::time);
		break;

	case 4:
		scene5.Draw(Window::time);
		break;

	case 5:
		scene6.Draw(Window::time);
		break;

	case 6:
		scene7.Draw(Window::time);
		break;
	case 7:
		scene8.Draw(Window::time);
		break;
	}

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	DisplayInstructions();
	glFlush();
}
Пример #3
0
/********************************************************
	render() called in main as: glutDisplayFunc(render);												
	The render function is used to draw objects
	to the screen.
********************************************************/
void render() {

	switch (Current_Game_Scene_Enum)
	{
	case _scene_start_menu:

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				//Clear the screen of previous drawn data
		
		//if player hits ENTER_KEY, change CURRENT_GAME_SCENE_ENUM == _scene_new_game_intro
		//glutTimerFunc(ms, startMenuKeypress, 0);

		glLoadIdentity();

		//camara
		gluLookAt(0, -1, 5, 0, 0, 0, 0, 1, 0);

		//draw BKGRND glQuad to the screen
		background.DrawStartMenuBackground();

		loadTitle();

		//swap buffers to clear and redraw
		glutSwapBuffers();

		break;

	case _scene_new_game_intro:
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				//Clear the screen of previous drawn data

		glutTimerFunc(ms, timeTick, 0);									//update at 60 frames per second

		glLoadIdentity();

		gluLookAt(0.0, 30.0, 90.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

		renderIntroText();

		background.DrawNewGameIntroBackground();

		if (fadeStarted && !(gameActive)) {
			decrementCount = sceneTransition.FadeOut(decrementCount);
			//check shrinking count for fadeout finished = 0
			if (decrementCount <= 0) {
				//change scene for render scene switch
				Current_Game_Scene_Enum = _scene_level_one;
				//reset some variables
				customScrollingCount = 0;
				decrementCount = 0;
				//firstPassTimer = true;
				fadeStarted = false;
				gameActive = true;
				level++;
				}
		}
		
		glutSwapBuffers();

		break;

	case _scene_level_one:
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				//Clear the screen of previous drawn data

		glutTimerFunc(ms, update, 0);									//update at 60 frames per second

		glLoadIdentity();
		
		displayLevelTitle();
		//Camera
		gluLookAt(0, -1, 5, 0, 0, 0, 0, 1, 0);
		displayLevelTitle();	
		displayLevelText();
		loadPlayerTitle();
		lifeTitle();
		lifeCountNumber();
		background.Draw();

		//Draw player
		player[0]->setColor(1.0f, 0.0f, 0.0f);
		player[0]->Draw();

		//Draw the enemies
		for (unsigned int i = 0; i < enemies.size(); i++) {
			enemies[i]->Draw();
			enemyModel.Position(enemies[i]->getX(), enemies[i]->getY() - 0.5f, enemies[i]->getZ());
			enemyModel.drawObject();
		}

		enemySpawn();

		//after update checks for correct kill count, being fadeOut
		if (fadeStarted) {
			cleanUp();
			//init and update the decrement-count
			if (firstPassTimerL1) {
				decrementCount = sceneTransition.FadeOut(70.0f);
				firstPassTimerL1 = false;
			}
			else if (!firstPassTimerL1){
				decrementCount = sceneTransition.FadeOut(decrementCount);

				//check shrinking count for fadeout finished = 0
				if (decrementCount <= 0) {
					//change scene for render scene switch
					if(player[0]->lives < 0)
						Current_Game_Scene_Enum = _scene_game_over;	//-- goes back to start screen
					else 
						Current_Game_Scene_Enum = _scene_level_two;
																	//reset some variables
					customScrollingCount = 0;
					decrementCount = 0;
					player[0]->playerReset();
					level++;
					//firstPassTimer = true;
					fadeStarted = false;
				}
			}
		}

		glutSwapBuffers();		//Swaps the buffers when double buffer is used

		break;

	case _scene_level_two:
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				//Clear the screen of previous drawn data

		glutTimerFunc(ms, update, 0);				

		glLoadIdentity();

		//Camera
		gluLookAt(0, -1, 5, 0, 0, 0, 0, 1, 0);
		loadPlayerTitle();
		displayLevelTitle();	
		displayLevelText();
		lifeTitle();
		lifeCountNumber();
		background.Draw();

		//Draw player
		player[0]->setColor(1.0f, 0.0f, 0.0f);
		player[0]->Draw();

		//Draw the enemies

		for (unsigned int i = 0; i < enemies.size(); i++) {
			enemies[i]->Draw();
			enemyModel.Position(enemies[i]->getX(), enemies[i]->getY() - 0.5f, enemies[i]->getZ());
			enemyModel.drawObject();
		}

		enemySpawn();

		//after update checks for correct kill count, being fadeOut
		if (fadeStarted) {
			//init and update the decrement-count
			cleanUp();
			if (firstPassTimerL1) {
				decrementCount = sceneTransition.FadeOut(70.0f);
				firstPassTimerL1 = false;
			}
			else if (!firstPassTimerL1){
				decrementCount = sceneTransition.FadeOut(decrementCount);

				//check shrinking count for fadeout finished = 0
				if (decrementCount <= 0) {
					//change scene for render scene switch
					if(player[0]->lives < 0)
						Current_Game_Scene_Enum = _scene_game_over;	//-- goes back to start screen
					else 
						Current_Game_Scene_Enum = _scene_game_over;
																	//reset some variables
					customScrollingCount = 0;
					decrementCount = 0;
					//firstPassTimer = true;
					player[0]->playerReset();
					level = 0;
					fadeStarted = false;
				}
			}
		}

		glutSwapBuffers();		//Swaps the buffers when double buffer is used

		break;

	case _scene_game_over:	//not implemented, here for later use
		cleanUp();
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				//Clear the screen of previous drawn data
		glLoadIdentity();
		gameActive = false;
		killCount = 0;
		//camara
		gluLookAt(0, -1, 5, 0, 0, 0, 0, 1, 0);
		resetIntroScrolling();
		//draw BKGRND glQuad to the screen
		background.DrawStartMenuBackground();
		player[0]->lives = 0;
		gameOverScreen();
		
		level = 0;

		//swap buffers to clear and redraw
		glutSwapBuffers();
		break;

	case _scene_high_score:	//not implemented, here for later use
		break;

	case _scene_exit:
		exit(0);
		break;

	default:
		printf("FATAL ERROR: 'Current_Game_Scene_Enum' is not set to any of the current enum values");
		break;
	}

	if(gameActive) {
		if(player[0]->isAlive == false) {
			glutTimerFunc(resetTime, resetPlayer, 0);									//update at 60 frames per second
		}
	}
}