aboutsummaryrefslogtreecommitdiffstats
path: root/include/components.hpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-12-21 21:40:05 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-12-21 21:40:05 -0500
commitae9ceadaa184f5e9775135ae264c8bbffd4efa9d (patch)
tree3707642bda2646ede6d4c77f33b9d8a0326b0636 /include/components.hpp
parenta44540462145212f7f2cc3ea2690308c58f60358 (diff)
parentfa802f8fbc62910b37002bcdd2f7c110f488e392 (diff)
Merge branch 'master' of https://github.com/tcsullivan/gamedev
Diffstat (limited to 'include/components.hpp')
-rw-r--r--include/components.hpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/include/components.hpp b/include/components.hpp
index f6521f8..bbf153a 100644
--- a/include/components.hpp
+++ b/include/components.hpp
@@ -147,7 +147,7 @@ struct Sprite {
Sprite(bool left = false)
: faceLeft(left) {}
- std::vector<std::pair<SpriteData, vec2>> getSprite() {
+ Frame getSprite() {
return sprite;
}
@@ -214,21 +214,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();
}
};