Ejemplo n.º 1
0
/**
 * draw_object
 * @x: x position 
 * @y: y position 
 * @type: object type
 * @cr: context to draw on
 *
 * Description:
 * Draws graphics for an object at specified location
 **/
static void
draw_object (gint x, gint y, gint type, cairo_t * cr)
{
  if (game_area == NULL)
    return;

  switch (type) {
  case OBJECT_PLAYER:
    draw_tile_pixmap (SCENARIO_PLAYER_START + player_animation,
                      x, y, cr);
    break;
  case OBJECT_ROBOT1:
    draw_tile_pixmap (SCENARIO_ROBOT1_START + robot_animation,
                      x, y, cr);
    break;
  case OBJECT_ROBOT2:
    draw_tile_pixmap (SCENARIO_ROBOT2_START + robot_animation,
                      x, y, cr);
    break;
  case OBJECT_HEAP:
    draw_tile_pixmap (SCENARIO_HEAP_POS, x, y, cr);
    break;
  case OBJECT_NONE:
    draw_tile_pixmap (-1, x, y, cr);
    break;
  }
}
Ejemplo n.º 2
0
/**
 * clear_bubble_area
 *
 * Description:
 * clears the area underneath a bubble
 **/
static void
clear_bubble_area (void)
{
  int t0i, t0j; /* (i,j) coordinates of bubble's top/left tile */
  int ntiles_hor, ntiles_ver; /* number of tiles hotizontal/vertically affected */
  int delta; /* pixels from tile's left/top border to bubble's left/top border */
  int i, j;

  if (game_area == NULL)
    return;

  t0i = bubble_xpos / tile_width;
  t0j = bubble_ypos / tile_height;
  ntiles_hor = (BUBBLE_WIDTH + tile_width - 1) / tile_width; /* first shot at number of tiles affected */
  delta = bubble_xpos % tile_width;
  if (delta > 0) { /* buble does not start at a tile's left boundary */
    if ((BUBBLE_WIDTH + delta) > ntiles_hor * tile_width) { /* catches an extra tile */
      ntiles_hor++;
    }
  }
  ntiles_ver = (BUBBLE_HEIGHT + tile_height - 1) / tile_height;
  delta = bubble_ypos % tile_height;
  if (delta > 0) { /* buble does not start at a tile's top boundary */
    if ((BUBBLE_HEIGHT + delta) > ntiles_ver * tile_height) { /* catches an extra tile */
      ntiles_ver++;
    }
  }
  for (i = t0i; i < t0i + ntiles_hor; ++i) {
    for (j = t0j; j < t0j + ntiles_ver; ++j) {
      draw_tile_pixmap (-1, i, j, game_area);
    }
  }
}
Ejemplo n.º 3
0
gint
expose_cb (GtkWidget * w, GdkEventExpose * e, gpointer data)
{
  int i, j;
  int x1, y1, x2, y2;

  x1 = e->area.x / tile_width;
  y1 = e->area.y / tile_height;
  x2 = x1 + e->area.width / tile_width + 1;
  y2 = y1 + e->area.height / tile_height + 1;

  for (j = y1; j <= y2; j++) {
    for (i = x1; i <= x2; i++) {
      /* Draw a blank space. Animation fills the objects in. */
      draw_tile_pixmap (-1, i, j, w);
    }
  }

  return TRUE;
}