aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/entities.hpp41
-rw-r--r--include/mob.hpp87
-rw-r--r--include/ui.hpp2
-rw-r--r--include/world.hpp7
4 files changed, 97 insertions, 40 deletions
diff --git a/include/entities.hpp b/include/entities.hpp
index 864c863..567380a 100644
--- a/include/entities.hpp
+++ b/include/entities.hpp
@@ -42,19 +42,6 @@ enum GENDER{
};
/**
- * An enumerator for mob types.. 'species'.
- * The subtype of a Mob will affect what texture is used to draw it as well as
- * how the Mob will behave.
- */
-enum MOB_SUB {
- MS_RABBIT = 1, /**< rabbits */
- MS_BIRD, /**< birds */
- MS_TRIGGER, /**< triggers, used to cue cutscenes */
- MS_DOOR, /**< doors, for exiting arenas */
- MS_PAGE /**< pages, cues page overlay */
-};
-
-/**
* An enumerator for strcture types.
* The subtype of a structure will affect how it is drawn and how it functions.
*/
@@ -190,9 +177,6 @@ protected:
// if set false, entity will be destroyed
bool alive;
- // if not null, the entity will move towards this one
- Entity *followee;
-
// TODO
float targetx;
@@ -259,6 +243,7 @@ public:
// 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){}
@@ -360,19 +345,6 @@ public:
void wander(int);
};
-class Mob : public Entity{
-public:
- bool aggressive;
- double init_y;
- void (*hey)(Mob *callee);
- std::string heyid;
-
- Mob(int);
- ~Mob();
-
- void wander(int);
-};
-
class Object : public Entity{
private:
std::string iname;
@@ -424,13 +396,10 @@ public:
void makeFlame(void){
flame = true;
}
-
- void follow(Entity *f){
- following = f;
- belongsTo = true;
- }
};
+#include <mob.hpp>
+
constexpr Object *Objectp(Entity *e) {
return (Object *)e;
}
@@ -443,8 +412,8 @@ constexpr Structures *Structurep(Entity *e) {
return (Structures *)e;
}
-constexpr Mob *Mobp(Entity *e) {
- return (Mob *)e;
+constexpr Merchant *Merchantp(Entity *e) {
+ return (Merchant *)e;
}
#endif // ENTITIES_H
diff --git a/include/mob.hpp b/include/mob.hpp
new file mode 100644
index 0000000..0ed6bc1
--- /dev/null
+++ b/include/mob.hpp
@@ -0,0 +1,87 @@
+#ifndef MOB_H_
+#define MOB_H_
+
+#include <common.hpp>
+#include <entities.hpp>
+#include <gametime.hpp>
+#include <ui.hpp>
+
+// local library headers
+#include <tinyxml2.h>
+using namespace tinyxml2;
+
+extern Player *player;
+extern std::string currentXML;
+
+class Mob : public Entity {
+protected:
+ unsigned int actCounter;
+ unsigned int actCounterInitial;
+public:
+ bool aggressive;
+ std::string heyid;
+
+ ~Mob(void);
+
+ void wander(void);
+ virtual void act(void) =0;
+ virtual bool bindTex(void) =0;
+ virtual void createFromXML(const XMLElement *e) =0;
+};
+
+constexpr Mob *Mobp(Entity *e) {
+ return (Mob *)e;
+}
+
+class Page : public Mob {
+private:
+ std::string pageTexPath;
+public:
+ Page(void);
+
+ void act(void);
+ bool bindTex(void);
+ void createFromXML(const XMLElement *e);
+};
+
+class Door : public Mob {
+public:
+ Door(void);
+
+ void act(void);
+ bool bindTex(void);
+ void createFromXML(const XMLElement *e);
+};
+
+class Rabbit : public Mob {
+public:
+ Rabbit(void);
+
+ void act(void);
+ bool bindTex(void);
+ void createFromXML(const XMLElement *e);
+};
+
+class Bird : public Mob {
+private:
+ float initialY;
+public:
+ Bird(void);
+
+ void act(void);
+ bool bindTex(void);
+ void createFromXML(const XMLElement *e);
+};
+
+class Trigger : public Mob {
+private:
+ std::string id;
+public:
+ Trigger(void);
+
+ void act(void);
+ bool bindTex(void);
+ void createFromXML(const XMLElement *e);
+};
+
+#endif // MOB_H_
diff --git a/include/ui.hpp b/include/ui.hpp
index 9e69497..7cee885 100644
--- a/include/ui.hpp
+++ b/include/ui.hpp
@@ -21,10 +21,10 @@
// local game headers
#include <common.hpp>
#include <config.hpp>
+#include <entities.hpp>
#include <inventory.hpp>
#include <ui_menu.hpp>
#include <ui_action.hpp>
-#include <world.hpp>
// local library headers
#include <SDL2/SDL_opengl.h>
diff --git a/include/world.hpp b/include/world.hpp
index dc8d497..b99e9ab 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -159,7 +159,7 @@ public:
virtual ~World(void);
// generates a world of the specified width
- void generate(unsigned int width);
+ void generate(int width);
// draws everything to the screen
virtual void draw(Player *p);
@@ -233,8 +233,9 @@ public:
void addMerchant(float x, float y, bool housed);
- void addMob(int type, float x, float y);
- void addMob(int type, float x, float y, void (*hey)(Mob *));
+ //void addMob(int type, float x, float y);
+ //void addMob(int type, float x, float y, void (*hey)(Mob *));
+ void addMob(Mob *m, vec2 coord);
void addNPC(float x, float y);