From bc2819cab2978c61b2ca1d7b68a5d1f223e8647a Mon Sep 17 00:00:00 2001 From: Mark Holmquist Date: Wed, 27 Jul 2011 10:18:09 -0700 Subject: Added ladders--they don't have any use yet, though --- src/content_mapnode.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/content_mapnode.cpp') diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index 7589f06ed..e3235778a 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -303,6 +303,19 @@ void content_mapnode_init() f->walkable = false; setDirtLikeDiggingProperties(f->digging_properties, 0.75); + i = CONTENT_LADDER; + f = &content_features(i); + f->setInventoryTexture("item_ladder.png"); + f->light_propagates = true; + f->param_type = CPT_LIGHT; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + f->wall_mounted = true; + f->solidness = 0; + f->air_equivalent = true; + f->walkable = false; + setWoodLikeDiggingProperties(f->digging_properties, 0.5); + // Deprecated i = CONTENT_COALSTONE; f = &content_features(i); -- cgit v1.2.3 From 1c59cff8328bd85d6aed7df38b7eaddbeeca0aec Mon Sep 17 00:00:00 2001 From: Mark Holmquist Date: Wed, 27 Jul 2011 14:38:48 -0700 Subject: Ladders implemented! --- src/content_mapnode.cpp | 1 + src/mapnode.h | 3 +++ src/player.cpp | 30 +++++++++++++++++++++++++++++- src/player.h | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) (limited to 'src/content_mapnode.cpp') diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index e3235778a..8e97fa6cd 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -314,6 +314,7 @@ void content_mapnode_init() f->solidness = 0; f->air_equivalent = true; f->walkable = false; + f->climbable = true; setWoodLikeDiggingProperties(f->digging_properties, 0.5); // Deprecated diff --git a/src/mapnode.h b/src/mapnode.h index 1fb84e1c9..484ad4e19 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -128,6 +128,8 @@ struct ContentFeatures bool pointable; // Player can dig these bool diggable; + // Player can climb these + bool climbable; // Player can build on these bool buildable_to; // Whether the node has no liquid, source liquid or flowing liquid @@ -171,6 +173,7 @@ struct ContentFeatures walkable = true; pointable = true; diggable = true; + climbable = false; buildable_to = false; liquid_type = LIQUID_NONE; wall_mounted = false; diff --git a/src/player.cpp b/src/player.cpp index c43276ef1..3846cd8f9 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -375,6 +375,21 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, 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 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 (" < (" @@ -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; diff --git a/src/player.h b/src/player.h index 29460e1e1..78ca14948 100644 --- a/src/player.h +++ b/src/player.h @@ -118,6 +118,7 @@ public: bool in_water; // This is more stable and defines the maximum speed of the player bool in_water_stable; + bool is_climbing; bool swimming_up; Inventory inventory; -- cgit v1.2.3 From 363487c97bd90a83497785dbcccebf462d9a64f8 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Mon, 1 Aug 2011 15:47:02 +0200 Subject: * less clumsy ladder texture, based on rails --- data/item_ladder.png | Bin 581 -> 0 bytes data/ladder.png | Bin 691 -> 395 bytes src/content_mapnode.cpp | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 data/item_ladder.png (limited to 'src/content_mapnode.cpp') diff --git a/data/item_ladder.png b/data/item_ladder.png deleted file mode 100644 index f35978ff9..000000000 Binary files a/data/item_ladder.png and /dev/null differ diff --git a/data/ladder.png b/data/ladder.png index dbbd680ec..11056359d 100644 Binary files a/data/ladder.png and b/data/ladder.png differ diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index 8e97fa6cd..b164033db 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -305,7 +305,7 @@ void content_mapnode_init() i = CONTENT_LADDER; f = &content_features(i); - f->setInventoryTexture("item_ladder.png"); + f->setInventoryTexture("ladder.png"); f->light_propagates = true; f->param_type = CPT_LIGHT; f->is_ground_content = true; -- cgit v1.2.3