diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/entities.hpp.bak (renamed from include/entities.hpp) | 0 | ||||
-rw-r--r-- | include/inventory.hpp.bak (renamed from include/inventory.hpp) | 0 | ||||
-rw-r--r-- | include/mob.hpp.bak (renamed from include/mob.hpp) | 0 | ||||
-rw-r--r-- | include/quest.hpp.bak (renamed from include/quest.hpp) | 0 | ||||
-rw-r--r-- | include/ui.hpp | 8 | ||||
-rw-r--r-- | include/ui_action.hpp.bak (renamed from include/ui_action.hpp) | 0 | ||||
-rw-r--r-- | include/ui_quest.hpp | 4 | ||||
-rw-r--r-- | include/world.hpp | 390 |
8 files changed, 49 insertions, 353 deletions
diff --git a/include/entities.hpp b/include/entities.hpp.bak index 945e8c8..945e8c8 100644 --- a/include/entities.hpp +++ b/include/entities.hpp.bak diff --git a/include/inventory.hpp b/include/inventory.hpp.bak index 533318c..533318c 100644 --- a/include/inventory.hpp +++ b/include/inventory.hpp.bak diff --git a/include/mob.hpp b/include/mob.hpp.bak index 24b8ed9..24b8ed9 100644 --- a/include/mob.hpp +++ b/include/mob.hpp.bak diff --git a/include/quest.hpp b/include/quest.hpp.bak index 2db65a2..2db65a2 100644 --- a/include/quest.hpp +++ b/include/quest.hpp.bak diff --git a/include/ui.hpp b/include/ui.hpp index 8671393..c7a69b6 100644 --- a/include/ui.hpp +++ b/include/ui.hpp @@ -21,10 +21,9 @@ // local game headers #include <common.hpp> #include <config.hpp> -#include <entities.hpp> -#include <inventory.hpp> +//#include <inventory.hpp> #include <ui_menu.hpp> -#include <ui_action.hpp> +//#include <ui_action.hpp> // local library headers #include <SDL2/SDL_opengl.h> @@ -71,7 +70,6 @@ namespace ui { extern bool posFlag; extern unsigned char dialogOptChosen; - extern unsigned char merchOptChosen; extern bool dialogBoxExists; extern bool dialogImportant; extern bool dialogPassive; @@ -123,8 +121,6 @@ namespace ui { void drawBox(vec2 c1, vec2 c2); void drawNiceBox(vec2 c1, vec2 c2, float z); void dialogBox(std::string name, std::string opt, bool passive, std::string text, ...); - void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...); - void merchantBox(); void closeBox(); void waitForDialog(void); diff --git a/include/ui_action.hpp b/include/ui_action.hpp.bak index a275ab3..a275ab3 100644 --- a/include/ui_action.hpp +++ b/include/ui_action.hpp.bak diff --git a/include/ui_quest.hpp b/include/ui_quest.hpp index 24a5e1b..8582b67 100644 --- a/include/ui_quest.hpp +++ b/include/ui_quest.hpp @@ -27,14 +27,14 @@ namespace ui { ui::putStringCentered(offset.x, top_y - 40, "Current Quests:"); - auto y = top_y - 100; + /*auto y = top_y - 100; const auto x = offset.x - 180; for (const auto &q : player->qh.current) { ui::putText(x, y, q.title.c_str()); y -= 20; ui::putText(x + 40, y, q.desc.c_str()); y -= 40; - } + }*/ std::swap(textWrap, ui::textWrapLimit); } diff --git a/include/world.hpp b/include/world.hpp index dc07267..36ccdfa 100644 --- a/include/world.hpp +++ b/include/world.hpp @@ -8,9 +8,13 @@ // local game includes #include <common.hpp> -#include <entities.hpp> #include <coolarray.hpp> +#include <events.hpp> +#include <texture.hpp> +#include <tinyxml2.h> +using namespace tinyxml2; + /** * The background type enum. * This enum contains all different possibilities for world backgrounds; used @@ -44,13 +48,6 @@ typedef struct { } WorldData; /** - * Contains info necessary for switching worlds. - * This pair contains a pointer to the new world, and the new set of - * coordinates the player should be at in that world. - */ -using WorldSwitchInfo = std::pair<World *, vec2>; - -/** * Alters how bright world elements are drawn. * This value is based off of the current time of day (tick count), set in * main.cpp. @@ -95,41 +92,6 @@ constexpr const unsigned int INDOOR_FLOOR_HEIGHTT = 400; */ constexpr const unsigned int INDOOR_FLOOR_HEIGHT = (INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS); -/** - * The village class. - * This class defines an area in a world that is considered to be a village, - * and provides a welcome message when the player enters the area. - */ -class Village { -public: - /** - * The name of the village. - */ - std::string name; - - /** - * The start and end coordinates of the village. - */ - vec2 start, end; - - /** - * A "player in village" flag. - * This flag is used to trigger displaying the welcome message. - */ - bool in; - - /** - * Constructs a village with the given name, inside the given world. - */ - Village(std::string meme, World *w); - - /** - * Destructs the village. - */ - ~Village(void){} -}; - - #include <entityx/entityx.h> constexpr const char* WorldWeatherString[3] = { @@ -138,20 +100,45 @@ constexpr const char* WorldWeatherString[3] = { "Snowy" }; +struct WorldData2 { + // data + std::vector<WorldData> data; + float startX; + + // indoor + bool indoor; + float indoorWidth; + GLuint indoorTex; + + // links + std::string toLeft, toRight; + + // style + WorldBGType style; + std::string styleFolder; + std::vector<std::string> sTexLoc; + + // music + std::string bgm; + + // village + float villageStart, villageEnd; +}; + class WorldSystem : public entityx::System<WorldSystem>, public entityx::Receiver<WorldSystem> { private: - World *world; - World *outside; + WorldData2 world; WorldWeather weather; Mix_Music *bgmObj; - std::string bgmObjFile; std::vector<std::string> bgFiles; TextureIterator bgTex; + XMLDocument xmlDoc; + public: explicit WorldSystem(void); ~WorldSystem(void); @@ -160,13 +147,14 @@ public: ev.subscribe<BGMToggleEvent>(*this); } + inline float getWidth(void) const + { return world.startX * -2.0f; } + void receive(const BGMToggleEvent &bte); void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; void render(void); - void setWorld(World *w); - inline const std::string getWeatherStr(void) const { return WorldWeatherString[static_cast<int>(weather)]; } @@ -175,299 +163,20 @@ public: void setWeather(const std::string &s); - void singleDetect(Entity *e, entityx::TimeDelta dt); void detect(entityx::TimeDelta dt); - void detect2(entityx::TimeDelta dt); - - void enterWorld(World *w); - void leaveWorld(void); -}; - - -/** - * The world class. - * This class handles entity creation, management, and deletion. Most - * world-related operations have to be done through this class, such as - * drawing. - */ -class World { -private: - bool m_Indoor; - -public: - - float HouseWidth; - GLuint houseTex; - - inline bool isIndoor(void) const - { return m_Indoor; } - - WorldBGType bgType; - - std::string styleFolder; + void goWorldLeft(void) {} + void goWorldRight(void) {} - /** - * An array of all the world's ground data, populated through - * World::generate(). - * @see generate() - */ - std::vector<WorldData> worldData; - - /** - * Contains the size of the 'worldData' array. - */ - unsigned int lineCount; - - /** - * The starting x-coordinate of the world. - */ - float worldStart; - - /** - * The path to the XML file of the world to the left. - * - * @see setToLeft() - */ - std::string toLeft; - - /** - * The path to the XML file of the world to the right. - * - * @see setToRight() - */ - std::string toRight; - - /** - * A vector of paths for the structure textures. - * The appearance of structures depends on the world's theme. - * - * @see setStyle() - */ - std::vector<std::string> sTexLoc; - - /** - * Contains randomly generated coordinates for stars. - */ - std::vector<vec2> star; - - /** - * A vector of all light elements in the world. - * - * @see addLight() - * @see getLastLight() - */ - std::vector<Light> light; - - /** - * A vector of all villages in the world. - * - * @see addVillage() - */ - std::vector<Village> village; - - std::vector<Entity *> entityPending; - - /** - * Destroys entities and clears vectors that contain them. - * This function is only called in the world destructor. - */ - void deleteEntities(void); - - /** - * The filename of the world's BGM file. - * - * @see setBGM() - */ - std::string bgm; - - CoolArray<Particles> particles; - - /** - * A vector of pointers to all entities from the other vectors. - * This is used to mass-manage entities, or operate on entities - * outside of what the world does. - * - * @see getNearInteractable() - */ - std::vector<Entity *> entity; - - /** - * Constructs the world, resets variables. - */ - World(bool indoor = false); - - /** - * Destructs the world, frees memory. - */ - virtual ~World(void); - - /** - * Generates a world of the specified width. - * This will populate the 'worldData' array and create star coordinates. - * It's necessary to call this function to actually use the world. - */ - void generate(int width); - - /** - * Draws everything the world handles to the screen (and the player). - * Drawing is based off of the player so that off-screen elements are not - * drawn. - */ - virtual void draw(Player *p); - - /** - * Gets the width of the world, presumably in pixels. - * TODO - */ - int getTheWidth(void) const; - - /** - * Gets the starting x-coordinate of the world. - * - * @see worldStart - */ - float getWorldStart(void) const; - - inline unsigned int getEntityCount(void) const { - return entity.size(); - } + // worlddata2 stuff + WorldData2 worldData; - /** - * Gets a pointer to the most recently created light. - * This is used to update properties of the light outside of the - * world class. - */ - Light& getLastLight(void); + void generate(unsigned int width = 0); + void addHole(const unsigned int& start, const unsigned int& end); + void addHill(const ivec2& peak, const unsigned int& width); - /** - * Gets a pointer ot the most recently created mob. - * This is used to update properties of the mob outside of the - * world class. - */ - Mob* getLastMob(void); - - /** - * Finds the entity nearest to the provided one. - */ - Entity* getNearInteractable(Entity &e); - - /** - * Finds the mob nearest to the given entity. - */ - Mob* getNearMob(Entity &e); - - /** - * Gets the coordinates of the `index`th structure. - */ - vec2 getStructurePos(int index); - - /** - * Gets the texture path of the `index`th structure - */ - std::string getSTextureLocation(unsigned int index) const; - - // saves the world's data to an XML file, either the one provided or the current path - void save(const std::string& s=""); - - // sets the world's background theme - void setBackground(WorldBGType bgt); - - // sets the folder to collect entity textures from - void setStyle(std::string pre); - - // gets the string that represents the current weather - std::string getWeatherStr(void) const; - const WorldWeather& getWeatherId(void) const; - - // sets the weatherrrr - void setWeather(const std::string& w); - - // sets / gets pathnames of XML files for worlds to the left and right - std::string setToLeft(std::string file); - std::string setToRight(std::string file); - std::string getToLeft(void) const; - std::string getToRight(void) const; - - // attempts to enter the left/right adjacent world, returning either that world or this - WorldSwitchInfo goWorldLeft(Player *p); - WorldSwitchInfo goWorldRight(Player *p); - - /** - * Attempts to move an NPC to the left adjacent world, returning true on success. - */ - bool goWorldLeft(NPC *e); - - /** - * Attempts to move an NPC to the world to the right, returning true on success. - */ - bool goWorldRight(NPC *e); - - // attempts to enter a structure that the player would be standing in front of - WorldSwitchInfo goInsideStructure(Player *p); - - /** - * Adopts an NPC from another world, taking its ownership. - */ - void adoptNPC(NPC *e); - - /** - * Adopts a mob from another world, taking its ownership. - */ - void adoptMob(Mob *e); - - // adds a hole at the specified start and end x-coordinates - void addHole(unsigned int start,unsigned int end); - - // adds a hill that peaks at the given coordinate and is `width` HLINEs wide - void addHill(ivec2 peak, unsigned int width); - - // functions to add entities to the world - void addLight(vec2 xy, float radius, Color color); - - void addMerchant(float x, float y, bool housed); - - void addMob(Mob *m, vec2 coord); - - void addNPC(NPC *n); - - void addObject(std::string in, std::string pickupDialog, float x, float y); - - void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int dur); - void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int dur, unsigned char flags); - - void addStructure(Structures *s); - - Village *addVillage(std::string name, World *world); -}; - -/** - * The arena class - creates an arena. - * - * This world, when created, expects a pointer to a Mob. This mob will be - * transported to a temporary world with the player, and the Mob will be - * killed upon exiting the arena. - */ - -class Arena : public World { -private: - - // the mob that the player is fighting - Mob *mmob; - -public: - - // creates the arena with the world being left for it - Arena(void); - - // frees memory - ~Arena(void); - - // starts a new fight?? - void fight(World *leave, const Player *p, Mob *m); - - // attempts to exit the arena, returning what world the player should be in - WorldSwitchInfo exitArena(Player *p); + bool save(const std::string& file); + void load(const std::string& file); }; /** @@ -495,13 +204,4 @@ World *loadWorldFromXMLNoTakeover(std::string path); */ World *loadWorldFromPtr(World *ptr); -/** - * Casts a normal world to an indoor world, to access IndoorWorld-exclusive - * elements. - */ -constexpr IndoorWorld *Indoorp(World *w) -{ - return (IndoorWorld *)w; -} - #endif // WORLD_H |