aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiner59 <speeedie@gmx.de>2015-07-05 14:52:55 +0200
committerest31 <MTest31@outlook.com>2015-08-02 19:40:23 +0200
commit060e56b24c21c4cda76fcac15eecbdce9682d16a (patch)
treea1ad15564abc71b81fe4573ca51d7f5dd6b607fb
parent868a1a5c13a0c086aa1ff3414a1eb12076821c27 (diff)
downloadminetest-060e56b24c21c4cda76fcac15eecbdce9682d16a.tar.gz
minetest-060e56b24c21c4cda76fcac15eecbdce9682d16a.tar.bz2
minetest-060e56b24c21c4cda76fcac15eecbdce9682d16a.zip
Fix "bouncy" blocks
Before players "bounced" too high. Now, while still allowing to bounce, higher speed bounces are throttled.
-rw-r--r--src/localplayer.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index d06015e06..1a59504ef 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -319,25 +319,15 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
/*
Report collisions
*/
- bool bouncy_jump = false;
+
// Dont report if flying
if(collision_info && !(g_settings->getBool("free_move") && fly_allowed)) {
for(size_t i=0; i<result.collisions.size(); i++) {
const CollisionInfo &info = result.collisions[i];
collision_info->push_back(info);
- if(info.new_speed.Y - info.old_speed.Y > 0.1*BS &&
- info.bouncy)
- bouncy_jump = true;
}
}
- if(bouncy_jump && control.jump){
- m_speed.Y += movement_speed_jump*BS;
- touching_ground = false;
- MtEvent *e = new SimpleTriggerEvent("PlayerJump");
- m_gamedef->event()->put(e);
- }
-
if(!touching_ground_was && touching_ground){
MtEvent *e = new SimpleTriggerEvent("PlayerRegainGround");
m_gamedef->event()->put(e);
@@ -371,6 +361,19 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
m_can_jump = touching_ground && !in_liquid;
if(itemgroup_get(f.groups, "disable_jump"))
m_can_jump = false;
+ // Jump key pressed while jumping off from a bouncy block
+ if (m_can_jump && control.jump && itemgroup_get(f.groups, "bouncy") &&
+ m_speed.Y >= -0.5 * BS) {
+ float jumpspeed = movement_speed_jump * physics_override_jump;
+ if (m_speed.Y > 1) {
+ // Reduce boost when speed already is high
+ m_speed.Y += jumpspeed / (1 + (m_speed.Y / 16 ));
+ } else {
+ m_speed.Y += jumpspeed;
+ }
+ setSpeed(m_speed);
+ m_can_jump = false;
+ }
}
void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d)