Пример #1
0
int main() {
  int w, h, x = -1, y, area = 0;
  char direct;
  scanf("%d%d", &w, &h);
  for (int i = 0; i < w; ++i) {
    scanf("%s", map[i]);
  }
  for (int i = 0; i < w && x == -1; ++i) {
    for (int j = 0; j < h; ++j) {
      if (map[i][j] != '.' && map[i][j] != '*') {
        y = i, x = j;
        direct = map[y][x];
        break;
      }
    }
  }
  while ( ! visited[y][x] || angle[y][x] != direct) {
    angle[y][x] = direct;
    if ( ! visited[y][x]) {
      visited[y][x] = true;
      ++area;
    }
    for (int i = 0; i < ROTATIONS; ++i) {
      int old_x = x, old_y = y;
      update_xy(x, y, direct);
      if (validate_xy(x, y, w, h) && map[y][x] != '*') {
        break;
      }
      x = old_x, y = old_y;
      rotate(direct);
    }
  }
  printf("%d\n", area);
  return 0;
}
Пример #2
0
/* Don't bother to update the cbox. */
int
gx_path_translate(gx_path * ppath, fixed dx, fixed dy)
{
    segment *pseg;

#define update_xy(pt)\
  pt.x += dx, pt.y += dy
    if (ppath->box_last != 0) {
	update_xy(ppath->bbox.p);
	update_xy(ppath->bbox.q);
    }
    if (path_position_valid(ppath))
	update_xy(ppath->position);
    for (pseg = (segment *) (ppath->first_subpath); pseg != 0;
	 pseg = pseg->next
	)
	switch (pseg->type) {
	    case s_curve:
#define pcseg ((curve_segment *)pseg)
		update_xy(pcseg->p1);
		update_xy(pcseg->p2);
#undef pcseg
	    default:
		update_xy(pseg->pt);
	}
#undef update_xy
    return 0;
}
Пример #3
0
void straight_self_bullet::loop()
{
	if(age==1)
	{
		cx=estg->self->x+startx;
		cy=estg->self->y+starty;
		update_xy();
		aim();
	}
	if(age==3)
		aim();
	x=age*_speed;
}