Skip to content

Commit

Permalink
[QoL] More climbable tweaks (#2512)
Browse files Browse the repository at this point in the history
Climbing zones now have a restriction to all 4 edges to prevent Tux from leaving without jumping. I also made it so you no longer leave without jumping by pressing the ACTION key, but rather by pressing DOWN + JUMP.

Possible improvement: checking for nearby climbable zones and disable boundaries that intersect directly with other zones.
  • Loading branch information
Raoul1808 authored Aug 17, 2023
1 parent 864ff52 commit 746ed7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/object/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ Player::stop_climbing(Climbable& /*climbable*/)
m_physic.set_velocity(0, 0);
m_physic.set_acceleration(0, 0);

if (m_controller->hold(Control::JUMP)) {
if (m_controller->hold(Control::JUMP) && !m_controller->hold(Control::DOWN)) {
m_on_ground_flag = true;
m_jump_early_apex = false;
do_jump(m_player_status.bonus[get_id()] == BonusType::AIR_BONUS ? -540.0f : -480.0f);
Expand All @@ -2541,18 +2541,19 @@ Player::handle_input_climbing()

float vx = 0;
float vy = 0;
if (m_controller->hold(Control::LEFT)) {
auto obj_bbox = m_climbing->get_bbox();
if (m_controller->hold(Control::LEFT) && m_col.m_bbox.get_left() > obj_bbox.get_left()) {
m_dir = Direction::LEFT;
vx -= MAX_CLIMB_XM;
}
if (m_controller->hold(Control::RIGHT)) {
if (m_controller->hold(Control::RIGHT) && m_col.m_bbox.get_right() < obj_bbox.get_right()) {
m_dir = Direction::RIGHT;
vx += MAX_CLIMB_XM;
}
if (m_controller->hold(Control::UP) && m_col.m_bbox.get_top() > m_climbing->get_bbox().get_top()) {
if (m_controller->hold(Control::UP) && m_col.m_bbox.get_top() > obj_bbox.get_top()) {
vy -= MAX_CLIMB_YM;
}
if (m_controller->hold(Control::DOWN)) {
if (m_controller->hold(Control::DOWN) && m_col.m_bbox.get_bottom() < obj_bbox.get_bottom()) {
vy += MAX_CLIMB_YM;
}
if (m_controller->hold(Control::JUMP)) {
Expand All @@ -2563,10 +2564,6 @@ Player::handle_input_climbing()
} else {
m_can_jump = true;
}
if (m_controller->hold(Control::ACTION)) {
stop_climbing(*m_climbing);
return;
}
m_physic.set_velocity(vx, vy);
m_physic.set_acceleration(0, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/trigger/climbable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Climbable::draw(DrawingContext& context)
void
Climbable::event(Player& player, EventType type)
{
if (type == EVENT_ACTIVATE) {
if (type == EVENT_ACTIVATE || (type == EVENT_TOUCH && player.get_controller().hold(Control::UP))) {
if (player.get_grabbed_object() == nullptr){
auto it = std::find_if(trying_to_climb.begin(), trying_to_climb.end(),
[&player](const ClimbPlayer& element)
Expand Down

0 comments on commit 746ed7d

Please sign in to comment.