コード例 #1
0
ファイル: CTitle.cpp プロジェクト: mvancompernolle/ai_project
bool Title::init(int Episode)
{
	SDL_Surface *pSurface;
	GsBitmap *pBitmap;
	gTimer.ResetSecondsTimer();
	mTime = 10; // show the title screen for 10 secs.
	pSurface = gVideoDriver.mpVideoEngine->getBlitSurface();
	if(!gVideoDriver.getSpecialFXConfig())
        gEffectController.setupEffect(new CColorMerge(16));
	else
        gEffectController.setupEffect(new CPixelate(16));
	
    if( (pBitmap = gGraphics.getBitmapFromStr("TITLE")) != NULL )
	{
		const int width = 160-(pBitmap->getWidth()/2);
		std::unique_ptr<CSpriteObject> obj(new CEGABitmap( &mMap, pSurface, pBitmap ));
		obj->setScrPos( width, 0 );		
        pBitmap->_draw( width, 0, pSurface );
		obj->draw();
		mObjects.push_back(std::move(obj));
	}


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

    if(gameRes.w == 320 && gameRes.h == 200 )
    {
        if( (pBitmap = gGraphics.getBitmapFromStr("F1HELP")) != NULL )
        {
            const int width = (Episode == 3) ? 128 : 96;
            pBitmap = gGraphics.getBitmapFromStr("F1HELP");
            std::unique_ptr<CSpriteObject> obj(new CEGABitmap( &mMap, pSurface, pBitmap ));
            obj->setScrPos( width, 182 );
            pBitmap->_draw( width, 182, pSurface);
            mObjects.push_back(move(obj));
        }
    }
	
	mMap.changeTileArrayY(2, 15, 2, gGraphics.getTileMap(1).EmptyBackgroundTile());

	mFinished = false;

	return true;
}
コード例 #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();
	}
	
}