Exemplo n.º 1
0
void
mr_view_page_trans (enum dir d)
{
  int x, y;

  mr.select_cycles = SELECT_CYCLES;

  struct mr_origin o;
  mr_save_origin (&o);

  switch (d) {
  case RIGHT:
    mr_rightmost_cell (&x, &y);
    mr_set_origin (mr.cell[x][y].room, 0, y);
    mr_view_trans (RIGHT);
    break;
  case LEFT:
    mr_leftmost_cell (&x, &y);
    mr_set_origin (mr.cell[x][y].room, mr.w - 1, y);
    mr_view_trans (LEFT);
    break;
  case BELOW:
    mr_bottommost_cell (&x, &y);
    mr_set_origin (mr.cell[x][y].room, x, 0);
    mr_view_trans (BELOW);
    break;
  case ABOVE:
    mr_topmost_cell (&x, &y);
    mr_set_origin (mr.cell[x][y].room, x, mr.h - 1);
    mr_view_trans (ABOVE);
    break;
  }

  mr_stabilize_origin (&o, d);
}
Exemplo n.º 2
0
void
mr_view_page_trans (enum dir d)
{
  int x, y;
  mr.select_cycles = 0;

  switch (d) {
  case RIGHT:
    mr_rightmost_cell (&x, &y);
    mr.room = mr.cell[x][y].room;
    mr.x = 0;
    mr.y = y;
    mr_map_rooms ();
    mr_view_trans (RIGHT);
    break;
  case LEFT:
    mr_leftmost_cell (&x, &y);
    mr.room = mr.cell[x][y].room;
    mr.x = mr.w - 1;
    mr.y = y;
    mr_map_rooms ();
    mr_view_trans (LEFT);
    break;
  case BELOW:
    mr_bottommost_cell (&x, &y);
    mr.room = mr.cell[x][y].room;
    mr.x = x;
    mr.y = 0;
    mr_map_rooms ();
    mr_view_trans (BELOW);
    break;
  case ABOVE:
    mr_topmost_cell (&x, &y);
    mr.room = mr.cell[x][y].room;
    mr.x = x;
    mr.y = mr.h - 1;
    mr_map_rooms ();
    mr_view_trans (ABOVE);
    break;
  }
}
Exemplo n.º 3
0
void
mr_center_room (int room)
{
  int x, y, lc = 0, c = 0, ld = INT_MAX;
  float ldc = INFINITY;
  int lx = mr.x;
  int ly = mr.y;
  for (y = mr.h - 1; y >= 0; y--)
    for (x = 0; x < mr.w; x++) {
      mr_set_origin (room, x, y);
      c = mr_count_rooms ();
      int cx, cy;
      mr_topmost_cell (&cx, &cy);
      int ca = cy;
      mr_bottommost_cell (&cx, &cy);
      int cb = (mr.h - 1) - cy;
      mr_leftmost_cell (&cx, &cy);
      int cl = cx;
      mr_rightmost_cell (&cx, &cy);
      int cr = (mr.w - 1) - cx;;
      int d = abs (ca - cb) + abs (cl - cr);
      float dc = dist_cart (x, y, (mr.w - 1) / 2, (mr.h - 1) / 2);
      if (c > lc
          || (c == lc && d < ld)
          || (c == lc && d == ld && dc < ldc)) {
        lx = x;
        ly = y;
        lc = c;
        ld = d;
        ldc = dc;
      }
    }

  mr_set_origin (room, lx, ly);
  mr.select_cycles = SELECT_CYCLES;
}