diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/animation_system.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
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) { | |||
65 | std::string animLine; | 65 | std::string animLine; |
66 | std::getline(datafile, animLine); // blank | 66 | std::getline(datafile, animLine); // blank |
67 | while (std::getline(datafile, animLine)) { | 67 | while (std::getline(datafile, animLine)) { |
68 | std::regex re(R"(([a-z!._]+)\[([a-z_]+)\]: ([0-9,]+))"); | 68 | std::regex re(R"(([a-z!._]+)\[([a-z_]+)\]: ([0-9,#]+))"); |
69 | std::smatch m; | 69 | std::smatch m; |
70 | std::regex_match(animLine, m, re); | 70 | std::regex_match(animLine, m, re); |
71 | 71 | ||
@@ -73,7 +73,15 @@ void AnimationSystem::initSprite(int spriteId, std::string_view filename) { | |||
73 | Animation anim; | 73 | Animation anim; |
74 | auto framestrs = splitStr<std::list<std::string>>(m[3], ","); | 74 | auto framestrs = splitStr<std::list<std::string>>(m[3], ","); |
75 | for (const std::string& f : framestrs) { | 75 | for (const std::string& f : framestrs) { |
76 | anim.frameIndices.push_back(std::stoi(f)); | 76 | int times = 1; |
77 | size_t repeat_it = f.find("#"); | ||
78 | if (repeat_it != std::string::npos) { | ||
79 | times = std::stoi(f.substr(repeat_it + 1)); | ||
80 | } | ||
81 | |||
82 | for (int i=0; i<times; i++) { | ||
83 | anim.frameIndices.push_back(std::stoi(f)); | ||
84 | } | ||
77 | } | 85 | } |
78 | 86 | ||
79 | if (animName.back() == '!') { | 87 | if (animName.back() == '!') { |