示例#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;
}
示例#2
0
/**
 * Draws the score on the screen
 * Score depends on the time needed to end the game and the
 * remaining tuxes on the board
 */
void	DrawScore( void )
{
	char			tscore[ 64 ];
	struct timeval tv;
	gettimeofday(&tv,0);

	score = tv.tv_sec - starttv.tv_sec;

	if ( score > 35000 )
		score=35000;

	score = 35000 - score;
	score = score - tuxes *1000;
	if (score < 0) {
	  score = 0;
	}
	if (tuxes == 1) {
	  score = 44444;
	  FBDrawString( 190, 130, 64, "You did it!", WHITE, 0 );
	}
	sprintf(tscore,"%ld",score);
	FBDrawString( 190, 210, 64, "Score", WHITE, 0 );
	FBDrawString( 190, 290, 64, tscore, WHITE, 0 );
#ifdef SOLBOARD_DEBUG
	printf("draw score %ld\n",score);
#endif

}
static	void	ShowHScore( HScore *g )
{
	int				i;
	int				x;
	char			pp[64];

	FBFillRect( 0, 0, 720, 576, BLACK );

#ifdef HAVE_CURL
	if ( g==ihsc )
		FBDrawString( 190, 32, 64, "Internet HighScore", RED, BLACK );
	else
#endif
		FBDrawString( 220, 32, 64, "HighScore", RED, BLACK );
	for( i=0; i < 8; i++ )
	{
		FBDrawString( 100, 100+i*48, 48, g[i].name, WHITE, 0 );
		sprintf(pp,"%ld",g[i].points);
		x = FBDrawString( 400, 100+i*48, 48, pp, BLACK, BLACK );
		FBDrawString( 500-x, 100+i*48, 48, pp, WHITE, BLACK );
	}
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
	FBFlushGrafic();
#endif
	while( realcode != 0xee )
		RcGetActCode();
}
void	DrawScore( void )
{
	char	cscore[64];
	int		x;

	sprintf(cscore,"%d",score);
	x=FBDrawString(250,264,64,"Score",WHITE,0);
	FBDrawString(250+x+18,264,64,cscore,WHITE,0);
}
示例#5
0
void Startbildschirm()
{
	int i;
	char tlevel[ 64 ];

//	int x,y;
//	for (y=0; y<576; y=y+56)
//		{
//		for (x=0; x<720; x=x+64)
//			{
//			FB2CopyImage(  x, y, 32, 28, man, 2);
//			}
//		}

static int bx[] = {
64,32,0,0,0,32,64,64,64,32,0,128,160,192,192,192,192,192,160,128,128,128,
128,256,256,256,256,256,288,320,320,320,320,384,416,448,448,448,448,448,416,
384,384,384,384,512,544,576,224,224,224,224,224,256,288,288,256,288,288,256,
352,352,352,352,352,384,416,416,416,416,416,384,480,480,480,480,480,512,512,
544,544,576,576,576,576,576 };

static int by[] = {
0,0,0,28,56,56,56,84,112,112,112,0,0,0,28,56,84,112,112,112,84,56,28,0,28,56,
84,112,56,0,28,84,112,0,0,0,28,56,84,112,112,112,84,56,28,56,56,56,312,284,256,
228,200,200,200,228,256,284,312,312,312,284,256,228,200,200,200,228,256,284,312,
256,200,228,256,284,312,228,256,256,284,200,228,256,284,312 };

	for (i=0;i<86;i++)
		{
		FBCopyImage(bx[i]+56,by[i]+118, 32, 28, wall );
		}

	FBFillRect( 55, 365, 200 , 40, BLACK );
	sprintf(tlevel,"%d",max_level);
	FBDrawString( 75,370, 30, tlevel, WHITE, BLACK );
	FBDrawString( 120,370, 30, "Level gefunden", WHITE, BLACK);

#ifdef USEX     
	FBFlushGrafic(); 
#endif

	while( actcode != RC_OK )
		{
			if (i>87) { i=0;} else {i++;}
			if (i<86) {FBCopyImage( bx[i]+56,by[i]+118, 32, 28, box );}
			if (i>=1 && i-1<=85) { FBCopyImage( bx[i-1]+56,by[i-1]+118, 32, 28, man );}
			if (i>=2 && i-2<=85) { FBCopyImage( bx[i-2]+56,by[i-2]+118, 32, 28, wall );}

#ifdef USEX
			FBFlushGrafic(); 
#endif
			RcGetActCode( );
			sleep(1);
		}
	FBFillRect(   0,  0, 720 , 576, BLACK );
}
示例#6
0
int	InitLemm( void )
{
	int				i;

#ifdef USEX
			FBFlushGrafic();
#endif
	FBFillRect( 0, 0, 720, 576, STEELBLUE );
	FBFillRect( 60, 448, 300, 100, BLACK );

	if ( !bgImage )
	{
		FBDrawString(64,482,32,"Initialize...",WHITE,0);
		FBDrawFx2Logo( 320, 486 );
#ifdef USEX
		FBFlushGrafic();
#endif

		initNumbers();

		if ( LoadPics() == -1 )
			return -1;
		bgImage=malloc(1600*160);
		SoundStart();
	}

	if ( !bgImage )
		return -1;

	for( i=0; i<12; i++ )
		svdimage[i]=malloc(32*48);

	for( i=0; i<320; i+=32 )
		inSc( 19, 0, i+main_x, 352, 1 );

	inSc( 29, 0, 66+main_x, 370, 1 );
	inSc( 29, 1, 100+main_x, 372, 1 );
	inSc( 8, 0, 134+main_x, 372, 0 );		// explosion
	inSc( 4, 10, 166+main_x, 374, 1 );		// lemming2
	inSc( 29, 2, 200+main_x, 368, 1 );
	inSc( 29, 3, 234+main_x, 368, 1 );
	inSc( 29, 4, 264+main_x, 372, 1 );
	inSc( 5, 2, 292+main_x, 368, 1 );

	inSc( 20, 0, 320+main_x, 352, 1 );

	FBDrawString(44,390,48,"-",GREEN,0);
	FBDrawString(76,390,48,"+",GREEN,0);

	return 0;
}
示例#7
0
/**
 * Draws the complete board according to the values of the cells
 * and the fx logo
 *
 * Possible field values:
 * #    : inactive cell (not reachable with mouse)
 * ' '  : field which is not on the board
 * n,b,B: empty field
 * x    : cell with a tux
 * s    : selected cell with a tux 
 */
