From 0415b7f0a9305cd43e8fd8c77a8bafd3b8016dd0 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Mon, 30 Nov 2015 08:47:24 -0500 Subject: Working on animations --- src/Texture.cpp | 1 - src/entities.cpp | 4 ++-- src/inventory.cpp | 44 +++++++++++++++++++++++--------------------- 3 files changed, 25 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/Texture.cpp b/src/Texture.cpp index 82baa71..586f5fd 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -13,7 +13,6 @@ namespace Texture{ GLuint loadTexture(const char *fileName){ SDL_Surface *image; GLuint object = 0; - unsigned int i; for(unsigned int i=0;iname,fileName)){ diff --git a/src/entities.cpp b/src/entities.cpp index 97b4d35..c2c560a 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -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, item[id].textureLoc); questObject = false; pickupDialog="\0"; @@ -122,7 +122,7 @@ Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupD height = HLINE * 8; maxHealth = health = 1; - //tex = new Texturec(1, item[id].textureLoc); + tex = new Texturec(1, item[id].textureLoc); } diff --git a/src/inventory.cpp b/src/inventory.cpp index 45d5bce..ed22fb6 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); Inventory::Inventory(unsigned int s){ @@ -63,6 +59,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; @@ -81,7 +78,7 @@ void Inventory::draw(void){ //dfp[a] = 0; a++; }a=0; - if(invOpening){ + if(invOpening && lop % 1 == 0){ end = 0; for(auto &d : dfp){ if(a != 0){ @@ -94,18 +91,12 @@ void Inventory::draw(void){ a++; }a=0; if(end < numSlot)invOpen=true; - }else if(!invOpening){ - for(auto &d : dfp){ + }else if(!invOpening && lop % 1 == 0){ + for(auto &d : boost::adaptors::reverse(dfp)){ if(d > 0){ - if(a != 0){ - //d-=25; - if(dfp[a-1]+25= numSlot)invOpen=false; } if(invOpen){ @@ -115,14 +106,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++; } } @@ -159,6 +160,7 @@ void Inventory::draw(void){ } }*/ if(inv[sel].count)itemDraw(player,inv[sel].id); + lop++; } static vec2 item_coord = {0,0}; -- cgit v1.2.3