diff options
-rw-r--r-- | assets/items/SWORD_WOOD.png | bin | 0 -> 256 bytes | |||
-rw-r--r-- | assets/names_en-us | 1 | ||||
-rw-r--r-- | assets/player.png | bin | 577 -> 577 bytes | |||
-rw-r--r-- | assets/player1.png | bin | 586 -> 586 bytes | |||
-rw-r--r-- | assets/player2.png | bin | 586 -> 586 bytes | |||
-rw-r--r-- | config/items.h | 6 | ||||
-rw-r--r-- | include/inventory.h | 2 | ||||
-rw-r--r-- | include/ui.h | 1 | ||||
-rw-r--r-- | main.cpp | 1 | ||||
-rw-r--r-- | src/entities.cpp | 4 | ||||
-rw-r--r-- | src/inventory.cpp | 34 | ||||
-rw-r--r-- | src/ui.cpp | 7 |
12 files changed, 41 insertions, 15 deletions
diff --git a/assets/items/SWORD_WOOD.png b/assets/items/SWORD_WOOD.png Binary files differnew file mode 100644 index 0000000..a6d3af3 --- /dev/null +++ b/assets/items/SWORD_WOOD.png diff --git a/assets/names_en-us b/assets/names_en-us index c65808b..a841bb8 100644 --- a/assets/names_en-us +++ b/assets/names_en-us @@ -55,6 +55,7 @@ mPingu mShrek mLogan mJohn Cena +mDex Dogtective fShani fIsidra fAja diff --git a/assets/player.png b/assets/player.png Binary files differindex 8881980..cfc327c 100644 --- a/assets/player.png +++ b/assets/player.png diff --git a/assets/player1.png b/assets/player1.png Binary files differindex 33e68f2..8204252 100644 --- a/assets/player1.png +++ b/assets/player1.png diff --git a/assets/player2.png b/assets/player2.png Binary files differindex 20e679b..63f4c08 100644 --- a/assets/player2.png +++ b/assets/player2.png diff --git a/config/items.h b/config/items.h index fc0ca96..1bd9111 100644 --- a/config/items.h +++ b/config/items.h @@ -11,8 +11,8 @@ ID DEBUG_ITEM ID TEST_ITEM NAME "Dank MayMay" TYPE TOOL - WIDTH HLINE - HEIGHT HLINE + WIDTH HLINE*1 + HEIGHT HLINE*1 STACKSIZE 420 TEX "assets/items/ITEM_TEST.png" ENI @@ -41,5 +41,5 @@ ID SWORD_WOOD WIDTH HLINE*4 HEIGHT HLINE*10 STACKSIZE 1 - TEX "assets/items/ITEM_SWORD.png" + TEX "assets/items/SWORD_WOOD.png" STOP diff --git a/include/inventory.h b/include/inventory.h index 33a113c..5f05f3a 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -91,5 +91,7 @@ public: void itemUse(void *p); void initInventorySprites(void); char *getItemTexturePath(ITEM_ID id); +int getItemWidth(ITEM_ID); +int getItemHeight(ITEM_ID); #endif // INVENTORY_H diff --git a/include/ui.h b/include/ui.h index 4d30b9b..f2c0114 100644 --- a/include/ui.h +++ b/include/ui.h @@ -27,6 +27,7 @@ namespace ui { extern unsigned int fontSize; extern bool dialogBoxExists; extern unsigned char dialogOptChosen; + extern bool edown; /* * Initializes the FreeType system. @@ -214,7 +214,6 @@ static unsigned int fadeIntensity = 0; int main(/*int argc, char *argv[]*/){ gameRunning=false; - /*! * (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually * make openGL calls. Exit if there was an error. diff --git a/src/entities.cpp b/src/entities.cpp index 729bcdd..b1a0c09 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -169,8 +169,8 @@ Object::Object(ITEM_ID id, bool qo, const char *pd){ type = OBJECTT; alive = true; near = false; - width = HLINE * 8; - height = HLINE * 8; + width = getItemWidth(id); + height = getItemHeight(id); maxHealth = health = 1; tex = new Texturec(1,getItemTexturePath(id)); diff --git a/src/inventory.cpp b/src/inventory.cpp index 310a6b5..e6433bb 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -26,6 +26,14 @@ char *getItemTexturePath(ITEM_ID id){ return item[id].textureLoc; } +int getItemWidth(ITEM_ID id){ + return item[id].width; +} + +int getItemHeight(ITEM_ID id){ + return item[id].height; +} + Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl){ id = i; type = t; @@ -179,7 +187,7 @@ void Inventory::draw(void){ highlight=sel+thing; if(highlight>numSlot-1)highlight=numSlot-1; if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)){ - highlight>numSlot-1 ? sel=numSlot-1 : sel = highlight; + sel = highlight; mouseSel=false; invHover=false; selected = true; @@ -205,10 +213,10 @@ void Inventory::draw(void){ glColor4f(0.0f, 0.0f, 0.0f, a == highlight ? 0.5f : 0.1f); 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)); - glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2)+itemWide); - glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2)+itemWide); + glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2)); + glVertex2i(r.end.x+(itemWide/2), r.end.y-(itemWide/2)); + glVertex2i(r.end.x+(itemWide/2), r.end.y+(itemWide/2)); + glVertex2i(r.end.x-(itemWide/2), r.end.y+(itemWide/2)); glEnd(); if(inv[a].count > 0){ @@ -216,16 +224,24 @@ void Inventory::draw(void){ glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]); glColor4f(1.0f, 1.0f, 1.0f, a == highlight ? 0.8f : 0.2f); glBegin(GL_QUADS); - glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2)); - glTexCoord2i(1,1);glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2)); - glTexCoord2i(1,0);glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2)+itemWide); - glTexCoord2i(0,0);glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2)+itemWide); + if(item[inv[a].id].height > item[inv[a].id].width){ + glTexCoord2i(0,1);glVertex2i(r.end.x-((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)), r.end.y-(itemWide/2)); + glTexCoord2i(1,1);glVertex2i(r.end.x+((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)), r.end.y-(itemWide/2)); + glTexCoord2i(1,0);glVertex2i(r.end.x+((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)), r.end.y+(itemWide/2)); + glTexCoord2i(0,0);glVertex2i(r.end.x-((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)), r.end.y+(itemWide/2)); + }else{ + glTexCoord2i(0,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,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(); glDisable(GL_TEXTURE_2D); //ui::putText(r.end.x-(itemWide/2)+(itemWide*.85),r.end.y-(itemWide/1.75),"%d",inv[a].count); } a++; } + 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); lop++; @@ -68,6 +68,11 @@ namespace ui { */ vec2 mouse; + + /* + * Variety of keydown bools + */ + bool edown; /* * Debugging flags. @@ -624,6 +629,7 @@ DONE: if(SDL_KEY==SDLK_F3)debug^=true; if(((SDL_KEY==SDLK_b) & (SDL_KEY==SDLK_F3)))posFlag^=true; if(SDL_KEY==SDLK_e){ + edown=true; if(heyOhLetsGo == 0){ heyOhLetsGo = loops; player->inv->mouseSel = false; @@ -646,6 +652,7 @@ DONE: if(SDL_KEY==SDLK_h)player->health-=5; if(SDL_KEY==SDLK_f)player->light ^= true; if(SDL_KEY==SDLK_e){ + edown=false; if(player->inv->invHover){ player->inv->invHover = false; heyOhLetsGo = 0; |