diff options
author | Mark Holmquist <marktraceur@gmail.com> | 2011-07-27 14:38:48 -0700 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2011-08-01 09:22:36 +0200 |
commit | 1c59cff8328bd85d6aed7df38b7eaddbeeca0aec (patch) | |
tree | 551b5a158be3dab163ab34e4e2908d55bdbd256c /src/player.cpp | |
parent | bc2819cab2978c61b2ca1d7b68a5d1f223e8647a (diff) | |
download | minetest-1c59cff8328bd85d6aed7df38b7eaddbeeca0aec.tar.gz minetest-1c59cff8328bd85d6aed7df38b7eaddbeeca0aec.tar.bz2 minetest-1c59cff8328bd85d6aed7df38b7eaddbeeca0aec.zip |
Ladders implemented!
Diffstat (limited to 'src/player.cpp')
-rw-r--r-- | src/player.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/player.cpp b/src/player.cpp index c43276ef1..3846cd8f9 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).d).climbable || + content_features(map.getNode(pp2).d).climbable); + } + 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 <<") -> (" @@ -814,6 +829,19 @@ void LocalPlayer::applyControl(float dtime) } } + if (is_climbing) { + if (control.up || control.left || control.right || control.down) { + v3f speed = getSpeed(); + speed.Y = 2*BS; + setSpeed(speed); + } + else { + v3f speed = getSpeed(); + speed.Y = -2*BS; + setSpeed(speed); + } + } + // The speed of the player (Y is ignored) if(superspeed) speed = speed.normalize() * walkspeed_max * 5.0; |