Пример #1
0
void UpdateBalloon( void )
{
	SDL_Rect balloonSDLRect;
	
	if( control[0] != kAutoControl ) return;
	if( GameTickCount() < balloonTime ) return;
	
	if( balloonChar )
	{
		char in = *balloonChar++;
				
		switch( in )
		{
			case 0:
				OpponentChatter( false );
				balloonChar = NULL;
				balloonTime += 120;
				break;
				
			case '\n':
				balloonPt.h = balloonRect.left + 10;
				balloonPt.v += 20;
				break;
				
			default:
				if( balloonFont->width[in] > 0 )
				{
					SDLU_AcquireSurface( balloonSurface );
					SurfaceBlitCharacter( balloonFont, in, &balloonPt, 0, 0, 0, 0 );
					SDLU_ReleaseSurface( balloonSurface );
					
					SDLU_MRectToSDLRect( &balloonRect, &balloonSDLRect );
					SDLU_BlitFrontSurface( balloonSurface, &balloonSDLRect, &balloonSDLRect );

					balloonTime += 2;
				}
				break;			
		}	
	}
	else
	{
		SDLU_MRectToSDLRect( &balloonRect, &balloonSDLRect );
		SDLU_BlitFrontSurface( backdropSurface, &balloonSDLRect, &balloonSDLRect );
		                    
		StopBalloon();
	}
}
Пример #2
0
void DrawFrozenOpponent( void )
{
	SDL_Rect   sourceSDLRect, destSDLRect;
	MRect      myRect = {0, 0, 64, 64};

	OffsetMRect( &myRect, opponentFrame * 64, 0 );

	SDLU_BlitFrontSurface( opponentSurface, 
	                       SDLU_MRectToSDLRect( &myRect, &sourceSDLRect ),
	                       SDLU_MRectToSDLRect( &opponentWindowRect, &destSDLRect ) );
}
Пример #3
0
void DrawBackdrop( void )
{
	SDL_Rect backdropRect = { 0, 0, 640, 480 };
	
	SDLU_BlitFrontSurface( backdropSurface, &backdropRect, &backdropRect );
}
Пример #4
0
void StartBalloon( const char *message )
{
	MPoint      balloonTip, balloonFill;
	int         replace;
	const char* match[] = { "~~", "||", "``", "{{" };
	char*       search;
	SDL_Rect    balloonSDLRect, balloonContentsSDLRect;
	MRect       balloonContentsRect;
	
	strcpy( balloonMsg, message );
	for( replace=0; replace<4; replace++ )
	{
		search = strstr( balloonMsg, match[replace] );
		if( search )
		{
			char temp[256];
			
			search[0] = '%';
			search[1] = 's';
			sprintf( temp, balloonMsg, SDL_GetKeyName( playerKeys[1][replace] ) );
			strcpy( balloonMsg, temp );
		}
	}
	
	// Erase previous balloons
	SDLU_MRectToSDLRect( &balloonRect, &balloonSDLRect );
	SDLU_BlitFrontSurface( backdropSurface, &balloonSDLRect, &balloonSDLRect );

	// Draw empty balloon outline
	SDLU_AcquireSurface( balloonSurface );

	balloonRect.left = balloonRect.right - 25 - CalculateBalloonWidth ( balloonMsg );
	balloonRect.top = balloonRect.bottom - 25 - CalculateBalloonHeight( balloonMsg );

	SDLU_MRectToSDLRect( &balloonRect, &balloonSDLRect );
	SDLU_BlitSurface( backdropSurface, &balloonSDLRect,
	                  balloonSurface,  &balloonSDLRect  );
	
	balloonContentsRect = balloonRect;
	balloonContentsRect.bottom -= 25;
		
	SurfaceGetEdges( balloonSurface, &balloonContentsRect );
	SDL_FillRect( balloonSurface, 
				  SDLU_MRectToSDLRect( &balloonContentsRect, &balloonContentsSDLRect ), 
				  SDL_MapRGB( balloonSurface->format, 0xFF, 0xFF, 0xFF ) );
	SurfaceCurveEdges( balloonSurface, &balloonContentsRect );
	
	balloonTip.v = balloonContentsRect.bottom - 2;
	balloonTip.h = balloonContentsRect.right - 40;
	balloonFill = balloonTip;

	SurfaceBlitCharacter( balloonFont, '\x01', &balloonFill,  0,  0,  0,  0 );
	SurfaceBlitCharacter( balloonFont, '\x02', &balloonTip,  31, 31, 31,  0 );
	
	SDLU_ReleaseSurface( balloonSurface );

	// Blit empty balloon to screen
	SDLU_MRectToSDLRect( &balloonRect, &balloonSDLRect );
	SDLU_BlitFrontSurface( balloonSurface, &balloonSDLRect, &balloonSDLRect );
	
	balloonPt.h = balloonRect.left + 10;
	balloonPt.v = balloonRect.top + 10;
	balloonChar = balloonMsg;
	balloonTime = GameTickCount( );
	
	OpponentChatter( true );
}
Пример #5
0
int main(int argc, char *argv[])
{
	// Initialize the SDL library
	// This is required to avoid _main errors at runtime.
#ifdef UseSDLMixer
	if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) {
#else
	if ( SDL_Init(SDL_INIT_VIDEO ) < 0 ) {
#endif		
		fprintf(stderr, "Couldn't initialize SDL: %s\n",
				SDL_GetError());
		exit(1);
	}

	// Init SDL_Image - only applies above 1.2.7
	// load support for the JPG and PNG image formats
	int IMGflags=IMG_INIT_JPG|IMG_INIT_PNG;
	int initted=IMG_Init(IMGflags);
	if(initted && IMGflags != IMGflags) {
		printf("IMG_Init: Failed to init required jpg and png support!\n");
		printf("IMG_Init: %s\n", IMG_GetError());
		// handle error
	}

		
#ifdef UseSDLMixer
	// Initialize SDL mixer.
	if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) != 0) {
		fprintf(stderr, "Unable to initialize audio: %s\n", Mix_GetError());
		exit(1);
	}