void	DrawBoard(void)
{
	int				x;
	int				y;
	unsigned char	*p = maze;

	for( y = 0; y < MAZEH; y++ )
	{
		for( x = 0; x < MAZEW; x++, p++ )
		{
			switch ( *p )
			{
			case '#' :
				FBFillRect( x*32, y*32, 32, 32, STEELBLUE );
				break;
			case ' ' :
				FBFillRect( x*32, y*32, 32, 32, BLACK );
				break;
			case 'n' :
				FBCopyImage( x*32, y*32, 32, 32, dout );
				break;
			case 'b' :
			        FBCopyImage( x*32, y*32, 32, 32, dout );
			        break;
			case 'B' :
			        FBCopyImage( x*32, y*32, 32, 32, dout );
				break;
			case 'x' :
			        FBCopyImage ( x*32, y*32, 32, 32, dtux );
			        break;
			case 's' :
			        FBCopyImage( x*32, y*32, 32, 32, dselectedtux );
			        break;
			}
		}
	}
	// draw white frame around board
	FBDrawRect( 3*32-3, 3*32-3, 9*32+5, 9*32+5, WHITE );
	FBDrawRect( 3*32-4, 3*32-4, 9*32+7, 9*32+7, WHITE );

	FBDrawString( LOGO_X-90, LOGO_Y, 32, "powered by", WHITE, 0 );
	FBDrawFx2Logo( LOGO_X, LOGO_Y );
	FBDrawString( LOGO_X-90, LOGO_Y+70, 32, 
		      "brought to you by", WHITE, 0 );
	FBDrawString( LOGO_X-80, LOGO_Y+110, 32, 
		      "ChakaZulu", WHITE, 0 );
	gettimeofday(&starttv,0);

	DrawMouse();
}
static	void	LocalSave( void )
{
	int		x;
	char	*user;
	int		i;

	localuser=-1;

	for( i=0; i < 8; i++ )
		if ( score > hsc[i].points )
			break;
	if ( i==8 )
		return;

	Fx2PigPause();

	FBFillRect( 500,32,3*52,4*52+4,BLACK );

	FBFillRect( 150,420,470,64,BLACK );
	FBDrawRect( 149,419,472,66,WHITE );
	FBDrawRect( 148,418,474,68,WHITE );
	x=FBDrawString( 154,420,64,"name : ",WHITE,0);
	user=FBEnterWord(154+x,420,64,9,WHITE);

	Fx2PigResume();

	if ( i < 7 )
		memmove( hsc+i+1,hsc+i,sizeof(HScore)*(7-i) );
	strcpy(hsc[i].name,user);
	hsc[i].points=score;

	localuser=i;
}
示例#9
0
void	DrawScore( void )
{
	char tmoves[ 64 ];
	char tpushes[ 64 ];		
	sprintf(tmoves,"%d",moves);

	FBDrawString( 100, 480, 30, "Moves", WHITE, 0 );
	FBFillRect( 100, 510, 30, 30, BLACK );
	FBDrawString( 100, 510, 30, tmoves, WHITE, 0 );

	sprintf(tpushes,"%d",pushes);

	FBDrawString( 160, 480, 30, "Pushes", WHITE, 0 );
	FBFillRect( 160, 510, 30, 30, BLACK );
	FBDrawString( 160, 510, 30, tpushes, WHITE, 0 );
}
示例#10
0
void	DrawInfo( int what )
{
	char	text[64];

	if ( what == 3 )
	{
		sprintf(text,"LEVEL %d/%d  ",level,LASTLEVEL);
		FBDrawString(80,354,30,text,GREEN,STEELBLUE);
	}
	if ( what & 1 )
	{
		sprintf(text,"OUT %d  ",in_level);
		FBDrawString(220,354,30,text,GREEN,STEELBLUE);
	}
	if ( what & 2 )
	{
		sprintf(text,"IN %d%%   ",lem_in*100/lem_cnt);
		FBDrawString(320,354,30,text,GREEN,STEELBLUE);
	}
}
int CTable::Run()
{

	BBSetBackground( BACK_C );

	FBCopyImage( 0, 0, WIDTH, HEIGHT, BBGetData() );

	FBDrawString( 300, 255, 42, "Loading...", 250, 0 );
#if defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
	FBFlushGrafic();
#endif

	//Outer loop for initialization
	while( 0 == doexit )
	{

#ifdef MARTII
		this->Init();
#else
//		this->Init();
#endif

		this->Display();

		//Inner loop for game controlling
		while( 0 == doexit )
		{
			//Handle keys
			this->HandleKeysPressed();

			if( 0 != doexit ) break;

			//Display changes
		}
	}

	return 0;
}
示例#12
0
void	RunLemm( void )
{
static	int		counter1=0;
static	int		blinkc=0;
	int			i;
	int			f;
	int			b;
	Sprite		*s;
	int			cursor_get=0;
	int			kab=0;
	int			hbk=0;	// hat boden kontakt
//int			hhy=0;

	blinkc++;

	if ( action==3 )
	{
		counter1=0;
		action=4;
		DrawSprite( deko[0] );
		return;
	}
	if ( action==4 )
	{
		counter1++;
		if ( counter1 < 24 )
			return;

		if ( to_rescue > lem_in )
		{
			FBDrawString( 252, 142, 64, "You lost !", WHITE, 0 );
			FBDrawString( 250, 140, 64, "You lost !", RED, 0 );
		}
		else
		{
			level++;
			if ( level>LASTLEVEL )
			{
				FBDrawString( 252, 142, 64, "all level solved", WHITE, 0 );
				FBDrawString( 250, 140, 64, "all level solved", GREEN, 0 );
				FBDrawString( 240, 250, 36, "thanx to emuman for his javacode,", WHITE, 0 );
				FBDrawString( 240, 286, 36, "Psygnosis and DMA for artwork...", WHITE, 0 );
				level=1;
				doexit=2;
				return;
			}
			else
			{
				FBDrawString( 252, 142, 64, "Level solved", WHITE, 0 );
				FBDrawString( 250, 140, 64, "Level solved", GREEN, 0 );
			}
		}
		if ( afunc != -1 )
			FBCopyImage( (afunc+2)*32+32, 384, 32, 48, svdimage[afunc+2] );
		action=5;
		doexit=1;
	}

	if ( action != 2 )
	{
		DrawSprite( deko[0] );
		return;
	}
	if ( pause )
	{
		UndrawSprite( deko[0] );
		for( i=0; i<lem_run; i++ )
		{
			if ( !lemm[i] )
				continue;
			UndrawSprite( lemm[i] );
		}
		DrawSprite( deko[1] );		// ziel
		DrawSprite( deko[2] );		// ziel
		for( i=0; i<lem_run; i++ )
		{
			if ( !lemm[i] )
				continue;
			s=lemm[i];
			if (( s->type & TYP_EXPLODE ) && ( s->countdown > 0 ))
			{
				DrawSimpleNumber( s->x-main_x, s->y-6, s->countdown, 1 );
			}
			SpriteGetBackground( s );
			DrawSprite( s );
		}
		SpriteSelPic( deko[0], 0 );
		SpriteGetBackground( deko[0] );
		DrawSprite( deko[0] );

		if ( blinkc%5 )
			return;
		if ( pause == 1 )
		{
			FBCopyImage( 10*32+32, 384, 32, 48, svdimage[10] );
			pause=2;
		}
		else
		{
			FBDrawRect( 10*32+32, 384, 31, 47, BLUE );
			FBDrawRect( 10*32+33, 385, 29, 45, BLUE );
			pause=1;
		}
		return;
	}

	sel_sprite=-1;

	if (( lem_run < lem_cnt ) && !( counter1%((newspeed/2)+3) ) && !killall )
	{
		lemm[ lem_run ] = CreateSprite(3,0,deko[1]->x+19,deko[1]->y);
		lemm[ lem_run ]->dir=0;		// rechts
		lemm[ lem_run ]->type = TYP_WALKER;

		in_level++;
		lem_run++;
		DrawInfo(1);
	}
	if ( in_level )
		UndrawSprite( deko[0] );
	for( i=0; i<lem_run; i++ )
	{
		if ( !lemm[i] )
			continue;
		s=lemm[i];
		if ( s->type & TYP_EXPLODE )
			restorecd( i );
		else if (( s->type & TYP_FALLEN ) && s->partikel )
			restorecd( i );
		UndrawSprite( s );
		s->counter1++;
		if ( !( s->counter1 % 10 ) && ( s->type & TYP_EXPLODE ) )
		{
			s->countdown--;
			if ( s->countdown == -1 )
			{
				s->counter1=0;
				bg2CopyImage( s->x-7, s->y-4, 21, 21, pbomb );
				CopyBg2Screen( s->x-7,s->y-4, 21, 21);
			}
		}
		if (( s->counter1 == 2 ) && ( s->type & TYP_STOPPER ) &&
			!( s->type & TYP_EXPLODE ))
			bgRect( s->x+1, s->y, s->width-1, s->height-2, 150 );
	}
//	DrawSprite( deko[2] );		// ziel
	UnanimatedDeko();
	for( i=0; i<lem_run; i++ )
	{
		if ( !lemm[i] )
			continue;

		s=lemm[i];

		if ( killall && !kab )
		{
			if ( !(s->type & TYP_EXPLODE ) )
			{
				s->type |= TYP_EXPLODE;
				s->counter1=1;
				kab++;
			}
		}

		if ( (s->countdown==-1) && ( s->type & TYP_EXPLODE ) )
		{
			s->partikel=1;
			partikel(i,1);
		}
		if ( !( s->counter1 % 10 ) && ( s->type & TYP_EXPLODE ) )
		{
			if ( s->countdown == -1 )
			{
				s->y-=4;
				s->x-=4;
				SpriteChangePic( s, 8 );		// explosion
				SpriteGetBackground( s );
				DrawSprite(s);
				SoundPlay( SND_EXPLODE );
			}
			if ( s->countdown == -2 )
			{
				partikel(i,0);
				killlem( i );
				s=0;
				DrawInfo(1);
			}
		}

		if ( s && ( s->countdown < 0 ))
			s=0;

		if ( s && ( s->type & TYP_FALLEN ) )
		{
			if ( s->counter1 < 10 )
			{
				s->partikel=1;
				partikel(i,1);
			}
			else
			{
				killlem( i );
				DrawInfo(1);
			}
			s=0;
		}

		if ( s&&(s->countdown>0) )
		{
			SpriteNextPic( s );
			if ( s->type&TYP_ATHOME )
			{
				s->y-=1;
				if(s->ani==4)
				{
					lem_in++;
					killlem(i);
					SoundPlay( SND_OING );
					DrawInfo(3);
				}
			}
			else
			{	/* lemming im ziel ? */
				if((s->x==haus_x)&&(s->y>haus_y1)&&
					(s->y<haus_y2))
				{
					s->type=TYP_ATHOME;
					s->counter2=0;
					SpriteChangePic( s, 6 );	// lemming4
				}
				else
				{	/* kein bodenkontakt ? */
					switch( s->type & TYP_WORK )
					{
					case TYP_WALKER :
					case TYP_DIGDOWN :
						hbk=isBrick(s->x+1,s->y+s->height,0)||
								isBrick(s->x-2+s->width,s->y+s->height,0);
						break;
					case TYP_STOPPER :
						hbk=isBrick(s->x+1,s->y+s->height+1,0)||
								isBrick(s->x-2+s->width,s->y+s->height+1,0);
						break;
					case TYP_DIGDIAG :
						hbk=isBrick(s->x+10,s->y+s->height-2,0)||
								isBrick(s->x+11,s->y+s->height-2,0);
						break;
					case TYP_BUILDER :
						hbk=1;
						break;
					}
					if ( !hbk )
					{
#if 0
if ( s->type & TYP_DIGDIAG )
{
hhy=s->y+s->height-2;
printf("kein boden on %d, %d\n",s->x,s->y+s->height);
}
#endif
						if( !( s->type&TYP_WALKER ) )
						{
							switch( s->type & TYP_WORK )
							{
							case TYP_STOPPER :
								bgRect(s->x+1,s->y,s->width-1,s->height-2,14);
								break;
							case TYP_DIGDIAG :
								s->y+=5;
								if ( !s->dir )
									s->x+=7;
								break;
							case TYP_DIGDOWN :
								s->y+=2;
								break;
							}
							s->type=TYP_WALKER|(s->type&TYP_UTILS);
							SpriteChangePic( s, 3 );	// lemming1-faller
							if ( s->dir )
								MirrorSprite( s );
						}
						// freier fall
						s->y += 2;
						s->counter2++;
						// aus bild gefallen
						if(s->y>=160)
						{
							SoundPlay( SND_DIE );
							killlem(i);
							DrawInfo(1);
						}
					}
					else
					{
						if(s->type&TYP_WALKER)
						{	/* aufgeschlagen */
							if(s->counter2>=40)
							{
								s->counter1=0;
								s->type=TYP_FALLEN;
								SoundPlay( SND_DIE );
								s->partikel=1;
								partikel(i,1);
								s=0;
							}
							else
							{	/* wieder auf boden */
								s->counter2=0;
								/* laeufer - getestet wird oben */
								if((isBrick(s->x,s->y+1,1)&&
									(s->dir==1))||
								   (isBrick(s->x+s->width,s->y+1,1)&&
									(s->dir==0)))
								{
									MirrorSprite( s );
									s->dir^=1;
								}
								else
								{
									s->x += (s->dir?-1:1);
									if ( s->dir )
									{
										for(b=8;b>0;b--)
										{
											if(isBrick(s->x,
												s->y+s->height-b,0))
											{
												s->y-=1;
												b=0;
											}
										}
									}
									else
									{
										for(b=8;b>0;b--)
										{
											if(isBrick(s->x+s->width,
												s->y+s->height-b,0))
											{
												s->y-=1;
												b=0;
											}
										}
									}
								}
							} /* else, kein matsch */
						} /** walker **/
						else if(s&&(s->type&TYP_BUILDER))
						{
							unsigned char	c=118;	// stair
							if ( !s->ani )
							{
								s->counter2++;
								s->y--;
								if ( s->counter2 != 13 )
								{
									if ( s->dir )
									{
										s->x-=2;
										bghLine(s->x+2,s->y+s->height,6,&c,1);
										CopyBg2Screen( s->x+2,s->y+s->height,6,1);
										if ( isBrick(s->x+1,s->y+2,1) )
										{
											s->y+=2;
											s->dir=0;
											s->counter2=13;
										}
									}
									else
									{
										s->x+=2;
										bghLine(s->x+1,s->y+s->height,6,&c,1);
										CopyBg2Screen( s->x+1,s->y+s->height,6,1);
										if ( isBrick(s->x+s->width,s->y+2,1) )
										{
											s->y+=2;
											s->dir=1;
											s->counter2=13;
										}
									}
								}
								if ( s->counter2 == 12 )
								{
									s->y+=2;
									SpriteChangePic( s, 32 );//keinesteine
									if ( s->dir )
										MirrorSprite( s );
								}
								if ( s->counter2 == 13 )
								{
									s->type&=TYP_UTILS;
									s->type|=TYP_WALKER;
									SpriteChangePic( s, 3 );// lemming1
									if ( s->dir )
										MirrorSprite( s );
								}
							}
						}
						else if(s&&(s->type&TYP_DIGDOWN))
						{
							if(!(s->counter1%8))
							{
								if(s->y<160)
								{
									bgRect( s->x+1, s->y+4, 10,
										8-max(0,s->y-152), STEELBLUE );
									s->y+=1;
									cursor_get=1;
								}
							}
						}	/* digger */
						else if(s&&(s->type&TYP_DIGDIAG))
						{
							if ( s->ani == 8 )
							{
								if ( s->dir )
								{
									unsigned char *data = GetMirrorPic(34);
									bg2CopyImage(s->x+1,s->y+2,6,14,data);
								}
								else
								{
									inBg(34,0,s->x+11,s->y+2);
								}
							}
							if ( !s->ani )
							{
								s->y+=1;
								if ( s->dir )
									s->x-=2;
								else
									s->x+=2;
							}
						}
					}	/* freier fall */
				}	/* nicht am ziel */
			}	/* countdown */
			if ( s&&(level==5) )
			{ /* ab ins feuer ? */
				for( f=5; f<11; f++ )
				{
					if ( SpriteCollide( deko[f], s->x+s->width, s->y ) )
					{
						SoundPlay( SND_DIE );
						killlem(i);
						s=0;
						break;
					}
				}
			}
		}	/* typ-fallen */

		if ( !lemm[i] || !s )
			continue;

		if (( s->type & TYP_EXPLODE ) && ( s->countdown > 0 ))
		{
			DrawSimpleNumber( s->x-main_x, s->y-6, s->countdown, 1 );
		}

		SpriteGetBackground( s );
		DrawSprite( s );
		if ( SpriteCollide( s, deko[0]->x+7, deko[0]->y+7 ) )
		{
			sel_sprite=i;
		}
	}
	if ( cursor_get )
		SpriteGetBackground( deko[0] );
	if ( sel_sprite != -1 )
	{
		SpriteSelPic( deko[0], 1 );
	}
	else
	{
		SpriteSelPic( deko[0], 0 );
	}
	DrawSprite( deko[0] );
#if 0
if ( hhy )
FBDrawLine(32,hhy+hhy+32,656,hhy+hhy+32,RED);
#endif
	counter1++;
}
示例#13
0
static	void	LoadHScore( void )
{
	CURL			*curl;
	CURLcode		res;
	FILE			*fp;
	char			url[ 512 ];
	char			*p;
	int				i;

	FBDrawString( 150,32,32,"try load high score from",GRAY,0);
	FBDrawString( 150,64,32,hscore,GRAY,0);
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
	FBFlushGrafic();
#endif

	sprintf(url,"%s/games/tetris.php?action=get",hscore);

	curl = curl_easy_init();
	if ( !curl )
		return;
	fp = fopen( "/var/tmp/trash", "w");
	if ( !fp )
	{
		curl_easy_cleanup(curl);
		return;
	}
	curl_easy_setopt( curl, CURLOPT_URL, url );
	curl_easy_setopt( curl, CURLOPT_FILE, fp );
	curl_easy_setopt( curl, CURLOPT_NOPROGRESS, TRUE );
	if ( proxy_addr )
	{
		curl_easy_setopt( curl, CURLOPT_PROXY, proxy_addr );
		if ( proxy_user )
			curl_easy_setopt( curl, CURLOPT_PROXYUSERPWD, proxy_user );
	}
	res = curl_easy_perform(curl);

	curl_easy_cleanup(curl);
	fclose( fp );

	if ( res )
		return;

	fp=fopen( "/var/tmp/trash", "r" );
	if ( !fp )
		return;

	for( i=0; i<8; i++ )
	{
		if ( !fgets(url,512,fp) )
			break;
		p=strchr(url,'\n');
		if ( p )
			*p=0;
		p=strchr(url,'&');
		if ( !p )
			break;
		*p=0;
		p++;

		strncpy(ihsc[i].name,url,10);
		ihsc[i].name[9]=0;
		ihsc[i].points = atoi(p);
	}
	if ( i==8 )
		use_ihsc=1;
	fclose(fp);
	unlink("/var/tmp/trash");
}
示例#14
0
int tetris_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;
	int				i;
	int				fd;
	FILE			*fp;
	char			*line;
	char			*p;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

