예제 #1
0
bool            Snake :: move(void)
{
    int         head;
    point_t     nh;

    head = this->get_size() - 1;
    nh = body[head];
    switch (this->get_direction())
    {
      case  X_POS: nh.x++; break;
      case  Y_POS: nh.y--; break;
      case  X_NEG: nh.x--; break;
      case  Y_NEG: nh.y++; break;
      default: return (false);
    }
    if (!surface_->check_space(body[head]) || colition(nh))
      return (false);
    if (food_->try_eat(nh, this->size))
    {
      body[head].type = F_SNAKE_SECT;
      body.push_back(nh);
      return (true);
    }
    move_body();
    body[head] = nh;
    return (true);
}
예제 #2
0
파일: move_body.c 프로젝트: rubda/KMM
void turn_body(int direction, double length){
	int a = current_step % 10;
		
	if(a < 5)
		move_body(0, length);
	else
		rotate_body(direction, length);

}
예제 #3
0
파일: Snake.cpp 프로젝트: mogria/ogre-snake
void Snake::move() {
  // the position of the last piece before moving
  // is the position of the new spawned piece
  // if the snake is growing
  map_coords grow_position = parts.back();

  move_body();
  move_head();
  grow_part(grow_position);
}