]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
inv. fixes
authorClyne Sullivan <tullivan99@gmail.com>
Thu, 3 Dec 2015 13:26:09 +0000 (08:26 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Thu, 3 Dec 2015 13:26:09 +0000 (08:26 -0500)
include/inventory.h
main.cpp
src/inventory.cpp
src/ui.cpp

index 18ef6c4f18e744c27a5178883e0feb3fde1fc70b..1ad46d0330740bc9543828f18ba2c3c5b1eed968 100644 (file)
@@ -39,8 +39,6 @@ enum ITEM_TYPE{
 class Item{
 protected:
 public:
-       friend class Inventory;
-       friend unsigned int initInventorySprites(void);
        ITEM_ID id;                             // ID of the item
        char *name;
        ITEM_TYPE type;                 // What category the item falls under
@@ -89,6 +87,7 @@ public:
 };
 
 void itemUse(void *p);
+void initInventorySprites(void);
 char *getItemTexturePath(ITEM_ID id);
 
 #endif // INVENTORY_H
index 19d67e7cdb9c745a3abd0a9fc0c02c01c056657f..f24b9bdea0c3ed53117d56bcbf853c92d6185233 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -434,10 +434,8 @@ int main(int argc, char *argv[]){
 
        invUI = Texture::loadTexture("assets/invUI.png" );
        
-       //std::cout << "Before invSprites\n";
-       //initInventorySprites();
-       //std::cout << "After invSprites\n";
-
+       initInventorySprites();
+       
        /**************************
        ****     GAMELOOP      ****
        **************************/
index 73e5e32d7f3f76f4e1be7a318989d63160a975bc..0eac3b265c6a9ada232f015920963ed84e634740 100644 (file)
@@ -15,6 +15,12 @@ static GLuint itemtex[ITEM_COUNT];
 
 void itemDraw(Player *p,ITEM_ID id);
 
+void initInventorySprites(void){
+       for(int i = 0;i<ITEM_COUNT;i++){
+               itemtex[i]=Texture::loadTexture(getItemTexturePath((ITEM_ID)i));
+       }
+}
+
 char *getItemTexturePath(ITEM_ID id){
        return item[id].textureLoc;
 }
@@ -41,9 +47,6 @@ Inventory::Inventory(unsigned int s){
        size=s;
        inv = new struct item_t[size];
        memset(inv,0,size*sizeof(struct item_t));
-       for(int i = 0;i<ITEM_COUNT;i++){
-               itemtex[i]=Texture::loadTexture(getItemTexturePath((ITEM_ID)i));
-       }
 }
 
 Inventory::~Inventory(void){
@@ -90,7 +93,6 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){
 }
 
 void Inventory::draw(void){
-       std::cout << invHover << std::endl;
        unsigned int i=0;
        static unsigned int lop = 0;
        float y,xoff;
index 181803d499e73b5e92b1362245f7bd2aec367bf3..e9b262f92c5158bfdb462d0058cbabc5aa1ca1a5 100644 (file)
@@ -354,15 +354,15 @@ namespace ui {
                 *      Create a wimpy buffer.
                */
                
-               buf = new char[128];    //(char *)calloc(128,sizeof(char));
-               memset(buf,0,128*sizeof(char));
+               buf = new char[512];    //(char *)calloc(128,sizeof(char));
+               memset(buf,0,512*sizeof(char));
                
                /*
                 *      Handle the formatted string, printing it to the buffer.
                */
                
                va_start(args,str);
-               vsnprintf(buf,128,str,args);
+               vsnprintf(buf,512,str,args);
                va_end(args);
                
                /*