예제 #1
0
/**
 * @brief Constructor.
 * @param speed speed of the movement in pixels per seconds
 * @param max_distance if the object goes further than this distance, it will come back
 */
RandomMovement::RandomMovement(int speed, int max_distance):
    RectilinearMovement(true),
    max_distance(max_distance) {

    set_speed(speed);
    set_next_direction();
}
예제 #2
0
/**
 * @brief Constructor.
 * @param speed speed of the movement in pixels per seconds
 * @param max_distance if the object goes further than this distance, it will come back
 */
RandomMovement::RandomMovement(int speed, int max_distance):
  StraightMovement(false, false),
  normal_speed(speed),
  max_distance(max_distance),
  next_direction_change_date(0) {

  set_next_direction();
}
예제 #3
0
/**
 * \brief Constructor.
 * \param speed Speed of the movement in pixels per seconds.
 * \param max_radius if the object goes further than this distance, it will come back
 */
RandomMovement::RandomMovement(int speed, int max_radius):
  StraightMovement(false, false),
  max_radius(max_radius),
  next_direction_change_date(0) {

  set_speed(speed);
  set_next_direction();
}
예제 #4
0
/**
 * @brief Updates the fairy movement.
 *
 * This function is called repeatedly by the map.
 * This is a redefinition of Movement::update()
 * to change the fairy's direction sometimes.
 */
void RandomMovement::update() {

    RectilinearMovement::update();

    if (!is_suspended()) {

        uint32_t now = System::now();
        if (now >= next_direction_change_date) {
            set_next_direction();
        }
    }
}
예제 #5
0
/**
 * \brief Notifies this movement that it just failed to apply
 * because of obstacles.
 */
void RandomMovement::notify_obstacle_reached() {

  StraightMovement::notify_obstacle_reached();
  set_next_direction();
}