From cedc826b4a71f7d00d55b7b1234c1019d3f6e96a Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Wed, 2 Dec 2015 07:28:21 -0500 Subject: Fixed item textures --- include/inventory.h | 2 +- src/gameplay.cpp | 3 +++ src/inventory.cpp | 51 ++++++++++++--------------------------------------- 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/include/inventory.h b/include/inventory.h index e95195b..ec71e94 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -21,7 +21,7 @@ */ enum ITEM_ID { - DEBUG_ITEM = 69, + DEBUG_ITEM = 0, TEST_ITEM = 1, PLAYER_BAG = 2, FLASHLIGHT = 3, diff --git a/src/gameplay.cpp b/src/gameplay.cpp index cc9ae6a..a4fec88 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -76,8 +76,11 @@ void initEverything(void){ playerSpawnHill=new World(); playerSpawnHill->setBackground(BG_FOREST); +<<<<<<< Updated upstream playerSpawnHill->generateFunc(1280,playerSpawnHillFunc); //playerSpawnHill->generate(1920); +======= +>>>>>>> Stashed changes /* * Setup the current world, making the player initially spawn in `test`. diff --git a/src/inventory.cpp b/src/inventory.cpp index 2af4de3..e67f031 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -7,10 +7,12 @@ extern Player *player; extern GLuint invUI; -static Item item[5]= { +static const Item item[ITEM_COUNT]= { #include "../config/items.h" }; +static GLuint itemtex[ITEM_COUNT]; + void itemDraw(Player *p,ITEM_ID id); char *getItemTexturePath(ITEM_ID id){ @@ -40,6 +42,9 @@ Inventory::Inventory(unsigned int s){ inv = new struct item_t[size]; memset(inv,0,size*sizeof(struct item_t)); tossd=false; + for(int i = 0;i 0){ - glBindTexture(GL_TEXTURE_2D, item[inv[a].id].text); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]); 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); @@ -148,43 +153,11 @@ void Inventory::draw(void){ glTexCoord2i(1,0);glVertex2i(r.end.x+45, r.end.y+45); glTexCoord2i(0,0);glVertex2i(r.end.x, r.end.y+45); glEnd(); + glDisable(GL_TEXTURE_2D); } a++; } } - - - /*else if(!invOpen){ - for(auto &d : dfp){ - d = 0; - } - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, invUI); - glBegin(GL_QUADS); - glTexCoord2i(0,1);glVertex2i(offset.x-SCREEN_WIDTH/2, 0); - glTexCoord2i(1,1);glVertex2i(offset.x-SCREEN_WIDTH/2+261, 0); - glTexCoord2i(1,0);glVertex2i(offset.x-SCREEN_WIDTH/2+261, 57); - glTexCoord2i(0,0);glVertex2i(offset.x-SCREEN_WIDTH/2, 57); - glEnd(); - glDisable(GL_TEXTURE_2D); - while(i 0 && i<5){ - y = 6; - xoff = (offset.x - (SCREEN_WIDTH /2)) + (51*i) + 6; - glEnable(GL_TEXTURE_2D); - item[inv[i].id].tex->bind(0); - if(sel==i)glColor3ub(255,0,255); - else glColor3ub(255,255,255); - glBegin(GL_QUADS); - glTexCoord2i(0,1);glVertex2i(xoff, y); - glTexCoord2i(1,1);glVertex2i(xoff+45, y); - glTexCoord2i(1,0);glVertex2i(xoff+45, y+45); - glTexCoord2i(0,0);glVertex2i(xoff, y+45); - glEnd(); - glDisable(GL_TEXTURE_2D); - i++; - } - }*/ - if(inv[sel].count)itemDraw(player,inv[sel].id); lop++; } @@ -198,7 +171,7 @@ void itemDraw(Player *p,ITEM_ID id){ static vec2 p1,p2; if(!id)return; glEnable(GL_TEXTURE_2D); - item[id].tex->bind(0); + glBindTexture(GL_TEXTURE_2D,itemtex[id]); if(!yes){ p1 = {p->loc.x+p->width/2, p->loc.y+p->width/2+HLINE*3}; -- cgit v1.2.3