/* load setup */
	fp = fopen( CONFIGDIR "/games.cfg", "r" );
	if ( fp )
	{
		line=malloc(128);
		isalloc=1;
#ifdef HAVE_CURL
		proxy_addr=0;
		proxy_user=0;
#endif
		hscore=0;
		while( fgets( line, 128, fp ) )
		{
			if ( *line == '#' )
				continue;
			if ( *line == ';' )
				continue;
			p=strchr(line,'\n');
			if ( p )
				*p=0;
			p=strchr(line,'=');
			if ( !p )
				continue;
			*p=0;
			p++;
#ifdef HAVE_CURL
			if ( !strcmp(line,"proxy") )
				proxy_addr=strdup(p);
			else if ( !strcmp(line,"proxy_user") )
				proxy_user=strdup(p);
			else if ( !strcmp(line,"hscore") )
				hscore=strdup(p);
#endif
		}
		fclose(fp);
		free(line);
	}

	fd = open( GAMESDIR "/tetris.hscore", O_RDONLY );
	if ( fd == -1 )
	{
		mkdir( GAMESDIR, 567 );
		for( i=0; i < 8; i++ )
		{
			strcpy(hsc[i].name,"nobody");
			hsc[i].points=30;
		}
	}
	else
	{
		read( fd, hsc, sizeof(hsc) );
		close(fd);
	}