#endif
    
    // Retrieve display gamma for reference in fade in/fade out routines.
    SDL_GetGammaRamp(redGamma, greenGamma, blueGamma);
//    printf("%u", *redGamma);
	Initialize( );	

	LoadPrefs( );
	
	ReserveMonitor( );	
	ShowTitle( );
	
	ChooseMusic( 13 );
	
	while( !finished )
	{
		if( showStartMenu )
		{
			GameStartMenu( );
			showStartMenu = false;
		}
		
		if( !finished )
		{
			DoFullRepaint = NeedRefresh;
			CheckKeys( );
			HandlePlayers( );
			UpdateOpponent( );
			UpdateBalloon( );
			UpdateSound( );
			DoFullRepaint = NoPaint;
			
			if( needsRefresh )
			{
				RefreshAll();
				needsRefresh = false;
			}
			
			if( !showStartMenu && pauseKey )
			{
				FreezeGameTickCount( );
				PauseMusic( );
				MaskRect( &playerWindowRect[0] );
				MaskRect( &playerWindowRect[1] );
				WaitForRelease( );
				
				HandleDialog( kPauseDialog );
								
				WaitForRelease( );
				RefreshPlayerWindow( 0 );
				RefreshPlayerWindow( 1 );
				ResumeMusic( );
				UnfreezeGameTickCount( );
			}
		}
	}
	
	SavePrefs( );
	ReleaseMonitor( );
	
	return 0;
}

void NoPaint( void )
{
}

void MaskRect( MRect *r )
{
	SDL_Rect sdlRect;
	SDLU_MRectToSDLRect( r, &sdlRect );
	SDLU_BlitFrontSurface( backdropSurface, &sdlRect, &sdlRect );
}