]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
screenshots, arena door
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 15 Feb 2017 13:51:42 +0000 (08:51 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 15 Feb 2017 13:51:42 +0000 (08:51 -0500)
include/entities.hpp.bak [deleted file]
include/inventory.hpp.bak [deleted file]
include/mob.hpp.bak [deleted file]
include/quest.hpp.bak [deleted file]
src/components.cpp
src/ui.cpp
src/window.cpp
src/world.cpp

diff --git a/include/entities.hpp.bak b/include/entities.hpp.bak
deleted file mode 100644 (file)
index e460a27..0000000
+++ /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 (file)
index 533318c..0000000
+++ /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 (file)
index 24b8ed9..0000000
+++ /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 (file)
index 2db65a2..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/** @file Quest.h\r
- * @brief The quest handling system.\r
- *\r
- * This file contains Quest and QuestHandler, used to manage quests inside the\r
- * game.\r
- */\r
-\r
-#ifndef QUEST_H\r
-#define QUEST_H\r
-\r
-#include <string>\r
-\r
-#include <inventory.hpp>\r
-\r
-/**\r
- * When defined, DEBUG allows extra messages to be printed to the terminal for\r
- * debugging purposes.\r
- */\r
-\r
-#define DEBUG\r
-\r
-typedef struct {\r
-       std::string title;\r
-       std::string desc;\r
-       std::pair<std::string, uint> reward;\r
-       std::vector<std::pair<std::string, int>> need;\r
-} Quest;\r
-\r
-/**\r
- * The Quest Handler class.\r
- *\r
- * This class handles quests, including the assigning, dropping, and completing\r
- * of the quests.\r
- */\r
-\r
-class QuestHandler {\r
-public:\r
-       std::vector<Quest>current;\r
-\r
-       /**\r
-        * Adds a quest to the current quest vector by its title.\r
-        */\r
-\r
-       int assign(std::string title,std::string desc,std::string req);\r
-\r
-       /**\r
-        * Drops a quest through its title.\r
-        */\r
-\r
-       int drop(std::string title);\r
-\r
-       /**\r
-        * Finishes a quest through it's title, also giving a pointer to the Entity\r
-        * that gave the quest originally.\r
-        */\r
-\r
-       int finish(std::string t);\r
-\r
-       /**\r
-        * Returns true if this handler is currently taking the quest.\r
-        */\r
-\r
-       bool hasQuest(std::string t);\r
-};\r
-\r
-#endif // QUEST_H\r
index 19ba0fb6bf9117ac56e87fe1866a547e04ad7ba4..644d504af20d99fd046d629f976b77e6fc913844 100644 (file)
@@ -53,12 +53,12 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e
                        if (entity.has_component<Aggro>()) {
                                auto ppos = game::engine.getSystem<PlayerSystem>()->getPosition();
                                if (ppos.x > position.x && ppos.x < position.x + entity.component<Solid>()->width) {
-                                       //auto& h = entity.component<Health>()->health;
-                                       //if (h > 0) {
+                                       auto& h = entity.component<Health>()->health;
+                                       if (h > 0) {
                                                fight = true;
                                                toFight = entity;
-                                       //      h = 0;
-                                       //}
+                                               h = 0;
+                                       }
                                } else
                                        direction.x = (ppos.x > position.x) ? .05 : -.05;
                        } else if (entity.has_component<Wander>()) {
index b9c2119d78ad689583da66c2ef1c048456b9a078..58a6b97d7cb837813c40a967ebbde0ab08cd6574 100644 (file)
@@ -1103,14 +1103,6 @@ namespace ui {
                auto SCREEN_WIDTH = game::SCREEN_WIDTH;
                auto SCREEN_HEIGHT = game::SCREEN_HEIGHT;
 
-               std::vector<GLubyte> bgr (SCREEN_WIDTH * SCREEN_HEIGHT * 3, 0);
-
-               for(unsigned int x = 0; x < SCREEN_WIDTH*SCREEN_HEIGHT*3; x+=3) {
-                       bgr[x] = pixels[x+2];
-                       bgr[x+1] = pixels[x+1];
-                       bgr[x+2] = pixels[x];
-               }
-
                time_t epoch = time(nullptr);
                struct tm* timen = localtime(&epoch);
 
@@ -1161,7 +1153,7 @@ namespace ui {
 
                fwrite(&bmfh, 1,sizeof(BITMAPFILEHEADER),bmp);
                fwrite(&bmih, 1,sizeof(BITMAPINFOHEADER),bmp);
-               fwrite(&bgr, 1,3*SCREEN_WIDTH*SCREEN_HEIGHT,bmp);
+               fwrite(pixels, 1,3*SCREEN_WIDTH*SCREEN_HEIGHT*sizeof(GLubyte),bmp);
 
                delete[] pixels;
 
index 049ee69f530043239fed66dd24d16c9e1744b473..7d8f8e78ba1b472f0809586a907bcbb09f253187 100644 (file)
@@ -97,14 +97,10 @@ void WindowSystem::render(void)
        if (doScreenshot.load()) {
                doScreenshot.store(false);
                // Make the BYTE array, factor of 3 because it's RBG.
-               static GLubyte* pixels;
                int count = 3 * game::SCREEN_WIDTH * game::SCREEN_HEIGHT;
-               pixels = new GLubyte[count];
-               glReadPixels(0, 0, game::SCREEN_WIDTH, game::SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
-               //for(int i = 0; i < count; i++)
-               //      pixels[i] = 255;
+               GLubyte* pixels = new GLubyte[count];
+               glReadPixels(0, 0, game::SCREEN_WIDTH, game::SCREEN_HEIGHT, GL_BGR, GL_UNSIGNED_BYTE, pixels);
                ui::takeScreenshot(pixels);
-               std::cout << "Triggered\n";
        }
 
     SDL_GL_SwapWindow(window);
index 5d6202db63eda4e7eae1633739680f311839da2c..6c5851547e7e2c68d8c46b21a0d8dea06822fa6d 100644 (file)
@@ -157,10 +157,27 @@ static std::vector<entityx::Entity::Id> savedEntities;
 
 void WorldSystem::fight(entityx::Entity entity)
 {
-       savedEntities.clear();
+       std::string exit = currentXMLFile;
+
        savedEntities.emplace_back(entity.id());
        load(entity.component<Aggro>()->arena);
+       savedEntities.clear();
+
+       entity.component<Health>()->health = entity.component<Health>()->maxHealth;
        entity.remove<Aggro>();
+
+       auto door = game::entities.create();
+       door.assign<Position>(0, 100);
+       door.assign<Grounded>();
+       door.assign<Visible>(-5);
+       door.assign<Portal>(exit);
+
+       auto sprite = door.assign<Sprite>();
+       Texture dtex ("assets/style/classic/door.png");
+       sprite->addSpriteSegment(SpriteData(dtex), 0);
+
+       auto dim = sprite->getSpriteSize();
+       door.assign<Solid>(dim.x, dim.y);
 }
 
 void WorldSystem::load(const std::string& file)
@@ -173,7 +190,7 @@ void WorldSystem::load(const std::string& file)
        if (file.empty())
                return;
 
-       // insert smiley face showing teeth as if we're doing something bad
+       // save the current world's data
        save();
 
        // load file data to string