3#ifndef GDK_GRAPHICS_EXT_SPRITE_ANIMATION_H
4#define GDK_GRAPHICS_EXT_SPRITE_ANIMATION_H
6#include <gdk/graphics/data_types.h>
12namespace gdk::graphics {
16 using normalized_texture_coordinate_type = float;
17 using time_type = float;
18 using texel_coordinate_type = int;
28 texel_coordinate_type x;
29 texel_coordinate_type y;
30 texel_coordinate_type w;
31 texel_coordinate_type h;
37 normalized_texture_coordinate_type u;
38 normalized_texture_coordinate_type v;
39 normalized_texture_coordinate_type w;
40 normalized_texture_coordinate_type h;
59 [[nodiscard]] time_type
length()
const;
75 texel_coordinate_type aTextureWidth,
76 texel_coordinate_type aTextureHeight,
81 std::vector<double> m_Starts;
84 std::vector<normalized_frame> m_Frames;
sprite_animation(std::span< const frame > aFrameData, texel_coordinate_type aTextureWidth, texel_coordinate_type aTextureHeight, play_mode aPlayMode=play_mode::loop)
builds an animation from frames cut out of a sprite sheet.
std::size_t frame_count() const
how many frames the animation has
bool has_finished(time_type aTime) const
whether a once animation has played out by the given time.
play_mode
what happens when the animation reaches its end
Definition sprite_animation.h:21
@ once
stop on the last frame. has_finished() then reports true.
Definition sprite_animation.h:23
@ loop
start again. The default, and what an idle or walk cycle wants.
Definition sprite_animation.h:22
time_type length() const
how long one cycle of the animation lasts, the total of its frames' lengths
normalized_frame at(time_type aTime) const
the frame showing at the given time, in normalized texture coordinates.
animation frame position and size in texels
Definition sprite_animation.h:27
animation frame position and size in normalized texture coordinate space
Definition sprite_animation.h:36