コード例 #1
0
GsBitmap::GsBitmap(const GsBitmap &bitmap) :
mName(bitmap.getName())
{
	SDL_Surface *sfc = bitmap.getSDLSurface();

    if( sfc != nullptr )
    {
        // Create a copy of the surface for that bitmap
        SDL_Surface *copySfc = SDL_ConvertSurface(sfc, sfc->format, 0 );

        mpBitmapSurface.reset( copySfc, &SDL_FreeSurface );
    }
}
コード例 #2
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;
}
コード例 #3
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();
	}
	
}
コード例 #4
0
bool CEGALatch::loadData( const std::string &path,
                          const short episode,
                          const int version,
                          const unsigned char *data,
                          const bool compresseddata )
{
	std::string filename;
	byte *RawData;
    Uint16 width, height;
    SDL_Surface *sfc;


	filename = getResourceFilename("egalatch.ck" + itoa(episode), path);

	FILE* latchfile = OpenGameFile(filename,"rb");

	if(!latchfile)
		return false;

	RawData = new byte[m_latchplanesize * 4];
    // get the data out of the file into the memory, decompressing it if necessary.
    if (compresseddata)
    {
		if (lz_decompress(latchfile, (unsigned char*) RawData))
		{
			return 1;
		}
    }
    else
    {
    	for(int i=0 ; i<(m_latchplanesize*4) ; i++)
    		RawData[i] = fgetc(latchfile);
    }

    fclose(latchfile);

	// these are the offsets of the different video planes as
	// relative to each other--that is if a pixel in plane1
	// is at N, the byte for that same pixel in plane3 will be
	// at (N + plane3).
	unsigned long plane1, plane2, plane3, plane4;

	plane1 = 0;
	plane2 = (m_latchplanesize * 1);
	plane3 = (m_latchplanesize * 2);
	plane4 = (m_latchplanesize * 3);

	// ** read the 8x8 tiles **
	// set up the getbit() function of CPlanes class
	CPlanes Planes(RawData);
	Planes.setOffsets(plane1 + m_fontlocation, plane2 + m_fontlocation,
					  plane3 + m_fontlocation, plane4 + m_fontlocation, 0);
	// Load these graphics into the GsFont Class of GsGraphics
	// The original vorticon engine only uses one fontmap, but we use another for
	// extra icons. For example sliders are in that map

	gGraphics.freeFonts();
	gGraphics.createEmptyFontmaps(3);

	gGraphics.getFont(0).loadinternalFont();

	GsFont &Font = gGraphics.getFont(1);
	Font.CreateSurface( gGraphics.Palette.m_Palette, SDL_SWSURFACE );
	sfc = Font.getSDLSurface();

	gGraphics.getFont(2).loadAlternateFont();


	if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);

	Uint8 *pixel = (Uint8*) sfc->pixels;
	SDL_FillRect(sfc, NULL, 0);

	for(int p=0;p<4;p++)
		Planes.readPlaneofTiles(p, pixel, 16, 8, m_fonttiles);

	if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);

	// prepare to ** read the 16x16 tiles **
	Planes.setOffsets(plane1 + m_tiles16location,
					 plane2 + m_tiles16location,
					 plane3 + m_tiles16location,
					 plane4 + m_tiles16location,
					 0);

	gGraphics.freeTilemap();
	gGraphics.createEmptyTilemaps(2);
	
	loadTilemap(gGraphics.getTileMap(0), Planes, episode, path);
	
	// prepare to ** read the 16x16 tiles **, this is for the second plane.
	Planes.setOffsets(plane1 + m_tiles16location,
					 plane2 + m_tiles16location,
					 plane3 + m_tiles16location,
					 plane4 + m_tiles16location,
					 0);	
	
	loadTilemap(gGraphics.getTileMap(1), Planes, episode, path);

    gGraphics.getTileMap(0).optimizeSurface();
    gGraphics.getTileMap(1).optimizeSurface();

	// make masked tiles according to it's surfaces
	applyMasks();

	////////////////////
	/// Load Bitmaps ///
	////////////////////

	Planes.setOffsets(plane1 + m_bitmaplocation,
					plane2 + m_bitmaplocation,
					plane3 + m_bitmaplocation,
					plane4 + m_bitmaplocation,
					0);

	// decode bitmaps into the BitmapData structure. The bitmaps are
	// loaded into one continuous stream of image data, with the bitmaps[]
	// array giving pointers to where each bitmap starts within the stream.

	for(int p=0 ; p<4 ; p++)
	{
		for(int b=0 ; b<m_bitmaps ; b++)
		{
            GsBitmap &bitmap = gGraphics.getBitmapFromId(b);
			// this points to the location that we're currently
			// decoding bitmap data to

			sfc= bitmap.getSDLSurface();
			if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
			Uint8* pixel = (Uint8*) sfc->pixels;
			if(p==0)
				SDL_FillRect(sfc, NULL, 0);
			width = bitmap.getWidth(); height = bitmap.getHeight();
			// Now read the raw data

			Planes.readPlane(p, pixel, width, height);

			if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);
		}
	}

	std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(path, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
	FilterFilelist(filelist, "bitmap");

	std::set<std::string>::iterator it = filelist.begin();

	for( ; it != filelist.end() ; it++ )
	{
		std::string filename=*it;
		int num = getRessourceID(filename, "bitmap");
        GsBitmap &bitmap = gGraphics.getBitmapFromId(num);
		filename = getResourceFilename("gfx/" + filename, path, false);
		bitmap.loadHQBitmap(filename);
	}

	if(RawData){ delete[] RawData; RawData = NULL;}

    // Create an intro in case it does not exist yet
    std::string fullpath = getResourceFilename("preview.bmp", path, false);
    if( fullpath == "" )
    {   // Not found create it
        fullpath = path + "/preview.bmp";
        fullpath = GetWriteFullFileName(fullpath, true);
        GsBitmap *pBitmap = gGraphics.getBitmapFromStr("TITLE");
        SDL_SaveBMP( pBitmap->getSDLSurface(), fullpath.c_str());
    }

	return true;
}