gdk-graphics 0b051eb9b5c1eaa0658babaa4463dd7a80aa9d2c
Loading...
Searching...
No Matches
sprite_animation.h
1// © Joseph Cameron - All Rights Reserved
2
3#ifndef GDK_SPRITE_ANIMATION_H
4#define GDK_SPRITE_ANIMATION_H
5
6#include <gdk/graphics_types.h>
7
8#include <map>
9
10namespace gdk {
13 class sprite_animation final {
14 public:
15 using normalized_texture_coordinate_type = float;
16 using normalized_time_type = float;
17 using texel_coordinate_type = int;
19 struct frame {
20 texel_coordinate_type x;
21 texel_coordinate_type y;
22 texel_coordinate_type w;
23 texel_coordinate_type h;
24 };
25
27 normalized_texture_coordinate_type u;
28 normalized_texture_coordinate_type v;
29 normalized_texture_coordinate_type w;
30 normalized_texture_coordinate_type h;
31 };
32 using frame_collection_type = std::map<normalized_time_type, frame>;
33
35 normalized_frame at(const normalized_time_type aNormalizedTime,
36 const texel_coordinate_type aTextureWidth,
37 const texel_coordinate_type aTextureHeight) const;
38
39 sprite_animation(frame_collection_type aFrameData);
40
41 private:
42 std::map<normalized_time_type, frame> m_Frames;
43 };
44}
45
46#endif
47
normalized_frame at(const normalized_time_type aNormalizedTime, const texel_coordinate_type aTextureWidth, const texel_coordinate_type aTextureHeight) const
gets the active frame at the given time in normalized texture coordinates
animation frame position and size in texels
Definition sprite_animation.h:19
animation frame position and size in normalized texture coordinate space
Definition sprite_animation.h:26