diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-02-02 08:49:38 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-02-02 08:49:38 -0500 |
commit | d83b7f3d1f50ee1b164095c0e9d94cc87a44ad8c (patch) | |
tree | d7b76cb1907f781e1eccd1691bc7a622ed27a63c /include | |
parent | 32855b564c2a7cd5c1a644dcf7039ab9b69295e4 (diff) |
inventory rewrite
Diffstat (limited to 'include')
-rw-r--r-- | include/Quest.h | 7 | ||||
-rw-r--r-- | include/entities.h | 6 | ||||
-rw-r--r-- | include/inventory.h | 84 | ||||
-rw-r--r-- | include/world.h | 2 |
4 files changed, 43 insertions, 56 deletions
diff --git a/include/Quest.h b/include/Quest.h index 8f5446c..d17ade4 100644 --- a/include/Quest.h +++ b/include/Quest.h @@ -21,13 +21,6 @@ #define DEBUG
/**
- * Contains the total number of quests in the game at compile time, see Quest.cpp
- * for the actual definition of these quests.
- */
-
-#define TOTAL_QUESTS 1
-
-/**
* The Quest class.
*
* This contains information for a single quest, and should only really be interacted
diff --git a/include/entities.h b/include/entities.h index 28fd7e9..f4959d6 100644 --- a/include/entities.h +++ b/include/entities.h @@ -220,13 +220,15 @@ public: class Object : public Entity{ private: - ITEM_ID identifier; + std::string iname; + //ITEM_ID identifier; public: char *pickupDialog; bool questObject = false; Object(); - Object(ITEM_ID id,const char *pd); + //Object(ITEM_ID id,const char *pd); + Object(std::string in,const char *pd); ~Object(); void reloadTexture(void); diff --git a/include/inventory.h b/include/inventory.h index a08954a..d3bdd4d 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -6,7 +6,7 @@ #define DEBUG -#define ID Item( +/*#define ID Item( #define NAME , #define TYPE , #define WIDTH , @@ -14,62 +14,66 @@ #define STACKSIZE , #define TEX , #define ENI ), -#define STOP ) +#define STOP )*/ /* * A list of all item IDs. */ +/*#define ITEM_COUNT 5 + enum ITEM_ID { DEBUG_ITEM = 0, - TEST_ITEM = 1, - PLAYER_BAG = 2, - FLASHLIGHT = 3, - SWORD_WOOD = 4 + TEST_ITEM, + PLAYER_BAG, + FLASHLIGHT, + SWORD_WOOD }; -enum ITEM_TYPE{ +enum ITEM_TYPE { TOOL = 1, - SWORD = 2, - RANGED = 3, - EQUIP = 4, - FOOD = 5 -}; + SWORD, + RANGED, + EQUIP, + FOOD +};*/ class Item{ protected: public: - ITEM_ID id; // ID of the item - char *name; - ITEM_TYPE type; // What category the item falls under + //ITEM_ID id; // ID of the item + //ITEM_TYPE type; // What category the item falls under + + //char *name; + //char *type; + + std::string name,type; + float width; float height; - int maxStackSize; - char* textureLoc; + int maxStackSize; + + std::string texloc; Texturec *tex; - GLuint text; - Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl); + //Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const char *tl); GLuint rtex(){ return tex->image[0]; } }; struct item_t{ - int count; - ITEM_ID id; + uint count; + uint/*ITEM_ID*/ id; } __attribute__((packed)); -typedef struct { - unsigned int size; - int os; - unsigned int sel; -} __attribute__ ((packed)) InventorySavePacket; - class Inventory { private: + + std::vector<item_t> items; + unsigned int size; // Size of 'item' array - item_t *inv; + //item_t *inv; int os = 0; public: unsigned int sel; @@ -83,34 +87,22 @@ public: Inventory(unsigned int s); // Creates an inventory of size 's' ~Inventory(void); // Free's allocated memory - 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 addItem(std::string name,uint count); + int takeItem(std::string name,uint count); + int useItem(void); bool detectCollision(vec2,vec2); 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) - - char *save(void){ - static InventorySavePacket *isp = new InventorySavePacket(); - isp->size = size; - isp->os = os; - isp->sel = sel; - return (char *)isp; - } - void load(InventorySavePacket *isp){ - size = isp->size; - os = isp->os; - sel = isp->sel; - } }; void initInventorySprites(void); void destroyInventory(void); -char *getItemTexturePath(ITEM_ID id); -int getItemWidth(ITEM_ID); -int getItemHeight(ITEM_ID); +const char *getItemTexturePath(std::string name); +float getItemWidth(std::string name); +float getItemHeight(std::string name); #endif // INVENTORY_H diff --git a/include/world.h b/include/world.h index d752728..a0c9a63 100644 --- a/include/world.h +++ b/include/world.h @@ -285,7 +285,7 @@ public: * upon object interaction. */ - void addObject(ITEM_ID id,const char *pickupDialog, float x, float y); + void addObject(/*ITEM_ID id*/std::string in,const char *pickupDialog, float x, float y); /** * Adds a particle to the world with the specified coordinates, dimensions, |