aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-04-28 11:49:17 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-04-28 11:49:17 -0400
commit4f0dff18e4680d9bb4e7efc9cffdb0b63937533c (patch)
tree82b5af2687d9a50fad897436ff1524fce48be865
parent68cb663a370747c325eeeeea66cca86803e4b8e5 (diff)
Sword Swinging
-rw-r--r--src/inventory.cpp2
-rw-r--r--src/items.cpp19
-rw-r--r--src/ui.cpp3
3 files changed, 18 insertions, 6 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 78502a7..ab31277 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -100,7 +100,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;
}
diff --git a/src/ui.cpp b/src/ui.cpp
index 48c260b..0f81f34 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -964,7 +964,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 &&