aboutsummaryrefslogtreecommitdiffstats
path: root/src/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index ed22fb6..3b2663b 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -9,15 +9,38 @@ extern GLuint invUI;
void itemDraw(Player *p,ITEM_ID id);
+char *getItemTexturePath(ITEM_ID id){
+ return item[id].textureLoc;
+}
+
+Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl){
+ id = i;
+ type = t;
+ width = w;
+ height = h;
+ maxStackSize = m;
+ count = 0;
+
+ name = new char[strlen(n)+1]; //(char*)calloc(strlen(n ),sizeof(char));
+ textureLoc = new char[strlen(tl)+1]; //(char*)calloc(strlen(tl),sizeof(char));
+
+ strcpy(name,n);
+ strcpy(textureLoc,tl);
+
+ tex= new Texturec(1,textureLoc);
+}
+
Inventory::Inventory(unsigned int s){
sel=0;
size=s;
- inv=(struct item_t *)calloc(size,sizeof(struct item_t));
+ inv = new struct item_t[size]; //(struct item_t *)calloc(size,sizeof(struct item_t));
+ memset(inv,0,size*sizeof(struct item_t));
tossd=false;
}
Inventory::~Inventory(void){
- free(item);
+ delete[] inv;
+ //free(item);
}
void Inventory::setSelection(unsigned int s){
@@ -61,8 +84,6 @@ void Inventory::draw(void){
unsigned int i=0;
static unsigned int lop = 0;
float y,xoff;
-
-
static int numSlot = 7;
static std::vector<int>dfp(numSlot);
static std::vector<Ray>iray(numSlot);
@@ -159,6 +180,7 @@ void Inventory::draw(void){
i++;
}
}*/
+
if(inv[sel].count)itemDraw(player,inv[sel].id);
lop++;
}