Example #1
0
File: main.cpp Project: boredzo/CCX
void CenterRectOnScreen( MRect *rect, double locationX, double locationY )
{
	MPoint dest = {0,0};
	
	dest.h = (short)(locationX * (640 - (rect->right - rect->left)));
	dest.h &= ~3;
	dest.v = (short)(locationY * (480 - (rect->bottom - rect->top)));

	OffsetMRect( rect, -rect->left, -rect->top );
	OffsetMRect( rect, dest.h, dest.v );
}
Example #2
0
void TweakFirstBlob( int player, MRect *first )
{
	int tweakValues[] = {0, -1, -2, -3, -6, -12};
	
	if( xTweak[player] > 0 )
	{
		OffsetMRect( first, xDirection[player] * tweakValues[xTweak[player]], 0 );
	}

	if( yTweak[player] > 0 )
	{
		OffsetMRect( first, 0, tweakValues[yTweak[player]] );
	}
}
Example #3
0
void TweakSecondBlob( int player, MRect *second )
{
	int x, y;
	
	CalcSecondBlobOffset( player, &x, &y );
	OffsetMRect( second,
				 tweakOffsetX[blobR[player]][rTweak[player]],
				 tweakOffsetY[blobR[player]][rTweak[player]] );
}
Example #4
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 ) );
}
Example #5
0
void EraseSpriteBlobs( int player )
{
	MRect myRect, secondRect;
	
	CalcBlobRect( blobX[player], blobY[player], &myRect );
	if( halfway[player] ) OffsetMRect( &myRect, 0, kBlobVertSize / 2 );

	TweakFirstBlob( player, &myRect );
	secondRect = myRect;
	secondRect.top    -= kBlobShadowError;
	secondRect.left   -= kBlobShadowError;
	secondRect.right  += kBlobShadowDepth + kBlobShadowError;
	secondRect.bottom += kBlobShadowDepth + kBlobShadowError;
	CleanSpriteArea( player, &secondRect );

	TweakSecondBlob( player, &myRect );
	myRect.top    -= kBlobShadowError;
	myRect.left   -= kBlobShadowError;
	myRect.right  += kBlobShadowDepth + kBlobShadowError;
	myRect.bottom += kBlobShadowDepth + kBlobShadowError;
	CleanSpriteArea( player, &myRect );
}
Example #6
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] );
}
Example #7
0
void UpdateOpponent( void )
{
	MRect    myRect = {0,0,64,64}, dstRect = {0,0,64,64}, maskRect;
	int      emotiMap[] = {0, 1, 2, 1}, draw = false, count;
	SDL_Rect srcSDLRect, dstSDLRect;
	
	if( GameTickCount( ) > opponentTime )
	{
		switch( opponentMood )
		{
			case 0: 				// Idle
				opponentTime += 60 + RandomBefore(180);
				opponentMood = RandomBefore(2) + 1;
				opponentFrame = (emotiMap[emotions[1]] * kOppFrames);
				break;
			
			case 1:					// Shifty Eyes
				opponentTime += 40 + RandomBefore(60);
				opponentMood = 0;
				opponentFrame = (emotiMap[emotions[1]] * kOppFrames) + RandomBefore(2) + 1;
				break;

			case 2:					// Blinks
				opponentTime += 3;
				opponentMood = 3;
				opponentFrame = (emotiMap[emotions[1]] * kOppFrames) + 3;
				break;
			
			case 3:					// Blinks (more)
				opponentTime += 3;
				opponentMood = 4;
				opponentFrame = (emotiMap[emotions[1]] * kOppFrames) + 4;
				break;
			
			case 4: 				// Blinks (more)
				opponentTime += 3;
				opponentMood = 0;
				opponentFrame = (emotiMap[emotions[1]] * kOppFrames) + 3;
				break;
			
			case 5:                 // Chatter (only good for tutorial)
				opponentTime += 8;
				opponentMood = 6;
				opponentFrame = 5;
				break;

			case 6:					// Chatter 2 (only good for tutorial)
				opponentTime += 8;
				opponentMood = 5;
				opponentFrame = 6;
				break;
			
			case 7:					// Pissed (when hit with punishments)
				opponentTime += 60;
				opponentFrame = 7;
				opponentMood = 0;
				break;
		}
		
		draw = true;
	}
	
	if( GameTickCount( ) > panicTime )
	{
		panicTime += 2;
		
		if( emotions[1] == kEmotionPanic )
		{
			if( ++panicFrame >= kGlowArraySize ) panicFrame = 0;
			draw = true;
		}
		else
		{
			panicFrame = 0;
		}
	}
	
	for( count=0; count<kGlows; count++ )
	{
		if( GameTickCount( ) > glowTime[count] )
		{
			glowTime[count] += character[1].glow[count].time;
			
			if( character[1].glow[count].color )
			{
				if( ++glowFrame[count] >= kGlowArraySize ) glowFrame[count] = 0;
				draw = true;
			}
			else
			{
				glowFrame[count] = 0;
			}
		}
	}
	
	if( draw )
	{
		OffsetMRect( &myRect, 64*opponentFrame, 0 );
		
		SDLU_AcquireSurface( opponentDrawSurface );
		
		SDLU_BlitSurface( opponentSurface,     SDLU_MRectToSDLRect( &myRect, &srcSDLRect ),
		                  opponentDrawSurface, SDLU_MRectToSDLRect( &dstRect, &dstSDLRect )  );
		
		maskRect = myRect;
		for( count=0; count<kGlows; count++ )
		{
			OffsetMRect( &maskRect, 0, 64 );

			if( glowFrame[count] )
			{
				if( character[1].glow[count].color & 0x8000 )
				{
					SurfaceBlitColor(  opponentMaskSurface,  opponentDrawSurface,
					                  &maskRect,            &dstRect, 
					                   (character[1].glow[count].color & 0x7C00) >> 10,
									   (character[1].glow[count].color & 0x03E0) >> 5,
									   (character[1].glow[count].color & 0x001F),
									   heavyGlowArray[glowFrame[count]] );
				}
				else
				{
					SurfaceBlitColor(  opponentMaskSurface,  opponentDrawSurface,
					                  &maskRect,            &dstRect, 
					                   (character[1].glow[count].color & 0x7C00) >> 10,
									   (character[1].glow[count].color & 0x03E0) >> 5,
									   (character[1].glow[count].color & 0x001F),
									   lightGlowArray[glowFrame[count]] );
				}
			}
		}