Пример #1
0
	void cWorld3D::Update(float afTimeStep)
	{
		START_TIMING(Physics);
		if(mpPhysicsWorld) mpPhysicsWorld->Update(afTimeStep);
		STOP_TIMING(Physics);


		START_TIMING(Entities);
		UpdateEntities(afTimeStep);
		STOP_TIMING(Entities);

		START_TIMING(Bodies);
		UpdateBodies(afTimeStep);
		STOP_TIMING(Bodies);

		START_TIMING(Particles);
		UpdateParticles(afTimeStep);
		STOP_TIMING(Particles);

		START_TIMING(Lights);
		UpdateLights(afTimeStep);
		STOP_TIMING(Lights);

		START_TIMING(SoundEntities);
		UpdateSoundEntities(afTimeStep);
		STOP_TIMING(SoundEntities);
	}
Пример #2
0
void NewLevel(Game *game, int graves,int villagers)  /*sets up a new level*/
{
  int i;
  int j;
  int width;
  int height;
  int sx,sy;
  if(BgMusic != NULL)
  {
    Mix_HaltMusic();
    Mix_FreeMusic(BgMusic);
  }
  BgMusic = Mix_LoadMUS("sounds/ambiant02.ogg");
  if(BgMusic == NULL)
  {
    fprintf(stderr, "Unable to Load Background Music: %s\n", SDL_GetError());
    exit(1);
  }
  Mix_VolumeMusic(MIX_MAX_VOLUME);
  Mix_PlayMusic(BgMusic,-1);/*play my background music infinitely*/
  game->level++;
  width = (int)sqrt(graves);
  if(width == 0)width = 1;
  height = graves / width;
  sx = 14 - (width/2);
  sy = 12 - (height/2);
  game->NumGraves =0;
  game->NumVillagers = villagers;  
  game->NumZombies = 0;
  ClearEntities();  /*lets get rid of what we ain't usin*/
  InitEntityList();
  ResetAllParticles();
  for(i = 0;i < 16;i++)
    SpawnTree((((rand()>>8) % 15)*2),(((rand()>>8) % 10)*2)+2, 200);
  for(j = 0;j < height;j++)
  {
    for(i = 0;i < width;i++)
    {
      SpawnCenter((i*2) + sx,(j*2)+ sy, 1,(rand()>>8)%2);
      game->NumGraves++;
    }
  }
  UpdateEntities();
}
Пример #3
0
/**
*@brief Draws the main game
*/
int StateGame()
{
		SDL_RenderClear(GetRenderer());	
		SDL_SetRenderTarget(GetRenderer(),game->mainSceneTexture);
		SDL_RenderClear(GetRenderer());
		SDL_SetRenderTarget(GetRenderer(),NULL);
		DrawMap(1,game->camera->x,game->camera->y,game->mainSceneTexture);
		DrawMap(2,game->camera->x,game->camera->y,game->mainSceneTexture);
		DrawMap(3,game->camera->x,game->camera->y,game->mainSceneTexture);
		DrawMap(0,0,0,game->mainSceneTexture);
		ThinkEntities();
		UpdateMap();
		UpdateEntities();
		DrawEntities();
		DrawMainScene();
		DrawSpecialLayer(map);
		UpdateGUI();
		SetCamera(*game->camera,hotBox);
		if(playerEnt->room->script != NULL)
			RunScript(playerEnt->room->script);
		NextFrame();
	return 0;
}
Пример #4
0
void GameView::OnUpdate()
{
    if (m_gameover)
    {
        if (!m_fadeQuad->GetColorAnim().isPlaying())
        {
            // we are done
            SendCommand(seed::eAppCommand::SWITCH_VIEW, "GameOverView");
            return;
        }
        UpdateCamera();
        UpdateUIs();
        return;
    }
    else
    {
        if (!m_fadeQuad->GetColorAnim().isPlaying())
        {
            m_fadeQuad->SetVisible(false);
        }
    }

    UpdateTime();
    UpdateDanceSequence();
    UpdateMonsterSpawning();
    UpdateEntities();
    UpdateCamera();
    UpdateUIs();

    // check if we are game over
    if (AllPlayersAreDead())
    {
        OnGameOver();
    }

    ClearEntities();
}
Пример #5
0
/*calls all of the update functions for everything*/
void Update_ALL()
{
  UpdateEntities();
  
}
Пример #6
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();
	}
Пример #7
0
void Level::Update(double ticksPassed)
{
	UpdateEntities(ticksPassed);
}
Пример #8
0
int Session::UpdateEntities(UpdateProxy<UserEntity>* proxy) {
    return UpdateEntities(proxy, "");
}
	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();

	}