aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndy <drumsetmonkey@gmail.com>2016-12-23 08:42:15 -0500
committerAndy <drumsetmonkey@gmail.com>2016-12-23 08:42:15 -0500
commitd7d1b397197893f0ce49b28f762711b7a9ef1087 (patch)
tree6a14f9daf59cb1640f09e7f82c6325d93d0a62dc /include
parent691411cdb214178f2d10ab589943993039fe080e (diff)
parent6dd6d03bb1af3c1c482a67355446998eccc3288c (diff)
Sprites are good. Merged.
Diffstat (limited to 'include')
-rw-r--r--include/brice.hpp39
-rw-r--r--include/common.hpp35
-rw-r--r--include/components.hpp41
-rw-r--r--include/config.hpp51
-rw-r--r--include/engine.hpp58
-rw-r--r--include/gametime.hpp36
-rw-r--r--include/player.hpp44
-rw-r--r--include/save_util.hpp36
-rw-r--r--include/shader_utils.hpp17
-rw-r--r--include/texture.hpp232
-rw-r--r--include/ui.hpp8
-rw-r--r--include/ui_quest.hpp19
-rw-r--r--include/world.hpp10
13 files changed, 402 insertions, 224 deletions
diff --git a/include/brice.hpp b/include/brice.hpp
index dc3ea96..1c4eccf 100644
--- a/include/brice.hpp
+++ b/include/brice.hpp
@@ -1,20 +1,59 @@
+/**
+ * @file brice.hpp
+ * @brief A system for saving player information.
+ */
+
#ifndef BRICE_H_
#define BRICE_H_
#include <string>
namespace game {
+
+ /**
+ * Allows the player to jump, if set to true.
+ */
extern bool canJump;
+
+ /**
+ * Allows the player to sprint, if set to true.
+ */
extern bool canSprint;
+ /**
+ * Gets a value from the saved brice and returns it.
+ * @param id the id of the value
+ * @return the string value
+ */
std::string getValue(const std::string& id);
+ /**
+ * Sets a value in the brice, creating it if it doesn't exist.
+ * @param id the id of the value
+ * @param value the value
+ * @return true if the value was updated, not created
+ */
bool setValue(const std::string& id, const std::string& value);
+ /**
+ * Resets the brice to it's default values.
+ * Note: these are hardcoded into the program.
+ */
void briceClear(void);
+
+ /**
+ * Saves the brice to it's file (brice.dat).
+ */
void briceSave(void);
+
+ /**
+ * Loads the brice from it's file (brice.dat).
+ */
void briceLoad(void);
+ /**
+ * Reloads the brice.
+ */
void briceUpdate(void);
}
diff --git a/include/common.hpp b/include/common.hpp
index 861905a..19af420 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -43,11 +43,8 @@
// game library includes
#include <config.hpp>
-
-
// windows stuff
#ifdef __WIN32__
-typedef unsigned int uint;
#undef near
#endif
@@ -77,12 +74,9 @@ typedef ivec2 dim2;
* Creates a coordinate out of floating point integers.
*/
struct vec2 {
- float x; /**< The x coordinate */
- float y; /**< The y coordinate */
+ float x;
+ float y;
- /**
- * Constructs a vec2 with the specified coordinates.
- */
vec2(float _x = 0.0f, float _y = 0.0f)
: x(_x), y(_y) {}
@@ -105,11 +99,14 @@ struct vec2 {
return vec2 (x + v.x, y + v.y);
}
- template<typename T>
- const vec2 operator*(const T &n) {
+ vec2 operator*(const float&n) const {
return vec2 (x * n, y * n);
}
+ vec2 operator/(const float& n) const {
+ return vec2 (x / n, y / n);
+ }
+
// std::swap can't work due to being packed
inline void swapX(vec2 &v) {
@@ -122,6 +119,10 @@ struct vec2 {
y = v.y, v.y = t;
}
+ std::string toString(void) const {
+ return "(" + std::to_string(x) + ", " + std::to_string(y) + ")";
+ }
+
} __attribute__ ((packed));
/**
@@ -188,8 +189,6 @@ public:
}
};
-extern GLuint colorIndex;
-
/**
* The amount of game ticks that should occur each second.
*/
@@ -263,17 +262,6 @@ extern vec2 offset;
*/
void DEBUG_prints(const char* file, int line, const char *s,...);
-// TODO make sure we don't use these. Then burn them.
-/**
- * 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);
-
unsigned int millis(void);
// reads the names of files in a directory into the given string vector
@@ -283,7 +271,6 @@ int getdir(std::string dir, std::vector<std::string> &files);
void strVectorSortAlpha(std::vector<std::string> *v);
// reads the given file into a buffer and returns a pointer to the buffer
-const char *readFile(const char *path);
std::string readFile(const std::string& path);
std::vector<std::string> readFileA(const std::string& path);
diff --git a/include/components.hpp b/include/components.hpp
index 2a8680d..5c067dd 100644
--- a/include/components.hpp
+++ b/include/components.hpp
@@ -125,32 +125,35 @@ struct Solid {
};
struct SpriteData {
-
- SpriteData(std::string path, vec2 offset):
- offset(offset) {
- pic = Texture::loadTexture(path);
- size = Texture::imageDim(path);
+
+ SpriteData(std::string path, vec2 off):
+ offset(off) {
+ tex = Texture(path);
+ size = tex.getDim();
+
size_tex = vec2(1.0, 1.0);
offset_tex.x = offset.x/size.x;
offset_tex.y = offset.y/size.y;
}
- SpriteData(std::string path, vec2 offset, vec2 size):
- offset(offset), size(size) {
- pic = Texture::loadTexture(path);
- vec2 tmpsize = Texture::imageDim(path);
+ SpriteData(std::string path, vec2 off, vec2 si):
+ size(si), offset(off) {
+ tex = Texture(path);
+ vec2 tmpsize = tex.getDim();
size_tex.x = size.x/tmpsize.x;
size_tex.y = size.y/tmpsize.y;
+
offset_tex.x = offset.x/tmpsize.x;
offset_tex.y = offset.y/tmpsize.y;
}
- GLuint pic;
+ Texture tex;
+ vec2 size;
vec2 offset;
+
vec2 offset_tex;
- vec2 size;
vec2 size_tex;
};
@@ -168,7 +171,7 @@ struct Sprite {
Sprite(bool left = false)
: faceLeft(left) {}
- std::vector<std::pair<SpriteData, vec2>> getSprite() {
+ Frame getSprite() {
return sprite;
}
@@ -210,15 +213,17 @@ struct Sprite {
}
for (auto &s : sprite) {
+ const auto& size = s.first.tex.getDim();
+
if (s.second.x < st.x)
st.x = s.second.x;
if (s.second.y < st.y)
st.y = s.second.y;
- if (s.second.x + s.first.size.x > dim.x)
- dim.x = s.second.x + s.first.size.x;
- if (s.second.y + s.first.size.y > dim.y)
- dim.y = s.second.y + s.first.size.y;
+ if (s.second.x + size.x > dim.x)
+ dim.x = s.second.x + size.x;
+ if (s.second.y + size.y > dim.y)
+ dim.y = s.second.y + size.y;
}
return dim;
@@ -321,9 +326,9 @@ public:
class RenderSystem : public entityx::System<RenderSystem> {
private:
std::string loadTexString;
- std::atomic<GLuint> loadTexResult;
+ Texture loadTexResult;
public:
- GLuint loadTexture(const std::string& file);
+ Texture loadTexture(const std::string& file);
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
};
diff --git a/include/config.hpp b/include/config.hpp
index bc9d052..e17df24 100644
--- a/include/config.hpp
+++ b/include/config.hpp
@@ -1,23 +1,72 @@
+/**
+ * @file config.hpp
+ * @brief Functions for loading/saving game settings.
+ */
+
#ifndef CONFIG_H
#define CONFIG_H
#include <string>
namespace game {
+ /**
+ * The size of an HLINE, according to the save file.
+ * This is the default "unit of measurement" in the game. Drawing scales to
+ * this, and it is used in game logic.
+ */
extern unsigned int HLINE;
+
+ /**
+ * The width of the screen, in pixels.
+ */
extern unsigned int SCREEN_WIDTH;
+
+ /**
+ * The height of the screen, in pixels.
+ */
extern unsigned int SCREEN_HEIGHT;
- extern bool FULLSCREEN;
+
+ /**
+ * The window is fullscreen if this is true.
+ */
+ extern bool FULLSCREEN;
namespace config {
+ /**
+ * The current volume level of the master channel.
+ * Volumes are percentages, 0 to 100.
+ */
extern float VOLUME_MASTER;
+
+ /**
+ * Volume level of the background music (BGM).
+ */
extern float VOLUME_MUSIC;
+
+ /**
+ * Volume level of game sound effects.
+ */
extern float VOLUME_SFX;
+ /**
+ * The path of the folder to load world XML files from.
+ */
extern std::string xmlFolder;
+ /**
+ * Reads the settings file (config/settings.xml) into the game.
+ * Default values are hardcoded in (see src/config.cpp).
+ */
void read(void);
+
+ /**
+ * Updates settings with the current values.
+ */
void update(void);
+
+ /**
+ * Saves the current settings to the settings file.
+ */
void save(void);
}
}
diff --git a/include/engine.hpp b/include/engine.hpp
index 1c5f510..2b03696 100644
--- a/include/engine.hpp
+++ b/include/engine.hpp
@@ -1,8 +1,13 @@
+/**
+ * @file engine.hpp
+ * @brief The main game engine, and functions to assist it.
+ */
+
#ifndef ENGINE_HPP_
#define ENGINE_HPP_
#include <entityx/entityx.h>
-#include "entityx/deps/Dependencies.h"
+#include <entityx/deps/Dependencies.h>
#include <texture.hpp>
#include <components.hpp>
@@ -10,28 +15,56 @@
//game::engine::Systems->add<entityx::deps::Dependency<Visible, Sprite>>();
+/**
+ * @class Engine
+ * The main game engine class. Only one instance of this should be created, it
+ * handles everything game-related.
+ */
class Engine : public entityx::Receiver<Engine> {
public:
+ /**
+ * A flag to indicate if a thread should continue to run.
+ */
bool shouldRun;
+ /**
+ * Handles game systems.
+ */
entityx::SystemManager systems;
explicit Engine(void);
+ /**
+ * Initializes the game engine, and all systems used within it.
+ */
void init(void);
+
+ /**
+ * Updates all rendering systems.
+ * @param dt the delta time
+ */
void render(entityx::TimeDelta dt);
void resetRender(entityx::TimeDelta dt);
+
+ /**
+ * Updates all logic systems.
+ * @param dt the delta time
+ */
void update(entityx::TimeDelta dt);
+ /**
+ * A shortcut to get a system, for calling system-specific functions.
+ * Takes the type of the desired system.
+ */
template<typename T>
inline T* getSystem(void) {
return dynamic_cast<T*>(systems.system<T>().get());
}
- /*void configure(entityx::EventManager &ev) {
- (void)ev;
- }*/
-
+ /**
+ * A handler for the game ending event.
+ * @param gee game end event data
+ */
inline void receive(const GameEndEvent &gee) {
shouldRun = !(gee.really);
}
@@ -39,16 +72,27 @@ public:
namespace game {
+ /**
+ * Handles all game events.
+ */
extern entityx::EventManager events;
+
+ /**
+ * Handles entity data.
+ */
extern entityx::EntityManager entities;
+ /**
+ * An instance of the main game engine.
+ */
extern Engine engine;
+ /**
+ * Ends the game.
+ */
inline void endGame(void) {
events.emit<GameEndEvent>();
}
-
- extern SpriteLoader sprite_l;
}
diff --git a/include/gametime.hpp b/include/gametime.hpp
index a809ef9..988533a 100644
--- a/include/gametime.hpp
+++ b/include/gametime.hpp
@@ -1,16 +1,52 @@
+/**
+ * @file gametime.hpp
+ * @brief Handles time related operations
+ */
+
#ifndef GAMETIME_H_
#define GAMETIME_H_
namespace game {
namespace time {
+ /**
+ * Sets the game's tick count to the desired amount.
+ * @param t desired tick count
+ */
void setTickCount(unsigned int t);
+
+ /**
+ * Gets the current tick count.
+ * @return the tick count
+ */
unsigned int getTickCount(void);
+
+ /**
+ * Calculates and returns the delta time.
+ * @return the delta time
+ */
unsigned int getDeltaTime(void);
+ /**
+ * Increments the game's tick count.
+ */
void tick(void);
+
+ /**
+ * Increments the game's tick count by the given amount of ticks.
+ * @param ticks the number of ticks to add
+ */
void tick(unsigned int ticks);
+
+ /**
+ * Determines if a tick has passed since the last call to this function.
+ * @return if a tick has passed
+ */
bool tickHasPassed(void);
+ /**
+ * Handles time updating.
+ * This should be called from the game's main loop.
+ */
void mainLoopHandler(void);
}
}
diff --git a/include/player.hpp b/include/player.hpp
index 59d6368..85dc821 100644
--- a/include/player.hpp
+++ b/include/player.hpp
@@ -1,3 +1,8 @@
+/**
+ * @file player.hpp
+ * @brief The player system
+ */
+
#ifndef PLAYER_HPP_
#define PLAYER_HPP_
@@ -8,8 +13,15 @@
#include <components.hpp>
#include <common.hpp>
+/**
+ * The constant velocity the player is given when moved with the arrow keys.
+ */
constexpr const float PLAYER_SPEED_CONSTANT = 0.15f;
+/**
+ * @class PlayerSystem
+ * Controls a player, with keyboard and stuff.
+ */
class PlayerSystem : public entityx::System<PlayerSystem>, public entityx::Receiver<PlayerSystem> {
private:
entityx::Entity player;
@@ -23,18 +35,50 @@ public:
PlayerSystem(void)
: moveLeft(false), moveRight(false), speed(1.0f) {}
+ /**
+ * Creates the player, adding it to the entity system.
+ */
void create(void);
+ /**
+ * Configures events for use with the entity system.
+ */
void configure(entityx::EventManager&);
+ /**
+ * Updates the player, mainly the player's velocity.
+ */
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
+ /**
+ * Handles key up events for the player.
+ * @param kue key up event data
+ */
void receive(const KeyUpEvent&);
+
+ /**
+ * Handles key down events for the player.
+ * @param kde key down event data
+ */
void receive(const KeyDownEvent&);
+ /**
+ * Gets the player's position.
+ * @return the player's position
+ */
vec2 getPosition(void) const;
+
+ /**
+ * Sets the player's X coordinate.
+ * @param x the x coordinate to give the player
+ */
inline void setX(const float& x)
{ player.component<Position>().get()->x = x; }
+
+ /**
+ * Gets the width of the player.
+ * @return the player's width, according to its sprite
+ */
inline float getWidth(void) const
{ return game::entities.component<Solid>(player.id())->width; }
};
diff --git a/include/save_util.hpp b/include/save_util.hpp
deleted file mode 100644
index 3d5cf54..0000000
--- a/include/save_util.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef SAVE_UTIL_H_
-#define SAVE_UTIL_H_
-
-/*
- * Save macros.
- */
-
-#define E_SAVE_COORDS { xmle->SetAttribute("x", loc.x); xmle->SetAttribute("y", loc.y); }
-
-#define E_SAVE_HEALTH xmle->SetAttribute("health", health);
-
-/*
- * Load macos.
- */
-
-#define E_LOAD_COORDS(yy) { float n; \
- if (xmle->QueryFloatAttribute("x", &n) == XML_NO_ERROR) \
- spawn(n, yy); \
- else \
- spawn(xmle->FloatAttribute("spawnx"), 100); \
- \
- if (xmle->QueryFloatAttribute("y", &n) == XML_NO_ERROR) \
- loc.y = n; }
-
-#define E_LOAD_HEALTH { float n; \
- \
- if (xmle->QueryFloatAttribute("maxHealth", &n) != XML_NO_ERROR) \
- maxHealth = 1; \
- \
- if (xmle->QueryFloatAttribute("health", &n) == XML_NO_ERROR) \
- health = n; \
- else \
- health = maxHealth; }
-
-
-#endif // SAVE_UTIL_H_
diff --git a/include/shader_utils.hpp b/include/shader_utils.hpp
index 243b3d4..06ac318 100644
--- a/include/shader_utils.hpp
+++ b/include/shader_utils.hpp
@@ -1,8 +1,11 @@
/**
+ * @file shader_utils.hpp
+ * @brief Utilities to use to handle GLSL shaders.
* From the OpenGL Programming wikibook: http://en.wikibooks.org/wiki/OpenGL_Programming
* This file is in the public domain.
* Contributors: Sylvain Beucler, Guus Sliepen
*/
+
#ifndef _CREATE_SHADER_H
#define _CREATE_SHADER_H
@@ -11,12 +14,12 @@
#include <SDL2/SDL.h>
-extern char* file_read(const char* filename);
-extern void print_log(GLuint object);
-extern GLuint create_shader(const char* filename, GLenum type);
-extern GLuint create_program(const char* vertexfile, const char *fragmentfile);
-extern GLint get_attrib(GLuint program, const char *name);
-extern GLint get_uniform(GLuint program, const char *name);
-extern void print_opengl_info();
+char* file_read(const char* filename);
+void print_log(GLuint object);
+GLuint create_shader(const char* filename, GLenum type);
+GLuint create_program(const char* vertexfile, const char *fragmentfile);
+GLint get_attrib(GLuint program, const char *name);
+GLint get_uniform(GLuint program, const char *name);
+void print_opengl_info();
#endif
diff --git a/include/texture.hpp b/include/texture.hpp
index ad5211c..e9082b3 100644
--- a/include/texture.hpp
+++ b/include/texture.hpp
@@ -1,11 +1,10 @@
-/** @file Texture.h
+/**
+ * @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
+#ifndef TEXTURE_HPP_
+#define TEXTURE_HPP_
#include <common.hpp>
@@ -16,137 +15,142 @@
#define DEBUG
/**
- * Texture functions are given a namespace for better organization.
+ * @class Texture
+ * Handles a single texture, loaded from the given file.
*/
-namespace Texture {
+class Texture {
+private:
+ std::string name; /**< The name (path) of the loaded file. */
+ GLuint tex; /**< The GLuint for the loaded texture. */
+ vec2 dim; /**< The dimensions of the loaded texture. */
+public:
/**
- * Loads a texture from the given file name, returning the GLuint used for
- * later referencing of the texture.
+ * Attempts to create a texture.
+ * Either:
+ * - Creates an empty class (no arguments given)
+ * - Load a texture from the given file, crashing if file not found
+ * - Fills the class with the given values
+ * @param file the path to the desired texture
+ * @param t the GLuint for the texture, if known
+ * @param v the size of the texture, if known
*/
+ Texture(const std::string& file = "", const GLuint& t = 0xFFFFF, const vec2& v = vec2(0, 0));
- GLuint loadTexture(std::string fileName);
- GLuint genColor(Color c);
+ /**
+ * Gets the name (path) of the loaded texture.
+ * @return the texture's name
+ */
+ const std::string& getName(void) const;
- void freeTextures(void);
+ /**
+ * Gets the dimensions of the loaded texture.
+ * @return the texture's dimensions
+ */
+ const vec2& getDim(void) const;
- void initColorIndex();
- vec2 getIndex(Color c);
- vec2 imageDim(std::string fileName);
-}
+ /**
+ * Binds the texture, so it may be used for rendering.
+ */
+ inline void use(void) const
+ { glBindTexture(GL_TEXTURE_2D, tex); }
-class SpriteLoader {
-private:
- std::unordered_map<uint64_t, GLuint> sprites;
- std::unordered_map<std::string, uint64_t> spritesLoc;
-
- uint64_t freeID = 0;
- uint64_t increaseID() {
- uint64_t id_t = 0;
- while (1) {
- try {
- sprites.at(id_t);
- } catch (const std::out_of_range& oor) {
- freeID = id_t;
- return freeID;
- }
- id_t++;
- }
- }
-public:
- uint64_t loadSprite(std::string s) {
- uint64_t tex_e = 0;
- try {
- tex_e = spritesLoc.at(s);
- } catch (const std::out_of_range& oor) {
- sprites.emplace(increaseID(), Texture::loadTexture (s));
- spritesLoc.emplace(s, freeID);
- return freeID;
- }
- return tex_e;
- }
-
- GLuint getSprite(uint64_t id) {
- return sprites.at(id);
- }
+ /**
+ * Frees GPU resources for the loaded texture.
+ */
+ inline void destroy(void)
+ { glDeleteTextures(1, &tex), tex = 0xFFFFF; }
+
+ /**
+ * Checks if a texture is currently loaded in this class.
+ * @return true if there is not a loaded texture
+ */
+ inline bool isEmpty(void) const
+ { return (tex == 0xFFFFF); }
};
/**
- * DRAFT texture iterator?
+ * @class ColorTex
+ * Creates a single-pixel texture of the given color.
*/
-class TextureIterator {
-private:
- std::vector<std::pair<GLuint, std::string>> textures;
- std::vector<std::pair<GLuint, std::string>>::iterator position;
+class ColorTex : public Texture {
public:
- TextureIterator(void) {
- position = std::begin(textures);
- }
- ~TextureIterator(void) {
- textures.clear();
- }
- TextureIterator(const std::vector<std::string> &l) {
- for (const auto &s : l)
- textures.emplace_back(Texture::loadTexture(s), s);
-
- position = std::begin(textures);
- }
- void operator++(int) noexcept {
- if (++position < std::end(textures))
- glBindTexture(GL_TEXTURE_2D, (*position).first);
- else
- position = std::end(textures) - 1;
- }
- void operator--(int) noexcept {
- if (--position >= std::begin(textures))
- glBindTexture(GL_TEXTURE_2D, (*position).first);
- else
- position = std::begin(textures);
- }
- void operator()(const int &index) {
- if (index < 0 || index > static_cast<int>(textures.size()))
- throw std::invalid_argument("texture index out of range");
-
- position = std::begin(textures) + index;
- glBindTexture(GL_TEXTURE_2D, (*position).first);
- }
- const std::string& getTexturePath(const int &index) {
- if (index < 0 || index > static_cast<int>(textures.size()))
- throw std::invalid_argument("texture index out of range");
-
- return textures[index].second;
- }
- const vec2 getTextureDim(void) {
- return Texture::imageDim((*position).second);
- }
+ ColorTex(void);
+
+ /**
+ * Creates a texture of the given color.
+ * @param color the desired color
+ */
+ ColorTex(const Color& color);
};
/**
- * The Texturec class.
- *
- * This class can handle an array of textures and allows easy binding of those
- * textures.
+ * A collection of preloaded colors, to save resources.
*/
+namespace Colors {
+ extern ColorTex white; /**< A solid white texture. */
+ extern ColorTex black; /**< A solid black texture. */
+ extern ColorTex red; /**< A solid red texture. */
-class Texturec{
+ /**
+ * Creates the colors.
+ */
+ void init(void);
+}
+
+/**
+ * @class TextureIterator
+ * Keeps a collection of textures for easy usage/looping.
+ */
+class TextureIterator {
private:
- unsigned int texState;
+ /**
+ * The set of textures to loop through.
+ */
+ std::vector<Texture> textures;
+ /**
+ * The current position in the texture array.
+ * @see textures
+ */
+ std::vector<Texture>::iterator position;
public:
+ TextureIterator(void)
+ : position(std::begin(textures)) {}
+ ~TextureIterator(void) {}
- std::vector<GLuint> image;
- std::vector<std::string> texLoc;
-
- Texturec(uint amt, ...);
- Texturec(uint amt,const char **paths);
- Texturec(std::vector<std::string>vec);
- Texturec(std::initializer_list<std::string> l);
-
- ~Texturec();
+ /**
+ * Constructs a set of textures from the given list.
+ * @param l the list of textures
+ */
+ TextureIterator(const std::vector<std::string> &l);
+ /**
+ * Shifts to the next texture in the array, stopping at the end if we're there.
+ * Also binds the texture.
+ */
+ void operator++(int) noexcept;
- void bindNext();
- void bindPrev();
- void bind(unsigned int);
+ /**
+ * Shifts back in the array, staying at the beginning if we're there.
+ * Also binds the texture.
+ */
+ void operator--(int) noexcept;
+ /**
+ * Goes to the given index in the list.
+ * @param index the index to use
+ */
+ void operator()(const int &index);
+ /**
+ * Gets the dimensions of the currently selected texture.
+ * @return the texture's dimensions
+ */
+ inline const vec2& getTextureDim(void)
+ { return position->getDim(); }
};
-#endif //TEXTURE_H
+/**
+ * Frees all loaded textures, rendering them all useless.
+ */
+void unloadTextures(void);
+
+#endif //TEXTURE_HPP_
diff --git a/include/ui.hpp b/include/ui.hpp
index 8d517c7..519d259 100644
--- a/include/ui.hpp
+++ b/include/ui.hpp
@@ -39,8 +39,8 @@
** The UI namespace
** --------------------------------------------------------------------------*/
-void setControl(unsigned int index, SDL_Keycode key);
-SDL_Keycode getControl(unsigned int index);
+void setControl(int index, SDL_Keycode key);
+SDL_Keycode getControl(int index);
#include <entityx/entityx.h>
@@ -92,7 +92,7 @@ namespace ui {
void setFontFace(const char *ttf);
void setFontSize(unsigned int size);
- void setFontColor(unsigned char r,unsigned char g,unsigned char b, unsigned char a);
+ void setFontColor(int r, int g, int b, int a);
void setFontZ(float z);
/*
@@ -145,8 +145,6 @@ namespace ui {
void drawFade(void);
void fadeUpdate(void);
- void quitGame();
-
/*
* Toggle the black overlay thing.
*/
diff --git a/include/ui_quest.hpp b/include/ui_quest.hpp
index 8582b67..d770011 100644
--- a/include/ui_quest.hpp
+++ b/include/ui_quest.hpp
@@ -1,3 +1,8 @@
+/**
+ * @file ui_quest.hpp
+ * @brief Handles UI elements related to quests.
+ */
+
#ifndef UI_QUEST_HPP_
#define UI_QUEST_HPP_
@@ -6,12 +11,20 @@
namespace ui {
namespace quest {
+ /**
+ * A flag to determine if the UI should be drawn.
+ */
bool _toggle = false;
- void toggle(void) {
- _toggle ^= true;
- }
+ /**
+ * Toggles displaying of the UI.
+ */
+ inline void toggle(void)
+ { _toggle ^= true; }
+ /**
+ * Draws the quest UI to the screen, if enabled.
+ */
void draw(void) {
static unsigned int textWrap = 40;
diff --git a/include/world.hpp b/include/world.hpp
index 5c021bf..8864d30 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -60,13 +60,6 @@ typedef struct {
} WorldData;
/**
- * Alters how bright world elements are drawn.
- * This value is based off of the current time of day (tick count), set in
- * main.cpp.
- */
-extern int worldShade;
-
-/**
* Defines how many game ticks it takes to go from day to night or vice versa.
* Technically a half day cycle...
*/
@@ -108,8 +101,7 @@ struct WorldData2 {
// Indoor variables
bool indoor; /**< Set to true if this is an indoor world. */
- float indoorWidth; /**< The width of the indoor texture (house). */
- GLuint indoorTex; /**< The texture to draw (house). */
+ Texture indoorTex; /**< The house's inside texture. */
std::string outdoor; /**< The file name of the outdoor world. */
vec2 outdoorCoords; /**< The coordinates the player should spawn to when exiting. */