示例#1
0
void key_s3c(void)
{
int which_key,i;
while((rPDATG & 0xf0)==0xf0);
which_key=rPDATG&0xf0;
    switch(which_key)
    {
case 0xe0:
   Led_Display(0x1);
   point.y_point-=20;
   if(point.y_point<20)
   point.y_point=200;
   break;
case 0xd0:
   Led_Display(0x2);
   point.x_point-=20;
   if(point.x_point<20)
   point.x_point=200;
   break;
case 0xb0:
   Led_Display(0x4);
   if( map[point.y_map][point.x_map]==0 )
{
change_color();
map[point.y_map][point.x_map]=point.color;
draw_map();

if( if_won(point.y_map,point.x_map,point.color) )
{
GUI_SetTextMode(GUI_DM_TRANS); //设置为透明
GUI_SetFont(&GUI_Font8x16x1x2);
GUI_DispStringAt("win!",250,90);

for(i=0;i<20;i++)
GUI_Delay(1000);
map_initial();

GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetColor(GUI_GREEN);
GUI_FillRect(0,0,320,240);
draw_net();
draw_point();
}

}
   break;
case 0x70:
   Led_Display(0x7);
   /*
   point.x_point+=20;
   if(point.x_point>200)
   point.x_point-=20;*/
   break;
default :
   break;
    }
    
    
}
示例#2
0
//@@@@@@@@@@@@@@@@@@@@  覆盖背景,重画方格 @@@@@@@@@@@@@@@@@@@@@@
void display_all(void)
{
GUI_SetColor(GUI_GREEN);
GUI_FillRect(0,0,320,240);

draw_net();
draw_map();
draw_point();

}
示例#3
0
文件: GRAPHS.C 项目: rickytan/Snooker
void draw_table()								/********绘制球桌********/
{
	setlinestyle(0,0,3);
	setcolor(WHITE);
	setwritemode(COPY_PUT);
	rectangle(1,100,638,480);

	draw_boundary();
	draw_net();

	setfillstyle(SOLID_FILL,TABLECOLOR);
	floodfill(300,400,WHITE);
	setfillstyle(SOLID_FILL,6);
	floodfill(20,290,WHITE);
	floodfill(620,290,WHITE);

	draw_mark();
}
示例#4
0
int main(int argc, char* argv[]) {
    char str[100] = "";
    int basepoint = 20;
    /*
    if (argc < 2) return 0;
    if (stricmp(argv[1], "/p") == 0)
    {
        HWND hwnd;
        sscanf(argv[2], "%d", &hwnd);
        attachHWND(hwnd);
    }
    else if (stricmp(argv[1], "/s")) return 0;//*/

    init();
    init_net(&g_net, basepoint * 4, basepoint * 3, g_width, g_height);
    setbkmode(TRANSPARENT);

    fps fps_obj;
    setrendermode(RENDER_MANUAL);
    for (; kbhit() == 0; delay_fps(60)) {
        cleardevice();
        setcolor(0x8000);
        draw_net(&g_net);

        setcolor(0xFFFFFF);
        outtextxy(0,0,str);

        move_net(&g_net);
        move_net(&g_net);
        {
            int x, y, k;
            getmouse(&x, &y, &k);
            if (k) {
                cap_pt(&g_net, x, y, 1);
            } else {
                cap_pt(&g_net, x, y, 0);
            }
        }
    }
    closegraph();
    return 0;
}
示例#5
0
//@@@@@@@@@@@@@@@@@@@@@@  MAIN  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void Main(void)
{
int i=0,j=0;


GUI_Init();
GUI_SetBkColor(GUI_GREEN);
GUI_Clear();
GUI_SetColor(GUI_BLACK);
point.x_point=20;point.y_point=20;
draw_net();
draw_point();
draw_curcolor(270,50,1);

while(1)
{
store_x=point.x_point;
store_y=point.y_point;


//Button();
key_s3c();
change_point();
draw_point();

if( (store_x!=point.x_point)||(store_y!=point.y_point) )
delete_point();

draw_map();
change_color();
draw_curcolor(270,50,point.color);
change_color();


GUI_Delay(3000);
}

}
示例#6
0
//@@@@@@@@@@@@@@@@@@@@@  屏幕上显示的按键  @@@@@@@@@@@@@@@@@@@@@@@@@@
static void Button(void) 
{

 BUTTON_Handle hButton[6];
 int t=0;
 int i=0;
 /* Create the button*/
      //BUTTON_SetBkColor(hButton[0],0,GUI_RED);

 hButton[0] = BUTTON_Create(260, 160, 20, 20, 1, WM_CF_SHOW);
 hButton[1] = BUTTON_Create(240, 180, 20, 20, 2, WM_CF_SHOW);
 hButton[2] = BUTTON_Create(260, 180, 20, 20, 3, WM_CF_SHOW);
 hButton[3] = BUTTON_Create(280, 180, 20, 20, 4, WM_CF_SHOW);
 hButton[4] = BUTTON_Create(260, 220, 20, 20, 5, WM_CF_SHOW);
 //hButton[5] = BUTTON_Create(240, 220, 20, 20, 6, WM_CF_SHOW);

 BUTTON_SetText(hButton[0], "w");
 BUTTON_SetText(hButton[1], "a");
 BUTTON_SetText(hButton[2], "s");
 BUTTON_SetText(hButton[3], "d");
 BUTTON_SetText(hButton[4], "B");
 //BUTTON_SetText(hButton[5], "W");

 t=GUI_WaitKey();
 
 switch( t )
 {
 case 1:
 point.y_point-=20;
 if(point.y_point<20)
 point.y_point+=20;
 break;
 case 2:
 point.x_point-=20;
 if(point.x_point<20)
 point.x_point+=20;
 break;
 case 3:
 point.y_point+=20;
 if(point.y_point>200)
 point.y_point-=20;
 break;
 case 4:
 point.x_point+=20;
 if(point.x_point>200)
 point.x_point-=20;
 break;
 case 5:
 if( map[point.y_map][point.x_map]==0 )
 {
change_color();
map[point.y_map][point.x_map]=point.color;
draw_map();

if( if_won(point.y_map,point.x_map,point.color) )
{
GUI_SetTextMode(GUI_DM_TRANS); //设置为透明
GUI_SetFont(&GUI_Font8x16x1x2);
GUI_DispStringAt("win!",250,90);

for(i=0;i<5;i++)
GUI_Delay(1000);
map_initial();

GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetColor(GUI_GREEN);
GUI_FillRect(0,0,320,240);
draw_net();
draw_point();
}

 }
 break;
 case 6:
 /*
 if( map[point.y_map][point.x_map]==0 )
map[point.y_map][point.x_map]=1;
 */
 break;
 default:

 break;
 
 }

 
 
 for(t=0;t<6;t++)
BUTTON_Delete(hButton[t]);
 
}
示例#7
0
文件: pong.c 项目: sushinumber1/pong
int main() {
	
	SDL_Surface *temp;

	/* Initialize SDL’s video system and check for errors */
	if (SDL_Init(SDL_INIT_VIDEO) != 0) {

		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		return 1;
	}
	
	/* Make sure SDL_Quit gets called when the program exits! */
	atexit(SDL_Quit);
	
	/* Attempt to set a 640x480 8 bit color video mode */
	screen = SDL_SetVideoMode(640, 480, 8,SDL_DOUBLEBUF);
	
	if (screen == NULL) {
		
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return 1;
	}

	//load the numbermap image strip of 10 number 64px * 64px
	temp = SDL_LoadBMP("numbermap.bmp");
	
	if (temp == NULL) {
	
		printf("Unable to load numbermap.bmp.\n");
		return 1;
	}

	/* Set the numbermaps colorkey. */
	Uint32 colorkey = SDL_MapRGB(temp->format, 255, 0, 255);
	SDL_SetColorKey(temp, SDL_SRCCOLORKEY, colorkey);
	
	//convert the numbermaps surface to the same type as the screen
	numbermap = SDL_DisplayFormat(temp);
	
	if (numbermap == NULL) {
	
		printf("Unable to convert bitmap.\n");
		return 1;
	}

	SDL_FreeSurface(temp);
	
	//load the numbermap image strip of 10 number 64px * 64px
	temp = SDL_LoadBMP("title.bmp");

	if (temp == NULL) {
	
		printf("Unable to load numbermap.bmp.\n");
		return 1;
	}

	/* Set the numbermaps colorkey. */
	SDL_SetColorKey(temp, SDL_SRCCOLORKEY, colorkey);
	
	//convert the numbermaps surface to the same type as the screen
	title = SDL_DisplayFormat(temp);
	
	if (numbermap == NULL) {
	
		printf("Unable to convert bitmap.\n");
		return 1;
	}

	SDL_FreeSurface(temp);

	//load the numbermap image strip of 10 number 64px * 64px
	temp = SDL_LoadBMP("gameover.bmp");

	if (temp == NULL) {
	
		printf("Unable to load gameover.bmp.\n");
		return 1;
	}

	//convert the end surface to the same type as the screen
	end = SDL_DisplayFormat(temp);
	
	if (end == NULL) {
	
		printf("Unable to convert bitmap.\n");
		return 1;
	}

	SDL_FreeSurface(temp);

	/* Initialize the ball position data. */
	init_ball();

	int quit = 0;
	int state = 0;
	Uint8 *keystate = 0;
	Uint32 next_game_tick = SDL_GetTicks();
	int sleep = 0;
	int r = 0;

	/* Animate */
	while (quit == 0) {
		
		/* Update SDL's internal input state information. */
		SDL_PumpEvents();

		/* Grab a snapshot of the keyboard. */
		keystate = SDL_GetKeyState(NULL);
		
		/* Respond to input. */
		if (keystate[SDLK_ESCAPE]) {
			quit = 1;
		}
		
		if (keystate[SDLK_DOWN]) {
			move_paddle(0);
		}

		if (keystate[SDLK_UP]) {
			move_paddle(1);
		}
		
		//draw the background
		draw_background();

		//display main menu
		if (state == 0 ) {
		
			if (keystate[SDLK_SPACE]) {
				state = 1;
			}
		
			//draw menu 
			draw_menu();
		
		//display gameover
		} else if (state == 2) {
		
			if (keystate[SDLK_SPACE]) {
				state = 0;
				//delay for a little bit so the space bar press dosnt get triggered twice
				//while the main menu is showing
            			SDL_Delay(500);
			}

			if (r == 1) {

				//if player 1 is AI if player 1 was human display the return value of r not 3
				draw_game_over(3);

			} else {
			
				//display gameover
				draw_game_over(r);
			}
				
		//display the game
		} else if (state == 1){
			
			//check score
			r = check_score();
			
			if (r == 1) {
				
				state = 2;	

			} else if (r == 2){
			
				state = 2;	
			}

			//paddle ai movement
			move_paddle_ai();

			/* Move the balls for the next frame. */
			move_ball();
			
			//draw net
			draw_net();

			//draw paddles
			draw_paddle();
			
			/* Put the ball on the screen. */
			draw_ball();
	
			//draw the score
			draw_player_0_score();
	
			//draw the score
			draw_player_1_score();
		}

		/* Ask SDL to update the entire screen. */
		SDL_Flip(screen);

		next_game_tick += 1000 / 60;
		sleep = next_game_tick - SDL_GetTicks();
	
		if( sleep >= 0 ) {

            		SDL_Delay(sleep);
        	}
	}
	
	return 0;
}