From 36ed75a7749b81fab69f66b9ef8bbf0d18489f73 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 19 Jan 2017 09:27:20 -0500 Subject: When entities stop, their legs stop --- include/components.hpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/components.hpp b/include/components.hpp index f8eeaf1..e0147b0 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -255,6 +255,22 @@ struct Limb { frame.push_back(fr); } + void firstFrame(Frame& duckmyass) { + // loop through the spritedata of the sprite we wanna change + for (auto &d : duckmyass) { + // if the sprite data is the same limb as this limb + if (d.first.limb == limbID) { + // rotate through (for safety) the first frame to set the limb + for (auto &fa : frame.at(0)) { + if (fa.first.limb == limbID) { + d.first = fa.first; + d.second = fa.second; + } + } + } + } + } + void nextFrame(Frame& duckmyass, float dt) { updateCurrent -= dt; if (updateCurrent <= 0) { @@ -306,8 +322,13 @@ struct Animate { // COMMENT - void firstFrame(Frame &sprite) { - (void)sprite; + void firstFrame(uint updateType, Frame &sprite) { + uint upid = updateType; //^see todo + for (auto &l : limb) { + if (l.updateType == upid) { + l.firstFrame(sprite); + } + } } //TODO make updateType an enum void updateAnimation(uint updateType, Frame& sprite, float dt) { -- cgit v1.2.3