diff options
Diffstat (limited to 'src/player.cpp')
-rw-r--r-- | src/player.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/player.cpp b/src/player.cpp index 7cfdfebb6..03ae24f45 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -309,12 +309,31 @@ LocalPlayer::LocalPlayer(): // Initialize hp to 0, so that no hearts will be shown if server // doesn't support health points hp = 0; + + // No tool wielded initially + wield = NULL; } LocalPlayer::~LocalPlayer() { } +void LocalPlayer::wieldItem(u16 item) +{ + m_selected_item = item; + + if(wield) { + InventoryItem* i = inventory.getList("main")->getItem(m_selected_item); + + if(i && strcmp(i->getName(), "ToolItem") == 0) { + wield->getMaterial(0).setTexture(0, i->getImageRaw()); + wield->setVisible(true); + } + else + wield->setVisible(false); + } +} + void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, core::list<CollisionInfo> *collision_info) { |