#ifdef HAVE_CURL
	if ( hscore )
	{
		LoadHScore();
	}
#endif

#if defined(HAVE_DBOX_HARDWARE) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
	Fx2ShowPig( 480, 400, 176, 144 );
#endif

	while( doexit != 3 )
	{
		BoardInitialize();
		DrawBoard( );	/* 0 = all */
		NextItem();
#ifdef HAVE_DREAMBOX_HARDWARE
		Fx2ShowPig(480, 400, 176, 144 );
#endif
		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */
			RcGetActCode( );
			if ( doexit )
				break;
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */
			RcGetActCode( );
			if ( doexit )
				break;
			MoveSide();
			if ( !FallDown() )
			{
				RemoveCompl();
				if ( !NextItem() )
					doexit=1;
			}
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif

			RcGetActCode( );
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			DrawGameOver();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			doexit=0;
			SaveGame();
#ifdef HAVE_CURL
			if ( use_ihsc )
				ShowIHScore();
#endif
			ShowHScore(hsc);
			Fx2PigPause();

#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			i=0;
			actcode=0xee;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
				i++;
				if ( i == 50 )
				{
					FBDrawString( 190, 480, 48, "press OK for new game",GRAY,0);
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
					FBFlushGrafic();
#endif
				}
			}
			Fx2PigResume();
		}
	}

	Fx2StopPig();

#if defined(HAVE_DBOX_HARDWARE) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}
#endif

	RcClose();
	FBClose();

/* save hscore */
	fd = open( GAMESDIR "/tetris.hscore", O_CREAT|O_WRONLY, 438 );
	if ( fd != -1 )
	{
		write( fd, hsc, sizeof(hsc) );
		close(fd);
	}

	if ( isalloc )
	{
#ifdef HAVE_CURL
		if ( proxy_addr )
			free ( proxy_addr );
		if ( proxy_user )
			free ( proxy_user );
#endif
		if ( hscore )
			free ( hscore );
	}

	return 0;
}
示例#15
0
void	DrawGameOver()
{
	DrawScore();
	FBDrawString( 300, 210, 64, "Level geschaft!", RED, 0 );
}
示例#16
0
static	void	SaveGame( void )
{
#ifdef HAVE_CURL
	CURL		*curl;
	CURLcode	res;
	FILE		*fp;
	char		url[ 512 ];
	char		*user=0;
	char		luser[ 32 ];
	int			x;
	int			n;
	char		*p;
	struct timeval	tv;
	unsigned long	chk=0;

	doexit=0;
#endif // HAVE_CURL

	if ( score < 31 )
		return;
	LocalSave();
#ifdef HAVE_CURL
	LocalSave();

	if ( !use_ihsc )
		return;

	for( x=0; x < 8; x++ )
	{
		if ( score > ihsc[x].points )
			break;
	}
	if ( x == 8 )
		return;

	FBDrawString( 100,230,64,"Inet-Send Highscore ? (OK/BLUE)",GREEN,0);
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
	FBFlushGrafic();
#endif

	while( realcode != 0xee )
		RcGetActCode();

	actcode=0xee;
	while( !doexit )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 100000;
		select( 0,0,0,0, &tv );
		RcGetActCode();
		if ( actcode == RC_BLUE )
			return;
		if ( actcode == RC_OK )
			break;
	}
	if ( doexit )
		return;

	if ( localuser != -1 )
	{
		strcpy(luser,hsc[localuser].name);
		user=luser;
	}
	else
	{
		Fx2PigPause();

		FBFillRect( 500,32,3*52,4*52+4,BLACK );

		FBFillRect( 150,420,470,64,BLACK );
		FBDrawRect( 149,419,472,66,WHITE );
		FBDrawRect( 148,418,474,68,WHITE );
		x=FBDrawString( 154,420,64,"name : ",WHITE,0);
		user=FBEnterWord(154+x,420,64,9,WHITE);

		Fx2PigResume();
	}

	n=FBDrawString( 210,360,48,"sending",BLACK,WHITE);

/* clean name */
	x = strlen(user);
	p=user;
	for( p=user; *p; x--, p++ )
	{
		if (( *p == ' ' ) || ( *p == '&' ) || ( *p == '/' ))
			memcpy(p,p+1,x);
	}

	chk=BuildCheck( user, score );

	sprintf(url,"%s/games/tetris.php?action=put&user=%s&score=%ld&chk=%lu",
		hscore,user,score,chk);

	curl = curl_easy_init();
	if ( !curl )
		return;
	fp = fopen( "/var/tmp/trash", "w");
	if ( !fp )
	{
		curl_easy_cleanup(curl);
		return;
	}
	curl_easy_setopt( curl, CURLOPT_URL, url );
	curl_easy_setopt( curl, CURLOPT_FILE, fp );
	curl_easy_setopt( curl, CURLOPT_NOPROGRESS, TRUE );
	if ( proxy_addr )
	{
		curl_easy_setopt( curl, CURLOPT_PROXY, proxy_addr );
		if ( proxy_user )
			curl_easy_setopt( curl, CURLOPT_PROXYUSERPWD, proxy_user );
	}
	res = curl_easy_perform(curl);

	FBFillRect( 210,360,n,48,GRAY);
	if ( !res )
		FBDrawString( 210,360,48,"success",GREEN,GRAY);
	else
		FBDrawString( 210,360,48,"failed",RED,GRAY);

	curl_easy_cleanup(curl);
	fclose( fp );
	unlink( "/var/tmp/trash" );

	LoadHScore();

	return;
