diff options
-rw-r--r-- | src/inventory.cpp | 2 | ||||
-rw-r--r-- | src/items.cpp | 19 | ||||
-rw-r--r-- | src/ui.cpp | 3 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index 83c1f0a..ff7284f 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -103,7 +103,7 @@ void items(void) int Inventory::addItem(std::string name, uint count) { - std::cout << "Adding: " << count << name << "\'s" << std::endl; + std::cout << "Adding: " << count << " " << name << std::endl; for (uint i = 0; i < ItemMap.size(); i++) { if (strCaseCmp(ItemMap[i]->name, name)) { for (auto &it : Items) { diff --git a/src/items.cpp b/src/items.cpp index 403c49e..b86abf7 100644 --- a/src/items.cpp +++ b/src/items.cpp @@ -19,10 +19,21 @@ int BaseItem::useItem() int Sword::useItem() { std::cout << "Swing!" << std::endl; - if (player->left) - rotation += 10.0f; - else - rotation -= 10.0f; + std::thread([this]{ + player->inv->usingi = true; + bool swing = true; + float coef = 0.0f; + + while (swing) { + coef += .01f; + if (player->left) + rotation = coef; + else + rotation = -coef; + } + player->inv->usingi = false; + }).detach(); + return 0; } @@ -965,7 +965,8 @@ EXIT: } else { // left click uses item if (e.button.button & SDL_BUTTON_LEFT) - player->inv->useCurrent(); + if(!player->inv->usingi) + player->inv->useCurrent(); } if(mouse.x > player->loc.x && mouse.x < player->loc.x + player->width && |