diff options
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index cd01c11..28612ae 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -7,10 +7,6 @@ extern Player *player; extern GLuint invUI; -static Item item[5]= { - #include "../config/items.h" -}; - void itemDraw(Player *p,ITEM_ID id); char *getItemTexturePath(ITEM_ID id){ @@ -25,8 +21,8 @@ Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const 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)); + name = new char[strlen(n)+1]; + textureLoc = new char[strlen(tl)+1]; strcpy(name,n); strcpy(textureLoc,tl); @@ -37,14 +33,13 @@ Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const Inventory::Inventory(unsigned int s){ sel=0; size=s; - inv = new struct item_t[size]; //(struct item_t *)calloc(size,sizeof(struct item_t)); + inv = new struct item_t[size]; memset(inv,0,size*sizeof(struct item_t)); tossd=false; } Inventory::~Inventory(void){ delete[] inv; - //free(item); } void Inventory::setSelection(unsigned int s){ @@ -86,6 +81,7 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){ void Inventory::draw(void){ ui::putText(offset.x-SCREEN_WIDTH/2,480,"%d",sel); unsigned int i=0; + static unsigned int lop = 0; float y,xoff; static int numSlot = 7; static std::vector<int>dfp(numSlot); @@ -106,9 +102,9 @@ void Inventory::draw(void){ end = 0; for(auto &d : dfp){ if(a != 0){ - if(dfp[a-1]>25)d+=25; + if(dfp[a-1]>50)d+=1.65*deltaTime; }else{ - d += 25; + d += 1.65*deltaTime; } if(d >= range) d = range; @@ -118,15 +114,9 @@ void Inventory::draw(void){ }else if(!invOpening){ for(auto &d : dfp){ if(d > 0){ - if(a != 0){ - //d-=25; - if(dfp[a-1]+25<d || dfp[a-1]<=0)d-=25; - }else{ - d-=25; - } + d-=1.65*deltaTime; }else end++; - a++; - }a=0; + } if(end >= numSlot)invOpen=false; } if(invOpen){ @@ -136,14 +126,24 @@ void Inventory::draw(void){ curCoord[a].y += float((dfp[a]) * sin(angle*PI/180)); r.end = curCoord[a]; - item[inv[i].id].tex->bind(0); - glColor4f(1.0f, 1.0f, 1.0f, (float)dfp[a]/(float)range); + glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)); glBegin(GL_QUADS); - glTexCoord2i(0,1);glVertex2i(r.end.x, r.end.y); - glTexCoord2i(1,1);glVertex2i(r.end.x+45, r.end.y); - glTexCoord2i(1,0);glVertex2i(r.end.x+45, r.end.y+45); - glTexCoord2i(0,0);glVertex2i(r.end.x, r.end.y+45); + glVertex2i(r.end.x, r.end.y); + glVertex2i(r.end.x+45, r.end.y); + glVertex2i(r.end.x+45, r.end.y+45); + glVertex2i(r.end.x, r.end.y+45); glEnd(); + + if(inv[a].count > 0){ + glBindTexture(GL_TEXTURE_2D, item[inv[a].id].text); + glColor4f(1.0f, 1.0f, 1.0f, (float)dfp[a]/(float)range); + glBegin(GL_QUADS); + glTexCoord2i(0,1);glVertex2i(r.end.x, r.end.y); + glTexCoord2i(1,1);glVertex2i(r.end.x+45, r.end.y); + glTexCoord2i(1,0);glVertex2i(r.end.x+45, r.end.y+45); + glTexCoord2i(0,0);glVertex2i(r.end.x, r.end.y+45); + glEnd(); + } a++; } } @@ -181,6 +181,7 @@ void Inventory::draw(void){ }*/ if(inv[sel].count)itemDraw(player,inv[sel].id); + lop++; } static vec2 item_coord = {0,0}; |