diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-01-22 12:03:22 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-01-22 12:03:22 -0500 |
commit | fa341a962e351de9efba3cd6d3dccb582b625721 (patch) | |
tree | 08a0bd1caed82b2fb8d296f79f87dbd993b0cbc9 /include | |
parent | d543982669364f66fc797f78aa2d604db4bc4325 (diff) |
windows
Diffstat (limited to 'include')
-rw-r--r-- | include/bmpimage.hpp | 4 | ||||
-rw-r--r-- | include/components.hpp | 16 | ||||
-rw-r--r-- | include/engine.hpp | 2 | ||||
-rw-r--r-- | include/thread.hpp | 36 | ||||
-rw-r--r-- | include/world.hpp | 2 |
5 files changed, 50 insertions, 10 deletions
diff --git a/include/bmpimage.hpp b/include/bmpimage.hpp index 69b78ac..5e056fe 100644 --- a/include/bmpimage.hpp +++ b/include/bmpimage.hpp @@ -1,3 +1,5 @@ +#ifndef __WIN32__ + #ifndef BMP_IMAGE_HPP #define BMP_IMAGE_HPP @@ -32,3 +34,5 @@ typedef struct { } __attribute__((packed)) BITMAPINFOHEADER; #endif // BMP_IMAGE_HPP + +#endif // __WIN32__
\ No newline at end of file diff --git a/include/components.hpp b/include/components.hpp index 5292fb2..14cff81 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -319,11 +319,11 @@ struct Limb { float updateRate; /**< How often we will change each frame. */ float updateCurrent; /**< How much has been updated in the current frame. */ - uint updateType; /**< What the updateRate will base it's updates off of. + unsigned int updateType; /**< What the updateRate will base it's updates off of. ie: Movement, attacking, jumping. */ - uint limbID; /**< The id of the limb we will be updating */ + unsigned int limbID; /**< The id of the limb we will be updating */ - uint index = 0; /**< The current sprite being used for the limb. */ + unsigned int index = 0; /**< The current sprite being used for the limb. */ std::vector<Frame> frame; /**< The multiple frames of each limb. */ }; @@ -333,7 +333,7 @@ struct Animate { // COMMENT std::vector<Limb> limb; // COMMENT - uint index; + unsigned int index; Animate(){ index = 0; @@ -341,8 +341,8 @@ struct Animate { // COMMENT - void firstFrame(uint updateType, Frame &sprite) { - uint upid = updateType; //^see todo + void firstFrame(unsigned int updateType, Frame &sprite) { + unsigned int upid = updateType; //^see todo for (auto &l : limb) { if (l.updateType == upid) { l.firstFrame(sprite); @@ -350,8 +350,8 @@ struct Animate { } } //TODO make updateType an enum - void updateAnimation(uint updateType, Frame& sprite, float dt) { - uint upid = updateType; //^see todo + void updateAnimation(unsigned int updateType, Frame& sprite, float dt) { + unsigned int upid = updateType; //^see todo for (auto &l : limb) { if (l.updateType == upid) { l.nextFrame(sprite, dt); diff --git a/include/engine.hpp b/include/engine.hpp index fda9980..112fd3c 100644 --- a/include/engine.hpp +++ b/include/engine.hpp @@ -8,7 +8,7 @@ #include <atomic> #include <chrono> -#include <thread> +#include <thread.hpp> #include <entityx/entityx.h> diff --git a/include/thread.hpp b/include/thread.hpp new file mode 100644 index 0000000..3adc43d --- /dev/null +++ b/include/thread.hpp @@ -0,0 +1,36 @@ +#ifndef THREAD_HPP_ +#define THREAD_HPP_ + +#ifndef __WIN32__ +#include <thread> +#else +#include <win32thread.hpp> +#endif // __WIN32__ + +#include <atomic> +#include <entityx/entityx.h> + +class GameThread : public entityx::Receiver<GameThread> { +private: + std::atomic_bool die; + std::thread thread; + +public: + GameThread(std::function<void(void)> func) { + die.store(false); + thread = std::thread([&](std::function<void(void)> f) { + while (!die.load()) + f(); + }, func); + } + + ~GameThread(void) { + thread.join(); + } + + inline void stop(void) { + die.store(true); + } +}; + +#endif // THREAD_HPP_
\ No newline at end of file diff --git a/include/world.hpp b/include/world.hpp index fe7d819..b4986e1 100644 --- a/include/world.hpp +++ b/include/world.hpp @@ -6,7 +6,6 @@ #define WORLD_HPP_ #include <string> -#include <thread> #include <vector> #include <SDL2/SDL_mixer.h> @@ -18,6 +17,7 @@ using namespace tinyxml2; #include <components.hpp> #include <events.hpp> #include <texture.hpp> +#include <thread.hpp> #include <vector2.hpp> /** |