예제 #1
0
/**
 * \brief Notifies this state that a directional key was just pressed.
 * \param direction4 direction of the key (0 to 3)
 */
void Hero::RunningState::notify_direction_command_pressed(int direction4) {

  if (!is_bouncing()
      && direction4 != get_sprites().get_animation_direction()) {
    Hero& hero = get_hero();
    hero.set_state(new FreeState(hero));
  }
}
예제 #2
0
/**
 * \brief Updates this state.
 */
void Hero::RunningState::update() {

  State::update();

  if (is_suspended()) {
    return;
  }

  uint32_t now = System::now();

  if (!is_bouncing() && now >= next_sound_date) {
    Sound::play("running");
    next_sound_date = now + 170;
  }

  Hero& hero = get_entity();
  if (phase == 0) {

    if (now >= next_phase_date) {

      double angle = Geometry::degrees_to_radians(get_sprites().get_animation_direction() * 90);
      std::shared_ptr<StraightMovement> movement =
          std::make_shared<StraightMovement>(false, true);
      movement->set_max_distance(3000);
      movement->set_speed(300);
      movement->set_angle(angle);
      hero.clear_movement();
      hero.set_movement(movement);

      get_sprites().set_animation_running();
      phase++;
    }
    else if (!is_pressing_running_key()) {
      hero.set_state(new FreeState(hero));
    }
  }
  else if (hero.get_movement()->is_finished()) {
    hero.start_state_from_ground();
  }
}
예제 #3
0
/**
 * \brief Returns whether a sensor is considered as an obstacle in this state.
 * \param sensor a sensor
 * \return true if the sensor is an obstacle in this state
 */
bool Hero::RunningState::is_sensor_obstacle(const Sensor& sensor) const {
  return is_bouncing();
}
예제 #4
0
/**
 * \brief Returns whether the hero ignores the effect of conveyor belts in this state.
 * \return true if the hero ignores the effect of conveyor belts in this state
 */
bool Hero::RunningState::can_avoid_conveyor_belt() const {
  return is_bouncing();
}
예제 #5
0
/**
 * \brief Returns whether the hero ignores the effect of teletransporters in this state.
 * \return true if the hero ignores the effect of teletransporters in this state
 */
bool Hero::RunningState::can_avoid_teletransporter() const {
  return is_bouncing();
}
예제 #6
0
/**
 * \brief Returns whether the hero ignores the effect of prickles in this state.
 * \return true if the hero ignores the effect of prickles in the current state
 */
bool Hero::RunningState::can_avoid_prickle() const {
  return is_bouncing();
}
예제 #7
0
/**
 * \brief Returns whether the hero ignores the effect of lava in this state.
 * \return true if the hero ignores the effect of lava in the current state
 */
bool Hero::RunningState::can_avoid_lava() const {
  return is_bouncing();
}
예제 #8
0
/**
 * \brief Returns whether the hero ignores the effect of deep water in this state.
 * \return true if the hero ignores the effect of deep water in the current state
 */
bool Hero::RunningState::can_avoid_deep_water() const {
  return is_bouncing();
}
예제 #9
0
/**
 * \brief Returns whether the hero is touching the ground in the current state.
 * \return true if the hero is touching the ground in the current state
 */
bool Hero::RunningState::is_touching_ground() const {
  return !is_bouncing();
}
예제 #10
0
/**
 * \brief Returns whether the game over sequence can start in the current state.
 * \return true if the game over sequence can start in the current state
 */
bool Hero::RunningState::can_start_gameover_sequence() const {
  return !is_bouncing();
}
예제 #11
0
/**
 * \brief Returns whether can trigger a jumper in this state.
 *
 * If false is returned, jumpers have no effect (but they are obstacle
 * for the hero).
 *
 * \return true if the hero can use jumpers in this state
 */
bool Hero::RunningState::can_take_jumper() const {
  return !is_bouncing();
}
예제 #12
0
/**
 * \brief Returns whether the hero can take stairs in this state.
 * If false is returned, stairs have no effect (but they are obstacle for the hero).
 * \return true if the hero ignores the effect of stairs in this state
 */
bool Hero::RunningState::can_take_stairs() const {
  return !is_bouncing();
}
예제 #13
0
/**
 * \copydoc Entity::State::can_avoid_stream
 */
bool Hero::RunningState::can_avoid_stream(const Stream& /* stream */) const {
  return is_bouncing();
}