diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-02-15 08:51:42 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-02-15 08:51:42 -0500 |
commit | 4a5d0a99f7c83c9f254cbfb8f41828831f8251db (patch) | |
tree | 26f2c99558586a1efd59640ba67ebccce5d2be46 /include | |
parent | 29876964587eda6e4d4bfc6543ea31efe983cf0a (diff) |
screenshots, arena door
Diffstat (limited to 'include')
-rw-r--r-- | include/entities.hpp.bak | 542 | ||||
-rw-r--r-- | include/inventory.hpp.bak | 284 | ||||
-rw-r--r-- | include/mob.hpp.bak | 140 | ||||
-rw-r--r-- | include/quest.hpp.bak | 66 |
4 files changed, 0 insertions, 1032 deletions
diff --git a/include/entities.hpp.bak b/include/entities.hpp.bak deleted file mode 100644 index e460a27..0000000 --- a/include/entities.hpp.bak +++ /dev/null @@ -1,542 +0,0 @@ -/* ---------------------------------------------------------------------------- -** The entity stuffs. -** -** Entities. -** --------------------------------------------------------------------------*/ -#ifndef ENTITIES_H -#define ENTITIES_H -#define DEBUG - -/* ---------------------------------------------------------------------------- -** Includes section -** --------------------------------------------------------------------------*/ - -// local game includes -#include <common.hpp> -#include <quest.hpp> -#include <inventory.hpp> -#include <texture.hpp> -#include <save_util.hpp> -#include <coolarray.hpp> - -// local library includes -#include <tinyxml2.h> -using namespace tinyxml2; - -/* ---------------------------------------------------------------------------- -** Structures section -** --------------------------------------------------------------------------*/ - -/** - * An entity type enumerator for identifying entities. - */ -enum _TYPE { - UNKNOWNT = -999, /**< who knows? */ - OBJECTT = -2, /**< an object (Object) */ - STRUCTURET, /**< a structure (Structures *) */ - PLAYERT, /**< the player (Player *) */ - NPCT, /**< an NPC (NPC *) */ - MERCHT, /**< a merchant (Merchant *) */ - MOBT /**< A mob (Mob *) */ -}; - -/** - * An enumerator for entity gender. - */ -enum GENDER{ - MALE, /**< male */ - FEMALE /**< female */ -}; - -/** - * An enumerator for strcture types. - * The subtype of a structure will affect how it is drawn and how it functions. - */ -enum BUILD_SUB{ - TOWN_HALL = 0, /**< a town hall */ - HOUSE, /**< a generic house */ - HOUSE2, /**< a generic house of a different style */ - HOUSE3, /**< a generic house of a different style */ - HOUSE4, /**< a generic house of a different style */ - FOUNTAIN, /**< a fountain, creates water particles */ - LAMP_POST, /**< a lamppost, creates light */ - FIRE_PIT, /**< a firepit, creates fire particles / light */ - STALL_MARKET = 70, /**< a stall for a merchant */ - STALL_TRADER -}; - -/** - * A structure for tracking potential trades between the player and a merchant. - */ -struct Trade { - // the names of the items up for trade - std::string item[2]; - // how much of each item to trade - int quantity[2]; - - // constructs a trade with the given values - Trade(int qo, std::string o, int qt, std::string t) { - item[0] = o; - item[1] = t; - quantity[0] = qo; - quantity[1] = qt; - } - - // creates an empty trade item - Trade(void) { - item[0] = ""; - item[1] = ""; - quantity[0] = 0; - quantity[1] = 0; - } -}; -typedef struct Trade Trade; - -/* ---------------------------------------------------------------------------- -** Variables section -** --------------------------------------------------------------------------*/ - -// the size of the player's inventory -extern const unsigned int PLAYER_INV_SIZE; -// the size of an NPC's inventory -extern const unsigned int NPC_INV_SIZE; - -/* ---------------------------------------------------------------------------- -** Classes / function prototypes section -** --------------------------------------------------------------------------*/ - -// a prototype of the world class, necessary for some function prototypes -class World; -class IndoorWorld; - -/** - * The light structure, used to store light coordinates and color. - */ - -class Light{ -public: - vec2 loc; /**< Light location */ - Color color; /**< Light color */ - float radius; /**< Light radius */ - - bool belongsTo; - Entity *following; - - bool flame; - float fireFlicker; - vec2 fireLoc; - Light() - { - loc = vec2(0,0); - color = Color(1.0, 1.0, 1.0); - radius = 0; - - belongsTo = false; - following = nullptr; - - flame = false; - } - - Light(vec2 l, float r, Color c) - { - loc = l; - color = c; - radius = r; - - belongsTo = false; - following = nullptr; - - flame = false; - } - - void follow(Entity *f) - { - following = f; - belongsTo = true; - } - - void makeFlame(void) - { - flame = true; - } - - void createFromXML(XMLElement *e); -}; - -/** - * The entity class. - * This class contains common functions and variables for all types of - * entities, i.e. a common structure. - */ -class Entity{ -protected: - // an incrementer for invincibility after a hit - unsigned int hitCooldown; - - // an incrementer for triggering change of movement with wander() - int ticksToUse; - - // entity handles an applied hit (sword) if set true - bool forcedMove; - - // if set false, entity will be destroyed - bool alive; - - // TODO - float targetx; - - // the cooldown display (red overlay) - float hitDuration; - - // the max cooldown display - float maxHitDuration; - - // the entity's XML element, for saving/loading stuff - XMLElement *xmle; - -public: - // contains the entity's coordinates, in pixels - vec2 loc; - float z; - - // contains the entity's velocity, in pixels - vec2 vel; - - // the entity's width, in pixels - float width; - - // the entity's height, in pixels - float height; - - // a speed multiplier, applied to velocity - float speed; - - // when true player may interact, and the entity's name will be drawn - bool near; - - // when true, the entity can move - int canMove; - - // tells direction entity is facing - bool right, left; - - // tells if the entity is from another world - char outnabout; - - // set to 1 if entity is on the ground, 0 if in the air - unsigned char ground; - - // the entity's inventory - Inventory *inv; - - // the entity's light - Light light; - - // the entity's health - float health; - - // the most health the entity can have - float maxHealth; - - // the type of the entity - _TYPE type; - - // the entity's subtype, if applicable - int subtype; - - // the entity's name, randomly generated on spawn - std::string name; - - // the entity's gender - GENDER gender; - - // a texture handler for the entity - TextureIterator tex; - - // draws the entity to the screen - void draw(void); - - // spawns the entity at the given coordinates - void spawn(float, float); - - // allows the entity to wander, according to what class is deriving this. - virtual void wander(int){} - virtual void wander(void){} - - // allows the entity to interact with the player - virtual void interact(void){} - - // causes the entity to move to the given x coordinate - void moveTo(float dest_x); - - // causes the entity to follow the one provided - void follow(Entity *e); - - // causes the entity to take a player-inflicted hit - void takeHit(unsigned int _health, unsigned int cooldown); - - // returns the amount of cool down before next hit - unsigned int coolDown(); - - // set the cool down - void setCooldown(unsigned int c); - - // handles hits if they've been taken - void handleHits(void); - - // insures that the entity is dead - void die(void); - - // checks if the entity is alive - bool isAlive(void) const; - - // checks if the entity is hit in some way - bool isHit(void) const; - - // returns true if this entity is near the one provided - bool isNear(const Entity *e); - - // returns true if the coordinate is within the entity - bool isInside(vec2 coord) const; - - // constructs the entity with an XML thing-thang - virtual void createFromXML(XMLElement *e, World *w=nullptr) =0; - virtual void saveToXML(void) =0; - -/* Entity - - ** - * Forces the given entity to follow this one. - * - void lead(Entity *e, unsigned int how); - - ** - * Attempts to break free from any following. - * - void unfollow(void);*/ - - // a common constructor, clears variables - Entity(void); - - // frees memory taken by the entity - virtual ~Entity(){} -}; - -class Player : public Entity { -public: - Entity *ride; - QuestHandler qh; - - Player(); - ~Player(); - void save(void); - void sspawn(float x,float y); - void createFromXML(XMLElement *e, World *w); - void saveToXML(void); -}; - -class Structures : public Entity { -public: - BUILD_SUB bsubtype; - World *inWorld; - World *insideWorld; - std::string inside; - std::string textureLoc; - - GLuint insideTex; - - Structures(); - ~Structures(); - - unsigned int spawn(BUILD_SUB, float, float); - void createFromXML(XMLElement *e, World *w); - void saveToXML(void); -}; - - -class NPC : public Entity { -private: - // the number of the random dialog to use - unsigned int randDialog; - - unsigned int dialogCount; - -public: - int dialogIndex; - - NPC(); - ~NPC(); - - void drawThingy(void) const; - - void addAIFunc(bool preload); - - void interact(); - void wander(int); - void createFromXML(XMLElement *e, World *w); - void saveToXML(void); -}; - -class Merchant : public NPC { -public: - std::vector<Trade>trade; - uint currTrade; - - std::string text[4]; - std::string *toSay; - //greeting - //accept - //deny - //farewell - - void interact(); - Structures *inside; - - Merchant(); - ~Merchant(); - - void wander(int); - void saveToXML(void); -}; - -class Object : public Entity{ -public: - std::string iname; - std::string pickupDialog; - bool questObject = false; - - Object(); - Object(std::string in,std::string pd); - ~Object(); - - void reloadTexture(void); - - void interact(void); - - bool operator==(const Object &o) { - return (name == o.name) && (loc == o.loc); - } - void createFromXML(XMLElement *e, World *w); - void saveToXML(void); -}; - -/** - * The particle class, handles a single particle. - */ -class Particles{ -public: - // the location of the particle - vec2 loc; - float zOffset; - - // the width of the particle, in pixels - float width; - - // the height of the particle, in pixels - float height; - - // the velocity of the particle, in pixels - vec2 vel; - - // the color of the particle - Color color; - - // TODO - vec2 index; - - // the amount of milliseconds left for the particle to live - float duration; - - // when true, the particle will move - bool canMove; - - // TODO - bool fountain; - - // when true, the particle will be affected by gravity - bool gravity; - - // when true, draws the particle behind structures - bool behind; - - // when true, the particle will bounce on impact with ground - bool bounce; - - Structures *stu; - - Particles(void){} - - // creates a particle with the desired characteristics - Particles(float x, float y, float w, float h, float vx, float vy, Color c, float d); - - // allows the particle to be destroyed - ~Particles(void){} - - // draws the particle - void draw(GLfloat*& p) const; - - // updates a particle - void update(float _gravity, float ground_y); - - // returns true if the particle should be killed - bool timeUp(void); -}; - -#include <mob.hpp> - -constexpr Object *Objectp(Entity *e) { - return (Object *)e; -} - -constexpr NPC *NPCp(Entity *e) { - return (NPC *)e; -} - -constexpr Structures *Structurep(Entity *e) { - return (Structures *)e; -} - -constexpr Merchant *Merchantp(Entity *e) { - return (Merchant *)e; -} - -#include <entityx/entityx.h> -#include <events.hpp> - -class PlayerSystem : public entityx::System<PlayerSystem>, public entityx::Receiver<PlayerSystem> { -private: - Player **m_Player; - bool m_MoveLeft, m_MoveRight; - -public: - PlayerSystem(Player **p) - : m_Player(p), m_MoveLeft(false), m_MoveRight(false) {} - - void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; - - void configure(entityx::EventManager &ev); - void receive(const KeyDownEvent &kde); - void receive(const KeyUpEvent &kue); -}; - -void entityxTest(); - -#endif // ENTITIES_H - -/** -ENTITY TYPES --1 STRUCTURES -|->1 Village -|->2 Castle -| -0 PLAYERS -|->Player -| -1 NPCS -|->0 Base -|->1 Merchant -| -2 MOBS -|->1 Rabbit -|->2 Bird -**/ diff --git a/include/inventory.hpp.bak b/include/inventory.hpp.bak deleted file mode 100644 index 533318c..0000000 --- a/include/inventory.hpp.bak +++ /dev/null @@ -1,284 +0,0 @@ -#ifndef INVENTORY_H -#define INVENTORY_H - -#include <common.hpp> -#include <string.h> - -#include <texture.hpp> -#include <events.hpp> - -#define DEBUG - -class Entity; - -/** - * The base item class - * This stores the name, width, height, and texture(s) - */ -class Item { -private: - bool beingUsed; - -protected: - std::vector<Entity*> interact; - -public: - - // what we want to call each item - std::string name; - - // how many pixel tall and white each thing is - dim2 dim; - - // the total amount of this item each slot can have - uint maxStackSize; - - // the array of textures for each frame of animation - Texturec *tex; - - // how much the item is rotated in the hand - float rotation = 0.0f; - - // return if the item is currently in use - virtual bool inUse(); - - // set the state of the item - virtual void setUse(bool use); - - // add entities to the list of those being interacted - virtual void addInteract(Entity* e); - virtual void addInteract(std::vector<Entity*> e); - - /** - * The function we use to call the child classes ability - * Note: Since this function is abstract, we HAVE to create one for each - * child class/type of item. - */ - virtual int useItem()=0; - - virtual Item* clone()=0; - - // destructor - virtual ~Item(); - // return the first texture for the item - GLuint rtex(); - - // return the nth texture for the item - GLuint rtex(int n); -}; - -/** - * Class for blank items, we use this for items that do not have an ability - * Like Quest or Debug items - */ -class BaseItem : public Item { -public: - // since the items don't have a use, we don't make one for it - int useItem(); - - BaseItem* clone(); - - //~BaseItem(){} -}; - -/** - * Sword class. This is for swords, y'know. Pretty basic stuff - */ -class Sword : public Item { -// can't touch this -private: - /** - * How much damage our sword will do - * notice that it's private to avoid a change - */ - float damage; - - Ray hitbox; - -//can touch this -public: - /** - * Lets us return the amount of damage the sword has - * TODO takes into account enchants and/or buffs/nerfs - */ - //TODO move - float getDamage(); - - // set the damage of the sword - void setDamage(float d); - - /** - * handles the swinging of the sword - */ - //TODO move - int useItem(); - - Sword* clone(); -}; - -class Arrow : public Item { -private: - // same as sword - float damage; -public: - - // see sword - float getDamage(); - - // sets amount of damage - void setDamage(float d); - - // uses item - int useItem(); - - Arrow *clone(); -}; - -/** - * Bow class. We use this for shooting bow and arrows - */ -class Bow : public Item { -private: - // same as sword - float damage; -public: - // returns the amount of damage, see sword - float getDamage(); - - // sets the amount of damages - void setDamage(float d); - - // handles shooting and arrow curving - int useItem(); - - Bow* clone(); -}; - -/** - * Raw food class, this will be used for uncooked meats... - * TODO Eating this may cause health loss, salmonela, mad cow diese - */ -class RawFood : public Item { -private: - // the amount of the health the food heals - float health; - -public: - // since the health is private, we get how much it is here - float getHealth(); - - // TODO chance to hurt - virtual int useItem(); - - RawFood* clone(); -}; - -/** - * Cooked/Naturale food class - * When this food is consumed, higher stats are gained than Raw Food and - * there is no chance of damage/de-buffs - */ -class Food : public RawFood { -private: -public: - - // consume food in hand, no chance for de-buff; - int useItem(); - - Food* clone(); -}; - -class ItemLight : public Item { -private: - // the color of the light - Color color; -public: - // turn on/off the light - // TODO - int useItem(); - - ItemLight* clone(); -}; - -/** - * Currency class. Well, it's used for currency - */ -class NewCurrency : public Item { -private: - // how much the coin is "worth" so to say - int value; -public: - // get the value of the coin - int getValue(); - - // TODO maybe play a jingling noise - // probably won't have a use - int useItem(); - - NewCurrency(){} - ~NewCurrency(){} -}; - -/*********************************************************************************** - * OLD STUFF THAT NEEDS TO GET UPDATED * - **********************************************************************************/ - -using InventorySlot = std::pair<Item *, unsigned int>; - -class Inventory { -private: - unsigned int size; //how many slots our inventory has - unsigned int sel; //what item is currently selected - int os = 0; -public: - std::vector<InventorySlot> Items; - - bool invOpen = false; //is the inventory open - bool invOpening = false; //is the opening animation playing - bool invHover = false; //are we using the fancy hover inventory - bool selected = false; //used in hover inventory to show which item has been selected - bool mouseSel = false; //the location of the temperary selection for the hover inv - bool usingi = false; //bool used to tell if inventory owner is using selected item - - Inventory(unsigned int s); // Creates an inventory of size 's' - ~Inventory(void); // Free's allocated memory - - int useCurrent(); - void currentAddInteract(Entity* e); - void currentAddInteract(std::vector<Entity*> e); - - int addItem(std::string name,uint count); - int takeItem(std::string name,uint count); - int hasItem(std::string name); - - int useItem(void); - bool detectCollision(vec2,vec2); - - void setSelection(unsigned int s); - void setSelectionUp(); - void setSelectionDown(); - - void draw(void); // Draws a text list of items in this inventory (should only be called for the player for now) - - const Item* getCurrentItem(void); -}; - -void initInventorySprites(void); -void destroyInventory(void); - -const char *getItemTexturePath(std::string name); -GLuint getItemTexture(std::string name); -float getItemWidth(std::string name); -float getItemHeight(std::string name); - -#include <entityx/entityx.h> - -class InventorySystem : public entityx::System<InventorySystem>, public entityx::Receiver<InventorySystem> { -public: - void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; - - void configure(entityx::EventManager &em); - void receive(const MouseScrollEvent &mse); -}; - -#endif // INVENTORY_H diff --git a/include/mob.hpp.bak b/include/mob.hpp.bak deleted file mode 100644 index 24b8ed9..0000000 --- a/include/mob.hpp.bak +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef MOB_H_ -#define MOB_H_ - -#include <forward_list> -#include <tuple> - -#include <common.hpp> -#include <entities.hpp> -#include <gametime.hpp> -#include <ui.hpp> -#include <save_util.hpp> - -// local library headers -#include <tinyxml2.h> -using namespace tinyxml2; - -extern Player *player; -extern std::string currentXML; - -using Drop = std::tuple<std::string, unsigned int, float>; - -class Mob : public Entity { -protected: - XMLElement *xmle; - std::forward_list<Drop> drop; - - unsigned int actCounter; - unsigned int actCounterInitial; - bool ridable; -public: - Entity *rider; - bool aggressive; - std::string heyid; - - Mob(void); - ~Mob(void); - - void wander(void); - void ride(Entity *e); - virtual void act(void) =0; - - virtual void onHit(unsigned int) =0; - virtual void onDeath(void); - - virtual bool bindTex(void) =0; -}; - -constexpr Mob *Mobp(Entity *e) { - return (Mob *)e; -} - -class Page : public Mob { -private: - std::string cId, cValue; - std::string pageTexPath; - GLuint pageTexture; -public: - Page(void); - - void act(void); - void onHit(unsigned int); - bool bindTex(void); - void createFromXML(XMLElement *e, World *w) final; - void saveToXML(void) final; -}; - -class Door : public Mob { -public: - Door(void); - - void act(void); - void onHit(unsigned int); - bool bindTex(void); - void createFromXML(XMLElement *e, World *w) final; - void saveToXML(void) final; -}; - -class Cat : public Mob { -public: - Cat(void); - - void act(void); - void onHit(unsigned int); - bool bindTex(void); - void createFromXML(XMLElement *e, World *w) final; - void saveToXML(void) final; -}; - -class Rabbit : public Mob { -public: - Rabbit(void); - - void act(void); - void onHit(unsigned int); - bool bindTex(void); - void createFromXML(XMLElement *e, World *w) final; - void saveToXML(void) final; -}; - -class Bird : public Mob { -private: - float initialY; -public: - Bird(void); - - void act(void); - void onHit(unsigned int); - bool bindTex(void); - void createFromXML(XMLElement *e, World *w) final; - void saveToXML(void) final; -}; - -class Trigger : public Mob { -private: - std::string id; - bool triggered; -public: - bool notext; - - Trigger(void); - - void act(void); - void onHit(unsigned int); - bool bindTex(void); - void createFromXML(XMLElement *e, World *w) final; - void saveToXML(void) final; -}; - -class Chest : public Mob { -public: - Chest(void); - - void act(void); - void onHit(unsigned int); - bool bindTex(void); - void createFromXML(XMLElement *e, World *w) final; - void saveToXML(void) final; -}; - -#endif // MOB_H_ diff --git a/include/quest.hpp.bak b/include/quest.hpp.bak deleted file mode 100644 index 2db65a2..0000000 --- a/include/quest.hpp.bak +++ /dev/null @@ -1,66 +0,0 @@ -/** @file Quest.h
- * @brief The quest handling system.
- *
- * This file contains Quest and QuestHandler, used to manage quests inside the
- * game.
- */
-
-#ifndef QUEST_H
-#define QUEST_H
-
-#include <string>
-
-#include <inventory.hpp>
-
-/**
- * When defined, DEBUG allows extra messages to be printed to the terminal for
- * debugging purposes.
- */
-
-#define DEBUG
-
-typedef struct {
- std::string title;
- std::string desc;
- std::pair<std::string, uint> reward;
- std::vector<std::pair<std::string, int>> need;
-} Quest;
-
-/**
- * The Quest Handler class.
- *
- * This class handles quests, including the assigning, dropping, and completing
- * of the quests.
- */
-
-class QuestHandler {
-public:
- std::vector<Quest>current;
-
- /**
- * Adds a quest to the current quest vector by its title.
- */
-
- int assign(std::string title,std::string desc,std::string req);
-
- /**
- * Drops a quest through its title.
- */
-
- int drop(std::string title);
-
- /**
- * Finishes a quest through it's title, also giving a pointer to the Entity
- * that gave the quest originally.
- */
-
- int finish(std::string t);
-
- /**
- * Returns true if this handler is currently taking the quest.
- */
-
- bool hasQuest(std::string t);
-};
-
-#endif // QUEST_H
|