This repository was archived by the owner on Mar 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsomething_sprite.hpp
More file actions
73 lines (59 loc) · 1.65 KB
/
something_sprite.hpp
File metadata and controls
73 lines (59 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef SOMETHING_SPRITE_HPP_
#define SOMETHING_SPRITE_HPP_
#include "./something_index.hpp"
struct Texture
{
SDL_Surface *surface;
SDL_Texture *texture;
SDL_Surface *surface_mask;
SDL_Texture *texture_mask;
};
struct Sprite
{
SDL_Rect srcrect;
Index<Texture> texture_index;
void render(SDL_Renderer *renderer,
Rectf destrect,
SDL_RendererFlip flip = SDL_FLIP_NONE,
RGBA shade = {0, 0, 0, 0},
double angle = 0.0,
Maybe<Vec2f> pivot = {}) const;
void render(SDL_Renderer *renderer,
Vec2f pos,
SDL_RendererFlip flip = SDL_FLIP_NONE,
RGBA shade = {0, 0, 0, 0},
double angle = 0.0,
Maybe<Vec2f> pivot = {}) const;
};
struct Frames
{
Sprite *sprites;
size_t count;
float duration;
};
struct Frames_Animat
{
Index<Frames> frames_index;
size_t frame_current;
float frame_cooldown;
void reset();
void render(SDL_Renderer *renderer,
Rectf dstrect,
SDL_RendererFlip flip = SDL_FLIP_NONE,
RGBA shade = {0, 0, 0, 0},
double angle = 0.0) const;
void render(SDL_Renderer *renderer,
Vec2f pos,
SDL_RendererFlip flip = SDL_FLIP_NONE,
RGBA shade = {0, 0, 0, 0},
double angle = 0.0) const;
void update(float dt);
bool has_finished() const;
};
Frames_Animat frames_animat(Index<Frames> frames_index)
{
Frames_Animat result = {};
result.frames_index = frames_index;
return result;
}
#endif // SOMETHING_SPRITE_HPP_