예제 #1
0
	void Engine::Update()
	{
		//calculate core framerate
		p_frameCount_core++;
		if (p_coreTimer.stopwatch(999)) {
			p_frameRate_core = p_frameCount_core;
			p_frameCount_core = 0;
		}
	
		//fast update with no timing
		game_update();

		//update entities
		if (!p_pauseMode) UpdateEntities();

		//perform global collision testing at 20 Hz
		if (!p_pauseMode && collisionTimer.stopwatch(50)) 
		{
			TestForCollisions();
		}

		//update with 60fps timing
		if (!timedUpdate.stopwatch(14)) 
		{
			if (!this->getMaximizeProcessor()) 
			{
				Sleep(1);
			}
		}
		else {
			//calculate real framerate
			p_frameCount_real++; 
			if (p_realTimer.stopwatch(999)) 
			{
				p_frameRate_real = p_frameCount_real;
				p_frameCount_real = 0;
			}
	
			//update input devices
			p_input->Update();
			this->UpdateKeyboard();
			this->UpdateMouse();

			//update audio system
			audio->Update();

			//begin rendering
			this->RenderStart();
 
            //call game 3d rendering
            game_render3d();

			//render 3D entities 
			if (!p_pauseMode) Draw3DEntities();

            //begin 2d rendering
			Render2D_Start();

			//render 2D entities 
			if (!p_pauseMode) Draw2DEntities();

            //let game do 2d rendering
			game_render2d();

            //done with 2d rendering
			Render2D_Stop();
        			
			//done rendering
			this->RenderStop();
		}

		//remove dead entities from the list	
		BuryEntities();
	}
	void Engine::Update()
	{
		//calculate core framerate
		p_frameCount_core++;
		if (p_coreTimer.stopwatch(999)) {
			p_frameRate_core = p_frameCount_core;
			p_frameCount_core = 0;
		}
	
		//fast update with no timing
		game_update();

//****CHAPTER 7			
		//update entities
		if (!p_pauseMode) UpdateEntities();

//*****ADD IN CHAPTER 9
//***correction
		//perform global collision testing at 20 Hz
		//***too much slowdown
		//if (!p_pauseMode && collisionTimer.stopwatch(50)) 
		if (!p_pauseMode)// && collisionTimer.stopwatch(5)) 
		{
			TestForCollisions();
		}


		//update with 60fps timing
		if (!timedUpdate.stopwatch(14)) {
			if (!this->getMaximizeProcessor()) 
			{
				Sleep(1);
			}
		}
		else {
			//calculate real framerate
			p_frameCount_real++; 
			if (p_realTimer.stopwatch(999)) {
				p_frameRate_real = p_frameCount_real;
				p_frameCount_real = 0;
			}
	
//***CHAPTER 5
			//update input devices
			p_input->Update();
			this->UpdateKeyboard();
			this->UpdateMouse();

//***CHAPTER 6
			//update audio system
			audio->Update();

			//begin rendering
			this->RenderStart();
 
            game_render3d();

//*****CHAPTER 7
			//render 3D entities 
			if (!p_pauseMode) Draw3DEntities();

///***** ADD DURING CHAPTER 3
			Render2D_Start();

//***CHAPTER 8 -- game_render2d must be moved BELOW Draw2DEntities so the console panel will overlay
			//game_render2d();

//*****CHAPTER 7
			//render 2D entities 
			if (!p_pauseMode) Draw2DEntities();


//CHAPTER 8 -- moved here from location above			
			game_render2d();


			Render2D_Stop();
        			
			//done rendering
			this->RenderStop();
		}

//****CHAPTER 7	
		//remove dead entities from the list	
		BuryEntities();

	}