From: drumsetmonkey Date: Mon, 30 Nov 2015 12:33:26 +0000 (-0500) Subject: Look at my fancy inventory X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=fbe1b6c3a0a3427111577e6b77600f5669012583;p=clyne%2Fgamedev.git Look at my fancy inventory --- fbe1b6c3a0a3427111577e6b77600f5669012583 diff --cc config/items.h index 3189a29,c2e7c95..62db071 --- a/config/items.h +++ b/config/items.h @@@ -1,5 -1,5 +1,6 @@@ -ID DEBUG_ITEM - NAME "Debug" ++ +ID DEBUG_ITEM + NAME "Debug\0" TYPE TOOL WIDTH 1 HEIGHT 1 diff --cc include/inventory.h index 3fdbf52,46053f6..2793ad7 --- a/include/inventory.h +++ b/include/inventory.h @@@ -48,32 -49,20 +48,28 @@@ public float height; int maxStackSize; char* textureLoc; + Texturec *tex; int count; Item(ITEM_ID i, char* n, ITEM_TYPE t, float w, float h, int m, char* tl): - id(i), name(n), type(t), width(w), height(h), maxStackSize(m), textureLoc(tl){ + id(i), type(t), width(w), height(h), maxStackSize(m){ count = 0; + + name = (char*)calloc(strlen(n ),sizeof(char)); + textureLoc = (char*)calloc(strlen(tl),sizeof(char)); + + strcpy(name,n); + strcpy(textureLoc,tl); + + tex= new Texturec(1,textureLoc); } - void addCount(int c){ - count += c; + GLuint rtex(){ + return tex->image[0]; } - }; - static Item item[5]= { - #include "../config/items.h" - }; - struct item_t{ int count; - ITEM_ID itmid; + ITEM_ID id; } __attribute__((packed)); diff --cc src/entities.cpp index c2c560a,af32cd6..97b4d35 --- a/src/entities.cpp +++ b/src/entities.cpp @@@ -108,7 -108,7 +108,7 @@@ Object::Object(int id):identifier(id) height = HLINE * 8; maxHealth = health = 1; - tex = new Texturec(1, item[id].textureLoc); - tex = new Texturec(1, "assets/items/ITEM_SWORD.png"); ++ //tex = new Texturec(1, item[id].textureLoc); questObject = false; pickupDialog="\0"; @@@ -122,7 -122,7 +122,7 @@@ Object::Object(int id, bool qo, char *p height = HLINE * 8; maxHealth = health = 1; - tex = new Texturec(1, item[id].textureLoc); - tex = new Texturec(1, "assets/items/ITEM_SWORD.png"); ++ //tex = new Texturec(1, item[id].textureLoc); } diff --cc src/inventory.cpp index 2547760,192a3a4..45d5bce --- a/src/inventory.cpp +++ b/src/inventory.cpp @@@ -7,8 -7,26 +7,12 @@@ extern Player *player; extern GLuint invUI; + static Item item[5]= { + #include "../config/items.h" + }; + -GLuint *ITEM_TEX; - void itemDraw(Player *p,ITEM_ID id); -unsigned int initInventorySprites(void){ - unsigned int i,loadCount=0; - ITEM_TEX=(GLuint *)calloc(ITEM_COUNT,sizeof(GLuint)); - for(i=0;i