aboutsummaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/player.cpp b/src/player.cpp
index c43276ef1..be478e869 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -376,6 +376,21 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
}
/*
+ Check if player is climbing
+ */
+
+ try {
+ v3s16 pp = floatToInt(position + v3f(0,0.5*BS,0), BS);
+ v3s16 pp2 = floatToInt(position + v3f(0,-0.2*BS,0), BS);
+ is_climbing = ((content_features(map.getNode(pp).getContent()).climbable ||
+ content_features(map.getNode(pp2).getContent()).climbable) && !free_move);
+ }
+ catch(InvalidPositionException &e)
+ {
+ is_climbing = false;
+ }
+
+ /*
Collision uncertainty radius
Make it a bit larger than the maximum distance of movement
*/
@@ -461,7 +476,7 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
Player is allowed to jump when this is true.
*/
touching_ground = false;
-
+
/*std::cout<<"Checking collisions for ("
<<oldpos_i.X<<","<<oldpos_i.Y<<","<<oldpos_i.Z
<<") -> ("
@@ -723,7 +738,7 @@ void LocalPlayer::applyControl(float dtime)
bool fast_move = g_settings.getBool("fast_move");
bool continuous_forward = g_settings.getBool("continuous_forward");
- if(free_move)
+ if(free_move || is_climbing)
{
v3f speed = getSpeed();
speed.Y = 0;
@@ -750,6 +765,12 @@ void LocalPlayer::applyControl(float dtime)
speed.Y = -walkspeed_max;
setSpeed(speed);
}
+ else if(is_climbing)
+ {
+ v3f speed = getSpeed();
+ speed.Y = -3*BS;
+ setSpeed(speed);
+ }
else
{
// If not free movement but fast is allowed, aux1 is
@@ -812,6 +833,12 @@ void LocalPlayer::applyControl(float dtime)
setSpeed(speed);
swimming_up = true;
}
+ else if(is_climbing)
+ {
+ v3f speed = getSpeed();
+ speed.Y = 3*BS;
+ setSpeed(speed);
+ }
}
// The speed of the player (Y is ignored)