Example #1
0
void Create_Hierarchy()
{
   mp_cputime_ref = clock();
   mplevels = Set_Level();
   partition(mplevels);

   mp_Init_Fine_Grid_ref = clock();
   Init_Fine_Grid(mplevels);
   mp_Init_Fine_Grid = clock()-mp_Init_Fine_Grid_ref;

   mp_Advance_Coeffs_ref = clock();
   Advance_Coeffs(mplevels);
   mp_Advance_Coeffs = clock() - mp_Advance_Coeffs_ref;

   mp_cputime += clock()-mp_cputime_ref;
}
Example #2
0
/* 游戏控制函数,完成一系列初始化操作,最后调用ManageMove函数,完后便显示谁胜及一些快捷键 */
void GameManage(void)
{
	int Quit=0,key,die,i=1;
	int start_game;
	CurrentCoor player1,player2;	/* 记录游戏者下标位置 */
	clock_t front_time,current_time;
	InitFace();
	HelpMassage();
	GetKey();
	while(Quit==0)
	{
		die=0;
		InitFace();
		InitCoordinate();
		InitPlayerPlace(&player1,&player2);
		Drawbar(player1,1);
		Drawbar(player2,2);
		while(die==0)
		{
			 die=ManageMove(player1,player2);
		}
		setcolor(WHITE);
		if(die==1)
			outtextxy(7,457,"Player2 Win!");
		else if(die==2)
			outtextxy(7,457,"Player1 Win!");
		else
			outtextxy(7,457,"Player1 as same as Player2!");

		front_time=current_time=clock();
		while(current_time-front_time<20)
		{
			current_time=clock();
		}

		setcolor(WHITE);
		outtextxy(257,457,"F1:      F2:       F3:");
		outtextxy(257,467,"Esc:     F4:");
		setcolor(YELLOW);
		outtextxy(257,457,"    Help    Level     Player1 Color");
		outtextxy(257,467,"    Exit    Player2 Color");

		front_time=clock();

		start_game=0;
		while(start_game==0)
		{
			while(!bioskey(1))
			{
				current_time=clock();
				if(current_time-front_time>8)
				{
					front_time=current_time;
					i=(i+1)%2;
					if(i==0)	setcolor(LIGHTRED);
					else		setcolor(BackColor);
					outtextxy(7,467,"Press F5 to continue...");
				}
			}
			key=GetKey();
			if(key==F1)
			{	HelpMassage();
				GetKey();
			}
			else if(key==F2)	Set_Level();
			else if(key==F3)	Set_Color(1);	/* set player1 color */
			else if(key==F4)	Set_Color(2);	/* set player2 color */
			else if(key==F5)	start_game=1;
			else if(key==ESC)
			{		Quit=Exit_Game();
					if(Quit==1)
						start_game=1;
			}
		}
	}
}