diff options
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index 83c1f0a..b617d09 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -41,6 +41,8 @@ void items(void) XMLElement *exml = xml.FirstChildElement("item"); XMLElement *cxml = xml.FirstChildElement("currency"); + Sword *tmpSword = new Sword(); + while (cxml) { // NEWEWEWEWEWEWEWEW @@ -60,7 +62,8 @@ void items(void) // if the type is a sword } else if (strCaseCmp(name, "sword")) { - ItemMap.push_back(new Sword()); + tmpSword->setDamage(exml->FloatAttribute("damage")); + ItemMap.push_back(tmpSword->clone()); // if the type is a bow } else if (strCaseCmp(name, "bow")) { @@ -68,7 +71,7 @@ void items(void) ItemMap.push_back(new Bow()); // uncooked / raw food - } else if (strCaseCmp(name, "rawfood")) { + } else if (strCaseCmp(name, "raw food")) { ItemMap.push_back(new RawFood()); @@ -103,7 +106,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) { @@ -587,14 +590,20 @@ void Inventory::draw(void) { void itemDraw(Player *p, Item *d) { itemLoc.y = p->loc.y+(p->height/3); - itemLoc.x = p->left?p->loc.x:p->loc.x+p->width; + itemLoc.x = p->left?p->loc.x-d->dim.x/2:p->loc.x+p->width-d->dim.x/2; glPushMatrix(); glUseProgram(shaderProgram); glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); - glTranslatef(itemLoc.x,itemLoc.y,0); - glRotatef(d->rotation, 0.0f, 0.0f, 1.0f); - glTranslatef(-itemLoc.x,-itemLoc.y,0); + if (p->left) { + glTranslatef(itemLoc.x+d->dim.x/2,itemLoc.y,0); + glRotatef(d->rotation, 0.0f, 0.0f, 1.0f); + glTranslatef(-itemLoc.x-d->dim.x/2,-itemLoc.y,0); + } else { + glTranslatef(itemLoc.x+d->dim.x/2,itemLoc.y,0); + glRotatef(d->rotation, 0.0f, 0.0f, 1.0f); + glTranslatef(-itemLoc.x-d->dim.x/2,-itemLoc.y,0); + } glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,d->tex->image[0]); glColor4ub(255,255,255,255); @@ -620,11 +629,23 @@ int Inventory::useItem(void) int Inventory::useCurrent() { - if(Items[sel].second) + if (Items[sel].second) return Items[sel].first->useItem(); return -1; } +void Inventory::currentAddInteract(Entity* e) +{ + if (Items[sel].second) + Items[sel].first->addInteract(e); +} + +void Inventory::currentAddInteract(std::vector<Entity*> e) +{ + if (Items[sel].second) + Items[sel].first->addInteract(e); +} + bool Inventory::detectCollision(vec2 one, vec2 two) { (void)one; (void)two; |