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) {
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;
}
} 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 &&