From f099a82eb2b2a6bb64cd51d98ab027f4ce45078c Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 30 Aug 2026 17:59:14 +0200 Subject: feat: little pepe --- src/ui/animated_image.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/ui/animated_image.h (limited to 'src/ui/animated_image.h') 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 +#include +#include + +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(m_width); } + auto height() const -> float { return static_cast(m_height); } + + private: + std::vector m_frames; + std::vector m_delays; + int m_width = 0; + int m_height = 0; + std::size_t m_current = 0; + float m_accumulator = 0.0f; + }; +} -- cgit v1.3