Exemple #1
0
int		game_loop(t_env *e)
{
	int	random;

	srand(time(NULL));
	random = (rand() % 2);
	board_disp(e);
	if (random)
	{
		turn_player(e);
		turn_ia(e);
	}
	else
		turn_ia(e);
	while (1)
	{
		if (turn_player(e) == 1)
			return (0);
		if (turn_ia(e) == 1)
			return (0);
	}
	return (0);
}
Exemple #2
0
/*
 * execute:
 *	Execute a single command
 */
void
execute(PLAYER *pp)
{
	char ch;

	ch = pp->p_cbuf[pp->p_ncount++];

#ifdef FLY
	if (pp->p_flying >= 0) {
		switch (ch) {
		  case CTRL('L'):
			sendcom(pp, REDRAW);
			break;
		  case 'q':
			(void) strcpy(pp->p_death, "| Quit |");
			break;
		}
		return;
	}
#endif

	switch (ch) {
	  case CTRL('L'):
		sendcom(pp, REDRAW);
		break;
	  case 'h':
		move_player(pp, LEFTS);
		break;
	  case 'H':
		turn_player(pp, LEFTS);
		break;
	  case 'j':
		move_player(pp, BELOW);
		break;
	  case 'J':
		turn_player(pp, BELOW);
		break;
	  case 'k':
		move_player(pp, ABOVE);
		break;
	  case 'K':
		turn_player(pp, ABOVE);
		break;
	  case 'l':
		move_player(pp, RIGHT);
		break;
	  case 'L':
		turn_player(pp, RIGHT);
		break;
	  case 'f':
	  case '1':
		fire(pp, 0);		/* SHOT */
		break;
	  case 'g':
	  case '2':
		fire(pp, 1);		/* GRENADE */
		break;
	  case 'F':
	  case '3':
		fire(pp, 2);		/* SATCHEL */
		break;
	  case 'G':
	  case '4':
		fire(pp, 3);		/* 7x7 BOMB */
		break;
	  case '5':
		fire(pp, 4);		/* 9x9 BOMB */
		break;
	  case '6':
		fire(pp, 5);		/* 11x11 BOMB */
		break;
	  case '7':
		fire(pp, 6);		/* 13x13 BOMB */
		break;
	  case '8':
		fire(pp, 7);		/* 15x15 BOMB */
		break;
	  case '9':
		fire(pp, 8);		/* 17x17 BOMB */
		break;
	  case '0':
		fire(pp, 9);		/* 19x19 BOMB */
		break;
	  case '@':
		fire(pp, 10);		/* 21x21 BOMB */
		break;
#ifdef OOZE
	  case 'o':
		fire_slime(pp, 0);	/* SLIME */
		break;
	  case 'O':
		fire_slime(pp, 1);	/* SSLIME */
		break;
	  case 'p':
		fire_slime(pp, 2);
		break;
	  case 'P':
		fire_slime(pp, 3);
		break;
#endif
	  case 's':
		scan(pp);
		break;
	  case 'c':
		cloak(pp);
		break;
	  case 'q':
		(void) strcpy(pp->p_death, "| Quit |");
		break;
	}
}