Beispiel #1
0
int game_is_lost()
{
	if (can_move_left(&grid) || can_move_right(&grid) || 
			can_move_up(&grid) || can_move_down(&grid)) {
		return 0;
	} else {
		return 1;
	}
}
Beispiel #2
0
int how_far_up(OBJp objp,int n)
{
   register int i;
   register int temp;

   temp = objp->y;     /* save the current position */

   /* increment the position until you can't move right any further */
   for (i = 0; i > n; i--)
   {
      objp->y--;
      if (!can_move_up(objp))
      {
          objp->y = temp;
          return(i);
      }
   }
   objp->y = temp;    /* restore the current position */
   return(n);         /* return how far right */
}
Beispiel #3
0
int
com (rtx insn, int blah)
{
  if (!can_move_up (insn, blah))
    foo ();
}
Beispiel #4
0
void play_game()
{
	board *b = &grid;

	do {

		switch (os_wait_for_key()) {
			case ESC_KEY:
				return;

			case UP_KEY:
				if (can_move_up(b)) {
					shift_up(b);
					merge_up(b);
					shift_up(b);
					add_big_int(&score, &merge_score);
					break;
				} else {
					continue;
				}

			case DOWN_KEY:
				if (can_move_down(b)) {
					shift_down(b);
					merge_down(b);
					shift_down(b);
					add_big_int(&score, &merge_score);
					break;
				} else {
					continue;
				}

			case LEFT_KEY:
				if (can_move_left(b)) {
					shift_left(b);
					merge_left(b);
					shift_left(b);
					add_big_int(&score, &merge_score);
					break;
				} else {
					continue;
				}

			case RIGHT_KEY:
				if (can_move_right(b)) {
					shift_right(b);
					merge_right(b);
					shift_right(b);
					add_big_int(&score, &merge_score);
					break;
				} else {
					continue;
				}

			default:
				continue;
		}

		add_tile(b);
		display_board(b);

	} while (!game_is_lost());
}