From bf39e32f2ec9008e48b0dd3ad53d640434e0738a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 24 Feb 2021 10:22:41 -0500 Subject: Added shorthand for repeated frames in animations --- src/animation_system.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/animation_system.cpp') diff --git a/src/animation_system.cpp b/src/animation_system.cpp index 2c2c6a5..b57816b 100644 --- a/src/animation_system.cpp +++ b/src/animation_system.cpp @@ -65,7 +65,7 @@ void AnimationSystem::initSprite(int spriteId, std::string_view filename) { std::string animLine; std::getline(datafile, animLine); // blank while (std::getline(datafile, animLine)) { - std::regex re(R"(([a-z!._]+)\[([a-z_]+)\]: ([0-9,]+))"); + std::regex re(R"(([a-z!._]+)\[([a-z_]+)\]: ([0-9,#]+))"); std::smatch m; std::regex_match(animLine, m, re); @@ -73,7 +73,15 @@ void AnimationSystem::initSprite(int spriteId, std::string_view filename) { Animation anim; auto framestrs = splitStr>(m[3], ","); for (const std::string& f : framestrs) { - anim.frameIndices.push_back(std::stoi(f)); + int times = 1; + size_t repeat_it = f.find("#"); + if (repeat_it != std::string::npos) { + times = std::stoi(f.substr(repeat_it + 1)); + } + + for (int i=0; i