galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
AnimationSystem.cpp
Go to the documentation of this file.
1
7
12
13#include "AnimationSystem.hpp"
14
15namespace galaxy
16{
17 namespace systems
18 {
22
26
27 void AnimationSystem::update(entt::registry& registry)
28 {
29 const auto group = registry.group<components::Animated>(entt::get<components::Sprite>, entt::exclude<flags::Disabled>);
30 for (auto&& [entity, animated, sprite] : group.each())
31 {
32 if (!animated.m_paused && animated.m_anim != nullptr)
33 {
34 animated.m_duration += (GALAXY_DT * animated.m_anim->m_speed);
35
36 if (animated.m_duration >= animated.m_anim->current().m_duration)
37 {
38 animated.m_duration = 0.0;
39 animated.m_anim->next();
40
41 sprite.set_clip(animated.m_anim->current().m_bounds);
42 }
43 }
44 }
45 }
46 } // namespace systems
47} // namespace galaxy
Allows for an entity to be animated.
Definition Animated.hpp:22
void update(entt::registry &registry) override
Abstract implementation for updating the system. Use the manager to retreive your components.
virtual ~AnimationSystem()
Destructor.
Timer.hpp galaxy.
Definition Async.hpp:17