diff options
| author | hachem <im@hachem.wtf> | 2026-08-30 17:59:14 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-30 17:59:14 +0200 |
| commit | f099a82eb2b2a6bb64cd51d98ab027f4ce45078c (patch) | |
| tree | ac83cedd80afb500b63ff8e517f6e24939742f9c /src/ui/animated_image.h | |
| parent | 5074ae48a95f96ec3370e464bb3c7242a3455411 (diff) | |
feat: little pepe
Diffstat (limited to 'src/ui/animated_image.h')
| -rw-r--r-- | src/ui/animated_image.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/ui/animated_image.h b/src/ui/animated_image.h new file mode 100644 index 0000000..4987d30 --- /dev/null +++ b/src/ui/animated_image.h @@ -0,0 +1,39 @@ +#pragma once + +#include <cstddef> +#include <filesystem> +#include <vector> + +namespace Hsdbg +{ + class AnimatedImage + { + public: + AnimatedImage() = default; + ~AnimatedImage(); + + AnimatedImage(const AnimatedImage&) = delete; + AnimatedImage(AnimatedImage&&) = delete; + auto operator=(const AnimatedImage&) -> AnimatedImage& = delete; + auto operator=(AnimatedImage&&) -> AnimatedImage& = delete; + + auto load(const std::filesystem::path& path) -> bool; + auto unload() -> void; + + auto advance(float delta_seconds) -> void; + + auto valid() const -> bool { return !m_frames.empty(); } + + auto texture() const -> unsigned int; + auto width() const -> float { return static_cast<float>(m_width); } + auto height() const -> float { return static_cast<float>(m_height); } + + private: + std::vector<unsigned int> m_frames; + std::vector<float> m_delays; + int m_width = 0; + int m_height = 0; + std::size_t m_current = 0; + float m_accumulator = 0.0f; + }; +} |