#endif  // HAVE_CURL
}
bool CTable::Setup()
{
	const int Hx = 100;
	const int Hy = 100;
	const int Hwidth = 520;
	const int Hheight = 376;

	bool SomeChanges = true;
	bool FirstRun = true;

	int loiShowCards = ShowCards;

	while( 1 )
	{
		timeval	tv;

		tv.tv_sec = 0;
		tv.tv_usec = 60000;
		select( 0, 0, 0, 0, &tv );		/* 60ms pause */

		RcGetActCode();

		if( false == FirstRun && realcode == 0xee ) continue;

		switch( actcode )
		{
		case RC_OK :
			ShowCards = loiShowCards;
			return true;
			break;
		case RC_RIGHT :
		case RC_LEFT :
			if( 3 == loiShowCards )
				loiShowCards = 1;
			else
				loiShowCards = 3;

			SomeChanges = true;
			break;
		case RC_SETUP :
			if( FirstRun ) break;
			RcGetActCode();
			return false;
			break;
		}

		if( SomeChanges )
		{
			unsigned char FC = Convert_24_8( 0,0,128);
			unsigned char BC = Convert_24_8( 255,255,0);

			if( FirstRun )
			{
				FBFillRect( Hx+8, Hy+8, Hwidth, Hheight, Convert_24_8( 0,0,0) );
				FBFillRect( Hx, Hy, Hwidth, Hheight, 19 );
			}

			FBDrawHLine( Hx + 5, Hy + 55, 400, Convert_24_8( 255,255,255) );
			FBDrawHLine( Hx + 5, Hy + 56, 400, Convert_24_8( 255,255,255) );

			FBDrawString( Hx + 5, Hy + 5, 48, "Setup", Convert_24_8( 255,255,255), 0 );

			FBDrawString( Hx + 5, Hy + 102, 32, "Open cards:", Convert_24_8( 255,255,255), 0 );


			FBFillRect( Hx + 150, Hy + 102, 100, 32, loiShowCards==3?BC:19 );
			FBFillRect( Hx + 260, Hy + 102, 100, 32, loiShowCards==1?BC:19 );

			FBDrawString( Hx + 160, Hy + 102, 32, "3 Cards",
				loiShowCards==3?FC:Convert_24_8( 255,255,255), 0 );
			FBDrawString( Hx + 270, Hy + 102, 32, "1 Card",
				loiShowCards==1?FC:Convert_24_8( 255,255,255), 0 );

			FBDrawString( Hx + 5, Hy + 333, 24, "(OK) - Accept changes, (DBOX) - Cancel", Convert_24_8( 255,255,255), 0 );
#if defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif

		}

		SomeChanges = false;
		FirstRun = false;
	}
	return false;
}
示例#18
0
void	MoveMouse()
{
static	int	locked = 0;
int dx=0;
int dy=0;
char zug=' ';

	if ( locked )
	{
		locked--;
		actcode=0xee;
		return;
	}

	switch( actcode )
	{
	case RC_RIGHT :		// Pinguin nach rechts
		if ( man_x+1 < MAZEW )
		{
		dx = 1;
		dy = 0;
		zug = 'r';
		locked=1;
		}
		break;

	case RC_LEFT :		// Pinguin nach links
		if ( man_x > 1 )
		{
		dx = -1;
		dy = 0;
		zug = 'l';
		locked=1;
		}
		break;

	case RC_DOWN :		// Pinguin nach unten
		if ( man_y+1 < MAZEH )
		{
		dx = 0;
		dy = 1;
		zug = 'd';
		locked=1;
		}
		break;

	case RC_UP :		// Pinguin nach oben
		if ( man_y > 1 )
		{
		dx = 0;
		dy = -1;
		zug = 'u';
		locked=1;
		}
		break;

	case RC_MINUS :		// letzte Züge rückgängig machen
		if (moves>0)
			{
			if (getField(man_x,man_y)=='@')
				{
				setField(man_x,man_y,' ');
				}
			else
				{
				setField(man_x,man_y,'.');
				}

			if (Zuege[moves]=='r' || Zuege[moves]=='R')
				{
				man_x--;
				dx=1;
				}
			else if (Zuege[moves]=='l' || Zuege[moves]=='L')
				{
				man_x++;
				dx=-1;
				}
			else if (Zuege[moves]=='u' || Zuege[moves]=='U')
				{
				man_y++;
				dy=-1;
				}
			else if (Zuege[moves]=='d' || Zuege[moves]=='D')
				{
				man_y--;
				dy=1;
				}

			if (getField(man_x,man_y)==' ')
				{
				setField(man_x,man_y,'@');
				}
			else
				{
				setField(man_x,man_y,'+');
				}

			if (isupper(Zuege[moves]))
				{
				if (getField(man_x+2*dx,man_y+2*dy)=='$')
					{
					setField(man_x+2*dx,man_y+2*dy,' ');
					}
				else
					{
					setField(man_x+2*dx,man_y+2*dy,'.');
					}

				if (getField(man_x+dx,man_y+dy)==' ')
					{
					setField(man_x+dx,man_y+dy,'$');
					}
				else
					{
					setField(man_x+dx,man_y+dy,'*');
					}
				pushes--;
				}
			moves--;
			dx=0;
			dy=0;
			DrawBoard();
			DrawScore();
		}
		locked=1;
		break;

	case RC_PLUS :		// Rückgängig rückgängig machen
		if (Zuege[moves+1]!=' ')
			{
			if (Zuege[moves+1]=='r' || Zuege[moves+1]=='R')
				{
				dx=1;
				}
			else if (Zuege[moves+1]=='l' || Zuege[moves+1]=='L')
				{
				dx=-1;
				}
			else if (Zuege[moves+1]=='u' || Zuege[moves+1]=='U')
				{
				dy=-1;
				}
			else if (Zuege[moves+1]=='d' || Zuege[moves+1]=='D')
				{
				dy=1;
				}
			}
		locked=1;
		break;

	case RC_RED :		// vorheriges Level - bei angefangenem Level nachfragen, ob wirklich sicher
		if (moves!=0)
			{
			FBFillRect( 160, 70, 400, 436, B );
			FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 );
			FBDrawString( 160,110, 30, "ROT   abbruch", WHITE, 0 );
			FBDrawString( 160,140, 30, "OK    naechstes Level", WHITE, 0 );
#ifdef USEX
			FBFlushGrafic();
#endif

			actcode=0xee;
			while( actcode != RC_OK && actcode != RC_RED )
				{
					RcGetActCode();
				}
			}
		if (actcode == RC_OK || moves==0)
			{
			if (level > 0)
				{
				level--;
				BoardInitialize();
				}
			else
				{
				level = max_level-1;
				BoardInitialize();
				}
			}
		else
			{
			FBFillRect( 0, 0, 720, 576, BLACK );
			DrawBoard();
			DrawScore();
			}

		locked=1;
		break;

	case RC_GREEN :		// naechstes Level - bei angefangenem Level nachfragen, ob wirklich sicher
		if (moves!=0)
			{
			FBFillRect( 160, 70, 400, 436, B );
			FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 );
			FBDrawString( 160,110, 30, "ROT   abbruch", WHITE, 0 );
			FBDrawString( 160,140, 30, "OK    vorheriges Level", WHITE, 0 );
#ifdef USEX
			FBFlushGrafic();
#endif

			actcode=0xee;
			while( actcode != RC_OK && actcode != RC_RED )
				{
					RcGetActCode();
				}
			}
		if (actcode == RC_OK || moves==0)
			{
			if (level+1 < max_level)
				{
				level++;
				BoardInitialize();
				}
			else
				{
				level = 0;
				BoardInitialize();
				}
			}
		else
			{
			FBFillRect( 0, 0, 720, 576, BLACK );
			DrawBoard();
			DrawScore();
			}

		locked=1;
		break;

	case RC_YELLOW :	// Randfelder ('a') aus-/einblenden
		if (Rand == 0)
			{
			Rand = 1;
			}
		else
			{
			Rand = 0;
			}
		locked=1;
		FBFillRect( 0, 0, 720, 576, BLACK );
		DrawBoard();
		DrawScore();
		FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 );
		break;

	case RC_BLUE :		// Level von vorne beginnen - bei angefangenem Level nachfragen, ob wirklich sicher
		if (moves!=0)
			{
			FBFillRect( 160, 70, 400, 436, B );
			FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 );
			FBDrawString( 160,110, 30, "ROT   abbruch", WHITE, 0 );
			FBDrawString( 160,140, 30, "OK    vorheriges Level", WHITE, 0 );
