aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-12-02 07:28:21 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-12-02 07:28:21 -0500
commitcedc826b4a71f7d00d55b7b1234c1019d3f6e96a (patch)
treeaea0e252837d6aa65ee5b3e7e753db13b85e7ff8 /src
parent67ebafca971ecd4dcfde92bc64a838ba64c16e99 (diff)
Fixed item textures
Diffstat (limited to 'src')
-rw-r--r--src/gameplay.cpp3
-rw-r--r--src/inventory.cpp51
2 files changed, 15 insertions, 39 deletions
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<ITEM_COUNT;i++){
+ itemtex[i]=Texture::loadTexture(getItemTexturePath((ITEM_ID)i));
+ }
}
Inventory::~Inventory(void){
@@ -54,12 +59,11 @@ int Inventory::addItem(ITEM_ID id,unsigned char count){
inv[os].id = id;
inv[os].count = count;
os++;
-
-
#ifdef DEBUG
DEBUG_printf("Gave player %u more %s(s)(ID: %d).\n",count,item[id].name,item[id].id);
#endif // DEBUG
+
/*#ifdef DEBUG
DEBUG_printf("Failed to add non-existant item with id %u.\n",id);
#endif // DEBUG*/
@@ -131,7 +135,7 @@ void Inventory::draw(void){
curCoord[a].y += float((dfp[a]) * sin(angle*PI/180));
r.end = curCoord[a];
- glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range));
+ glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)*0.3f);
glBegin(GL_QUADS);
glVertex2i(r.end.x, r.end.y);
glVertex2i(r.end.x+45, r.end.y);
@@ -140,7 +144,8 @@ void Inventory::draw(void){
glEnd();
if(inv[a].count > 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<size && inv[i].count > 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};