コード例 #1
0
static int OnDrawCommon( MyName )( PSI_CONTROL pc )
{
    ClearImageTo( GetControlSurface( pc ), BASE_COLOR_BLACK );
    return 1;
}
コード例 #2
0
int main( void )
{
	uint32_t width, height;
	uint32_t imagecount = 0;
	uint32_t testimagesatinitialization = 0;
	Image blank;

	srand( time( NULL ) );

	for(width=0; width< NUM_REELS; width++)
	{
		g.uiSpeedCounter[width] = 0;
		g.uiSpeedStep[width] = 2;
		g.idx[width]= 0;
	}

	g.pdi = GetDisplayInterface();
	g.pii = GetImageInterface();

			//SetSystemLog( SYSLOG_FILE, stdout );
   SetSystemLoggingLevel( 1000 + LOG_NOISE);
	GetDisplaySize( &width, &height );;
	g.render = OpenDisplaySizedAt( 0, width, height, 0, 0 );
	UpdateDisplay(g.render);
	g.surface = GetDisplayImage( g.render );
	SetMouseHandler( g.render, MouseMethod, 0 );

//	blank = LoadImageFile( WIDE("blankimage.jpg"));
	blank = MakeImageFile(96,96);
   ClearImageTo( blank, BASE_COLOR_CYAN );
	g.playagain=LoadImageFile( WIDE("%images%/playagain.jpg"));
	g.playing  =LoadImageFile( WIDE("%images%/playing.jpg"));
   g.background = LoadImageFile( WIDE("%images%/background.jpg") );
//   g.background = blank;
	g.strip = LoadImageFile( WIDE("%images%/slot_strip.jpg") );
	g.nReels = NUM_REELS;


	{
      Image icons[NUM_ICONS];
		int n, m;
      INDEX idx;

		for( n = 0; n < NUM_ICONS; n++ )
		{
			icons[n] = MakeSubImage( g.strip, 96 * n, 0, 96, 96 );
		}
		n =  width = imagecount = height = 0;
		while(imagecount < NUM_IMAGES )
		{
			idx = rand()%NUM_ICONS;
			g.images[imagecount] = icons[idx];
			if( testimagesatinitialization )
			{
				BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 );
				width++;
				if(!( width % 8 ))
				{
					width=0;
					height++;
				}
			}
         imagecount++;
  			for( m = 0; m < (( rand()%2 )  ); m++)
  			{
				g.images[imagecount] = blank;
				if( testimagesatinitialization )
				{
					BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 );
					width++;
					if(!( width % 8 ))
					{
						width=0;
						height++;
					}
				}
				imagecount++;
			}

			if( testimagesatinitialization )
			{
				SyncRender( g.render);
				UpdateDisplay(g.render);
			}

		}
		if( !testimagesatinitialization )
		{
				SyncRender( g.render);
				UpdateDisplay(g.render);
		}


		for( n = 0; n < NUM_BLURS; n++ )
		{
			g.blurs[n] = MakeImageFile( 96, (NUM_PICS) * 96 );
         g.dodges[n] = MakeImageFile( 96, (NUM_PICS) * 96 );
			for( m = 0; m < NUM_IMAGES; m++ )
			{
            idx = rand()%NUM_IMAGES;
				g.reel[0][m] = g.images[idx];
			}
			Blur( g.blurs[n], g.reel[0] );
			DodgeEx( g.dodges[n], g.reel[0] , 2);
		}
		for( n = 0; n < NUM_REELS; n++)
		{
			g.subsurface[n]  = MakeSubImage( g.surface
													 , REEL_OFSX + REEL_STEPX * n
													 ,  REEL_OFSY
													 , REEL_WIDTH, (96 * NUM_PICS_IN_WINDOW) );
			g.testsurface[n] = MakeSubImage( g.surface, REEL_OFSX + REEL_STEPX * n + 480,  REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS) );
		}
		g.statussurface = MakeSubImage( g.surface
												, 490, 10
												, 140,  68
												);


		g.backgroundsurface = MakeSubImage( g.surface
												, 0, 0
												, 640,  460
												);
	}
   g.flags.bBackgroundInitialized = 0;

	ThreadTo( ReadInput, 0 );

	{
		uint32_t start = GetTickCount();
		xlprintf(LOG_NOISE)("Started at %lu"
								 , start);
      g.ofs = 0;
		while( 1 )
		{
			if( g.flags.bSpinning )
			{
				DrawSpinningReels(FALSE);
			}

#ifndef __ARM__
         // scale to approx unit speeds..
  			WakeableSleep( 250 );
			//WakeableSleep( 33);
#endif
		}
	}
	CloseDisplay( g.render );
	UnmakeImageFile( g.strip );
   return 0;
}
コード例 #3
0
int CPROC DrawGrid( PSI_CONTROL frame )
	{
		int p_r, p_c, p, x, y;
      Image surface = GetControlSurface( frame );
      ClearImageTo( surface, BASE_COLOR_BLACK );
		for( p_r = 0; p_r < 3; p_r++ )
		{
			for( p_c = 0; p_c < 4; p_c++ )
			{
				p = p_r*4 + p_c;
				BlatColor( surface
							, patch_left(p_c)
							, patch_top( p_r )
							, patch_width(p_c)
							, patch_height( p_r )
							, BASE_COLOR_DARKGREY
							);
				for( x = 0; x < HEX_SIZE; x++ )
					for( y = 0; y < HEX_SIZE; y++ )
					{
						// 640 / 4 = 160
						// 480 / 3 = 160
						//lprintf( WIDE("r_left is %d -> %d r_right is %d"), r_left(x), r_left(x+1), r_width(x) );

						if( x == cur_x && y == cur_y && p == cur_s )
						{
							if( bodymap.band[p][x][y] )
							{
								BlatColor( surface, r_left(x), r_top( y )
											, r_width(x), r_height( y )
											, BASE_COLOR_YELLOW
											);
							}
							else
							{
								BlatColor( surface, r_left(x), r_top( y )
											, r_width(x), r_height( y )
											, BASE_COLOR_RED
											);
							}
						}
						else
						{
							if( bodymap.band[p][x][y] )
							{
								BlatColor( surface
											, r_left(x), r_top( y )
											, r_width(x), r_height( y )
											, BASE_COLOR_BLUE
											);
							}
							else
							{
								BlatColor( surface
											, r_left(x), r_top( y )
											, r_width(x), r_height( y )
											, BASE_COLOR_GREEN
											);
							}
						}
					}
			}
		}
		return 1;
	}
