////
// Process Routine
////
void CPlayGameVorticon::process()
{
	// Check for fading processes if necessary
	if(g_pGfxEngine->Palette.in_progress())
		g_pGfxEngine->Palette.applyFade();

	if(mp_HighScores) // Are we requesting Highscores
	{
		mp_HighScores->process();

		// Blit the background
		g_pVideoDriver->blitScrollSurface();

		if(mp_HighScores->destroyed())
		{
			SAFE_DELETE(mp_HighScores);
			m_endgame = true;
		}
	}
	else // No, we are in the middle of the game
	{
		if(!m_paused && m_MessageBoxes.empty() && !mp_Menu) // Game is not paused, no messages have to be shown and no menu is open
		{
			if (!mp_Finale) // Hasn't the game yet been finished?
			{
				// Perform AIs
				mp_ObjectAI->process();

				/// The following functions must be worldmap dependent
				if( m_Level == WORLD_MAP_LEVEL_VORTICON )
					processOnWorldMap();
				else
					processInLevel();

				// Does one of the players need to pause the game?
				for( int i=0 ; i<m_NumPlayers ; i++ )
				{
					// Did he open the status screen?
					if(m_Player[i].m_showStatusScreen)
						m_paused = true; // this is processed in processPauseDialogs!

					if(!m_Player[0].pdie)
						m_Player[0].processCamera();
				}
			}
			else // In this case the Game has been finished, goto to the cutscenes
			{
				mp_Finale->process();

				if(mp_Finale->getHasFinished())
				{
					SAFE_DELETE(mp_Finale);

					if(!m_gameover)
					{
						mp_HighScores = new CHighScores(m_Episode, m_Gamepath, true);
						collectHighScoreInfo();
					}
				}

				m_Player[0].processEvents();
			}
		}

		// Draw all the Stuff here!
		drawAllElements();

		if( m_Level == WORLD_MAP_LEVEL_VORTICON && m_showKeensLeft )
			showKeensLeft();


		// Check if we are in gameover mode. If yes, than show the bitmaps and block the FKeys().
		// Only confirmation button is allowes
		if(m_gameover && !mp_Finale) // game over mode
		{
			if(mp_gameoverbmp != NULL)
			{
				mp_gameoverbmp->process();

				if( g_pInput->getPressedAnyCommand() )
				{
					mp_HighScores = new CHighScores(m_Episode, m_Gamepath, true);

					collectHighScoreInfo();
				}
			}
			else // Bitmap must first be created
			{
				CBitmap *pBitmap = g_pGfxEngine->getBitmap("GAMEOVER");
				g_pSound->playSound(SOUND_GAME_OVER, PLAY_NOW);
				mp_gameoverbmp = new CEGABitmap(&m_Map , g_pVideoDriver->getBlitSurface(), pBitmap);
				mp_gameoverbmp->setScrPos( 160-(pBitmap->getWidth()/2), 100-(pBitmap->getHeight()/2) );
			}
		}
		else // No game over
		{
			// Handle special functional keys for paused game, F1 Help, god mode, all items, etc.
			if(!mp_Menu)
				handleFKeys();
		}

		//////////////////////////////////////////
		//// Menu Code... processed if opened
		//////////////////////////////////////////

		// If the menu is open process it!
		if(mp_Menu)
		{
			if( mp_Menu->mustClose() || mp_Menu->getExitEvent() ||
					mp_Menu->mustEndGame() || mp_Menu->mustStartGame()	)
			{
				if( mp_Menu->getExitEvent() )
					m_exitgame = true;
				else if( mp_Menu->mustEndGame() )
					m_endgame = true;
				else if( mp_Menu->mustStartGame() )
				{
					m_NumPlayers = mp_Menu->getNumPlayers();
					m_Difficulty = mp_Menu->getDifficulty();
					m_startgame = true;
				}

				mp_Menu->cleanup();
				SAFE_DELETE(mp_Menu);
				m_hideobjects = false;
			}
			else
			{
				mp_Menu->processSpecific();

				if(m_restartVideo) // Happens when in Game resolution was changed!
				{
					mp_Menu->cleanup();
					SAFE_DELETE(mp_Menu);
					SDL_Rect gamerect = g_pVideoDriver->getGameResolution();
					m_Map.m_maxscrollx = (m_Map.m_width<<4) - gamerect.w - 36;
					m_Map.m_maxscrolly = (m_Map.m_height<<4) - gamerect.h - 36;
					m_Map.drawAll();
					m_restartVideo = false;
				}

				// Does the player want to load/save a game?
				if(m_SavedGame.getCommand() == CSavedGame::SAVE)
					saveGameState();
				else if(m_SavedGame.getCommand() == CSavedGame::LOAD)
					loadGameState();
			}
		}
		// Open the Main Menu if ESC Key pressed and mp_Menu not opened.  Prevent the menu if the player is not solid.
		else if( !mp_Finale && g_pInput->getPressedCommand(IC_QUIT) && ( m_Player[0].solid || m_Player[0].godmode ) )
		{	// Open the menu
			mp_Menu = new CMenuVorticon( ACTIVE, m_Map, m_SavedGame, m_restartVideo, m_hideobjects );
		}


		if (g_pVideoDriver->getVidConfig().showfps)
		{
			SDL_Surface *sfc = g_pVideoDriver->mp_VideoEngine->getBlitSurface();
			std::string tempbuf;
#ifdef DEBUG
			tempbuf = "FPS: " + itoa(g_pTimer->getFramesPerSec()) +
								"; x = " + itoa(m_Player[0].getXPosition()) + " ; y = " + itoa(m_Player[0].getYPosition());
#else
			tempbuf = "FPS: " + itoa(g_pTimer->getFramesPerSec());
#endif
			g_pGfxEngine->getFont(0).drawFont(sfc,tempbuf,320-(tempbuf.size()<<3)-1, true);

		}
	}
}
Exemplo n.º 2
0
////
// Process Routine
////
void CPlayGameVorticon::ponder(const float deltaT)
{
	if( !mpFinale && !gMenuController.active() ) // Game is not paused, no messages have to be shown and no menu is open
	{
		if(mMessageBoxes.empty() && !StatusScreenOpen())
		{
			// Perform AIs
			mpObjectAI->process();

			if( !g_pBehaviorEngine->paused() )
			{
			  // The following functions must be worldmap dependent
			  if( m_Level == WORLD_MAP_LEVEL_VORTICON )
			  {
                processOnWorldMap(); // TODO: I think the main loop of that should be here!
			  }
			  else
			  {
                processInLevel(); // TODO: I think the main loop of that should be here!
			  }



              if(m_Player.size() > (unsigned int)mCamLead )
              {

                  if(m_Player[mCamLead].pdie)
                  {
                      const int numPlayers = g_pBehaviorEngine->mPlayers;
                      for( int i=0 ; i<numPlayers ; i++ )
                      {
                          if(m_Player[i].pdie)
                              cycleCamLead();
                      }
                  }
                  else
                  {
                      for(auto &player : m_Player)
                      {
                          // Process Players' Cameras
                          player.processCamera();
                      }
                  }
              }                            
            }

            for(auto &player : m_Player)
            {
                // Process Players' Events
                player.processEvents();
            }


		}
	}

    if(mpFinale) // Finale processing if it is opened
    {
        mpFinale->ponder();

        if( mpFinale->getHasFinished() )
        {
            mpFinale.release();

            if(!m_gameover)
            {
                CHighScores *pHighScores = new CHighScores();
                pHighScores->init();
                collectHighScoreInfo(*pHighScores);
                gEventManager.add(new GMSwitchToPassiveMode(/*m_Gamepath, m_Episode*/));
                gEventManager.add(new StartInfoSceneEvent( pHighScores ));
            }
        }
    }

    // Render the dialogs which are seen when the game is paused
    if( !mMessageBoxes.empty() )
    {
        // Finally draw Dialogs like status screen, game paused, etc.
        processPauseDialogs();
    }


	// Check if we are in gameover mode. If yes, than show the bitmaps and block the FKeys().
    // Only confirmation button is allowed
	if(m_gameover && !mpFinale) // game over mode
	{
		if( mpGameoverBmp )
		{
			if( gInput.getPressedAnyCommand() )
			{
				CHighScores *pHighScores = new CHighScores();
				pHighScores->init();
				collectHighScoreInfo(*pHighScores);
                gEventManager.add(new GMSwitchToPassiveMode(/*m_Gamepath, m_Episode*/));
				gEventManager.add(new StartInfoSceneEvent( pHighScores ));
			}
		}
		else // Bitmap must first be created
		{
            GsBitmap *pBitmap = gGraphics.getBitmapFromStr("GAMEOVER");
			g_pSound->playSound(SOUND_GAME_OVER, PLAY_NOW);
			mpGameoverBmp.reset( new CEGABitmap( mMap.get() , gVideoDriver.getBlitSurface(), pBitmap) );

            GsRect<Uint16> gameRes = gVideoDriver.getGameResolution();

            mpGameoverBmp->setScrPos( (gameRes.w/2) -(pBitmap->getWidth()/2), (gameRes.h/2) -(pBitmap->getHeight()/2) );
		}
	}
	else // No game over
	{
		// Handle special functional keys for paused game, F1 Help, god mode, all items, etc.
		handleFKeys();
	}
	
}
Exemplo n.º 3
0
////
// Process Routine
////
void CPlayGameVorticon::process()
{
	// Check for fading processes if necessary
	if(g_pGfxEngine->Palette.in_progress())
		g_pGfxEngine->Palette.applyFade();

	if( !mpFinale && !gpMenuController->active() ) // Game is not paused, no messages have to be shown and no menu is open
	{
		if(mMessageBoxes.empty() && !StatusScreenOpen())
		{
			// Perform AIs
			mpObjectAI->process();


			if( !g_pBehaviorEngine->paused() )
			{
				/// The following functions must be worldmap dependent
				if( m_Level == WORLD_MAP_LEVEL_VORTICON )
				{
					processOnWorldMap();
				}
				else
				{
					processInLevel();
				}


				if(m_Player[mCamLead].pdie)
				{
					for( int i=0 ; i<m_NumPlayers ; i++ )
					{
						if(m_Player[i].pdie)
							cycleCamLead();
					}
				}
				else
				{
					// Process Players' Cameras
					m_Player[mCamLead].processCamera();
				}


			}

		}
	}


	// Draw all the Stuff here!
	drawAllElements();

	if( m_Level == WORLD_MAP_LEVEL_VORTICON && m_showKeensLeft )
		showKeensLeft();



	// Check if we are in gameover mode. If yes, than show the bitmaps and block the FKeys().
	// Only confirmation button is allowes
	if(m_gameover && !mpFinale) // game over mode
	{
		if( mpGameoverBmp )
		{
			mpGameoverBmp->process();

			if( g_pInput->getPressedAnyCommand() )
			{
				CHighScores *pHighScores = new CHighScores();
				pHighScores->init();
				collectHighScoreInfo(*pHighScores);
				g_pBehaviorEngine->EventList().add(new GMSwitchToPassiveMode(m_Gamepath, m_Episode));
				g_pBehaviorEngine->EventList().add(new StartInfoSceneEvent( pHighScores ));

			}
		}
		else // Bitmap must first be created
		{
			CBitmap *pBitmap = g_pGfxEngine->getBitmap("GAMEOVER");
			g_pSound->playSound(SOUND_GAME_OVER, PLAY_NOW);
			mpGameoverBmp.reset( new CEGABitmap( mMap.get() , g_pVideoDriver->getBlitSurface(), pBitmap) );
			mpGameoverBmp->setScrPos( 160-(pBitmap->getWidth()/2), 100-(pBitmap->getHeight()/2) );
		}
	}
	else // No game over
	{
		// Handle special functional keys for paused game, F1 Help, god mode, all items, etc.
		handleFKeys();
	}
	
	auto &eventContainer = g_pBehaviorEngine->EventList();	
	if( eventContainer.occurredEvent<EventEndGamePlay>() )
	{
		m_endgame = true;
		eventContainer.pop_Event();
	}
}