diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-11-30 21:37:01 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-11-30 21:37:01 -0500 |
commit | e472a62b750e57724a26d299bb682b4f39405d05 (patch) | |
tree | 6c9a722c6840d1f7446edec2be3290da20be5db6 /include | |
parent | cc2a768ff19e9fc83661a51d4cb4fef9b354ff30 (diff) | |
parent | 44a42be2087b0d6e4b732596029d8f41d7ca6b40 (diff) |
fixed coalesce
Diffstat (limited to 'include')
-rw-r--r-- | include/common.hpp | 6 | ||||
-rw-r--r-- | include/components.hpp | 21 |
2 files changed, 13 insertions, 14 deletions
diff --git a/include/common.hpp b/include/common.hpp index 7b98ea9..3caa083 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -58,11 +58,7 @@ typedef unsigned int uint; #define BREAKPOINT __asm__("int $3") -template<typename T> -inline const T * const& coalesce(const void * &p1, const void * &p2) -{ - return ((p1 == nullptr) ? reinterpret_cast<T*>(p2) : p1); -} +#define coalesce(v1, v2) ((v1 != nullptr) ? v1 : v2) /** * Creates a coordinate of integers. diff --git a/include/components.hpp b/include/components.hpp index 4f8ef56..d630f83 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -216,21 +216,24 @@ struct Animate { // COMMENT std::vector<Frame> frame; // COMMENT - std::vector<Frame>::iterator currentFrame; + uint index; Animate(){ - currentFrame = std::begin(frame); + index = 0; } // COMMENT Frame nextFrame() { - std::rotate(frame.begin(), frame.begin()+1, frame.end()); - return frame[0]; - /*if (currentFrame < std::end(frame)) - return (*currentFrame++); - else - currentFrame = std::begin(frame); - return (*currentFrame);*/ + if (index < frame.size() - 1) { + index++; + } else { + index = 0; + } + return frame.at(index); + } + + Frame firstFrame() { + return frame.front(); } }; |