From a277430f0ddde9ea2583f4b0c44fcafe8a2528bf Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 2 Oct 2015 08:47:11 -0400 Subject: added inventories --- include/Quest.h | 8 +++++--- include/entities.h | 11 ++++++++++- include/inventory.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 include/inventory.h (limited to 'include') diff --git a/include/Quest.h b/include/Quest.h index c4b8780..11d04a6 100644 --- a/include/Quest.h +++ b/include/Quest.h @@ -5,13 +5,15 @@ #include #include +#include + #define TOTAL_QUESTS 1 class Quest { public: char *title,*desc; - unsigned int reward; - Quest(const char *t,const char *d,unsigned int r); + struct item_t reward; + Quest(const char *t,const char *d,struct item_t r); ~Quest(); }; @@ -20,7 +22,7 @@ public: std::vectorcurrent; int assign(const char *t); int drop(const char *t); - int finish(const char *t); + int finish(const char *t,void *completer); bool hasQuest(const char *t); }; diff --git a/include/entities.h b/include/entities.h index b58d569..4c1b484 100644 --- a/include/entities.h +++ b/include/entities.h @@ -2,18 +2,25 @@ #define ENTITIES_H #include +#include #define NPCp(n) ((NPC *)n) +#define PLAYER_INV_SIZE 30 // The size of the player's inventory +#define NPC_INV_SIZE 3 // Size of an NPC's inventory + extern FILE* names; class Entity{ public: + Inventory *inv; + void *inWorld; + float width; //width and height of the player float height; float speed; //speed of the play - //type and subtype + int subtype; _TYPE type; //example: @@ -21,8 +28,10 @@ public: // |(subtype) // |-> 0 Base NPC // |-> 1 Merchant + vec2 loc; //location and velocity of the entity vec2 vel; + bool near; bool right,left, canMove; //movement variables bool alive; //the flag for whether or not the entity is alive diff --git a/include/inventory.h b/include/inventory.h new file mode 100644 index 0000000..8f42cc5 --- /dev/null +++ b/include/inventory.h @@ -0,0 +1,29 @@ +#ifndef INVENTORY_H +#define INVENTORY_H + +#include + +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) +}; + +struct item_t { // Used to define entries in an entity's inventory + short count; // Quantity of the item in this slot + ITEM_ID id; // ID of the item +} __attribute__ ((packed)); + +class Inventory { +private: + unsigned int size; // Size of 'item' array + struct item_t *item; // An array of the items contained in this inventory. +public: + Inventory(unsigned int s); // Creates an inventory of size 's' + ~Inventory(void); // Free's 'item' + + 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 + + void draw(void); // Draws a text list of items in this inventory (should only be called for the player for now) +}; + +#endif // INVENTORY_H -- cgit v1.2.3