コード例 #4
0
int CPROC MouseMethod( uintptr_t psv, int32_t x, int32_t y, uint32_t b )
{
	if( !g.flags.bSpinning )
	{
		if( !b  )
		{
			g.ofs = -7;
			DrawReels();

		}
		else if( b == 1 )
		{
			if( g.ofs == -7 )
			{
				int n;
				if( !g.flags.bBackgroundInitialized)
				{
					ClearImageTo( g.backgroundsurface, BASE_COLOR_BLACK );
					BlotImage( g.backgroundsurface, g.background, 0, 0 );
					g.flags.bBackgroundInitialized = 1;
				}
				for( n = 0; n < NUM_REELS; n++ )
				{
               g.bReelSpinning[n] = 1;
				}
				g.flags.bSpinning = 1;

            if( 0 )//yucky. real cheesey.
				{
					int n, i;
					for( n = 0; n < g.nReels; n++ )
						for( i = 0; i < NUM_PICS+2; i++ )
						{
							g.reel[n][i] = g.images[rand()%10];
						}
				}
				DrawSpinningReels(TRUE);
			}
		}
	}
	else
	{
		if( b )
		{
			int reel = (x - REEL_OFSX) / REEL_STEPX;
			if( reel >= 0 && reel < NUM_REELS )
			{
				if( g.bReelSpinning[reel] )
				{
					g.bReelSpinning[reel] = 0;
					g.ofs = -32;
//    					DrawReel(reel);
					UpdateDisplayPortion( g.render
											  , REEL_OFSX
											  , REEL_OFSY
											  , REEL_STEPX*(reel)
											  , REEL_WIDTH );
					g.ofs = 7;
//  					DrawReel(reel);
					UpdateDisplayPortion( g.render
											  , REEL_OFSX
											  , REEL_OFSY
											  , REEL_STEPX*(reel)
											  , REEL_WIDTH );
					WakeableSleep( 100 );
					g.ofs = 0;
//  					DrawReel(reel);
					UpdateDisplayPortion( g.render
											  , REEL_OFSX
											  , REEL_OFSY
											  , REEL_STEPX*(reel)
											  , REEL_WIDTH );
					{
						int n;
						for( n = 0; n < NUM_REELS; n++ )
							if( g.bReelSpinning[n] )
								break;
						if( n == NUM_REELS )
						{
							g.flags.bSpinning = 0;
                     SyncRender( g.render);
//  							SetReelSpeedStep();

						}
					}
				}
			}
		}
	}
   return 1;
}