#ifdef USEX
			FBFlushGrafic();
#endif
			actcode=0xee;
			while( actcode != RC_OK && actcode != RC_RED )
				{
					RcGetActCode();
				}
			}
		if (actcode == RC_OK || moves==0)
			{
			BoardInitialize();
			}
		else
			{
			FBFillRect( 0, 0, 720, 576, BLACK );
			DrawBoard();
			DrawScore();
			}
		locked=1;
		break;

	case RC_HELP :		// Hilfe anzeigen
		locked=1;
		FBFillRect( 160, 70, 400, 436, B );
		FBDrawString( 160, 70, 30, "ROT   vorheriges Level", WHITE, 0 );
		FBDrawString( 160,100, 30, "GRUEN naechstes Level", WHITE, 0 );
		FBDrawString( 160,130, 30, "GELB  Rand ein/aus", WHITE, 0 );
		FBDrawString( 160,160, 30, "BLAU  Level neu starten", WHITE, 0 );
		FBDrawString( 160,190, 30, "MINUS Zug zurueck", WHITE, 0 );
		FBDrawString( 160,220, 30, "PLUS  Zug vor", WHITE, 0 );
		FBDrawString( 160,260, 30, "HOME  Spiel beenden", WHITE, 0 );
		FBDrawString( 160,290, 30, "STUMM Spiel aus-/einblenden", WHITE, 0 );
		FBDrawString( 160,330, 30, "HILFE diese Hilfe", WHITE, 0 );
		FBDrawString( 160,370, 30, "OK    weiter", WHITE, 0 );
#ifdef USEX
		FBFlushGrafic();
#endif

		actcode=0xee;
		while( actcode != RC_OK )
			{
				RcGetActCode( );
			}
		FBFillRect( 0, 0, 720, 576, BLACK );
		DrawBoard();
		DrawScore();
		FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 );
		break;
	}

	if (dx != 0 || dy != 0)		// Soll Pinguin verschoben werden?
	{
	if (getField(man_x+dx, man_y+dy) == ' ')	// Zug auf leeres Feld - keine Kiste vorhanden
		{
		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'@');

		DrawField(man_x, man_y);

		moves++;
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '.')	// Zug auf Zielfeld - keine Kiste vorhanden
		{
		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'+');

		DrawField(man_x, man_y);

		moves++;
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '$' && getField(man_x+(2*dx), man_y+(2*dy)) == ' ')	// Zug auf Feld mit Kiste - Kiste auf leeres Feld
		{
		setField(man_x+(2*dx), man_y+(2*dy),'$');
		setField(man_x+dx, man_y+dy,' ');
		DrawField(man_x+(2*dx), man_y+(2*dy));

		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'@');

		DrawField(man_x, man_y);

		moves++;
		pushes++;
		zug = toupper (zug);
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '$' && getField(man_x+(2*dx), man_y+(2*dy)) == '.')	// Zug auf Feld mit Kiste - Kiste auf Zielfeld
		{
		setField(man_x+(2*dx), man_y+(2*dy),'*');
		setField(man_x+dx, man_y+dy,' ');
		DrawField(man_x+(2*dx), man_y+(2*dy));

		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'@');

		DrawField(man_x, man_y);

		moves++;
		pushes++;
		zug = toupper (zug);
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '*' && getField(man_x+(2*dx), man_y+(2*dy)) == ' ')	// Zug auf Zielfeld mit Kiste - Kiste auf leeres Feld
		{
		setField(man_x+(2*dx), man_y+(2*dy),'$');
		setField(man_x+dx, man_y+dy,'.');
		DrawField(man_x+(2*dx), man_y+(2*dy));

		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'+');

		DrawField(man_x, man_y);

		moves++;
		pushes++;
		zug = toupper (zug);
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '*' && getField(man_x+(2*dx), man_y+(2*dy)) == '.')	// Zug auf Zielfeld mit Kiste - Kiste auf Zielfeld
		{
		setField(man_x+(2*dx), man_y+(2*dy),'*');
		setField(man_x+dx, man_y+dy,'.');
		DrawField(man_x+(2*dx), man_y+(2*dy));

		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'+');

		DrawField(man_x, man_y);

		moves++;
		pushes++;
		zug = toupper (zug);
		DrawScore();
		}
	else
		{
		zug = ' ';
		}
	}

	if (zug !=' ')
		{
		Zuege[moves]=zug;
		}

	if (win() == 1)		// durch letzten Zug gewonnen?
		{
		if (level+1 < max_level)
			{
			level++;
			}
		else
			{
			level = 0;
			}

		doexit=1;
		}
#ifdef USEX
	FBFlushGrafic();
#endif
	return;
}
void	DrawGameOver( void )
{
	FBDrawString( 250, 200, 64, "Game Over", RED, 0 );
}
示例#20
0
static	void	SortBouquet( Channel *ch, int num )
{
	int				i;
	int				color;
	int				p1=0;
	int				pos=0;
	int				w=0;
	int				redraw=0;
	int				mode=0;
	int				x;
	int				x2;
	struct timeval	tv;
	Channel			chs;
	char			text[16];

	FBFillRect( 0,0,720,576,BLACK);

	FBDrawString( 200, 32, 48, ch==tv_ch?"TV bouquet":"Radio bouquet",RED,0);

	while( realcode != 0xee )
		RcGetActCode();
	actcode=0xee;

	while( !doexit )
	{
		if ( w )
			FBFillRect( 150, 90, w+150, 44*9+48, BLACK );
		w=0;
		for( i=p1; i<p1+10; i++ )
		{
			sprintf(text,"%d",i+1);
			x2=FBDrawString( 150,90+(i-p1)*44,48,text,BLACK,0);
			FBDrawString( 260-x2,90+(i-p1)*44,48,text,GRAY,0);

			color= ch[i].flag == '0' ? GRAY : GRAY2;
			if ( i== pos )
				color=mode?RED:WHITE;

			x=FBDrawString( 300,90+(i-p1)*44,48,ch[i].name,color,0);
			if ( x > w )
				w=x;
		}
		FBDrawString( 50, 100, 32, "OK select",GRAY,0);
		FBFillRect( 50, 142, 8, 8, BLUE );
		FBDrawString( 62, 130, 32, "hide/show",GRAY,0);
		FBFillRect( 50, 172, 8, 8, RED );
		FBDrawString( 62, 160, 32, "save",GRAY,0);
		FBFillRect( 50, 202, 8, 8, YELLOW );
		FBDrawString( 62, 190, 32, ch==tv_ch?"radio":"tv",GRAY,0);
#ifdef USEX
	FBFlushGrafic();
#endif
		while( realcode != 0xee )
			RcGetActCode();

		redraw=0;
		while( !doexit && !redraw )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 200000;
			select( 0,0,0,0,&tv );
			actcode=0xee;
			RcGetActCode();
			if ( actcode == 0xee )
				continue;
			switch( actcode )
			{
			case RC_UP :
				if ( pos == 0 )
					continue;
				pos--;
				if ( mode )
				{
					memcpy(&chs,ch+pos+1,sizeof(Channel));
					memcpy(ch+pos+1,ch+pos,sizeof(Channel));
					memcpy(ch+pos,&chs,sizeof(Channel));
				}
				if ( pos < p1 )
				{
					p1 -= 9;
					redraw=1;
					if ( p1 < 0 )
						p1 = 0;
				}
				else
				{
					if ( mode )
					{
						FBDrawString( 300,90+(pos+1-p1)*44,48,
							ch[pos].name, BLACK,0);
						FBDrawString( 300,90+(pos-p1)*44,48,
							ch[pos+1].name, BLACK,0);
					}
					color= ch[pos+1].flag == '0' ? GRAY : GRAY2;
					FBDrawString( 300,90+(pos+1-p1)*44,48,ch[pos+1].name,
						color,0);
					color=mode?RED:WHITE;
					FBDrawString( 300,90+(pos-p1)*44,48,ch[pos].name,
						color,0);
				}
				break;
			case RC_DOWN :
				if ( pos == num-1 )
					continue;
				pos++;
				if ( mode )
				{
					memcpy(&chs,ch+pos-1,sizeof(Channel));
					memcpy(ch+pos-1,ch+pos,sizeof(Channel));
					memcpy(ch+pos,&chs,sizeof(Channel));
				}
				if ( pos > p1+9 )
				{
					p1 += 9;
					redraw=1;
					if ( p1 > num-10 )
						p1 = num-10;
				}
				else
				{
					if ( mode )
					{
						FBDrawString( 300,90+(pos-1-p1)*44,48,
							ch[pos].name, BLACK,0);
						FBDrawString( 300,90+(pos-p1)*44,48,
							ch[pos-1].name, BLACK,0);
					}
					color= ch[pos-1].flag == '0' ? GRAY : GRAY2;
					FBDrawString( 300,90+(pos-1-p1)*44,48,ch[pos-1].name,
						color,0);
					color=mode?RED:WHITE;
					FBDrawString( 300,90+(pos-p1)*44,48,ch[pos].name,
						color,0);
				}
				break;
			case RC_BLUE :
				ch[pos].flag = ch[pos].flag == '0' ? '1' : '0';
				break;
			case RC_OK :
				color=mode?WHITE:RED;
				FBDrawString( 300,90+(pos-p1)*44,48,ch[pos].name,
						color,0);
				mode=!mode;
				break;
			case RC_RED :
				doexit=1;
				break;
			case RC_YELLOW :
				doexit=2;
				break;
			}
#ifdef USEX
			FBFlushGrafic();
#endif
			while( realcode != 0xee )
				RcGetActCode();
		}
	}
}
示例#21
0
int bouquet_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				t;
	int				r;
	int				i;
	int				idx=0;
	int				cnum;
	int				x;
	Channel			*ch=NULL;
	FILE			*fp;
	char			line[512];
	char			l2[512];
	char			*p;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

