Ladders implemented!

This commit is contained in:
Mark Holmquist 2011-07-27 14:38:48 -07:00 committed by Giuseppe Bilotta
parent bc2819cab2
commit 1c59cff832
4 changed files with 34 additions and 1 deletions

@ -314,6 +314,7 @@ void content_mapnode_init()
f->solidness = 0; f->solidness = 0;
f->air_equivalent = true; f->air_equivalent = true;
f->walkable = false; f->walkable = false;
f->climbable = true;
setWoodLikeDiggingProperties(f->digging_properties, 0.5); setWoodLikeDiggingProperties(f->digging_properties, 0.5);
// Deprecated // Deprecated

@ -128,6 +128,8 @@ struct ContentFeatures
bool pointable; bool pointable;
// Player can dig these // Player can dig these
bool diggable; bool diggable;
// Player can climb these
bool climbable;
// Player can build on these // Player can build on these
bool buildable_to; bool buildable_to;
// Whether the node has no liquid, source liquid or flowing liquid // Whether the node has no liquid, source liquid or flowing liquid
@ -171,6 +173,7 @@ struct ContentFeatures
walkable = true; walkable = true;
pointable = true; pointable = true;
diggable = true; diggable = true;
climbable = false;
buildable_to = false; buildable_to = false;
liquid_type = LIQUID_NONE; liquid_type = LIQUID_NONE;
wall_mounted = false; wall_mounted = false;

@ -375,6 +375,21 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
in_water_stable = false; in_water_stable = false;
} }
/*
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 Collision uncertainty radius
Make it a bit larger than the maximum distance of movement Make it a bit larger than the maximum distance of movement
@ -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) // The speed of the player (Y is ignored)
if(superspeed) if(superspeed)
speed = speed.normalize() * walkspeed_max * 5.0; speed = speed.normalize() * walkspeed_max * 5.0;

@ -118,6 +118,7 @@ public:
bool in_water; bool in_water;
// This is more stable and defines the maximum speed of the player // This is more stable and defines the maximum speed of the player
bool in_water_stable; bool in_water_stable;
bool is_climbing;
bool swimming_up; bool swimming_up;
Inventory inventory; Inventory inventory;