Example #1
0
static	int	GameOver( int mask )
{
	int		k;
	k=TestGameOver( mask );
	if ( !k )
		return 0;
	if ( k == 2 )		// patt
	{
#ifdef MARTII
		FBDrawString( 190, 410, 64, "Good game !", WHITE, 0 );
#else
		FBDrawString( 190, 410, 64, "good game !", WHITE, 0 );
#endif
	}
	else if ( mask == 1 )
	{
		FBDrawString( 190, 410, 64, "You won !", WHITE, 0 );
	}
	else
	{
#ifdef MARTII
		FBDrawString( 190, 410, 64, "I am the Winner !", WHITE, 0 );
#else
		FBDrawString( 190, 410, 64, "Iam the Winner !", WHITE, 0 );
#endif
	}
	doexit=1;
	return 1;
}
Example #2
0
void Tetris::Update(game_info* gi, float deltatime)
{
	if (gi->state == STATE_TETRIS_TRANS)
	{
		gi->rot2 += TRANSITION_SPEED * deltatime;

		if (gi->rot2 >= 180)
		{
			gi->rot2 = 180;
			engine.ChangeState(gi, STATE_BREAKOUT);
		}

		engine.PassMessage(MSG_ROT_BOARD2, (gi->rot2 / 180.0f) * 255.0f, 0,0);
		return;
	}

	if (gi->attacking)
	{
		gi->rot += TETRIS_ATTACK_ROT_SPEED * deltatime;
		gi->attack_rot += TETRIS_ATTACK_ROT_SPEED * deltatime;

		if (gi->attack_rot >= 360)
		{
			gi->rot = -BOARD_NORMAL_ROT;
			gi->attack_rot = 0;

			gi->attacking = 0;

			gi->score += (10 * 100);
			engine.PassMessage(MSG_APPENDSCORE, 100, 10, 0);
		}

		engine.PassMessage(MSG_ROT_BOARD, (gi->rot / 360.0f) * 255.0f, 0,0);
	}


	if (!engine.network_thread)
	{
		if (engine.keys[SDLK_DOWN])
		{
			gi->fine += deltatime * (TETRIS_SPEED + 4.3 + 0.3 * LEVEL);
		}
		else
		{
			gi->fine += deltatime * (TETRIS_SPEED + 0.3 * LEVEL);
		}
	}
	else
	{
		if (engine.keys[SDLK_DOWN])
		{
			gi->fine += deltatime * (TETRIS_SPEED + 4.3);
		}
		else
		{
			gi->fine += deltatime * TETRIS_SPEED;
		}
	}

	//gi->rot2+=50.0 * deltatime;

	if (TestCollision(gi))
	{
		// we collided! oh no!
		if (TestGameOver(gi))
		{
			engine.GameOver();
		}
		else
		{
			AddPiece(gi);
		}
	}

	//printf("%f\n", gi->fine);
	engine.PassMessage(MSG_UPDATEPIECEY, (unsigned char)((gi->fine / 11.0f) * 255.0f), 0, 0);
}
Example #3
0
void	MoveMouse( void )
{
static	int	locked = 0;
	int		k;

	if ( locked )
	{
		locked--;
		actcode=0xee;
		return;
	}
	k=0;
	switch( actcode )
	{
	case RC_7 : k++;
	case RC_6 : k++;
	case RC_5 : k++;
	case RC_4 : k++;
	case RC_3 : k++;
	case RC_2 : k++;
	case RC_1 : k++;
		break;
	}
	if ( k )
		ipos=k-1;
	switch( actcode )
	{
	case RC_RIGHT :
		if ( ipos < 6 )
		{
			FBFillRect( ipos*48+64+6, 48+4, 36, 40, BLACK );
			ipos++;
			FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE,
				dred, 0,0,0);
			locked=1;
		}
		break;
	case RC_LEFT :
		if ( ipos > 0 )
		{
			FBFillRect( ipos*48+64+6, 48+4, 36, 40, BLACK );
			ipos--;
			FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE,
				dred, 0,0,0);
			locked=1;
		}
		break;
	case RC_7 :
	case RC_6 :
	case RC_5 :
	case RC_4 :
	case RC_3 :
	case RC_2 :
	case RC_1 :

	case RC_OK :
		locked=1;
		if ( maze[ipos+35] )
			break;
		Fall( ipos, dred, 1 );
		k=TestGameOver( 1 );
		if ( GameOver(1) )
			return;
		MyPlay();
		if ( GameOver(2) )
			return;
		ipos=3;
		FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE,
				dred, 0,0,0);
		break;
	}
}
Example #4
0
static	void	MyPlay( void )
{
	int		x;
	int		idx;
	int		k;
	int		vidx[7];
	int		max=0;

	for( x=0; x<7; x++ )
		tst[x]=0;
/* test: eigener sieg in 1nem zug */
	for( x=0; x<7; x++ )
	{
		idx=vFall( x, 6 );
//printf("test %d (pos=%d)%c\n",x,idx,0x0d);
//outmaze();
		if ( idx != -1 )
		{
			if ( TestGameOver(2) )	// great ! - choose it
			{
				maze[idx]=0;	// remove virt. chip
				CPlay( x );
				return;
			}
			k=vFall( x, 5 ); // put playerchip over me
			if ( k != -1 )
			{
				if ( TestGameOver(1) )	// fault - this field is ugly
					tst[x] -= 50;
				else
					tst[x]++;
				maze[k]=0;	// remove virt. chip
			}
			else
				tst[x]++;
			maze[idx]=0;	// remove virt. chip
		}
		else
			tst[x]=-999999;	// neg val
	}
/* test: player sieg in 1-2 zuegen */
	for( x=0; x<7; x++ )
	{
		idx=vFall( x, 5 );
		if ( idx != -1 )
		{
			if ( TestGameOver(1) )	// great ! - choose it
				tst[x] += 50;
			else
			{
				int		idx2;

				for( k=0;k<7;k++)
				{
					if ( k==x )
						continue;
					idx2=vFall(k,5);
					if ( idx2 != -1 )
					{
						if ( TestGameOver(1) )	// great ! - choose it
							tst[x] += 10;
						maze[idx2]=0;	// remove virt. chip
					}
				}
			}
			maze[idx]=0;	// remove virt. chip
		}
	}

// search highest val
	for( x=1; x<7; x++ )
		if ( tst[x] > tst[max] )
			max=x;
	idx=0;
	for( x=0; x<7; x++ )
	{
		if (( tst[x] == tst[max] ) && !maze[35+x] )
		{
			vidx[idx] = x;
			idx++;
		}
	}

	if ( !idx )	// never reached
		return;

	if ( idx > 1 )
	{
		int		i1;
		int		i2;

		for( k=0;k<idx;k++)
		{
			i1=vFall( vidx[k], 5 );
			if ( i1 == -1 )
				continue;
			for( x=0;x<7;x++)
			{
				i2=vFall(x,5);
				if ( i2 == -1 )
					continue;
				if ( TestGameOver(2) )	// great ! - choose it
					tst[vidx[k]] += 5;
				maze[i2]=0;				// remove virt. chip
			}
			maze[i1]=0;				// remove virt. chip
		}
	}
// search highest val again
	max=0;
	for( x=1; x<7; x++ )
		if ( tst[x] > tst[max] )
			max=x;
	idx=0;
	for( x=0; x<7; x++ )
	{
		if (( tst[x] == tst[max] ) && !maze[35+x] )
		{
			vidx[idx] = x;
			idx++;
		}
	}

	if ( !idx )	// never reached
		return;

	idx=myrand(idx);
	CPlay(vidx[idx]);
}