From f31b0a3361c0c39b9f6f6ee440b93293690bbe02 Mon Sep 17 00:00:00 2001 From: JacobF Date: Wed, 7 Sep 2011 10:56:04 -0400 Subject: Display which tool the player is holding And some simple animation when trying to dig... --- src/player.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/player.cpp') 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 *collision_info) { -- cgit v1.2.3