mirror of https://github.com/minetest/minetest.git
Modified jumping control to stop "flying" up block-stairs
This commit is contained in:
parent
2f170a63c6
commit
c571e62658
|
@ -29,6 +29,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "util/numeric.h"
|
#include "util/numeric.h"
|
||||||
|
|
||||||
|
//<dev>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
//</dev>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
LocalPlayer
|
LocalPlayer
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +61,8 @@ LocalPlayer::LocalPlayer(IGameDef *gamedef):
|
||||||
m_old_node_below_type("air"),
|
m_old_node_below_type("air"),
|
||||||
m_need_to_get_new_sneak_node(true),
|
m_need_to_get_new_sneak_node(true),
|
||||||
m_can_jump(false),
|
m_can_jump(false),
|
||||||
m_cao(NULL)
|
m_cao(NULL),
|
||||||
|
m_jumptime(0.0)
|
||||||
{
|
{
|
||||||
// Initialize hp to 0, so that no hearts will be shown if server
|
// Initialize hp to 0, so that no hearts will be shown if server
|
||||||
// doesn't support health points
|
// doesn't support health points
|
||||||
|
@ -324,6 +332,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
||||||
touching_ground = false;
|
touching_ground = false;
|
||||||
MtEvent *e = new SimpleTriggerEvent("PlayerJump");
|
MtEvent *e = new SimpleTriggerEvent("PlayerJump");
|
||||||
m_gamedef->event()->put(e);
|
m_gamedef->event()->put(e);
|
||||||
|
cout << "Jumped because " << m_jumptime << " is less than " << env->getTimeOfDay() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!touching_ground_was && touching_ground){
|
if(!touching_ground_was && touching_ground){
|
||||||
|
@ -356,7 +365,12 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
||||||
*/
|
*/
|
||||||
const ContentFeatures &f = nodemgr->get(map->getNodeNoEx(getStandingNodePos()));
|
const ContentFeatures &f = nodemgr->get(map->getNodeNoEx(getStandingNodePos()));
|
||||||
// Determine if jumping is possible
|
// Determine if jumping is possible
|
||||||
m_can_jump = touching_ground && !in_liquid;
|
m_can_jump = touching_ground && !in_liquid && (m_jumptime <= env->getTimeOfDay());
|
||||||
|
if(!touching_ground){
|
||||||
|
m_jumptime = env->getTimeOfDay()+movement_jump_dealy;
|
||||||
|
}
|
||||||
|
//cout << m_jumptime << ":" << (env->getTimeOfDay()) << ":" << m_can_jump << "\n";
|
||||||
|
|
||||||
if(itemgroup_get(f.groups, "disable_jump"))
|
if(itemgroup_get(f.groups, "disable_jump"))
|
||||||
m_can_jump = false;
|
m_can_jump = false;
|
||||||
}
|
}
|
||||||
|
@ -478,8 +492,7 @@ void LocalPlayer::applyControl(float dtime)
|
||||||
speedV.Y = -movement_speed_climb;
|
speedV.Y = -movement_speed_climb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(continuous_forward)
|
if(continuous_forward)
|
||||||
speedH += move_direction;
|
speedH += move_direction;
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ private:
|
||||||
std::string m_old_node_below_type;
|
std::string m_old_node_below_type;
|
||||||
// Whether recalculation of the sneak node is needed
|
// Whether recalculation of the sneak node is needed
|
||||||
bool m_need_to_get_new_sneak_node;
|
bool m_need_to_get_new_sneak_node;
|
||||||
|
f32 m_jumptime;
|
||||||
bool m_can_jump;
|
bool m_can_jump;
|
||||||
|
|
||||||
GenericCAO* m_cao;
|
GenericCAO* m_cao;
|
||||||
|
|
|
@ -53,6 +53,7 @@ Player::Player(IGameDef *gamedef):
|
||||||
m_last_pos(0,0,0),
|
m_last_pos(0,0,0),
|
||||||
m_last_hp(PLAYER_MAX_HP),
|
m_last_hp(PLAYER_MAX_HP),
|
||||||
m_last_inventory(gamedef->idef())
|
m_last_inventory(gamedef->idef())
|
||||||
|
m_jumping_dir(0,0,0);
|
||||||
{
|
{
|
||||||
updateName("<not set>");
|
updateName("<not set>");
|
||||||
inventory.clear();
|
inventory.clear();
|
||||||
|
@ -83,6 +84,7 @@ Player::Player(IGameDef *gamedef):
|
||||||
movement_liquid_fluidity_smooth = 0.5 * BS;
|
movement_liquid_fluidity_smooth = 0.5 * BS;
|
||||||
movement_liquid_sink = 10 * BS;
|
movement_liquid_sink = 10 * BS;
|
||||||
movement_gravity = 9.81 * BS;
|
movement_gravity = 9.81 * BS;
|
||||||
|
movement_jump_dealy = 0.3 * BS;
|
||||||
|
|
||||||
// Movement overrides are multipliers and must be 1 by default
|
// Movement overrides are multipliers and must be 1 by default
|
||||||
physics_override_speed = 1;
|
physics_override_speed = 1;
|
||||||
|
|
|
@ -267,6 +267,7 @@ public:
|
||||||
f32 movement_liquid_fluidity_smooth;
|
f32 movement_liquid_fluidity_smooth;
|
||||||
f32 movement_liquid_sink;
|
f32 movement_liquid_sink;
|
||||||
f32 movement_gravity;
|
f32 movement_gravity;
|
||||||
|
f32 movement_jump_dealy;
|
||||||
|
|
||||||
float physics_override_speed;
|
float physics_override_speed;
|
||||||
float physics_override_jump;
|
float physics_override_jump;
|
||||||
|
|
Loading…
Reference in New Issue