示例#1
0
void CleanSplat( int player, int x, int y, int level )
{
	int count, color, type;
	SDL_Rect chunkRect;

	if( flashyAnimation )
	{
		SDLU_AcquireSurface( playerSpriteSurface[player] );

		for( count=-2; count<=2; count++ )
		{
			if( count != 0 )
			{
				if( level > 0 )
				{
					CalcBlobRect( x, y, &chunkRect );
					GetZapStyle( player, &chunkRect, &color, &type, count, level-1, 4 );
					CleanSpriteArea( player, &chunkRect );
				}

				if( level < kZapFrames )
				{
					CalcBlobRect( x, y, &chunkRect );
					GetZapStyle( player, &chunkRect, &color, &type, count, level, 4 );
					CleanSpriteArea( player, &chunkRect );
				}
			}
		}

		SDLU_ReleaseSurface( playerSpriteSurface[player] );
	}
}
示例#2
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();
	}
}
示例#3
0
void DrawSplat( int player, int x, int y, int level )
{
	int count, color = kGray, type;
	SDL_Rect chunkRect;

	if( flashyAnimation )
	{
		SDLU_AcquireSurface( playerSpriteSurface[player] );

		for( count=-2; count<=2; count++ )
		{
			if( level < kZapFrames && count != 0 )
			{
				CalcBlobRect( x, y, &chunkRect );
				GetZapStyle( player, &chunkRect, &color, &type, count, level, 4 );
				SurfaceDrawAlpha( &chunkRect, kGray, kLight, type );
			}
		}

		SDLU_ReleaseSurface( playerSpriteSurface[player] );
	}
}
示例#4
0
void DrawChunks( int player, int x, int y, int level, int style )
{
	int count, color, type;
	SDL_Rect chunkRect;

	if( flashyAnimation )
	{
		SDLU_AcquireSurface( playerSpriteSurface[player] );

		for( count=-3; count<=3; count++ )
		{
			if( count != 0 )
			{
				CalcBlobRect( x, y, &chunkRect );
				color = grid[player][x][y];
				GetZapStyle( player, &chunkRect, &color, &type, count, level, style );
				SurfaceDrawSprite( &chunkRect, color, type );
			}
		}

		SDLU_ReleaseSurface( playerSpriteSurface[player] );
	}
}
示例#5
0
void DrawSpriteBlobs( int player, int type )
{
	MRect firstRect, secondRect, thirdRect;
	const int repeat = 0xFF, forever = 0xFE;
	
	static const unsigned char blobAnimation[6][2][25] = 
	{ 
	    { { kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction,
	        kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction,
	        kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction,       
		    kFlashBrightBlob, kFlashBrightBlob, kFlashBrightBlob, kFlashBrightBlob,
		    kFlashBrightBlob, kFlashBrightBlob, kFlashBrightBlob, kFlashBrightBlob,
		    kFlashBrightBlob, kFlashBrightBlob, kFlashBrightBlob, kFlashBrightBlob, repeat }, 
		  { kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction,
		    kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction,
		    kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction,
		    kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction,
		    kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction,
		    kNoSuction,       kNoSuction,       kNoSuction,       kNoSuction, repeat } },
		{ { kNoSuction,       kSquish,          kNoSuction,       kSquash,        
		    kNoSuction,       kSquish,          kNoSuction,       kSquash,
		    kNoSuction,       forever },
		  { kNoSuction,       kSquish,          kNoSuction,       kSquash,        
		    kNoSuction,       kSquish,          kNoSuction,       kSquash,
		    kNoSuction,       forever } },
		{ { kSobBlob,         kSobBlob,         kSobBlob,         kSobBlob,         
			kSob2Blob,        kSob2Blob,        kSob2Blob,        kSob2Blob,        
			repeat },
		  { kSobBlob,         kSobBlob,         kSobBlob,         kSobBlob,         
			kSob2Blob,        kSob2Blob,        kSob2Blob,        kSob2Blob,        
			repeat } },
		{ { kBombFuse1,       kBombFuse2,       kBombFuse3,       repeat }, 
		  { kBombFuse1,       kBombFuse2,       kBombFuse3,       repeat } }, 
		{ { kBlinkBomb1,      kBombFuse2,       kBlinkBomb3,      kBombFuse1,        
		    kBlinkBomb2,      kBombFuse3,       repeat },
		  { kBlinkBomb1,      kBombFuse2,       kBlinkBomb3,      kBombFuse1,        
		    kBlinkBomb2,      kBombFuse3,       repeat } }
	};
	
	if( grenade[player] ) type += 3;
	
	SDLU_AcquireSurface( playerSpriteSurface[player] );
	
	if( blobAnimation[type][0][anim[player]] == forever ) anim[player]--;
	if( blobAnimation[type][0][anim[player]] == repeat  ) anim[player] = 0;
	
	CalcBlobRect( blobX[player], blobY[player], &firstRect );
	if( halfway[player] ) OffsetMRect( &firstRect, 0, kBlobVertSize / 2 );
	
	TweakFirstBlob ( player, &firstRect );
	secondRect = firstRect;
	TweakSecondBlob( player, &secondRect );
		
	thirdRect = firstRect;
	thirdRect.top    -= kBlobShadowError;
	thirdRect.left   -= kBlobShadowError;
	thirdRect.right  += kBlobShadowDepth + kBlobShadowError;
	thirdRect.bottom += kBlobShadowDepth + kBlobShadowError;
	CleanSpriteArea( player, &thirdRect );
							
	thirdRect = secondRect;
	thirdRect.top    -= kBlobShadowError;
	thirdRect.left   -= kBlobShadowError;
	thirdRect.right  += kBlobShadowDepth + kBlobShadowError;
	thirdRect.bottom += kBlobShadowDepth + kBlobShadowError;
	CleanSpriteArea( player, &thirdRect );
	
	thirdRect = firstRect;
	OffsetMRect( &thirdRect, shadowDepth[player], shadowDepth[player] );
	SurfaceDrawShadow( &thirdRect,  colorA[player], blobAnimation[type][0][anim[player]] );

	thirdRect = secondRect;
	OffsetMRect( &thirdRect, shadowDepth[player], shadowDepth[player] );
	SurfaceDrawShadow( &thirdRect, colorB[player], blobAnimation[type][1][anim[player]] );

	SurfaceDrawSprite( &firstRect,  colorA[player], blobAnimation[type][0][anim[player]] );
	
	SurfaceDrawSprite( &secondRect, colorB[player], blobAnimation[type][1][anim[player]] );
	
	SDLU_ReleaseSurface( playerSpriteSurface[player] );
}
示例#6
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 );
}
示例#7
0
void KillBlobs( int player )
{
	int x,y;
	const int   position[] = {  0, 15, 27, 39, 51, 63, 72, 81, 90, 99,105,
	                          111,117,123,126,129,131,132,133,134,135,135,
	                          136,136,137,137,138,138,138,139,139,139,139,
	                          140,140,140 },
	            shading [] = {20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
	                          31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
	                          31, 30, 29, 28, 26, 24, 21, 18, 15, 12, 9,
	                           6,  3,  0 },
	            blobGraphic[kZapFrames] = { kDying,   kDying,   kDying,   kDying,   kSquish1,
	                                        kSquish1, kSquish1, kSquish1, kSquish2, kSquish2,
	                                        kSquish2, kSquish2, kSquish3, kSquish3, kSquish3,
	                                        kSquish3, kSquish4, kSquish4, kSquish4, kSquish4 },
	            grayGraphic[kZapFrames] = { kGrayBlink1, kGrayBlink1, kGrayBlink1,
	                                        kGrayBlink1, kGrayBlink1, kGrayBlink1,
	                                        kGrayBlink2, kGrayBlink2, kGrayBlink2,
	                                        kGrayBlink2, kGrayBlink2, kGrayBlink2,
	                                        kGrayBlink3, kGrayBlink3, kGrayBlink3,
	                                        kGrayBlink3, kGrayBlink3, kGrayBlink3,
	                                        kGrayBlink3, kGrayBlink3 };
	SDL_Rect myRect;
	bool busy = false;
	SDLU_Point dPoint, oPoint;
	char *scan;

	if( blobTime[player] > GameTickCount( ) )
		return;

	blobTime[player]++;

	SDLU_AcquireSurface( playerSurface[player] );

	// clear grenade sprite
	if( grenadeFrame[player] <= kBlastFrames )
	{
		CleanSpriteArea( player, &grenadeRect[player] );
		if( grenadeFrame[player] == kBlastFrames ) grenadeFrame[player]++;
	}

	for( x=0; x<kGridAcross; x++ )
	{
		for( y=0; y<kGridDown; y++ )
		{
			if( grid[player][x][y] >= kFirstBlob &&  // if a blob is dying
				grid[player][x][y] <= kLastBlob &&
				suction[player][x][y] == kInDeath )
			{
				death[player][x][y]++;
				busy = true;

				CalcBlobRect( x, y, &myRect );

				if( death[player][x][y] >= 0 && death[player][x][y] <= kZapFrames ) // draw its death
				{
					if( death[player][x][y] == kZapFrames )
					{
						grid[player][x][y] = kEmpty;
						suction[player][x][y] = kNoSuction;
						charred[player][x][y] = kNoCharring;
						SurfaceDrawBlob( player, &myRect, kEmpty, kNoSuction, kNoCharring );
						CleanSpriteArea( player, &myRect );
					}
					else
					{
						SurfaceDrawBlob( player, &myRect,
						                 grid[player][x][y],
						                 blobGraphic[ death[player][x][y] ],
						                 kNoCharring );
						CleanSpriteArea( player, &myRect );
					}

					CleanChunks( player, x, y, death[player][x][y], character[player].zapStyle );
				}
				else
				{
					SurfaceDrawBlob( player, &myRect, grid[player][x][y],
								(blobTime[player] & 2)? kFlashDarkBlob: kNoSuction, kNoCharring );
					CleanSpriteArea( player, &myRect );
				}
			}
			else
			{
				if( grid[player][x][y] == kGray &&					// gray dying
					suction[player][x][y] == kGrayBlink1 )
				{
					CalcBlobRect( x, y, &myRect );

					if( death[player][x][y] >= 0 && death[player][x][y] <= kZapFrames )
					{
						if( death[player][x][y] == kZapFrames )
						{
							grid[player][x][y] = kEmpty;
							suction[player][x][y] = kNoSuction;
							SurfaceDrawBlob( player, &myRect, kEmpty, kNoSuction, kNoCharring );
						}
						else
						{
							SurfaceDrawBoard( player, &myRect );
							SurfaceDrawAlpha( &myRect, kGray, kLight, grayGraphic[ death[player][x][y] ] );
							busy = true;
						}
						CleanSpriteArea( player, &myRect );
					}

					death[player][x][y]++;
				}
			}
		}
	}

	// draw score info above blobs but below chunks and explosions

	if( zapScoreFrame[player] < arrsize(position) )
	{
		myRect.y = zapScorePt[player].y - (position[zapScoreFrame[player]    ]);
		myRect.x = zapScorePt[player].x;
		myRect.h = 15 - (position[zapScoreFrame[player] - 1]);
		myRect.w = zapScoreWidth[player];
		CleanSpriteArea( player, &myRect );

		if( zapScoreFrame[player] < arrsize(position)-1 )
		{
			SDLU_AcquireSurface( playerSpriteSurface[player] );

			dPoint.y = oPoint.y = myRect.y;
			dPoint.x = oPoint.x = myRect.x;
			scan = zapScore[player];
			while( *scan )
			{
				SurfaceBlitWeightedCharacter( zapFont,    *scan, &dPoint, zapScoreR[player], zapScoreG[player], zapScoreB[player], shading[zapScoreFrame[player]] );
				SurfaceBlitWeightedCharacter( zapOutline, *scan, &oPoint, 0,                 0,                 0,                 shading[zapScoreFrame[player]] );
				scan++;
			}

			SDLU_ReleaseSurface( playerSpriteSurface[player] );

			zapScoreFrame[player]++;
			busy = true;
		}
	}

	///////////////////////////////////////////////////////////////

	for( x=0; x<kGridAcross; x++ )
	{
		for( y=0; y<kGridDown; y++ )
		{
			if( grid[player][x][y] >= kFirstBlob &&  // if a blob is dying
				grid[player][x][y] <= kLastBlob &&
				suction[player][x][y] == kInDeath &&
				death[player][x][y] >= 0 && death[player][x][y] < kZapFrames ) // draw chunks (after all that stuff)
			{
				DrawChunks( player, x, y, death[player][x][y], character[player].zapStyle );
			}
		}
	}

	SDLU_ReleaseSurface( playerSurface[player] );

	if( grenadeFrame[player] < kBlastFrames )
	{
		busy = true;

		SDLU_AcquireSurface( playerSpriteSurface[player] );

		myRect.y = grenadeFrame[player] * kBlastHeight;
		myRect.x = 0;
		myRect.h = kBlastHeight;
		myRect.w = kBlastWidth;

		SurfaceBlitAlpha(  playerSpriteSurface[player],  blastSurface,  blastMaskSurface,  playerSpriteSurface[player],
		                  &grenadeRect[player],         &myRect,       &myRect,           &grenadeRect[player]          );

		grenadeFrame[player]++;

		SDLU_ReleaseSurface( playerSpriteSurface[player] );
	}

	if( !busy && role[player] == kKillBlobs )
	{
		blobTime[player] = GameTickCount( );
		halfway[player] = false;
		role[player] = kDropBlobs;
	}
}