/** * \brief Constructor. * \param hero The hero controlled by this state. * \param stairs The stairs to take. * \param way The way you are taking the stairs. */ Hero::StairsState::StairsState( Hero& hero, Stairs& stairs, Stairs::Way way): State(hero, "stairs"), stairs(stairs), way(way), phase(0), next_phase_date(0), carried_item(nullptr) { if (get_previous_carried_item_behavior() == CarriedItem::BEHAVIOR_KEEP) { // Keep the carried item of the previous state. carried_item = hero.get_carried_item(); } }
/** * \brief Constructor. * \param hero The hero controlled by this state. * \param direction8 Direction of the jump (0 to 7). * \param distance Distance of the jump in pixels. * \param ignore_obstacles \c true to make the movement ignore obstacles. * \param with_sound \c true to play the "jump" sound. */ Hero::JumpingState::JumpingState( Hero& hero, int direction8, int distance, bool ignore_obstacles, bool with_sound ): BaseState(hero, "jumping"), carried_item() { if (get_previous_carried_item_behavior() == CarriedItem::BEHAVIOR_KEEP) { // Keep the carried item of the previous state. carried_item = hero.get_carried_item(); } this->movement = std::make_shared<JumpMovement>( direction8, distance, 0, ignore_obstacles ); this->direction8 = direction8; this->with_sound = with_sound; }