From 9ab6025a0cc3ab31c476f0b478ac69bfadd7f670 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 29 Oct 2015 15:51:07 -0400 Subject: inventory visuals / item drop (Q) --- Changelog | 5 ++++ include/inventory.h | 13 ++++++++-- src/inventory.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ui.cpp | 5 ++++ src/world.cpp | 8 +++++- 5 files changed, 99 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index a5b5df9..6283ad9 100644 --- a/Changelog +++ b/Changelog @@ -201,3 +201,8 @@ - documented world.h - fixed camera ortho - began working on layer-switching animation + - added variable width backgrounds + - added a debug sprint speed + + - the currently selected item is now drawn on the player + - pressing q discards (w/ visuals) the currently selected item diff --git a/include/inventory.h b/include/inventory.h index cb3e59d..e27391a 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -5,8 +5,12 @@ #define DEBUG -enum ITEM_ID { // Contains item IDs for every item in the game, this is how items are stored. IDs are also used to lookup item strings - TEST_ITEM = 1, // A test item (duh) +/* + * A list of all item IDs. +*/ + +enum ITEM_ID { + TEST_ITEM = 1, SWORD_ITEM = 2 }; @@ -26,10 +30,15 @@ public: int addItem(ITEM_ID id,unsigned char count); // Add 'count' items with an id of 'id' to the inventory int takeItem(ITEM_ID id,unsigned char count); // Take 'count' items with an id of 'id' from the inventory + int useItem(ITEM_ID id); + + bool tossd; + int itemToss(void); void setSelection(unsigned int s); void draw(void); // Draws a text list of items in this inventory (should only be called for the player for now) + }; unsigned int initInventorySprites(void); // Loads as many inventory textures as it can find, returns count diff --git a/src/inventory.cpp b/src/inventory.cpp index 2eb0087..3043e80 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -20,6 +20,8 @@ const char *ITEM_SPRITE[]={ GLuint *ITEM_TEX; +void itemDraw(Player *p,ITEM_ID id); + unsigned int initInventorySprites(void){ unsigned int i,loadCount=0; ITEM_TEX=(GLuint *)calloc(ITEM_COUNT,sizeof(GLuint)); @@ -36,6 +38,7 @@ Inventory::Inventory(unsigned int s){ sel=0; size=s; item=(struct item_t *)calloc(size,sizeof(struct item_t)); + tossd=false; } Inventory::~Inventory(void){ @@ -74,6 +77,9 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){ unsigned int i; for(i=0;iloc.x+p->width/2, + p->loc.y+p->width/2+HLINE*3}; + p2 = {(float)(p1.x+p->width*(p->left?-.5:.5)), + p->loc.y+HLINE*3}; + } + if(p->inv->tossd) yes=true; + std::cout<ground=false; } } + if(SDL_KEY==SDLK_q){ + player->inv->itemToss(); + } if(SDL_KEY==SDLK_c){ dialogBox("","You pressed `c`, but nothing happened."); } @@ -287,6 +290,8 @@ namespace ui { } } + if(player->inv->tossd)player->inv->itemToss(); + unsigned int i; if(!dialogBoxExists&&AIpreaddr.size()){ // Flush preloaded AI functions if necessary for(i=0;iinfront){ + hey=hey->infront; + goto LOOP; + } + return -hey->x_start*2; } IndoorWorld::IndoorWorld(void){ -- cgit v1.2.3