/* load setup */
	fp = fopen( CONFIGDIR "/zapit/services.xml", "r" );
	if ( !fp )
	{
		FBDrawString( 190, 100, 64, "services.xml not found !", RED, 0 );
#ifdef USEX
		FBFlushGrafic();
#endif
		tv.tv_sec = 5;
		tv.tv_usec = 0;
		select( 0, 0, 0, 0, &tv );

		RcClose();
		FBClose();

		return 0;
	}

	while( fgets(line,512,fp) )
	{
		num_lines++;
		if ( strstr(line,"channelNR") )
		{
			p=strstr(line,"serviceType");
			if ( p && (*(p+15) == '0') )
			{
				p+=16;
				if ( *p == '1' )
					num_ch_tv++;
				if ( *p == '2' )
					num_ch_radio++;
				if ( *p == '4' )
					num_ch_tv++;
			}
		}
	}
	fclose(fp);

	lines = (char**)malloc(sizeof(char*)*num_lines);
	tv_ch = (Channel*)malloc(sizeof(Channel)*num_ch_tv);
	radio_ch = (Channel*)malloc(sizeof(Channel)*num_ch_radio);
	for( i=0;i<num_ch_tv;i++)
		tv_ch[i].flag=0;
	for( i=0;i<num_ch_radio;i++)
		radio_ch[i].flag=0;

	fp = fopen( CONFIGDIR "/zapit/services.xml", "r" );
	t=num_ch_tv-1;
	r=num_ch_radio-1;
	for(i=0; i<num_lines;i++)
	{
		fgets( line, 512, fp );
		lines[i] = strdup(line);
		if ( !strstr(line,"channelNR") )
			continue;

		p=strstr(line,"name=");
		copyname(l2,p+6);

		p=strstr(line,"channelNR=");
		cnum=_atoi(p+11);

		if ( cnum )
			idx=cnum-1;

		p=strstr(line,"serviceType");
		if ( !p || ( *(p+15) != '0' ) )
			continue;

		switch( *(p+16) )
		{
		case '1' :
		case '4' :
			ch=tv_ch;
			if ( !cnum || ch[idx].flag )
			{
				idx=t;
				t--;
			}
			break;
		case '2' :
			ch=radio_ch;
			if ( !cnum || ch[idx].flag )
			{
				idx=r;
				r--;
			}
			break;
		default:
			p=0;
			break;
		}
		if ( !p )
			continue;

		ch[idx].name=strdup(l2);
		ch[idx].flag=*(p+14);
		ch[idx].line=lines[i];
	}
	fclose(fp);

	t=0;
	while( doexit != 3 )
	{
		if ( t )
			SortBouquet( radio_ch, num_ch_radio );
		else
			SortBouquet( tv_ch, num_ch_tv );
		t=!t;
		switch( doexit )
		{
		case 2 :
			doexit=0;
			break;
		case 1 :
			SaveServices();
			doexit=3;
			break;
		}
	}

	for( i=0; i<num_ch_tv; i++ )
		free( tv_ch[i].name );
	for( i=0; i<num_ch_radio; i++ )
		free( radio_ch[i].name );
	for( i=0; i<num_lines; i++ )
		free( lines[i] );
	free( lines );
	free( tv_ch );
	free( radio_ch );

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
示例#22
0
static	void	SaveServices( void )
{
	FILE	*fp;
	Channel	*ch;
	int		i;
	int		n;
	int		nr;
	char	*p;
	char	*p2;
	int		perc;
	int		lp=-1;

	FBDrawString( 62, 160, 32, "save",BLACK,GRAY);
#ifdef USEX
		FBFlushGrafic();
#endif
	fp = fopen( CONFIGDIR "/zapit/services.xml", "w" );
	if ( !fp )
		return;
	FBFillRect( 96, 226, 508, 24, WHITE );
	FBFillRect( 100, 230, 500, 16, GRAY2 );
	for( n=0; n<num_lines; n++ )
	{
		perc=n*500/num_lines;
		if ( perc != lp )
		{
			FBFillRect( 100, 230, perc, 16, GRAY );
#ifdef USEX
			FBFlushGrafic();
#endif
		}
		nr=0;
		ch=tv_ch;
		for( i=0; i<num_ch_tv;i++ )
			if ( tv_ch[i].line == lines[n] )
				break;
		if ( i==num_ch_tv )
		{
			ch=radio_ch;
			for( i=0; i<num_ch_radio;i++ )
				if ( radio_ch[i].line == lines[n] )
					break;
			if ( i == num_ch_radio )
				ch=0;
			else
				nr=i;
		}
		else
			nr=i;
		if ( !ch )
		{
			fprintf(fp,"%s",lines[n]);
			continue;
		}
		p=strstr(lines[n],"serviceType=");
		p+=14;
		*p = ch[nr].flag;
		p2=strstr(lines[n],"channelNR=");
		p2+=11;
		for( p=lines[n]; p!=p2; p++ )
			fprintf(fp,"%c",*p);
		fprintf(fp,"%d",nr+1);
		p=strchr(p,'"');
		for( ; *p; p++ )
			fprintf(fp,"%c",*p);
	}
	fclose(fp);
}
示例#23
0
void	InitLevel( void )
{
	int		i;
	char	text[64];

	in_level=0;
	pause=0;
	killall=0;
	action=0;
	lem_in=0;
	lem_run=0;
	afunc=-1;
	main_x=660;
	memset(deko,0,sizeof(deko));
	memset(bgImage,STEELBLUE,1600*160);
	deko[0]=CreateSprite(0,0,main_x+160,80);			// cursor
	deko[0]->anilocked=1;
	switch( level )
	{
	case 1 :
	case 4 :
	case 6 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,39);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,0,871,106);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,876,108);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,902,108);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		switch( level )
		{
		case 6 :
			portfolio[7]=2;
			portfolio[3]=2;
			portfolio[2]=2;
			break;
		case 1 :
			portfolio[7]=10;
#if 1
portfolio[6]=10;
portfolio[4]=10;
portfolio[3]=10;
portfolio[2]=10;
#endif
			break;
		case 4 :
			portfolio[2]=5;
			break;
		}
		haus_x=889;
		haus_y1=117;
		haus_y2=135;
		to_rescue=level==6?39:5;
		newspeed=level==6?1:50;
		lem_cnt=level==6?40:10;
		break;
	case 2 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,7);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,700,128);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,704,129);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,731,129);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[3]=4;
		haus_x=718;
		haus_y1=139;
		haus_y2=157;
		to_rescue=25;
		newspeed=50;
		lem_cnt=50;
		break;
	case 3 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,23);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,1000,128);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,1004,129);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,1031,129);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[3]=2;
		portfolio[7]=2;
		haus_x=1018;
		haus_y1=139;
		haus_y2=157;
		to_rescue=50;
		newspeed=50;
		lem_cnt=50;
		break;
	case 5 :
		/* deko */
		deko[1]=CreateSprite(1,0,712,3);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,1150,117);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,1154,118);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,1181,118);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* feuer */
		deko[5]=CreateSprite(9,0,849,39);		// feuer
		deko[6]=CreateSprite(9,0,979,39);		// feuer
		deko[7]=CreateSprite(9,0,880,66);		// feuer
		deko[8]=CreateSprite(9,0,880,107);		// feuer
		deko[9]=CreateSprite(9,0,979,131);		// feuer
		deko[10]=CreateSprite(9,0,1002,86);		// feuer

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[2]=5;
		portfolio[3]=3;
		haus_x=1168;
		haus_y1=128;
		haus_y2=146;
		to_rescue=30;
		newspeed=50;
		lem_cnt=50;
		break;
	}
	minspeed=newspeed;
	DrawLevelIntoBg();
	/* copy level to screen */
	CopyBg2Screen( main_x, 0, 328, 160 );
	SpritesGetBackground();
	DrawSprites();
	/* Draw Menu-Item-Numbers */
	for( i=0; i<8; i++ )
		DrawNumber( 106+i*32, 389, portfolio[i] );

	DrawNumber( 42, 389, newspeed );
	DrawNumber( 74, 389, 100-newspeed );
	DrawInfo(3);
	/* show level info */
	FBFillRect( 60, 448, 200, 100, BLACK );
	sprintf(text,"Lemmings : %d  ",lem_cnt);
	FBDrawString(64,450,32,text,WHITE,0);
	sprintf(text,"%d%% to be saved  ",to_rescue*100/lem_cnt);
	FBDrawString(64,482,32,text,WHITE,0);
	sprintf(text,"Release Rate %d  ",100-newspeed);
	FBDrawString(64,514,32,text,WHITE,0);
	SoundPlay( SND_LETSGO );
}
示例#24
0
void	BoardInitialize()
{
	char* verz = DATADIR "/sokoban/";
	char* verz2 = CONFIGDIR "/sokoban/";
	FILE *Datei=0;
	int x,y,z;
	int i;
	char* d;

	if (levelverz[level]==1)
		{
		d = malloc (strlen(verz)+strlen(levelname[level])+1);
		strcpy (d,verz);
		strcat (d,levelname[level]);
		}
	else
		{
		d = malloc (strlen(verz2)+strlen(levelname[level])+1);
		strcpy (d,verz2);
		strcat (d,levelname[level]);
		}

	FBFillRect( 0, 0, 720, 576, BLACK );

	Datei = fopen(d, "r");

	free(d);

	if ( !Datei )
	{	// installation error
		doexit=4;
		FBDrawString( 200, 510, 30, "Installation Error. Cant find Level", WHITE, 0 );
		return;
	}

	MAZEW = 0;
	MAZEH = 0;

	for (y=0; y<18; y++)
		{
		for (x=0; x<22; x++)
			{
			setField(x, y, 'a');
			}
		}

	x=0; y=0;
	while(!feof(Datei))
		{
		z = fgetc(Datei);

		if (z!='#' && z!='.' && z!='$' && z!='@' && z!='+' && z!='*' && z!=' ' && z!=0x0d && z!=0x0a)
			{
			MAZEH=y;
			break;
			}
		else if (z == 0x0d)
			{
			z=fgetc(Datei);
			for (i=x; board[i][y] != '#' && i > 3; i--) {x=i;}
			if (MAZEW < x) {MAZEW = x;}
			y++;
			x=0;
			MAZEH=y;
			}
		else if (z == 0x0a)
			{
			for (i=x; board[i][y] != '#' && i > 3; i--) {x=i;}
			if (MAZEW < x) {MAZEW = x;}
			y++;
			x=0;
			MAZEH=y;
			}
		else
			{
			if (y<18 && x<22)
				{
				setField(x, y, z);
				if ((z=='@') || (z=='+'))
					{
					man_x = x;
					man_y = y;
					}
				}
			x++;
			}
		}

	fclose(Datei);

	ox = (720 - (MAZEW*32))/2;
	oy = (576 - (MAZEH*28))/2;

	for (y=0; y<18; y++)
		{
		for (x=0; x<22; x++)
			{
			if (getField(x, y) != '#') {setField (x, y, 'a');}
				else break;
			}
		for (x=21; x>=0; x--)
			{
			if (getField(x, y) != '#') {setField (x, y, 'a');}
				else break;
			}
		}

	for (x=0; x<22; x++)
		{
		for (y=0; y<18; y++)
			{
			if (getField(x, y) != '#') {setField (x, y, 'a');}
				else break;
			}
		for (y=17; y>=0; y--)
			{
			if (getField(x, y) != '#') {setField (x, y, 'a');}
				else break;
			}
		}

	moves = 0;
	pushes = 0;

	DrawBoard();
	DrawScore();
	FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 );
	
	for (i=0; i<=1500;i++)
		{
		Zuege[i]=' ';
		}
}
void CTable::ShowHelp()
{

	const int Hx = 100;
	const int Hy = 100;
	const int Hwidth = 520;
	const int Hheight = 376;

	FBFillRect( Hx+8, Hy+8, Hwidth, Hheight, Convert_24_8( 0,0,0) );
	FBFillRect( Hx, Hy, Hwidth, Hheight, 19 );

	FBDrawHLine( Hx + 5, Hy + 55, 400, Convert_24_8( 255,255,255) );
	FBDrawHLine( Hx + 5, Hy + 56, 400, Convert_24_8( 255,255,255) );

	FBDrawString( Hx + 5, Hy + 5, 48, "Solitair for D-BOX", Convert_24_8( 255,255,255), 0 );

	FBDrawString( Hx + 5, Hy + 60, 32, "TheMoon, 2003", Convert_24_8( 255,255,255), 0 );

	FBDrawString( Hx + 5, Hy + 102, 32, "Key mappings:", Convert_24_8( 255,255,255), 0 );

	FBDrawString( Hx + 5, Hy + 135, 32, "(Red)", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 105, Hy + 135, 32, "- Restart game", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 5, Hy + 168, 32, "(Blue)", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 105, Hy + 168, 32, "- Wizard", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 5, Hy + 201, 32, "(?)", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 105, Hy + 201, 32, "- Help screen", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 5, Hy + 234, 32, "(Home)", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 105, Hy + 234, 32, "- Exit", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 5, Hy + 267, 32, "(1 - 7)", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 105, Hy + 267, 32, "- Tableau", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 5, Hy + 300, 32, "(-) (+)", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 105, Hy + 300, 32, "- Change selection", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 5, Hy + 333, 32, "DBOX", Convert_24_8( 255,255,255), 0 );
	FBDrawString( Hx + 105, Hy + 333, 32, "- Setup menu", Convert_24_8( 255,255,255), 0 );



}