aboutsummaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-08-05 11:22:13 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-08-05 11:22:13 +0300
commit64a6da3e45838a6f764777728736dfa0f6678778 (patch)
tree570cfe68e9036f77ef10f6ca57c3ca489cbb393f /src/player.cpp
parent5f8809e425ba814f102c4387b6bf0cf323bd96c5 (diff)
parentdd9909a574514f59eb527db682a4e8d85350ead9 (diff)
downloadminetest-64a6da3e45838a6f764777728736dfa0f6678778.tar.gz
minetest-64a6da3e45838a6f764777728736dfa0f6678778.tar.bz2
minetest-64a6da3e45838a6f764777728736dfa0f6678778.zip
merged delta and c55
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)