<item name="Dank MayMay" type="Tool" maxStackSize="420" width="10" height="10" sprite="assets/items/ITEM_TEST.png" />
<item name="Your Bag" type="Equip" maxStackSize="1" width="5" height="5" sprite="assets/items/ITEM_TEST.png" />
<item name="Flashlight" type="Tool" maxStackSize="1" width="4" height="8" sprite="assets/items/flashlight_off.png" />
-<item name="Wood Sword" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword" type="Sword" damage="69" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword2" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword3" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword4" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword5" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword6" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword7" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword8" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword9" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword10" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword11" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword12" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword13" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword14" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword15" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword16" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword17" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword18" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword19" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword20" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword21" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword22" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword23" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword24" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword25" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword26" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword27" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword28" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword29" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword30" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword31" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword32" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword33" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword34" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword35" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword36" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword37" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword38" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+<item name="Wood Sword39" type="Sword" maxStackSize="1" width="4" height="10" sprite="assets/items/SWORD_WOOD.png" />
+++ /dev/null
-/** @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 <cstring>\r
-\r
-#include <common.h>\r
-#include <inventory.h>\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
-struct need_t {\r
- std::string name;\r
- int n;\r
-};\r
-\r
-typedef struct {\r
- std::string title;\r
- std::string desc;\r
- struct item_t reward;\r
- std::vector<struct need_t> 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
--- /dev/null
+/** @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 <cstring>\r
+\r
+#include <common.hpp>\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
+struct need_t {\r
+ std::string name;\r
+ int n;\r
+};\r
+\r
+typedef struct {\r
+ std::string title;\r
+ std::string desc;\r
+ struct item_t reward;\r
+ std::vector<struct need_t> 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
+++ /dev/null
-/** @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 <common.h>
-
-/**
- * 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<GLuint> 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::vector<std::string>vec);
- Texturec( std::initializer_list<std::string> 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
--- /dev/null
+/** @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 <common.hpp>
+
+/**
+ * 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<GLuint> 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::vector<std::string>vec);
+ Texturec( std::initializer_list<std::string> 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
+++ /dev/null
-/** @file common.h
- * @brief Common items needed by most other files.
- *
- * This file contains headers, variables and functions that are needed in
- * most other files included in this project.
- */
-
-#ifndef COMMON_H
-#define COMMON_H
-
-// holy moly
-#include <iostream>
-#include <cstdlib>
-#include <string>
-#include <vector>
-#include <string>
-#include <fstream>
-#include <thread>
-#include <mutex>
-#include <future>
-#include <math.h>
-#include <threadpool.h>
-#include <algorithm>
-
-#define GLEW_STATIC
-#include <GL/glew.h>
-
-#include <SDL2/SDL.h>
-#include <SDL2/SDL_opengl.h>
-#include <SDL2/SDL_image.h>
-#include <SDL2/SDL_mixer.h>
-
-#ifdef __WIN32__
-typedef unsigned int uint;
-#undef near
-#endif
-
-/**
- * This flag lets the compiler know that we want to use shaders.
- */
-
-#define SHADERS
-
-template<typename N>
-N abso(N v){
- if(v < 0){
- return v * -1;
- }else
- return v;
-}
-
-template<class A>
-float averagef(A v){
- float avg = 0;
- for(auto &a : v){
- avg += a;
- }
- avg /= v.size();
- return avg;
-}
-
-
-extern GLuint colorIndex; // Texture.cpp?
-
-/**
- * This structure contains a set of coordinates for ease of coding.
- */
-
-typedef struct {
- int x;
- int y;
-} ivec2;
-
-typedef struct {
- float x;
- float y;
-} vec2;
-
-typedef struct {
- float x;
- float y;
- float z;
-} vec3;
-
-typedef ivec2 dim2;
-
-/**
- * This structure contains two sets of coordinates for ray drawing.
- */
-
-typedef struct {
- vec2 start;
- vec2 end;
-} Ray;
-
-struct col {
- float red;
- float green;
- float blue;
- col operator-=(float a){
- red-=a;
- green-=a;
- blue-=a;
- return{red+a,green+a,blue+a};
- }
- col operator+=(float a){
- return{red+a,green+a,blue+a};
- }
- col operator=(float a){
- return{red=a,green=a,blue=a};
- }
-};
-
-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++"
-
-/**
- * The desired width of the game window.
- */
-
-extern unsigned int SCREEN_WIDTH;
-
-/**
- * The desired height of the game window.
- */
-
-extern unsigned int SCREEN_HEIGHT;
-
-extern bool FULLSCREEN;
-extern bool uiLoop;
-extern std::mutex mtx;
-
-/**
- * Define the length of a single HLINE.
- * The game has a great amount of elements that need to be drawn or detected, and having each
- * of them use specific hard-coded numbers would be painful to debug. As a solution, this
- * definition was made. Every item being drawn to the screen and most object detection/physic
- * handling is done based off of this number. Increasing it will give the game a zoomed-in
- * feel, while decreasing it will do the opposite.
- *
- */
-
-extern unsigned int HLINE;
-
-extern float VOLUME_MASTER;
-extern float VOLUME_MUSIC;
-extern float VOLUME_SFX;
-/**
- * A 'wrapper' for libc's srand(), as we hope to eventually have our own random number
- * generator.
- */
-
-#define initRand(s) srand(s)
-
-/**
- * A 'wrapper' for libc's rand(), as we hope to eventually have our own random number
- * generator.
- */
-
-#define getRand() rand()
-
-#define randGet rand
-#define randInit srand
-
-/**
- * Included in common.h is a prototype for DEBUG_prints, which writes a formatted
- * string to the console containing the callee's file and line number. This macro simplifies
- * it to a simple printf call.
- *
- * DEBUG must be defined for this macro to function.
- */
-
-#define DEBUG_printf( message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__ )
-
-/**
- * Defines pi for calculations that need it.
- */
-
-#define PI 3.1415926535
-
-
-/**
- * References the variable in main.cpp, used for smoother drawing.
- */
-
-extern unsigned int deltaTime;
-
-/**
- * References the variable in main.cpp, used for drawing with the player.
- */
-
-extern vec2 offset;
-
-/**
- * Counts the number of times logic() (see main.cpp) has been called, for animating
- * sprites.
- */
-extern unsigned int loops;
-
-extern GLuint shaderProgram;
-
-/**
- * Prints a formatted debug message to the console, along with the callee's file and line
- * number.
- */
-
-void DEBUG_prints(const char* file, int line, const char *s,...);
-
-/**
- * Sets color using glColor3ub(), but handles potential overflow.
- */
-
-void safeSetColor(int r,int g,int b);
-
-/**
- * Sets color using glColor4ub(), but handles potential overflow.
- */
-
-void safeSetColorA(int r,int g,int b,int a);
-
-
-/**
- * We've encountered many problems when attempting to create delays for triggering
- * the logic function. As a result, we decided on using the timing libraries given
- * by <chrono> in the standard C++ library. This function simply returns the amount
- * of milliseconds that have passed since the epoch.
- */
-
-#ifdef __WIN32__
-#define millis() SDL_GetTicks()
-#else
-unsigned int millis(void);
-#endif // __WIN32__
-
-int getdir(const char *dir, std::vector<std::string> &files);
-void strVectorSortAlpha(std::vector<std::string> *v);
-
-const char *readFile(const char *path);
-
-int strCreateFunc(const char *equ);
-
-template<typename N, size_t s>
-size_t arrAmt(N (&)[s]){return s;}
-
-void UserError(std::string reason);
-
-#endif // COMMON_H
--- /dev/null
+/** @file common.h
+ * @brief Common items needed by most other files.
+ *
+ * This file contains headers, variables and functions that are needed in
+ * most other files included in this project.
+ */
+
+#ifndef COMMON_H
+#define COMMON_H
+
+// holy moly
+#include <iostream>
+#include <cstdlib>
+#include <string>
+#include <vector>
+#include <string>
+#include <fstream>
+#include <thread>
+#include <mutex>
+#include <future>
+#include <math.h>
+#include <threadpool.hpp>
+#include <algorithm>
+
+#define GLEW_STATIC
+#include <GL/glew.h>
+
+#include <SDL2/SDL.h>
+#include <SDL2/SDL_opengl.h>
+#include <SDL2/SDL_image.h>
+#include <SDL2/SDL_mixer.h>
+
+#ifdef __WIN32__
+typedef unsigned int uint;
+#undef near
+#endif
+
+/**
+ * This flag lets the compiler know that we want to use shaders.
+ */
+
+#define SHADERS
+#define C(x) std::cout << x << std::endl
+
+template<typename N>
+N abso(N v){
+ if(v < 0){
+ return v * -1;
+ }else
+ return v;
+}
+
+template<class A>
+float averagef(A v){
+ float avg = 0;
+ for(auto &a : v){
+ avg += a;
+ }
+ avg /= v.size();
+ return avg;
+}
+
+
+extern GLuint colorIndex; // Texture.cpp?
+
+/**
+ * This structure contains a set of coordinates for ease of coding.
+ */
+
+typedef struct {
+ int x;
+ int y;
+} ivec2;
+
+typedef struct {
+ float x;
+ float y;
+} vec2;
+
+typedef struct {
+ float x;
+ float y;
+ float z;
+} vec3;
+
+typedef ivec2 dim2;
+
+/**
+ * This structure contains two sets of coordinates for ray drawing.
+ */
+
+typedef struct {
+ vec2 start;
+ vec2 end;
+} Ray;
+
+struct col {
+ float red;
+ float green;
+ float blue;
+ col operator-=(float a){
+ red-=a;
+ green-=a;
+ blue-=a;
+ return{red+a,green+a,blue+a};
+ }
+ col operator+=(float a){
+ return{red+a,green+a,blue+a};
+ }
+ col operator=(float a){
+ return{red=a,green=a,blue=a};
+ }
+};
+
+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++"
+
+/**
+ * The desired width of the game window.
+ */
+
+extern unsigned int SCREEN_WIDTH;
+
+/**
+ * The desired height of the game window.
+ */
+
+extern unsigned int SCREEN_HEIGHT;
+
+extern bool FULLSCREEN;
+extern bool uiLoop;
+extern std::mutex mtx;
+
+/**
+ * Define the length of a single HLINE.
+ * The game has a great amount of elements that need to be drawn or detected, and having each
+ * of them use specific hard-coded numbers would be painful to debug. As a solution, this
+ * definition was made. Every item being drawn to the screen and most object detection/physic
+ * handling is done based off of this number. Increasing it will give the game a zoomed-in
+ * feel, while decreasing it will do the opposite.
+ *
+ */
+
+extern unsigned int HLINE;
+
+extern float VOLUME_MASTER;
+extern float VOLUME_MUSIC;
+extern float VOLUME_SFX;
+/**
+ * A 'wrapper' for libc's srand(), as we hope to eventually have our own random number
+ * generator.
+ */
+
+#define initRand(s) srand(s)
+
+/**
+ * A 'wrapper' for libc's rand(), as we hope to eventually have our own random number
+ * generator.
+ */
+
+#define getRand() rand()
+
+#define randGet rand
+#define randInit srand
+
+/**
+ * Included in common.h is a prototype for DEBUG_prints, which writes a formatted
+ * string to the console containing the callee's file and line number. This macro simplifies
+ * it to a simple printf call.
+ *
+ * DEBUG must be defined for this macro to function.
+ */
+
+#define DEBUG_printf( message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__ )
+
+/**
+ * Defines pi for calculations that need it.
+ */
+
+#define PI 3.1415926535
+
+
+/**
+ * References the variable in main.cpp, used for smoother drawing.
+ */
+
+extern unsigned int deltaTime;
+
+/**
+ * References the variable in main.cpp, used for drawing with the player.
+ */
+
+extern vec2 offset;
+
+/**
+ * Counts the number of times logic() (see main.cpp) has been called, for animating
+ * sprites.
+ */
+extern unsigned int loops;
+
+extern GLuint shaderProgram;
+
+/**
+ * Prints a formatted debug message to the console, along with the callee's file and line
+ * number.
+ */
+
+void DEBUG_prints(const char* file, int line, const char *s,...);
+
+/**
+ * Sets color using glColor3ub(), but handles potential overflow.
+ */
+
+void safeSetColor(int r,int g,int b);
+
+/**
+ * Sets color using glColor4ub(), but handles potential overflow.
+ */
+
+void safeSetColorA(int r,int g,int b,int a);
+
+
+/**
+ * We've encountered many problems when attempting to create delays for triggering
+ * the logic function. As a result, we decided on using the timing libraries given
+ * by <chrono> in the standard C++ library. This function simply returns the amount
+ * of milliseconds that have passed since the epoch.
+ */
+
+#ifdef __WIN32__
+#define millis() SDL_GetTicks()
+#else
+unsigned int millis(void);
+#endif // __WIN32__
+
+int getdir(const char *dir, std::vector<std::string> &files);
+void strVectorSortAlpha(std::vector<std::string> *v);
+
+const char *readFile(const char *path);
+
+int strCreateFunc(const char *equ);
+
+template<typename N, size_t s>
+size_t arrAmt(N (&)[s]){return s;}
+
+void UserError(std::string reason);
+
+#endif // COMMON_H
+++ /dev/null
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#include <iostream>
-#include <SDL2/SDL_mixer.h>
-#include <tinyxml2.h>
-
-void readConfig(void);
-
-void updateConfig(void);
-
-void saveConfig();
-
-#endif //CONFIG_H
\ No newline at end of file
--- /dev/null
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include <iostream>
+#include <SDL2/SDL_mixer.h>
+#include <tinyxml2.h>
+
+void readConfig(void);
+
+void updateConfig(void);
+
+void saveConfig();
+
+#endif //CONFIG_H
\ No newline at end of file
+++ /dev/null
-#ifndef ENTITIES_H
-#define ENTITIES_H
-
-#include <common.h>
-#include <Quest.h>
-#include <inventory.h>
-#include <Texture.h>
-
-#include <sstream>
-
-#define DEBUG
-
-#define NPCp(n) ((NPC *)n)
-#define Structurep(n) ((Structures *)n)
-#define Mobp(n) ((Mob *)n)
-
-#define PLAYER_INV_SIZE 30 // The size of the player's inventory
-#define NPC_INV_SIZE 3 // Size of an NPC's inventory
-
-enum _TYPE {
- OBJECTT = -2,
- STRUCTURET,
- PLAYERT,
- NPCT,
- MERCHT,
- MOBT
-};
-
-enum GENDER{
- MALE,
- FEMALE
-};
-
-enum MOB_SUB {
- MS_RABBIT = 1,
- MS_BIRD,
- MS_TRIGGER,
- MS_DOOR,
- MS_PAGE
-};
-
-enum BUILD_SUB{
- TOWN_HALL = 0,
- HOUSE = 1,
- HOUSE2 = 2,
- HOUSE3 = 3,
- HOUSE4 = 4,
- FOUNTAIN = 5,
- LAMP_POST = 6,
- FIRE_PIT = 7,
- STALL_MARKET = 70,
- STALL_TRADER = 71
-};
-
-class Trade{
-public:
- std::string item[2];
- int quantity[2];
- Trade(int qo, const char* o, int qt, const char* t){
- item[0] = o;
- item[1] = t;
-
- quantity[0] = qo;
- quantity[1] = qt;
-
- std::cout << "Trading: " << quantity[0] << " " << item[0] << " for " << quantity[1] << " " << item[1] << std::endl;
- }
- Trade(){}
-};
-
-class World;
-
-class Particles{
-public:
- vec2 loc;
- float width;
- float height;
- float velx;
- float vely;
- Color color;
- vec2 index;
- float duration;
- bool canMove;
- bool fountain;
- bool gravity;
- bool behind;
- Particles(float x, float y, float w, float h, float vx, float vy, Color c, float d){
- loc.x = x;
- loc.y = y;
- width = w;
- height = h;
- velx = vx;
- vely = vy;
- color = c;
- duration = d;
- fountain = false;
- gravity = true;
- behind = false;
- index = Texture::getIndex(c);
- }
- ~Particles(){
-
- }
- void draw(){
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, colorIndex);
- glUseProgram(shaderProgram);
- glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
- glEnable(GL_TEXTURE_2D);
- glColor3ub(255,255,255);
- glBegin(GL_QUADS);
- glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y);
- glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x + width, loc.y);
- glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x + width, loc.y + height);
- glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y + width);
- glEnd();
- glDisable(GL_TEXTURE_2D);
- glUseProgram(0);
- }
- bool kill(float delta){
- duration -= delta;
- if(duration <= 0.0f){
- return true;
- }
- else return false;
- }
-};
-
-void initEntity();
-
-class Entity{
-public:
- Entity *followee;
- Inventory *inv;
-
- /*
- * Movement variables
- */
-
- vec2 loc;
- vec2 vel;
-
- float width;
- float height;
-
- float speed; // A speed factor for X movement
-
- /*
- * Movement flags
- */
-
- bool near; // Causes name to display
- bool canMove; // Enables movement
- bool canJape; // Enables world leaving
- bool right,left; // Direction faced by Entity
- bool alive;
- bool hit;
- unsigned char ground; // Shows how the Entity is grounded (if it is)
-
- /*
- * Health variables
- */
-
- float health;
- float maxHealth;
-
- /*
- * Identification variables
- */
-
- _TYPE type;
- int subtype;
-
- char *name;
- GENDER gender;
-
- Texturec *tex;
- Texturec *ntex;
-
- unsigned int randDialog;
-
- void draw(void);
- void spawn(float, float);
-
- int ticksToUse; // Used by wander()
-
- virtual void wander(int){}
- virtual void interact(){}
-
- void follow(Entity *e);
-
- virtual ~Entity(){}
-};
-
-class Player : public Entity{
-public:
- QuestHandler qh;
-
- Player();
- ~Player();
- void save(void);
- void sspawn(float x,float y);
-};
-
-class Structures : public Entity{
-public:
- BUILD_SUB bsubtype;
- World *inWorld;
- std::string inside;
- std::string textureLoc;
-
- Structures();
- ~Structures();
-
- unsigned int spawn(BUILD_SUB, float, float);
-};
-
-
-class NPC : public Entity {
-public:
- std::vector<int (*)(NPC *)>aiFunc;
- int dialogIndex;
-
- NPC();
- NPC(NPC *n);
- ~NPC();
-
- void addAIFunc(int (*func)(NPC *),bool preload);
- void clearAIFunc(void);
- virtual void interact();
- virtual void wander(int);
-};
-
-class Merchant : public NPC{
-public:
- std::vector<Trade>trade;
- uint currTrade;
-
- void interact();
- Structures *inside;
-
- Merchant();
- ~Merchant();
-
- 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;
-public:
- std::string pickupDialog;
- bool questObject = false;
-
- Object();
- Object(std::string in,std::string pd);
- ~Object();
-
- void reloadTexture(void);
-
- void interact(void);
-};
-#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
-**/
--- /dev/null
+#ifndef ENTITIES_H
+#define ENTITIES_H
+
+#include <common.hpp>
+#include <Quest.hpp>
+#include <inventory.hpp>
+#include <Texture.hpp>
+
+#include <sstream>
+
+#define DEBUG
+
+#define NPCp(n) ((NPC *)n)
+#define Structurep(n) ((Structures *)n)
+#define Mobp(n) ((Mob *)n)
+
+#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 {
+ OBJECTT = -2,
+ STRUCTURET,
+ PLAYERT,
+ NPCT,
+ MERCHT,
+ MOBT
+};
+
+enum GENDER{
+ MALE,
+ FEMALE
+};
+
+enum MOB_SUB {
+ MS_RABBIT = 1,
+ MS_BIRD,
+ MS_TRIGGER,
+ MS_DOOR,
+ MS_PAGE
+};
+
+enum BUILD_SUB{
+ TOWN_HALL = 0,
+ HOUSE = 1,
+ HOUSE2 = 2,
+ HOUSE3 = 3,
+ HOUSE4 = 4,
+ FOUNTAIN = 5,
+ LAMP_POST = 6,
+ FIRE_PIT = 7,
+ STALL_MARKET = 70,
+ STALL_TRADER = 71
+};
+
+class Trade{
+public:
+ std::string item[2];
+ int quantity[2];
+ Trade(int qo, const char* o, int qt, const char* t){
+ item[0] = o;
+ item[1] = t;
+
+ quantity[0] = qo;
+ quantity[1] = qt;
+
+ std::cout << "Trading: " << quantity[0] << " " << item[0] << " for " << quantity[1] << " " << item[1] << std::endl;
+ }
+ Trade(){}
+};
+
+class World;
+
+class Particles{
+public:
+ vec2 loc;
+ float width;
+ float height;
+ float velx;
+ float vely;
+ Color color;
+ vec2 index;
+ float duration;
+ bool canMove;
+ bool fountain;
+ bool gravity;
+ bool behind;
+ Particles(float x, float y, float w, float h, float vx, float vy, Color c, float d){
+ loc.x = x;
+ loc.y = y;
+ width = w;
+ height = h;
+ velx = vx;
+ vely = vy;
+ color = c;
+ duration = d;
+ fountain = false;
+ gravity = true;
+ behind = false;
+ index = Texture::getIndex(c);
+ }
+ ~Particles(){
+
+ }
+ void draw(){
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, colorIndex);
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
+ glEnable(GL_TEXTURE_2D);
+ glColor3ub(255,255,255);
+ glBegin(GL_QUADS);
+ glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y);
+ glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x + width, loc.y);
+ glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x + width, loc.y + height);
+ glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y + width);
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
+ glUseProgram(0);
+ }
+ bool kill(float delta){
+ duration -= delta;
+ if(duration <= 0.0f){
+ return true;
+ }
+ else return false;
+ }
+};
+
+void initEntity();
+
+class Entity{
+public:
+ Entity *followee;
+ Inventory *inv;
+
+ /*
+ * Movement variables
+ */
+
+ vec2 loc;
+ vec2 vel;
+
+ float width;
+ float height;
+
+ float speed; // A speed factor for X movement
+
+ /*
+ * Movement flags
+ */
+
+ bool near; // Causes name to display
+ bool canMove; // Enables movement
+ bool canJape; // Enables world leaving
+ bool right,left; // Direction faced by Entity
+ bool alive;
+ bool hit;
+ unsigned char ground; // Shows how the Entity is grounded (if it is)
+
+ /*
+ * Health variables
+ */
+
+ float health;
+ float maxHealth;
+
+ /*
+ * Identification variables
+ */
+
+ _TYPE type;
+ int subtype;
+
+ char *name;
+ GENDER gender;
+
+ Texturec *tex;
+ Texturec *ntex;
+
+ unsigned int randDialog;
+
+ void draw(void);
+ void spawn(float, float);
+
+ int ticksToUse; // Used by wander()
+
+ virtual void wander(int){}
+ virtual void interact(){}
+
+ void follow(Entity *e);
+
+ virtual ~Entity(){}
+};
+
+class Player : public Entity{
+public:
+ QuestHandler qh;
+
+ Player();
+ ~Player();
+ void save(void);
+ void sspawn(float x,float y);
+};
+
+class Structures : public Entity{
+public:
+ BUILD_SUB bsubtype;
+ World *inWorld;
+ std::string inside;
+ std::string textureLoc;
+
+ Structures();
+ ~Structures();
+
+ unsigned int spawn(BUILD_SUB, float, float);
+};
+
+
+class NPC : public Entity {
+public:
+ std::vector<int (*)(NPC *)>aiFunc;
+ int dialogIndex;
+
+ NPC();
+ NPC(NPC *n);
+ ~NPC();
+
+ void addAIFunc(int (*func)(NPC *),bool preload);
+ void clearAIFunc(void);
+ virtual void interact();
+ virtual void wander(int);
+};
+
+class Merchant : public NPC{
+public:
+ std::vector<Trade>trade;
+ uint currTrade;
+
+ void interact();
+ Structures *inside;
+
+ Merchant();
+ ~Merchant();
+
+ 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;
+public:
+ std::string pickupDialog;
+ bool questObject = false;
+
+ Object();
+ Object(std::string in,std::string pd);
+ ~Object();
+
+ void reloadTexture(void);
+
+ void interact(void);
+};
+#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
+**/
+++ /dev/null
-#ifndef INVENTORY_H
-#define INVENTORY_H
-
-#include <common.h>
-#include <string.h>
-
-#include <Texture.h>
-
-#define DEBUG
-
-class Item{
-public:
- std::string name,type;
-
- float width;
- float height;
- int maxStackSize;
-
- std::string texloc;
- Texturec *tex;
-
- GLuint rtex(){
- return tex->image[0];
- }
-};
-
-struct item_t{
- uint count;
- uint id;
-} __attribute__((packed));
-
-class Inventory {
-private:
- unsigned int size;
- int os = 0;
-public:
- std::vector<item_t> items;
- unsigned int sel;
- bool invOpen = false;
- bool invOpening = false;
- bool invHover = false;
- bool selected = false;
- bool mouseSel = false;
- bool usingi = false;
-
- Inventory(unsigned int s); // Creates an inventory of size 's'
- ~Inventory(void); // Free's allocated memory
-
- 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)
-};
-
-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);
-
-#endif // INVENTORY_H
--- /dev/null
+#ifndef INVENTORY_H
+#define INVENTORY_H
+
+#include <common.hpp>
+#include <string.h>
+
+#include <Texture.hpp>
+
+#define DEBUG
+
+class Item{
+public:
+ std::string name,type;
+
+ float width;
+ float height;
+ int maxStackSize;
+
+ std::string texloc;
+ Texturec *tex;
+
+ GLuint rtex(){
+ return tex->image[0];
+ }
+};
+
+struct item_t{
+ uint count;
+ uint id;
+} __attribute__((packed));
+
+class Inventory {
+private:
+ unsigned int size;
+ int os = 0;
+public:
+ std::vector<item_t> items;
+ unsigned int sel;
+ bool invOpen = false;
+ bool invOpening = false;
+ bool invHover = false;
+ bool selected = false;
+ bool mouseSel = false;
+ bool usingi = false;
+
+ Inventory(unsigned int s); // Creates an inventory of size 's'
+ ~Inventory(void); // Free's allocated memory
+
+ 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)
+};
+
+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);
+
+#endif // INVENTORY_H
+++ /dev/null
-#ifndef THREADPOOL_H
-#define THREADPOOL_H
-
-#include <vector>
-#include <queue>
-#include <thread>
-#include <mutex>
-#include <condition_variable>
-#include <iostream>
-#include <unistd.h>
-
-using namespace std;
-
-class ThreadPool
-{
-public:
-
- // Constructor.
- ThreadPool(int threads);
-
- // Destructor.
- ~ThreadPool();
-
- // Adds task to a task queue.
- void Enqueue(function<void()> f);
-
- // Shut down the pool.
- void ShutDown();
-
-private:
- // Thread pool storage.
- vector<thread> threadPool;
-
- // Queue to keep track of incoming tasks.
- queue<function<void()>> tasks;
-
- // Task queue mutex.
- mutex tasksMutex;
-
- // Condition variable.
- condition_variable condition;
-
- // Indicates that pool needs to be shut down.
- bool terminate;
-
- // Indicates that pool has been terminated.
- bool stopped;
-
- // Function that will be invoked by our threads.
- void Invoke();
-};
-
-#endif //THRE
\ No newline at end of file
--- /dev/null
+#ifndef THREADPOOL_H
+#define THREADPOOL_H
+
+#include <vector>
+#include <queue>
+#include <thread>
+#include <mutex>
+#include <condition_variable>
+#include <iostream>
+#include <unistd.h>
+
+using namespace std;
+
+class ThreadPool
+{
+public:
+
+ // Constructor.
+ ThreadPool(int threads);
+
+ // Destructor.
+ ~ThreadPool();
+
+ // Adds task to a task queue.
+ void Enqueue(function<void()> f);
+
+ // Shut down the pool.
+ void ShutDown();
+
+private:
+ // Thread pool storage.
+ vector<thread> threadPool;
+
+ // Queue to keep track of incoming tasks.
+ queue<function<void()>> tasks;
+
+ // Task queue mutex.
+ mutex tasksMutex;
+
+ // Condition variable.
+ condition_variable condition;
+
+ // Indicates that pool needs to be shut down.
+ bool terminate;
+
+ // Indicates that pool has been terminated.
+ bool stopped;
+
+ // Function that will be invoked by our threads.
+ void Invoke();
+};
+
+#endif //THRE
\ No newline at end of file
+++ /dev/null
-/** @file ui.h
- * @brief Contains functions for handling the user interface.
- */
-
-#ifndef UI_H
-#define UI_H
-
-#include <common.h>
-#include <inventory.h>
-#include <cstdarg>
-
-#include <config.h>
-#include <world.h>
-#include <ft2build.h>
-#include <SDL2/SDL_opengl.h>
-#include <thread>
-#include FT_FREETYPE_H
-
-#define DEBUG
-
-typedef void(*menuFunc)();
-
-struct menuItem{
- int member;
- union{
- struct{
- vec2 loc;
- dim2 dim;
- Color color;
- const char* text;
- menuFunc func;
- }button;
- struct{
- vec2 loc;
- dim2 dim;
- Color color;
- float minValue;
- float maxValue;
- const char* text;
- float* var;
-
- float sliderLoc;
- }slider;
- };
-};
-
-class Menu{
-public:
- std::vector<menuItem>items;
- Menu *child;
- Menu *parent;
- ~Menu(){
- child = NULL;
- parent = NULL;
- delete child;
- delete parent;
- }
-
- void gotoChild();
- void gotoParent();
-};
-
-typedef uint8_t BYTE;
-typedef uint16_t WORD;
-typedef uint32_t DWORD;
-typedef int32_t LONG;
-
-typedef struct{
- WORD bfType;
- DWORD bfSize;
- WORD bfReserved1, bfReserved2;
- DWORD bfOffBits; //how many bytes before the image data
-} __attribute__ ((packed)) BITMAPFILEHEADER;
-
-typedef struct{
- DWORD biSize; //size of header in bytes
- LONG biWidth;
- LONG biHeight;
- WORD biPlanes;
- WORD biBitCount; //how many bits are in a pixel
- DWORD biCompression;
- DWORD biSizeImage; //size of image in bytes
- LONG biXPelsPerMeter;
- LONG biYPelsPerMeter;
- DWORD biClrUsed; //how many colors there are
- DWORD biClrImportant; //important colors
-} __attribute__ ((packed)) BITMAPINFOHEADER;
-
-namespace ui {
- menuItem createButton(vec2 l, dim2 d, Color c, const char* t, menuFunc f);
- menuItem createChildButton(vec2 l, dim2 d, Color c, const char* t);
- menuItem createParentButton(vec2 l, dim2 d, Color c, const char* t);
- menuItem createSlider(vec2 l, dim2 d, Color c, float min, float max, const char* t, float* v);
- /**
- * Contains the coordinates of the mouse inside the window.
- */
-
- extern vec2 mouse;
-
- /*
- * These flags are used elsewhere.
- */
-
- extern unsigned int fontSize;
-
- extern bool debug;
- extern bool posFlag;
-
- extern unsigned char dialogOptChosen;
- extern unsigned char merchOptChosen;
- extern bool dialogBoxExists;
- extern bool dialogImportant;
- extern bool dialogPassive;
-
- extern unsigned int textWrapLimit;
- extern int fontTransInv;
-
- /*
- * Initializes the FreeType system.
- */
-
- void initFonts(void);
-
- void destroyFonts(void);
-
- /*
- * Sets the current font/font size.
- */
-
- void setFontFace(const char *ttf);
- void setFontSize(unsigned int size);
- void setFontColor(unsigned char r,unsigned char g,unsigned char b, unsigned char a);
-
- /*
- * Draw a centered string.
- */
-
- float putStringCentered(const float x,const float y,std::string s);
-
- /*
- * Draws a formatted string at the given coordinates.
- */
-
- float putText(const float x,const float y,const char *str,...);
-
- /*
- * Creates a dialogBox text string (format: `name`: `text`). This function simply sets up
- * variables that are drawn in ui::draw(). When the dialog box exists player control is
- * limited until a right click is given, closing the box.
- */
-
- void dialogBox(const char *name,const char *opt,bool passive,const char *text,...);
- void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...);
- void merchantBox();
- void closeBox();
- void waitForDialog(void);
-
- void drawPage( std::string path );
- /*
- * Draws a larger string in the center of the screen. Drawing is done inside this function.
- */
-
- void importantText(const char *text,...);
- void passiveImportantText(int duration,const char *text,...);
-
- /*
- * Draw various UI elements (dialogBox, player health)
- */
-
- void draw(void);
-
-
- /*
- * Draw various menu items
- */
- void quitGame();
- void drawMenu(Menu* menu);
-
-
- /*
- * Handle keyboard/mouse events.
- */
- void handleEvents(void);
-
- /*
- * Toggle the black overlay thing.
- */
-
- void toggleBlack(void);
- void toggleBlackFast(void);
- void toggleWhite(void);
- void toggleWhiteFast(void);
- void waitForCover(void);
-
-}
-
-#endif // UI_H
--- /dev/null
+/** @file ui.h
+ * @brief Contains functions for handling the user interface.
+ */
+
+#ifndef UI_H
+#define UI_H
+
+#include <common.hpp>
+#include <inventory.hpp>
+#include <cstdarg>
+
+#include <config.hpp>
+#include <world.hpp>
+#include <ft2build.h>
+#include <SDL2/SDL_opengl.h>
+#include <thread>
+#include FT_FREETYPE_H
+
+#define DEBUG
+
+typedef void(*menuFunc)();
+
+struct menuItem{
+ int member;
+ union{
+ struct{
+ vec2 loc;
+ dim2 dim;
+ Color color;
+ const char* text;
+ menuFunc func;
+ }button;
+ struct{
+ vec2 loc;
+ dim2 dim;
+ Color color;
+ float minValue;
+ float maxValue;
+ const char* text;
+ float* var;
+
+ float sliderLoc;
+ }slider;
+ };
+};
+
+class Menu{
+public:
+ std::vector<menuItem>items;
+ Menu *child;
+ Menu *parent;
+ ~Menu(){
+ child = NULL;
+ parent = NULL;
+ delete child;
+ delete parent;
+ }
+
+ void gotoChild();
+ void gotoParent();
+};
+
+typedef uint8_t BYTE;
+typedef uint16_t WORD;
+typedef uint32_t DWORD;
+typedef int32_t LONG;
+
+typedef struct{
+ WORD bfType;
+ DWORD bfSize;
+ WORD bfReserved1, bfReserved2;
+ DWORD bfOffBits; //how many bytes before the image data
+} __attribute__ ((packed)) BITMAPFILEHEADER;
+
+typedef struct{
+ DWORD biSize; //size of header in bytes
+ LONG biWidth;
+ LONG biHeight;
+ WORD biPlanes;
+ WORD biBitCount; //how many bits are in a pixel
+ DWORD biCompression;
+ DWORD biSizeImage; //size of image in bytes
+ LONG biXPelsPerMeter;
+ LONG biYPelsPerMeter;
+ DWORD biClrUsed; //how many colors there are
+ DWORD biClrImportant; //important colors
+} __attribute__ ((packed)) BITMAPINFOHEADER;
+
+namespace ui {
+ menuItem createButton(vec2 l, dim2 d, Color c, const char* t, menuFunc f);
+ menuItem createChildButton(vec2 l, dim2 d, Color c, const char* t);
+ menuItem createParentButton(vec2 l, dim2 d, Color c, const char* t);
+ menuItem createSlider(vec2 l, dim2 d, Color c, float min, float max, const char* t, float* v);
+ /**
+ * Contains the coordinates of the mouse inside the window.
+ */
+
+ extern vec2 mouse;
+
+ /*
+ * These flags are used elsewhere.
+ */
+
+ extern unsigned int fontSize;
+
+ extern bool debug;
+ extern bool posFlag;
+
+ extern unsigned char dialogOptChosen;
+ extern unsigned char merchOptChosen;
+ extern bool dialogBoxExists;
+ extern bool dialogImportant;
+ extern bool dialogPassive;
+
+ extern unsigned int textWrapLimit;
+ extern int fontTransInv;
+
+ /*
+ * Initializes the FreeType system.
+ */
+
+ void initFonts(void);
+
+ void destroyFonts(void);
+
+ /*
+ * Sets the current font/font size.
+ */
+
+ void setFontFace(const char *ttf);
+ void setFontSize(unsigned int size);
+ void setFontColor(unsigned char r,unsigned char g,unsigned char b, unsigned char a);
+
+ /*
+ * Draw a centered string.
+ */
+
+ float putStringCentered(const float x,const float y,std::string s);
+
+ /*
+ * Draws a formatted string at the given coordinates.
+ */
+
+ float putText(const float x,const float y,const char *str,...);
+
+ /*
+ * Creates a dialogBox text string (format: `name`: `text`). This function simply sets up
+ * variables that are drawn in ui::draw(). When the dialog box exists player control is
+ * limited until a right click is given, closing the box.
+ */
+
+ void dialogBox(const char *name,const char *opt,bool passive,const char *text,...);
+ void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...);
+ void merchantBox();
+ void closeBox();
+ void waitForDialog(void);
+
+ void drawPage( std::string path );
+ /*
+ * Draws a larger string in the center of the screen. Drawing is done inside this function.
+ */
+
+ void importantText(const char *text,...);
+ void passiveImportantText(int duration,const char *text,...);
+
+ /*
+ * Draw various UI elements (dialogBox, player health)
+ */
+
+ void draw(void);
+
+
+ /*
+ * Draw various menu items
+ */
+ void quitGame();
+ void drawMenu(Menu* menu);
+
+
+ /*
+ * Handle keyboard/mouse events.
+ */
+ void handleEvents(void);
+
+ /*
+ * Toggle the black overlay thing.
+ */
+
+ void toggleBlack(void);
+ void toggleBlackFast(void);
+ void toggleWhite(void);
+ void toggleWhiteFast(void);
+ void waitForCover(void);
+
+}
+
+#endif // UI_H
+++ /dev/null
-/** @file world.h
- * @brief The world system.
- *
- * This file contains the classes and variables necessary to create an in-game
- * world.
- */
-
-#ifndef WORLD_H
-#define WORLD_H
-
-#include <common.h>
-#include <entities.h>
-
-#define GROUND_HEIGHT_INITIAL 80
-#define GROUND_HEIGHT_MINIMUM 60
-#define GROUND_HEIGHT_MAXIMUM 110
-
-#define GROUND_HILLINESS 10
-
-/**
- * Defines how many game ticks it takes for a day to elapse.
- */
-
-#define DAY_CYCLE 12000
-
-/**
- * The background type enum.
- * This enum contains all different possibilities for world backgrounds; used
- * in World::setBackground() to select the appropriate images.
- */
-
-enum class WorldBGType : unsigned char {
- Forest, /**< A forest theme. */
- WoodHouse /**< An indoor wooden house theme. */
-};
-
-/**
- * The weather type enum.
- * This enum contains every type of weather currently implemented in the game.
- * Weather is set by the world somewhere.
- */
-
-enum class WorldWeather : unsigned char {
- Sunny = 0, /**< Sunny/daytime */
- Dark, /**< Nighttime */
- Rain, /**< Rain */
- Snowy /**< Snow */
-};
-
-/**
- * The line structure.
- * This structure is used to store the world's ground, stored in vertical
- * lines. Dirt color and grass properties are also kept track of here.
- */
-
-typedef struct {
- bool grassUnpressed;
- float grassHeight[2];
- float groundHeight;
- unsigned char groundColor;
-} WorldData;
-
-/**
- * A value used by World::draw() for shading, ranges from -50 to 50 depending
- * on the current time of day.
- */
-
-extern int worldShade;
-
-/**
- * The path to the currently loaded XML file.
- */
-
-extern std::string currentXML;
-
-// prototype so Village can reference it
-class World;
-
-/**
- * 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(vec2 l, Color c, float r){
- loc = l;
- color = c;
- radius = r;
-
- belongsTo = false;
- following = nullptr;
-
- flame = false;
- }
-
- void makeFlame(void){
- flame = true;
- }
-
- void follow(Entity *f){
- following=f;
- belongsTo = true;
- }
-};
-
-
-/**
- * The village class, used to group structures into villages.
- */
-
-class Village {
-public:
- std::string name;
- vec2 start;
- vec2 end;
- bool in;
- std::vector<Structures *> build;
-
- Village(const char *meme, World *w);
- ~Village(void){}
-};
-
-/**
- * The world class. This class does everything a world should do.
- */
-
-class World {
-protected:
-
- /**
- * The line array.
- *
- * This array is created through 'new' in World::generate(), with an amount
- * of elements provided by the function.
- */
-
- std::vector<WorldData> worldData;
-
- /**
- * Starting x coordinate.
- *
- * This x value is the point at which line[0] should reside, can be used to
- * calculate the width of the world.
- */
-
- int worldStart;
-
- /**
- * Handle physics for a single entity.
- *
- * This function handles gravity and death for an entity. The public version
- * of this, World::detect(), handles all entities in the world as well as
- * the player. World::singleDetect() should never be used outside of
- * World::detect(), which is why it is declared private.
- */
-
- void singleDetect( Entity *e );
-
- /**
- * Empties all entity vectors.
- *
- * Each entity vector is iterated through, calling delete for each entry.
- * Once all specific vectors are cleared, the general entity vector is
- * emptied of the pointers to those other vectors. This function should only
- * be called in World's destructor, as there shouldn't be another reason to
- * call this function.
- */
-
- void deleteEntities( void );
-
- /**
- * Number of lines in the world.
- *
- * While this number is helpful for knowing the world's width, it is kept
- * private for security reasons. To compensate for this,
- * World::getTheWidth() is provided (see below).
- */
-
- unsigned int lineCount;
-
- /**
- * An array of star coordinates.
- */
-
- std::vector<vec2> star;
-
- /**
- * The Texturec object that holds the background sprites for this world.
- */
-
- Texturec *bgTex;
-
- /**
- * Defines the set of background images that should be used for this world.
- */
-
- WorldBGType bgType;
-
- /**
- * The Mix_Music object that holds the background soundtrack for the world.
- */
-
- Mix_Music *bgmObj;
-
- /**
- * The file path of the song wished to be loaded by bgmObj.
- */
-
- std::string bgm;
-
- std::vector<std::string> bgFiles;
- std::vector<std::string> bgFilesIndoors;
-
-public:
-
- /**
- * The filename of the XML file for the world to the left; NULL if no world
- * is present.
- */
-
- std::string toLeft;
-
- /**
- * The filename of the XML file for the world to the right; NULL if no world
- * is present.
- */
-
- std::string toRight;
-
- /**
- * Sets what XML file to use for loading the world to the left.
- */
-
- std::string setToLeft( std::string file );
-
- /**
- * Sets what XML file to use for loading the world to the right.
- */
-
- std::string setToRight( std::string file );
-
- /**
- * A vector of pointers to every NPC, Structure, Mob, and Object in this
- * world.
- */
-
- std::vector<Entity *> entity;
-
- /**
- * A vector of all NPCs in this world.
- */
-
- std::vector<NPC *> npc;
- std::vector<Merchant *> merchant;
-
- /**
- * A vector of all Structures in this world.
- */
-
- std::vector<Structures *> build;
-
- /**
- * A vector of all Mobs in this world.
- */
-
- std::vector<Mob *> mob;
-
- /**
- * A vector of all Objects in this world.
- */
-
- std::vector<Object *> object;
-
- /**
- * A vector of all particles in this world.
- */
-
- std::vector<Particles> particles;
-
-
- std::vector<Village *> village;
-
- /**
- * A vector of all light elements in this world.
- */
-
- std::vector<Light> light;
-
- /**
- * Vector of all building textures for the current world style
- */
-
- std::vector<std::string> sTexLoc;
-
- /**
- * NULLifies pointers and allocates necessary memory. This should be
- * followed by some combination of setBackground(), setBGM(), or
- * generate().
- */
-
- World( void );
-
- /**
- * Frees resources taken by the world.
- */
-
- virtual ~World(void);
-
- /**
- * Adds a structure to the world, with the specified subtype and
- * coordinates. `inside` is a file name for the IndoorWorld XML file that
- * this structure will lead to; if NULL the player won't be able to enter
- * the structure.
- */
-
- void addStructure(BUILD_SUB subtype,float x,float y, std::string tex, std::string inside);
-
- /**
- * Adds a Mob to the world with the specified type and coordinates.
- */
-
- void addMob(int type,float x,float y);
-
- /**
- * Adds a Mob to the world with a handler function that can be called by
- * certain mobs to trigger events.
- */
-
- void addMob(int t,float x,float y,void (*hey)(Mob *));
-
- /**
- * Adds an NPC to the world with the specified coordinates.
- */
-
- void addNPC(float x,float y);
-
- /**
- * Adds a Merchant to the world at the specified coordinates.
- */
-
- void addMerchant(float x, float y);
-
- /**
- * Adds an object to the world with the specified item id and coordinates.
- * If `pickupDialog` is not NULL, that string will display in a dialog box
- * upon object interaction.
- */
-
- void addObject( std::string in, std::string pickupDialog, float x, float y);
-
- /**
- * Adds a particle to the world with the specified coordinates, dimensions,
- * velocity, color and duration (time to live).
- */
-
- void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d);
- void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, bool gravity );
-
- /**
- * Adds a light to the world with the specified coordinates and color.
- */
-
- void addLight(vec2 xy, Color color);
-
- /**
- * Updates the coordinates of everything in the world that has coordinates
- * and a velocity. The provided delta time is used for smoother updating.
- */
-
- void update( Player *p, unsigned int delta );
-
- /**
- * Generate a world of the provided width. Worlds are drawn centered on the
- * y-axis, so the reachable coordinates on the world would be from negative
- * half-width to positive half-width.
- */
-
- virtual void generate(unsigned int width);
-
- /**
- * Sets the background theme, collecting the required textures into a
- * Texturec object.
- */
-
- void setBackground(WorldBGType bgt);
-
- /**
- * Sets the background music for the world, required for the world to be
- * playable.
- */
-
- void setBGM(std::string path);
-
- /**
- * Sets the worlds style folder
- */
-
- void setStyle(std::string pre);
-
- /**
- * Plays/stops this world's BGM. If `prev` is not NULL, that world's BGM
- * will be faded out followed by the fading in of this world's BGM.
- */
-
- void bgmPlay(World *prev) const;
-
- /**
- * Draw the world and entities based on the player's coordinates.
- */
-
- virtual void draw(Player *p);
-
- /**
- * Handles collision between the entities and the world, as well as entity
- * death.
- */
-
- void detect(Player *p);
-
- /**
- * Attempts to let the player enter the left-linked world specified by
- * `toLeft`. Returns the world to the left if the movement is possible,
- * otherwise returns this world.
- */
-
- World *goWorldLeft(Player *p);
- bool goWorldLeft( NPC *e );
-
- /**
- * Attempts to let the player enter the right-linked world specified by
- * `toRight`. Returns the world to the right if the movement is possible,
- * otherwise returns this world.
- */
-
- World *goWorldRight(Player *p);
-
- /**
- * This function looks for any structure the player is standing in front of
- * that also have an inside world. Returns the inside world if those
- * conditions are met, otherwise returns this world.
- */
-
- World *goInsideStructure(Player *p);
-
- /**
- * Adds a hole between the specified y coordinates. If the player falls in
- * this hole the game will exit.
- */
-
- void addHole(unsigned int start,unsigned int end);
-
- /**
- * Adds a hill to the world, given the peak's coordinates and how wide the
- * hill can be.
- */
-
- void addHill( ivec2 peak, unsigned int width );
-
- /**
- * Gets the world's width.
- */
-
- int getTheWidth(void) const;
-
- void save(void);
- void load(void);
-};
-
-/*
- * IndoorWorld - Indoor settings stored in a World class
- */
-
-class IndoorWorld : public World {
-public:
- IndoorWorld(void);
- ~IndoorWorld(void);
-
- void generate(unsigned int width); // Generates a flat world of width 'width'
- void draw(Player *p); // Draws the world (ignores layers)
-};
-
-/**
- * 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 a world with the player and mob, returning the player to the
- * world `leave` upon exit.
- */
-
- Arena( World *leave, Player *p, Mob *m );
-
- /**
- * Frees resources taken by the arena.
- */
-
- ~Arena( void );
-
- /**
- * Attempts to exit the world, returning the player to the world they were
- * last in.
- */
-
- World *exitArena( Player *p );
-};
-
-std::string getWorldWeatherStr( WorldWeather ww );
-
-/**
- * Loads the player into the world created by the given XML file. If a world is
- * already loaded it will be saved before the transition is made.
- */
-
-World *loadWorldFromXML(std::string path);
-
-/**
- * Loads the player into the XML-scripted world, but does not save data from the
- * previous world if one was loaded.
- */
-
-World *loadWorldFromXMLNoSave(std::string path);
-
-World *loadWorldFromPtr( World *ptr );
-
-#endif // WORLD_H
--- /dev/null
+/** @file world.h
+ * @brief The world system.
+ *
+ * This file contains the classes and variables necessary to create an in-game
+ * world.
+ */
+
+#ifndef WORLD_H
+#define WORLD_H
+
+#include <common.hpp>
+#include <entities.hpp>
+
+#define GROUND_HEIGHT_INITIAL 80
+#define GROUND_HEIGHT_MINIMUM 60
+#define GROUND_HEIGHT_MAXIMUM 110
+
+#define GROUND_HILLINESS 10
+
+/**
+ * Defines how many game ticks it takes for a day to elapse.
+ */
+
+#define DAY_CYCLE 12000
+
+/**
+ * The background type enum.
+ * This enum contains all different possibilities for world backgrounds; used
+ * in World::setBackground() to select the appropriate images.
+ */
+
+enum class WorldBGType : unsigned char {
+ Forest, /**< A forest theme. */
+ WoodHouse /**< An indoor wooden house theme. */
+};
+
+/**
+ * The weather type enum.
+ * This enum contains every type of weather currently implemented in the game.
+ * Weather is set by the world somewhere.
+ */
+
+enum class WorldWeather : unsigned char {
+ Sunny = 0, /**< Sunny/daytime */
+ Dark, /**< Nighttime */
+ Rain, /**< Rain */
+ Snowy /**< Snow */
+};
+
+/**
+ * The line structure.
+ * This structure is used to store the world's ground, stored in vertical
+ * lines. Dirt color and grass properties are also kept track of here.
+ */
+
+typedef struct {
+ bool grassUnpressed;
+ float grassHeight[2];
+ float groundHeight;
+ unsigned char groundColor;
+} WorldData;
+
+/**
+ * A value used by World::draw() for shading, ranges from -50 to 50 depending
+ * on the current time of day.
+ */
+
+extern int worldShade;
+
+/**
+ * The path to the currently loaded XML file.
+ */
+
+extern std::string currentXML;
+
+// prototype so Village can reference it
+class World;
+
+/**
+ * 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(vec2 l, Color c, float r){
+ loc = l;
+ color = c;
+ radius = r;
+
+ belongsTo = false;
+ following = nullptr;
+
+ flame = false;
+ }
+
+ void makeFlame(void){
+ flame = true;
+ }
+
+ void follow(Entity *f){
+ following=f;
+ belongsTo = true;
+ }
+};
+
+
+/**
+ * The village class, used to group structures into villages.
+ */
+
+class Village {
+public:
+ std::string name;
+ vec2 start;
+ vec2 end;
+ bool in;
+ std::vector<Structures *> build;
+
+ Village(const char *meme, World *w);
+ ~Village(void){}
+};
+
+/**
+ * The world class. This class does everything a world should do.
+ */
+
+class World {
+protected:
+
+ /**
+ * The line array.
+ *
+ * This array is created through 'new' in World::generate(), with an amount
+ * of elements provided by the function.
+ */
+
+ std::vector<WorldData> worldData;
+
+ /**
+ * Starting x coordinate.
+ *
+ * This x value is the point at which line[0] should reside, can be used to
+ * calculate the width of the world.
+ */
+
+ int worldStart;
+
+ /**
+ * Handle physics for a single entity.
+ *
+ * This function handles gravity and death for an entity. The public version
+ * of this, World::detect(), handles all entities in the world as well as
+ * the player. World::singleDetect() should never be used outside of
+ * World::detect(), which is why it is declared private.
+ */
+
+ void singleDetect( Entity *e );
+
+ /**
+ * Empties all entity vectors.
+ *
+ * Each entity vector is iterated through, calling delete for each entry.
+ * Once all specific vectors are cleared, the general entity vector is
+ * emptied of the pointers to those other vectors. This function should only
+ * be called in World's destructor, as there shouldn't be another reason to
+ * call this function.
+ */
+
+ void deleteEntities( void );
+
+ /**
+ * Number of lines in the world.
+ *
+ * While this number is helpful for knowing the world's width, it is kept
+ * private for security reasons. To compensate for this,
+ * World::getTheWidth() is provided (see below).
+ */
+
+ unsigned int lineCount;
+
+ /**
+ * An array of star coordinates.
+ */
+
+ std::vector<vec2> star;
+
+ /**
+ * The Texturec object that holds the background sprites for this world.
+ */
+
+ Texturec *bgTex;
+
+ /**
+ * Defines the set of background images that should be used for this world.
+ */
+
+ WorldBGType bgType;
+
+ /**
+ * The Mix_Music object that holds the background soundtrack for the world.
+ */
+
+ Mix_Music *bgmObj;
+
+ /**
+ * The file path of the song wished to be loaded by bgmObj.
+ */
+
+ std::string bgm;
+
+ std::vector<std::string> bgFiles;
+ std::vector<std::string> bgFilesIndoors;
+
+public:
+
+ /**
+ * The filename of the XML file for the world to the left; NULL if no world
+ * is present.
+ */
+
+ std::string toLeft;
+
+ /**
+ * The filename of the XML file for the world to the right; NULL if no world
+ * is present.
+ */
+
+ std::string toRight;
+
+ /**
+ * Sets what XML file to use for loading the world to the left.
+ */
+
+ std::string setToLeft( std::string file );
+
+ /**
+ * Sets what XML file to use for loading the world to the right.
+ */
+
+ std::string setToRight( std::string file );
+
+ /**
+ * A vector of pointers to every NPC, Structure, Mob, and Object in this
+ * world.
+ */
+
+ std::vector<Entity *> entity;
+
+ /**
+ * A vector of all NPCs in this world.
+ */
+
+ std::vector<NPC *> npc;
+ std::vector<Merchant *> merchant;
+
+ /**
+ * A vector of all Structures in this world.
+ */
+
+ std::vector<Structures *> build;
+
+ /**
+ * A vector of all Mobs in this world.
+ */
+
+ std::vector<Mob *> mob;
+
+ /**
+ * A vector of all Objects in this world.
+ */
+
+ std::vector<Object *> object;
+
+ /**
+ * A vector of all particles in this world.
+ */
+
+ std::vector<Particles> particles;
+
+
+ std::vector<Village *> village;
+
+ /**
+ * A vector of all light elements in this world.
+ */
+
+ std::vector<Light> light;
+
+ /**
+ * Vector of all building textures for the current world style
+ */
+
+ std::vector<std::string> sTexLoc;
+
+ /**
+ * NULLifies pointers and allocates necessary memory. This should be
+ * followed by some combination of setBackground(), setBGM(), or
+ * generate().
+ */
+
+ World( void );
+
+ /**
+ * Frees resources taken by the world.
+ */
+
+ virtual ~World(void);
+
+ /**
+ * Adds a structure to the world, with the specified subtype and
+ * coordinates. `inside` is a file name for the IndoorWorld XML file that
+ * this structure will lead to; if NULL the player won't be able to enter
+ * the structure.
+ */
+
+ void addStructure(BUILD_SUB subtype,float x,float y, std::string tex, std::string inside);
+
+ /**
+ * Adds a Mob to the world with the specified type and coordinates.
+ */
+
+ void addMob(int type,float x,float y);
+
+ /**
+ * Adds a Mob to the world with a handler function that can be called by
+ * certain mobs to trigger events.
+ */
+
+ void addMob(int t,float x,float y,void (*hey)(Mob *));
+
+ /**
+ * Adds an NPC to the world with the specified coordinates.
+ */
+
+ void addNPC(float x,float y);
+
+ /**
+ * Adds a Merchant to the world at the specified coordinates.
+ */
+
+ void addMerchant(float x, float y);
+
+ /**
+ * Adds an object to the world with the specified item id and coordinates.
+ * If `pickupDialog` is not NULL, that string will display in a dialog box
+ * upon object interaction.
+ */
+
+ void addObject( std::string in, std::string pickupDialog, float x, float y);
+
+ /**
+ * Adds a particle to the world with the specified coordinates, dimensions,
+ * velocity, color and duration (time to live).
+ */
+
+ void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d);
+ void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, bool gravity );
+
+ /**
+ * Adds a light to the world with the specified coordinates and color.
+ */
+
+ void addLight(vec2 xy, Color color);
+
+ /**
+ * Updates the coordinates of everything in the world that has coordinates
+ * and a velocity. The provided delta time is used for smoother updating.
+ */
+
+ void update( Player *p, unsigned int delta );
+
+ /**
+ * Generate a world of the provided width. Worlds are drawn centered on the
+ * y-axis, so the reachable coordinates on the world would be from negative
+ * half-width to positive half-width.
+ */
+
+ virtual void generate(unsigned int width);
+
+ /**
+ * Sets the background theme, collecting the required textures into a
+ * Texturec object.
+ */
+
+ void setBackground(WorldBGType bgt);
+
+ /**
+ * Sets the background music for the world, required for the world to be
+ * playable.
+ */
+
+ void setBGM(std::string path);
+
+ /**
+ * Sets the worlds style folder
+ */
+
+ void setStyle(std::string pre);
+
+ /**
+ * Plays/stops this world's BGM. If `prev` is not NULL, that world's BGM
+ * will be faded out followed by the fading in of this world's BGM.
+ */
+
+ void bgmPlay(World *prev) const;
+
+ /**
+ * Draw the world and entities based on the player's coordinates.
+ */
+
+ virtual void draw(Player *p);
+
+ /**
+ * Handles collision between the entities and the world, as well as entity
+ * death.
+ */
+
+ void detect(Player *p);
+
+ /**
+ * Attempts to let the player enter the left-linked world specified by
+ * `toLeft`. Returns the world to the left if the movement is possible,
+ * otherwise returns this world.
+ */
+
+ World *goWorldLeft(Player *p);
+ bool goWorldLeft( NPC *e );
+
+ /**
+ * Attempts to let the player enter the right-linked world specified by
+ * `toRight`. Returns the world to the right if the movement is possible,
+ * otherwise returns this world.
+ */
+
+ World *goWorldRight(Player *p);
+
+ /**
+ * This function looks for any structure the player is standing in front of
+ * that also have an inside world. Returns the inside world if those
+ * conditions are met, otherwise returns this world.
+ */
+
+ World *goInsideStructure(Player *p);
+
+ /**
+ * Adds a hole between the specified y coordinates. If the player falls in
+ * this hole the game will exit.
+ */
+
+ void addHole(unsigned int start,unsigned int end);
+
+ /**
+ * Adds a hill to the world, given the peak's coordinates and how wide the
+ * hill can be.
+ */
+
+ void addHill( ivec2 peak, unsigned int width );
+
+ /**
+ * Gets the world's width.
+ */
+
+ int getTheWidth(void) const;
+
+ void save(void);
+ void load(void);
+};
+
+/*
+ * IndoorWorld - Indoor settings stored in a World class
+ */
+
+class IndoorWorld : public World {
+public:
+ IndoorWorld(void);
+ ~IndoorWorld(void);
+
+ void generate(unsigned int width); // Generates a flat world of width 'width'
+ void draw(Player *p); // Draws the world (ignores layers)
+};
+
+/**
+ * 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 a world with the player and mob, returning the player to the
+ * world `leave` upon exit.
+ */
+
+ Arena( World *leave, Player *p, Mob *m );
+
+ /**
+ * Frees resources taken by the arena.
+ */
+
+ ~Arena( void );
+
+ /**
+ * Attempts to exit the world, returning the player to the world they were
+ * last in.
+ */
+
+ World *exitArena( Player *p );
+};
+
+std::string getWorldWeatherStr( WorldWeather ww );
+
+/**
+ * Loads the player into the world created by the given XML file. If a world is
+ * already loaded it will be saved before the transition is made.
+ */
+
+World *loadWorldFromXML(std::string path);
+
+/**
+ * Loads the player into the XML-scripted world, but does not save data from the
+ * previous world if one was loaded.
+ */
+
+World *loadWorldFromXMLNoSave(std::string path);
+
+World *loadWorldFromPtr( World *ptr );
+
+#endif // WORLD_H
* Game includes
*/
-#include <config.h>
-#include <common.h>
-#include <world.h>
-#include <ui.h>
-#include <entities.h>
+#include <config.hpp>
+#include <common.hpp>
+#include <world.hpp>
+#include <ui.hpp>
+#include <entities.hpp>
/**
* Defines how many game ticks should occur in one second, affecting how often
#include <algorithm>\r
\r
-#include <Quest.h>\r
-#include <entities.h>\r
+#include <Quest.hpp>\r
+#include <entities.hpp>\r
\r
extern Player *player;\r
\r
int QuestHandler::assign(std::string title,std::string desc,std::string req){\r
Quest tmp;\r
char *tok;\r
- \r
+\r
tmp.title = title;\r
tmp.desc = desc;\r
\r
strcpy(buf.get(),req.c_str());\r
tok = strtok(buf.get(),"\n\r\t,");\r
tmp.need.push_back({"\0",0});\r
- \r
+\r
while(tok){\r
if(tmp.need.back().name != "\0"){\r
tmp.need.back().n = atoi(tok);\r
tmp.need.push_back({"\0",0});\r
}else\r
tmp.need.back().name = tok;\r
- \r
+\r
tok = strtok(NULL,"\n\r\t,");\r
}\r
- \r
+\r
tmp.need.pop_back();\r
current.push_back(tmp);\r
\r
current.end(),\r
[&](Quest q){ return q.title == title; }),\r
current.end() );\r
- \r
+\r
return 0;\r
}\r
\r
if ( player->inv->hasItem( n.name ) < n.n )\r
return 0;\r
}\r
- \r
+\r
for ( auto &n : (*c).need )\r
player->inv->takeItem( n.name, n.n );\r
- \r
+\r
current.erase( c );\r
return 1;\r
}\r
}\r
- \r
+\r
return 0;\r
}\r
\r
if ( c.title == t )\r
return true;\r
}\r
- \r
+\r
return false;\r
}\r
#include <algorithm>
#include <string>
-#include <Texture.h>
+#include <Texture.hpp>
/**
* A structure for keeping track of loaded textures.
# include <vector>
#endif // __WIN32__
-#include <common.h>
+#include <common.hpp>
#ifndef __WIN32__
std::ifstream in (path,std::ios::in);
unsigned int size;
GLchar *buf;
-
+
if(!in.is_open()){
std::cout<<"Error reading file "<<path<<"!"<<std::endl;
abort();
}
-
+
in.seekg(0,in.end);
buf = new GLchar[(size = in.tellg()) + 1];
in.seekg(0,in.beg);
in.read(buf,size);
buf[size] = '\0';
-
+
in.close();
return buf;
}
-#include <config.h>
+#include <config.hpp>
-#include <ui.h>
+#include <ui.hpp>
using namespace tinyxml2;
xml.LoadFile("config/settings.xml");
scr = xml.FirstChildElement("screen");
-
+
if(scr->QueryUnsignedAttribute("width",&uval) == XML_NO_ERROR)
SCREEN_WIDTH = uval;
else SCREEN_WIDTH = 1280;
else HLINE = 3;
vol = xml.FirstChildElement("volume");
-
+
if(vol->FirstChildElement("master")->QueryFloatAttribute("volume",&fval) == XML_NO_ERROR)
VOLUME_MASTER = fval;
else VOLUME_MASTER = 50;
if(vol->FirstChildElement("sfx")->QueryFloatAttribute("volume",&fval) == XML_NO_ERROR)
VOLUME_SFX = fval;
else VOLUME_SFX = 50;
-
+
ui::initFonts();
ui::setFontFace(xml.FirstChildElement("font")->Attribute("path"));
updateConfig();
#include <istream>
-#include <entities.h>
-#include <ui.h>
+#include <entities.hpp>
+#include <ui.hpp>
extern std::istream *names;
-#include <common.h>
-#include <entities.h>
-#include <world.h>
-#include <ui.h>
+#include <common.hpp>
+#include <entities.hpp>
+#include <world.hpp>
+#include <ui.hpp>
#include <tinyxml2.h>
using namespace tinyxml2;
void commonPageFunc( Mob *callee )
{
static bool lock = false;
-
+
if ( !lock ) {
lock = true;
-
+
ui::drawPage( callee->heyid );
ui::waitForDialog();
-
+
callee->alive = false;
lock = false;
}
-#include <inventory.h>
-#include <entities.h>
-#include <ui.h>
+#include <inventory.hpp>
+#include <entities.hpp>
+#include <ui.hpp>
#include <tinyxml2.h>
using namespace tinyxml2;
void Inventory::draw(void){
static unsigned int lop = 0;
- //const unsigned int numSlot = 7;
static std::vector<int>dfp(numSlot);
static std::vector<Ray>iray(numSlot);
static std::vector<vec2>curCoord(numSlot);
glVertex2i(mr.x-(itemWide/2)+itemWide,mr.y-(itemWide/2)+itemWide);
glVertex2i(mr.x-(itemWide/2), mr.y-(itemWide/2)+itemWide);
glEnd();
+ if(!items.empty() && a < items.size() && items[a+numSlot].count){
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, itemtex[items[a+numSlot].id]);
+ glColor4f(1.0f, 1.0f, 1.0f, ((float)massDfp[a]/(float)(massRange?massRange:1))*0.8f);
+ glBegin(GL_QUADS);
+ if(itemMap[items[a].id]->height > itemMap[items[a+numSlot].id]->width){
+ glTexCoord2i(0,1);glVertex2i(mr.x-((itemWide/2)*((float)itemMap[items[a+numSlot].id]->width/(float)itemMap[items[a+numSlot].id]->height)), mr.y-(itemWide/2));
+ glTexCoord2i(1,1);glVertex2i(mr.x+((itemWide/2)*((float)itemMap[items[a+numSlot].id]->width/(float)itemMap[items[a+numSlot].id]->height)), mr.y-(itemWide/2));
+ glTexCoord2i(1,0);glVertex2i(mr.x+((itemWide/2)*((float)itemMap[items[a+numSlot].id]->width/(float)itemMap[items[a+numSlot].id]->height)), mr.y+(itemWide/2));
+ glTexCoord2i(0,0);glVertex2i(mr.x-((itemWide/2)*((float)itemMap[items[a+numSlot].id]->width/(float)itemMap[items[a+numSlot].id]->height)), mr.y+(itemWide/2));
+ }else{
+ glTexCoord2i(0,1);glVertex2i(mr.x-(itemWide/2),mr.y-(itemWide/2)*((float)itemMap[items[a+numSlot].id]->height/(float)itemMap[items[a+numSlot].id]->width));
+ glTexCoord2i(1,1);glVertex2i(mr.x+(itemWide/2),mr.y-(itemWide/2)*((float)itemMap[items[a+numSlot].id]->height/(float)itemMap[items[a+numSlot].id]->width));
+ glTexCoord2i(1,0);glVertex2i(mr.x+(itemWide/2),mr.y+(itemWide/2)*((float)itemMap[items[a+numSlot].id]->height/(float)itemMap[items[a+numSlot].id]->width));
+ glTexCoord2i(0,0);glVertex2i(mr.x-(itemWide/2),mr.y+(itemWide/2)*((float)itemMap[items[a+numSlot].id]->height/(float)itemMap[items[a+numSlot].id]->width));
+ }
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
+ ui::setFontColor(255,255,255,((float)massDfp[a]/(float)(massRange?massRange:1))*255);
+ ui::putText(mr.x-(itemWide/2)+(itemWide*.85),mr.y-(itemWide/2),"%d",items[a+numSlot].count);
+ ui::setFontColor(255,255,255,255);
+ }
a++;
}a=0;
}
glEnd();
glDisable(GL_TEXTURE_2D);
- ui::putText(r.end.x-(itemWide/2),r.end.y-(itemWide*.9),"%s",itemMap[items[a].id]->name.c_str());
+ ui::setFontColor(255,255,255,((float)dfp[a]/(float)(range?range:1))*255);
+ ui::putStringCentered(r.end.x,r.end.y-(itemWide*.9),itemMap[items[a].id]->name.c_str());
ui::putText(r.end.x-(itemWide/2)+(itemWide*.85),r.end.y-(itemWide/2),"%d",items[a].count);
+ ui::setFontColor(255,255,255,255);
}
if(sel == a){
static float sc = 1;
static bool up;
- up ? sc += .01 : sc -= .01;
+ up ? sc += .0005*deltaTime : sc -= .0005*deltaTime;
if(sc > 1.2){
up = false;
sc = 1.2;
up = true;
sc = 1.0;
}
- glPushMatrix();
- glLoadIdentity();
- //glTranslatef(-sc, -sc, 0);
- //glScalef(sc,sc,0.0f);
glBegin(GL_QUADS);
glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)(range?range:1)));
glVertex2f(r.end.x - (itemWide*sc)/2 - (itemWide*sc)*.09,r.end.y - (itemWide*sc)/2 - (itemWide*sc)*.09);
glVertex2f(r.end.x + (itemWide*sc)/2 + (itemWide*sc)*.09,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
glVertex2f(r.end.x + (itemWide*sc)/2 ,r.end.y + (itemWide*sc)/2 + (itemWide*sc)*.09);
glEnd();
- glPopMatrix();
}
a++;
}
-#include "threadpool.h"
+#include <threadpool.hpp>
/**
* Stolen from some guy.
-#include <ui.h>
+#include <ui.hpp>
/*
* Create a macro to easily access SDL keypresses
#include <algorithm>
#include <sstream>
-#include <world.h>
-#include <ui.h>
+#include <world.hpp>
+#include <ui.hpp>
#include <tinyxml2.h>
using namespace tinyxml2;
safeSetColorA( 255, 255, 255, weather == WorldWeather::Snowy ? 150 : 255 - worldShade * 4);
glBegin( GL_QUADS );
- glTexCoord2i( 0, 0 ); glVertex2i( worldStart, SCREEN_HEIGHT );
- glTexCoord2i( 1, 0 ); glVertex2i( -worldStart, SCREEN_HEIGHT );
- glTexCoord2i( 1, 1 ); glVertex2i( -worldStart, 0 );
- glTexCoord2i( 0, 1 ); glVertex2i( worldStart, 0 );
+ glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2, SCREEN_HEIGHT );
+ glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2, SCREEN_HEIGHT );
+ glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2, 0 );
+ glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2, 0 );
glEnd();
bgTex->bindNext();
<text id="4">
Have a sword though.
- <give id="Wood Sword" count="1" />
+ <give id="Wood Sword" count="1"/>
+ <give id="Wood Sword2" count="1"/>
+ <give id="Wood Sword3" count="1"/>
+ <give id="Wood Sword4" count="1"/>
+ <give id="Wood Sword5" count="1"/>
+ <give id="Wood Sword6" count="1"/>
+ <give id="Wood Sword7" count="1"/>
+ <give id="Wood Sword8" count="1"/>
+ <give id="Wood Sword9" count="1"/>
+ <give id="Wood Sword10" count="1"/>
+ <give id="Wood Sword11" count="1"/>
+ <give id="Wood Sword12" count="1"/>
+ <give id="Wood Sword13" count="1"/>
+ <give id="Wood Sword14" count="1"/>
+ <give id="Wood Sword15" count="1"/>
+ <give id="Wood Sword16" count="1"/>
+ <give id="Wood Sword17" count="1"/>
+ <give id="Wood Sword18" count="1"/>
+ <give id="Wood Sword19" count="1"/>
+ <give id="Wood Sword20" count="1"/>
+ <give id="Wood Sword21" count="1"/>
+ <give id="Wood Sword22" count="1"/>
+ <give id="Wood Sword23" count="1"/>
+ <give id="Wood Sword24" count="1"/>
+ <give id="Wood Sword25" count="1"/>
+ <give id="Wood Sword26" count="1"/>
+ <give id="Wood Sword27" count="1"/>
+ <give id="Wood Sword28" count="1"/>
+ <give id="Wood Sword29" count="1"/>
+ <give id="Wood Sword30" count="1"/>
+ <give id="Wood Sword31" count="1"/>
+ <give id="Wood Sword32" count="1"/>
+ <give id="Wood Sword33" count="1"/>
+ <give id="Wood Sword34" count="1"/>
+ <give id="Wood Sword35" count="1"/>
+ <give id="Wood Sword36" count="1"/>
+ <give id="Wood Sword37" count="1"/>
+ <give id="Wood Sword38" count="1"/>
+ <give id="Wood Sword39" count="1"/>
</text>
</Dialog>