void Player::walk_left() { _walk_left->increment_frame(); apply_movement(-_walk, 0); if (_movement.x < -_max_walk) set_movement(-_max_walk, _movement.y); _facing_right = false; set_state(ENTITY_WALKING); }
void Player::walk_right() { _walk_right->increment_frame(); apply_movement(_walk, 0); if (_movement.x >_max_walk) set_movement(_max_walk, _movement.y); _facing_right = true; set_state(ENTITY_WALKING); }
/** * \brief Add the effect representing the power of water. */ void ptb::power_effect::add_water_effect() { remove_water_effect(); bear::engine::base_item* result = create_power_item("animation/effect/power/water_effect.canim"); apply_movement(*result); m_water = result; } // power_effect::add_water_effect()
void Player::stop_walking() { //Decelerate if (_state == ENTITY_WALKING) { if (_movement.x < 0) { apply_movement(_walk_stop, 0); if (_movement.x > 0) set_movement(0, _movement.y); } else if (_movement.x > 0) { apply_movement(-_walk_stop, 0); if (_movement.x < 0) set_movement(0, _movement.y); } if (round(_movement.x) == 0.f) { set_movement(0.f, _movement.y); unset_state(ENTITY_WALKING); } } }
void Player::jump() { if (!is_state_set(ENTITY_JUMPING)) { apply_movement(0.f, _jump_speed); set_state(ENTITY_JUMPING); } }
void Player::fall() { apply_movement(0, _fall_speed); if (_movement.y > _max_fall_speed) set_movement(_movement.x, _max_fall_speed); }
void Player::float_down() { apply_movement(0, _walk); if (_movement.y >_max_walk) set_movement(_movement.x, _max_walk); }
void Player::float_up() { apply_movement(0, -_walk); if (_movement.y < -_max_walk) set_movement(_movement.x, -_max_walk); }