From a9a9777190086bd2ce2aa54e20a1101509614463 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 29 Mar 2016 08:48:52 -0400 Subject: began reworking indoors --- include/Quest.h | 72 ------------------------------------ include/Texture.h | 103 ---------------------------------------------------- include/common.h | 3 +- include/config.h | 16 +++----- include/entities.h | 6 +-- include/inventory.h | 2 +- include/quest.h | 66 +++++++++++++++++++++++++++++++++ include/texture.h | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/world.h | 13 +++++-- 9 files changed, 191 insertions(+), 193 deletions(-) delete mode 100644 include/Quest.h delete mode 100644 include/Texture.h create mode 100644 include/quest.h create mode 100644 include/texture.h (limited to 'include') diff --git a/include/Quest.h b/include/Quest.h deleted file mode 100644 index 8b1e142..0000000 --- a/include/Quest.h +++ /dev/null @@ -1,72 +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 - -#include -#include - -/** - * When defined, DEBUG allows extra messages to be printed to the terminal for - * debugging purposes. - */ - -#define DEBUG - -struct need_t { - std::string name; - int n; -}; - -typedef struct { - std::string title; - std::string desc; - struct item_t reward; - std::vector need; -} Quest; - -/** - * The Quest Handler class. - * - * This class handles quests, including the assigning, dropping, and completing - * of the quests. - */ - -class QuestHandler { -public: - std::vectorcurrent; - - /** - * 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 diff --git a/include/Texture.h b/include/Texture.h deleted file mode 100644 index 816a8bf..0000000 --- a/include/Texture.h +++ /dev/null @@ -1,103 +0,0 @@ -/** @file Texture.h - * @brief Defines a method for loading textures. - * - * This file gives facilities for easily loading and binding textures. - */ - -#ifndef TEXTURE_H -#define TEXTURE_H - -#include - -/** - * When defined, DEBUG allows extra messages to be printed to the terminal for - * debugging purposes. - */ - -#define DEBUG - -/** - * Texture functions are given a namespace for better organization. - */ - -namespace Texture { - - /** - * Loads a texture from the given file name, returning the GLuint used for - * later referencing of the texture. - */ - - GLuint loadTexture(std::string fileName); - - void freeTextures(void); - - void initColorIndex(); - vec2 getIndex(Color c); - dim2 imageDim(std::string fileName); -} - -/** - * The Texturec class. - * - * This class can handle an array of textures and allows easy binding of those - * textures. - */ - -class Texturec{ -private: - - /** - * Contains the index in the image array of the currently loaded texture. - */ - - unsigned int texState; - -public: - - /** - * Contains an array of the GLuints returned from Texture::loadTexture(). - */ - - std::vector image; - - /** - * Populates the image array from a list of strings, with each string as a - * separate argument. - */ - - Texturec(uint amt, ...); - - /** - * Populates the image array from an array of strings. - */ - - Texturec(uint amt,const char **paths); - Texturec(std::vectorvec); - Texturec( std::initializer_list l ); - - /** - * Frees memory taken by the image array. - */ - - ~Texturec(); - - /** - * Binds the next texture in the array, incrementing texState. - */ - - void bindNext(); - - /** - * Binds the previous texture in the array, decrementing texState. - */ - - void bindPrev(); - - /** - * Binds the texture with the provided index. - */ - - void bind(unsigned int); -}; - -#endif //TEXTURE_H diff --git a/include/common.h b/include/common.h index 6f453b0..216dc01 100644 --- a/include/common.h +++ b/include/common.h @@ -117,7 +117,7 @@ typedef col Color; * Define the game's name (displayed in the window title). */ -#define GAME_NAME "Independent Study v.0.6 alpha - NOW WITH more c++" +#define GAME_NAME "Independent Study v0.7 alpha - NOW WITH lights and snow and stuff" /** * The desired width of the game window. @@ -176,6 +176,7 @@ extern float VOLUME_SFX; */ #define DEBUG_printf( message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__ ) +#define C(x) std::cout << x << std::endl; /** * Defines pi for calculations that need it. diff --git a/include/config.h b/include/config.h index 4d56d9c..e2f7239 100644 --- a/include/config.h +++ b/include/config.h @@ -1,14 +1,10 @@ #ifndef CONFIG_H #define CONFIG_H -#include -#include -#include +namespace config { + void read( void ); + void update( void ); + void save( void ); +} -void readConfig(void); - -void updateConfig(void); - -void saveConfig(); - -#endif //CONFIG_H \ No newline at end of file +#endif //CONFIG_H diff --git a/include/entities.h b/include/entities.h index 1250708..f455726 100644 --- a/include/entities.h +++ b/include/entities.h @@ -2,9 +2,9 @@ #define ENTITIES_H #include -#include +#include #include -#include +#include #include @@ -14,7 +14,7 @@ #define Structurep(n) ((Structures *)n) #define Mobp(n) ((Mob *)n) -#define PLAYER_INV_SIZE 30 // The size of the player's inventory +#define PLAYER_INV_SIZE 43 // The size of the player's inventory #define NPC_INV_SIZE 3 // Size of an NPC's inventory enum _TYPE { diff --git a/include/inventory.h b/include/inventory.h index 7369642..08a145e 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -4,7 +4,7 @@ #include #include -#include +#include #define DEBUG diff --git a/include/quest.h b/include/quest.h new file mode 100644 index 0000000..4da38bf --- /dev/null +++ b/include/quest.h @@ -0,0 +1,66 @@ +/** @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 + +#include + +/** + * 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; + struct item_t reward; + std::vector> need; +} Quest; + +/** + * The Quest Handler class. + * + * This class handles quests, including the assigning, dropping, and completing + * of the quests. + */ + +class QuestHandler { +public: + std::vectorcurrent; + + /** + * 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 diff --git a/include/texture.h b/include/texture.h new file mode 100644 index 0000000..816a8bf --- /dev/null +++ b/include/texture.h @@ -0,0 +1,103 @@ +/** @file Texture.h + * @brief Defines a method for loading textures. + * + * This file gives facilities for easily loading and binding textures. + */ + +#ifndef TEXTURE_H +#define TEXTURE_H + +#include + +/** + * When defined, DEBUG allows extra messages to be printed to the terminal for + * debugging purposes. + */ + +#define DEBUG + +/** + * Texture functions are given a namespace for better organization. + */ + +namespace Texture { + + /** + * Loads a texture from the given file name, returning the GLuint used for + * later referencing of the texture. + */ + + GLuint loadTexture(std::string fileName); + + void freeTextures(void); + + void initColorIndex(); + vec2 getIndex(Color c); + dim2 imageDim(std::string fileName); +} + +/** + * The Texturec class. + * + * This class can handle an array of textures and allows easy binding of those + * textures. + */ + +class Texturec{ +private: + + /** + * Contains the index in the image array of the currently loaded texture. + */ + + unsigned int texState; + +public: + + /** + * Contains an array of the GLuints returned from Texture::loadTexture(). + */ + + std::vector image; + + /** + * Populates the image array from a list of strings, with each string as a + * separate argument. + */ + + Texturec(uint amt, ...); + + /** + * Populates the image array from an array of strings. + */ + + Texturec(uint amt,const char **paths); + Texturec(std::vectorvec); + Texturec( std::initializer_list l ); + + /** + * Frees memory taken by the image array. + */ + + ~Texturec(); + + /** + * Binds the next texture in the array, incrementing texState. + */ + + void bindNext(); + + /** + * Binds the previous texture in the array, decrementing texState. + */ + + void bindPrev(); + + /** + * Binds the texture with the provided index. + */ + + void bind(unsigned int); +}; + +#endif //TEXTURE_H diff --git a/include/world.h b/include/world.h index 0b87134..f730715 100644 --- a/include/world.h +++ b/include/world.h @@ -165,7 +165,7 @@ protected: * World::detect(), which is why it is declared private. */ - void singleDetect( Entity *e ); + virtual void singleDetect( Entity *e ); /** * Empties all entity vectors. @@ -386,7 +386,7 @@ public: * half-width to positive half-width. */ - virtual void generate(unsigned int width); + void generate(unsigned int width); /** * Sets the background theme, collecting the required textures into a @@ -482,11 +482,18 @@ public: */ class IndoorWorld : public World { +private: + + std::vector> floor; + + void singleDetect( Entity *e ); + public: IndoorWorld(void); ~IndoorWorld(void); - void generate(unsigned int width); // Generates a flat world of width 'width' + void addFloor( unsigned int width ); + void draw(Player *p); // Draws the world (ignores layers) }; -- cgit v1.2.3