Exemplo n.º 1
0
Arquivo: GoBang.c Projeto: hebly723/NW
int main()
{
	int player_x=1, player_y=1;
	#ifdef DEBUG
	showHand(a);
	#endif
	#ifndef DEBUG
	printf("\033[2J");
	#endif
	showGo(go);
	do{
		printf("----------------------------------------\n");
		scanf("%d%d", &player_x, &player_y);
		while (!(player_x>0&&player_x<16&&player_y>0&&player_y<16)||(go[player_x-1][player_y-1]!=0)){
			printf("请重新输入:\n");
			scanf("%d%d", &player_x, &player_y);
		}
		printf("----------------------------------------\n");
		go[player_x-1][player_y-1] = 1;
		//deepl(player_x-1, player_y-1, 1);
		deepl(player_x-1, player_y-1, 1);

		disDeep();
		#ifndef DEBUG
		printf("\033[2J");
		#endif

		showGo(go);
		//deepl(player_x-1, player_y-1, 1);
	}while(player_x<16&&player_y<16);
	//show(go);
	return 0;
}
Exemplo n.º 2
0
Arquivo: GoBang.c Projeto: hebly723/NW
int deepl(int x, int y, int color)
{
	//int count = 0;printf("\033[2J");

	int a=0, b=0, c=0, d=0;
	int max = a;
	int count = 0;
	a = deep(x, y, 0, color);
	b = deep(x, y, 1, color);
	c = deep(x, y, 2, color);
	d = deep(x, y, 3, color);
	max = a;
	#ifdef DEBUG
	printf("x=%d;y=%d;a=%d;b=%d;c=%d;d=%d;",  x, y, a, b, c, d );
	#endif
	if ((b%10) > (max%10))
		max = b;
	if ((c%10) > (max%10))
		max = c;
	if ((d%10) > (max%10))
		max = d;
	#ifdef DEBUG
	//if (x<4)
	printf("之后是x=%d;y=%d;a=%d;b=%d;c=%d;d=%d;max=%d;\n",  x, y, a, b, c, d, max );
	#endif
	if (max%10 == 3)
	{
		if (a == 13)
			count=count+10;
		else if (b==13)
			count=count+10;
		else if (c==13)
			count=count+10;
		else if (d==13)
			count=count+10;
		max = count + 3;
	}
	if ((max%10)>=5&&color==go[x][y]&&color!=0)
	{
		if (max>10&&((max%10)-1)<5)
			;
		else if (color==1)
		{
			printf("\033[2J");
			showGo(go);
			printf("你赢了\n");
			exit(0);
		}
		else if (color == 2)
		{
			printf("\033[2J");
			showGo(go);
			printf("你输了\n");
			exit(0);
		}
	}
	return max;
}
Exemplo n.º 3
0
void GameScene::countTime(float dt)
{
	mTime++;
	CCLOG("countTime = %d",mTime);
	if(mTime == -2)
	{
		showGo();

	}
	if(mTime==0)
	{
		pr->setPercentage(0);
		CCProgressTo* to = CCProgressTo::create(TOTAL_GAME_TIME,100);
		pr->setReverseProgress(true);
		pr->runAction(to);
	}
	if (mTime>=TOTAL_GAME_TIME*80/100)
	{
		pr->runAction(CCBlink::create(0.3f,4));
	}
	if (mTime>=TOTAL_GAME_TIME)
	{
		showGameEnd();
		unschedule(schedule_selector(GameScene::countTime));
		gameLayer->setTouchEnabled(false);
	}
}