Exemplo n.º 1
0
int main()
{
	int res;
	MOUSEMSG m;

	initgraph(DRAWINGAREAWIDTH, DRAWINGAREAHEIGHT);  

	init();

	Speed = 100;

    while(1)	
	{
		if(MouseHit())
		{
			/* 检查鼠标信息 */
			m = GetMouseMsg();
			/* 根据信息进行操作 */
			GetMessage(m);
		}
	}
	
	closegraph(); 

	return 0;
}
Exemplo n.º 2
0
//定义每一个函数//
int main()
{
	begin();
	int i;
	fp=fopen("排行榜","r");
    for(i=0;i<5;i++)
	    fread(&end_score[i],2,1,fp);
	fclose(fp);
	MOUSEMSG m;                           //定义鼠标消息//
    while(true)
	{
	  m=GetMouseMsg();
	  switch(m.uMsg)
	  {
	  case WM_LBUTTONDOWN:
	   if(m.x>=10&&m.y>=130&&m.y<=200&&m.x<=290)
	       design_cp1();
	   if(m.x>=10&&m.y>=230&&m.y<=300&&m.x<=290)
		   rules();
       if(m.x>=10&&m.y>=330&&m.y<=400&&m.x<=290)
		   select();
	   if(m.x>=10&&m.y>=430&&m.y<=500&&m.x<=290)
		   see_rank();
	   if(m.x>=10&&m.y>=530&&m.y<=600&&m.x<=290)
		   exit(0);
	  }
	}
    return 0;
}
Exemplo n.º 3
0
void select()
{
	initgraph(640,480);
	setbkcolor(GREEN);
    cleardevice();
	setcolor(YELLOW);
	setfont(80,0,"华文行楷");
	outtextxy(200,40,"第一关");
	outtextxy(200,200,"第二关");
	outtextxy(200,360,"第三关");
	MOUSEMSG m; 
	while(true)
	{
	  m=GetMouseMsg();
	  switch(m.uMsg)
	  {
	  case WM_LBUTTONDOWN:
	   if(m.x>=200&&m.y>=40&&m.y<=120&&m.x<=440)
		   design_cp1();
	   if(m.x>=200&&m.y>=200&&m.y<=280&&m.x<=440)
		   design_cp2();
	   if(m.x>=200&&m.y>=360&&m.y<=4400&&m.x<=440)
		   design_cp3();
	  }
	}
}
Exemplo n.º 4
0
void  rules()
{
	initgraph(850,600);
    setbkcolor(DARKGRAY);
	cleardevice();
	setcolor(LIGHTGREEN);
	setfont(60,0,"华文隶书");
	outtextxy(270,1,"游戏介绍");
	setcolor(LIGHTCYAN);
	setfont(40,0,"华文行楷");
    outtextxy(20,65,"1.黄颜色的小方块表示美味的食物。");
	outtextxy(20,110,"2.紫色的实心小圆表示可恶的地雷。");
	outtextxy(20,160,"3.绿色的实心小圆表示可恨的毒草。");
	outtextxy(20,210,"4.小蛇每吃到一个食物,身体便会增加一节。");
	outtextxy(20,260,"5.小蛇碰到地雷,身体会被炸掉一半。要小心哦!!");
	outtextxy(20,310,"6,小蛇碰到毒草,身体会变短一节。要小心哦!!");
	outtextxy(20,360,"7.小蛇的头撞到四周的墙会死。");
	outtextxy(20,410,"8.小蛇的头撞到自己的身体也会死亡。");
	outtextxy(20,460,"9.用鼠标点击下面的“→”区域,回到主页面。");
	outtextxy(20,510,"10.祝您好运!!!");
	setcolor(BROWN);
	setfont(60,0,"华文隶书");
    outtextxy(580,520,"→主页面");
	MOUSEMSG m; 
	while(true)
	{
	  m=GetMouseMsg();
	  switch(m.uMsg)
	  {
	  case WM_LBUTTONDOWN:
	   if(m.x>=580&&m.y>=520&&m.y<=580&&m.x<=820)
		   main();
	  }
	}
}
Exemplo n.º 5
0
void solve()
{
     MOUSEMSG m;	
	 long i,j,k,r,w,x,y;
	 long nowx=-1,nowy=-1;
     while(1)
	 {
	    m = GetMouseMsg();
	    x = ( m.x - (BL-SIDE/2) ) / SIDE;
	    y = ( m.y - (BH-SIDE/2) ) / SIDE;
	    if( ok(x,y) )
		{  
	 	  switch(m.uMsg)
		  {
		  	   case WM_MOUSEMOVE:     //移动
				   if(  nowx != x || nowy != y )  MoveMouse(x,y);
				   break;

			   case WM_LBUTTONDOWN:  //按下
			  	   PressMouse(x,y);
				   Computer();
				   break;
		  }
		  nowx = x; nowy = y;  
		  if( Pan() ) break;
		}
     }
	 End();
}
Exemplo n.º 6
0
//主页菜单
int MainMenu(){
	int i = 1, y1 = 250;

	cleardevice();
	IMAGE img;

	loadimage(&img, "1.jpg", 1000, 600, true);
	putimage(0, 0, &img);

	//设置主菜单文字
	setlocale(LC_ALL, "chs");//解决中文乱码,在头文件locale.h中
	settextstyle(80, 0, "华文彩云",0,0,10000,0,0,0);
	settextcolor(MAGENTA);
	setbkmode(TRANSPARENT);/*处理文字后面的黑色,使文字后的背景为图片*/
	outtextxy(400, 150, "菜单");
	
	settextcolor(DARKGRAY);
	settextstyle(40, 0, "幼圆",0,0,1000,0,1,0);	
	int WIDTH = textwidth(_T("1 画图"));
	outtextxy(WDIS, 250, _T("1 画图"));
	outtextxy(WDIS, 300, _T("2 分形"));
	outtextxy(WDIS, 350, _T("3 配置"));
	outtextxy(WDIS, 400, _T("4 退出"));
	
	//获取鼠标信息
	FlushMouseMsgBuffer();
	while (true){
		if (MouseHit()){   //检测
			m = GetMouseMsg();//获取鼠标状态
			if (m.uMsg == WM_LBUTTONDOWN){
				while (m.x >= WDIS&&m.x <=  WIDTH+WDIS&&m.y >= 250 && m.y <= 425){
					if (m.y >= y1&&m.y <= 25 + y1)
						return i;
					else if (y1 >= 400)
						break;
					else
						y1 += 50, i++;
				}
			}		

		}
		//通过按键也可以实现主菜单跳转
		if (_kbhit()){
			char c = _getch();
			if (c >= '1'&&c <= '4')
				return (c - '0');
		}
	}
	_getch();
	closegraph();

}
Exemplo n.º 7
0
void welcome()
{
	MOUSEMSG m;
	
	putimage(0, 0, &welcome_bk);
	while (1)
	{
		m = GetMouseMsg();
		if (m.uMsg == WM_LBUTTONDOWN && m.x >= 74 && m.x <= 105 && m.y >= 110 && m.y <= 200)
		{
			break;
		}
		else if (m.uMsg == WM_LBUTTONDOWN && m.x >= 74 && m.x <= 105 && m.y >= 264 && m.y <= 355)
		{
			exit(1);
		}
	}
}
Exemplo n.º 8
0
void gameover()
{
	if(cp==1)
	   endscore=score;
	if(cp==2)
		endscore=score+40;
	if(cp==3)
		endscore=score+70;
	Sleep(100);
	initgraph(700,600);
	setbkcolor(BLUE);
	cleardevice();
	setcolor(RED);
	setfont(100,0,"华文行楷");
	outtextxy(160,80,"游戏结束");
	setcolor(YELLOW);
	setfont(70,0,"华文行楷");
	outtextxy(160,210,"最后得分:");
	char str[10];
	setcolor(YELLOW);
	setfont(70,0,"华文行楷");
    sprintf(str,"%d",score);
    outtextxy(460,210,str);
	setcolor(CYAN);
	setfont(60,0,"楷体");
	outtextxy(20,320,"点击右下角返回到主页面");
	setcolor(LIGHTGREEN);
	setfont(60,0,"华文隶书");
	outtextxy(440,500,"→主页面");
    set_rank();
	MOUSEMSG m; 
	while(true)
	{
	  m=GetMouseMsg();
	  switch(m.uMsg)
	  {
	  case WM_LBUTTONDOWN:
	   if(m.x>=440&&m.y>=500&&m.y<=560&&m.x<=680)
		   main();
	  }
	}
}
Exemplo n.º 9
0
void solve()
{
     MOUSEMSG m;	
	 long i,j,k,r,w,x,y,ox=-1,oy=-1;
	 long nowx=-1,nowy=-1;
     while(1)


	 {
	    m = GetMouseMsg();
	    x = ( m.x - (BL-SIDE/2) ) / SIDE;
	    y = ( m.y - (BH-SIDE/2) ) / SIDE;
	    if( ok(x,y) )
		{  
	 	  switch(m.uMsg)
		  {
		  	   case WM_MOUSEMOVE:     //移动
				   if(  nowx != x || nowy != y )  MoveMouse(x,y,nowx,nowy);
				   break;

			   case WM_LBUTTONDOWN:  //按下
                    if(map[y][x] != 0) break;
			  	    PressMouse(x,y);
                    over = 0;
					if(Pan())break;

				    k = Max(1,-MAXN-3,MAXN+3);
                    
					if(k >= MAXN ) over =2;
					if(k <= -MAXN ) {  /*over =1; */ Xia(); }
				    ComXia(xx,yy);
				    break;
		  }
		  nowx = x; nowy = y;  
		  if( Pan() ) break;
		}
     }
	 End();
}
Exemplo n.º 10
0
int game(int where, int where_num)
{
	MOUSEMSG m;
	int temp_x, temp_y, i, j, flag = 0, num = 480/where;
	int step = 0;

	while (1)
	{
		m = GetMouseMsg();
		if (m.uMsg == WM_LBUTTONDOWN && m.x < 480)
		{
			if (m.x == num || m.y == num)
			{
				continue;
			}
			mciSendString("open audio/change.mp3 alias change", NULL, 0, NULL);
			mciSendString("play change", NULL, 0, NULL);
			step += 1;
			temp_x = m.x/num;
			temp_y = m.y/num;
			if (map_check[temp_y][temp_x] == 0)
			{
				setfillstyle(RED);
				floodfill(m.x, m.y , GREEN);
				map_check[temp_y][temp_x] = 1;
			}
			else
			{
				setfillstyle(BLACK);
				floodfill(m.x, m.y, GREEN);
				map_check[temp_y][temp_x] = 0;
			}
			if (temp_x - 1 >= 0)
			{
				if (map_check[temp_y][temp_x-1])
				{
					setfillstyle(BLACK);
					floodfill(m.x - num, m.y, GREEN);
					map_check[temp_y][temp_x-1] = 0;
				}
				else
				{
					setfillstyle(RED);
					floodfill(m.x - num, m.y, GREEN);
					map_check[temp_y][temp_x-1] = 1;
				}
			}
			if (temp_y - 1 >= 0)
			{
				if (map_check[temp_y-1][temp_x])
				{
					setfillstyle(BLACK);
					floodfill(m.x, m.y - num, GREEN);
					map_check[temp_y-1][temp_x] = 0;
				}
				else
				{
					setfillstyle(RED);
					floodfill(m.x, m.y - num, GREEN);
					map_check[temp_y-1][temp_x] = 1;
				}
			}
			if (temp_x + 1 < where)
			{
				if (map_check[temp_y][temp_x+1])
				{
					setfillstyle(BLACK);
					floodfill(m.x + num, m.y, GREEN);
					map_check[temp_y][temp_x+1] = 0;
				}
				else
				{
					setfillstyle(RED);
					floodfill(m.x + num, m.y , GREEN);
					map_check[temp_y][temp_x+1] = 1;
				}
			}
			if (temp_y + 1 < where)
			{
				if (map_check[temp_y+1][temp_x])
				{
					setfillstyle(BLACK);
					floodfill(m.x, m.y + num, GREEN);
					map_check[temp_y+1][temp_x] = 0;
				}
				else
				{
					setfillstyle(RED);
					floodfill(m.x, m.y + num, GREEN);
					map_check[temp_y+1][temp_x] = 1;
				}
			}
			Sleep(200);
			mciSendString("stop change", NULL, 0, NULL);
			mciSendString("close change", NULL, 0, NULL);
		}
		for (i = 0; i < where && !flag; i++)
		{
			for (j = 0; j < where && !flag; j++)
			{
				if (map_check[i][j] == 0)
				{
					flag = 1;
				}
			}
		}
		game_info(flag, step, where_num);
		if (flag == 0)
		{
			break;
		}
		flag = 0;
	}
	return 0;
}