diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-12-10 18:33:40 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-12-10 18:33:40 -0500 |
commit | b6141f6cbf07f0fbfadc892488f2ba83b7cf1719 (patch) | |
tree | d48e05a6ab29409350637b67aa9777f09af9709a /include | |
parent | e472a62b750e57724a26d299bb682b4f39405d05 (diff) |
doc updates
Diffstat (limited to 'include')
-rw-r--r-- | include/brice.hpp | 39 | ||||
-rw-r--r-- | include/components.hpp | 2 | ||||
-rw-r--r-- | include/config.hpp | 49 | ||||
-rw-r--r-- | include/engine.hpp | 63 | ||||
-rw-r--r-- | include/gametime.hpp | 36 | ||||
-rw-r--r-- | include/save_util.hpp | 36 | ||||
-rw-r--r-- | include/shader_utils.hpp | 3 | ||||
-rw-r--r-- | include/ui_quest.hpp | 19 |
8 files changed, 200 insertions, 47 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/components.hpp b/include/components.hpp index d630f83..2e09fc7 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -151,7 +151,7 @@ struct Sprite { Sprite(bool left = false) : faceLeft(left) {} - std::vector<std::pair<SpriteData, vec2>> getSprite() { + Frame getSprite() { return sprite; } diff --git a/include/config.hpp b/include/config.hpp index bc9d052..908c376 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; + + /** + * 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 c842b59..d4028d8 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,27 +15,55 @@ //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); + + /** + * 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); } @@ -38,16 +71,32 @@ public: namespace game { + /** + * Handles all game events. + */ extern entityx::EventManager events; + + /** + * Handles entity data. + */ extern entityx::EntityManager entities; + /** + * Handles sprite loading, for the sprite system. + */ + extern SpriteLoader sprite_l; + + /** + * 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/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..08ca7b3 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 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; |