aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp2
-rw-r--r--src/inventory.cpp47
-rw-r--r--src/ui.cpp4
-rw-r--r--src/world.cpp6
4 files changed, 41 insertions, 18 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 05b79b5..f2d7270 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -208,7 +208,7 @@ void Entity::draw(void){ //draws the entities
case PLAYERT:
static int texState = 0;
static bool up = true;
- if(loops % (int)((float)3 / (float)speed) == 0){
+ if(loops % (int)((float)4/(float)speed) == 0){
if(up){
if(++texState==2)up=false;
tex->bindNext();
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 7d3bc6d..8bf8d42 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -12,8 +12,7 @@ static const Item item[ITEM_COUNT]= {
};
static GLuint itemtex[ITEM_COUNT];
-
-void itemDraw(Player *p,ITEM_ID id);
+void itemDraw(Player *p,ITEM_ID id, ITEM_TYPE type);
void initInventorySprites(void){
unsigned int i;
@@ -69,16 +68,14 @@ int Inventory::addItem(ITEM_ID id,unsigned char count){
//std::cout << id << "," << inv[os].id << std::endl;
for(unsigned int i = 0; i < size; i++){
- if(id == inv[i].id){
+ if(inv[i].id == id){
inv[i].count += count;
- break;
- }else{
- inv[os].id = id;
- inv[os].count = count;
- os++;
- break;
+ return 0;
}
}
+ 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);
@@ -148,7 +145,7 @@ void Inventory::draw(void){
curCoord[a].y += float((dfp[a]) * sin(angle*PI/180));
r.end = curCoord[a];
- glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)range)*0.4f);
+ glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)*0.5f);
glBegin(GL_QUADS);
glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2));
glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2));
@@ -171,7 +168,8 @@ void Inventory::draw(void){
glTexCoord2i(1,1);glVertex2i(r.end.x+(itemWide/2), r.end.y-(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
glTexCoord2i(1,0);glVertex2i(r.end.x+(itemWide/2), r.end.y+(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
glTexCoord2i(0,0);glVertex2i(r.end.x-(itemWide/2), r.end.y+(itemWide/2)*((float)item[inv[a].id].height/(float)item[inv[a].id].width));
- } glEnd();
+ }
+ glEnd();
glDisable(GL_TEXTURE_2D);
ui::putText(r.end.x-(itemWide/2),r.end.y-(itemWide*.9),"%s",item[inv[a].id].name);
ui::putText(r.end.x-(itemWide/2)+(itemWide*.85),r.end.y-(itemWide/2),"%d",inv[a].count);
@@ -257,12 +255,24 @@ void Inventory::draw(void){
}
if(inv[highlight].count > 0)ui::putStringCentered(player->loc.x+player->width/2, player->loc.y + range*.75,item[inv[highlight].id].name);
}
- if(inv[sel].count)itemDraw(player,inv[sel].id);
+ if(inv[sel].count)itemDraw(player,inv[sel].id,item[inv[sel].id].type);
lop++;
}
-void itemDraw(Player *p,ITEM_ID id){
+void itemDraw(Player *p,ITEM_ID id,ITEM_TYPE type){
+ static float angle = 0.0f;
+ glPushMatrix();
if(!id)return;
+ switch(type){
+ case SWORD:
+ angle = 15.0f;
+ break;
+ default:
+ angle = 0.0f;
+ }
+ //glTranslatef(player->loc.x*2,player->loc.y*2,0);
+ glTranslatef(0-player->loc.x*2,0,0);
+ glRotatef(angle, 0.0f, 1.0f, 0.0f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,itemtex[id]);
glColor4ub(255,255,255,255);
@@ -273,11 +283,20 @@ void itemDraw(Player *p,ITEM_ID id){
glTexCoord2i(0,0);glVertex2f(p->loc.x, p->loc.y+item[id].height);
glEnd();
glDisable(GL_TEXTURE_2D);
+ glTranslatef(player->loc.x*2,0,0);
+ glPopMatrix();
}
int Inventory::useItem(void){
- ITEM_ID id = item[inv[sel].id].id;
+ ITEM_ID id = item[inv[sel].id].id;
+ ITEM_TYPE type = item[inv[sel].id].type;
if(!invHover){
+ switch(type){
+ case SWORD:
+
+ break;
+ default:break;
+ }
switch(id){
case FLASHLIGHT:
player->light ^= true;
diff --git a/src/ui.cpp b/src/ui.cpp
index 9b96254..e6dadc2 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -650,7 +650,7 @@ DONE:
}
break;
case SDLK_LSHIFT:
- player->speed = debug ? 4 : 3;
+ player->speed = debug ? 4.0f : 3.0f;
break;
case SDLK_LCTRL:
player->speed = .5;
@@ -688,6 +688,8 @@ DONE:
player->right = false;
break;
case SDLK_LSHIFT:
+ player->speed = 1;
+ break;
case SDLK_LCTRL:
player->speed = 1;
break;
diff --git a/src/world.cpp b/src/world.cpp
index 1b90a4b..1e37a78 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -666,11 +666,11 @@ void World::singleDetect(Entity *e){
*/
if(!e->alive||e->health<=0){
-
for(i=0;i<entity.size();i++){
if(entity[i]==e){
switch(e->type){
case STRUCTURET:
+ std::cout<<"Killed a building..."<<std::endl;
for(j=0;j<build.size();j++){
if(build[j]==e){
delete build[j];
@@ -680,6 +680,7 @@ void World::singleDetect(Entity *e){
}
break;
case NPCT:
+ std::cout<<"Killed an NPC..."<<std::endl;
for(j=0;j<npc.size();j++){
if(npc[j]==e){
delete npc[j];
@@ -689,6 +690,7 @@ void World::singleDetect(Entity *e){
}
break;
case MOBT:
+ std::cout<<"Killed a mob..."<<std::endl;
for(j=0;j<mob.size();j++){
if(mob[j]==e){
delete mob[j];
@@ -698,6 +700,7 @@ void World::singleDetect(Entity *e){
}
break;
case OBJECTT:
+ std::cout<<"Killed an object..."<<std::endl;
for(j=0;j<object.size();j++){
if(object[j]==e){
delete object[j];
@@ -711,7 +714,6 @@ void World::singleDetect(Entity *e){
exit(0);
break;
}
- std::cout<<"Killed an entity..."<<std::endl;
entity.erase(entity.begin()+i);
return;
}