-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphics-component.hpp
More file actions
37 lines (31 loc) · 890 Bytes
/
graphics-component.hpp
File metadata and controls
37 lines (31 loc) · 890 Bytes
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
#pragma once
#include <SDL2/SDL.h>
#include <vector>
#include <unordered_map>
#include "components.hpp"
#include "animation.hpp"
class GraphicsComponent : public Component {
public:
SDL_RendererFlip flip;
GraphicsComponent(SDL_Rect&);
bool animation_complete = false;
int alpha = 255;
int animationIndex = 0;
void draw(Entity*);
void addAnimation(int, SDL_Rect, int, int);
void addAnimation(int, SDL_Rect, int, int, int);
void addAnimation(int, SDL_Rect, int, int, int, int);
void setAnimation(int, SDL_RendererFlip);
void setAnimation(int);
void unsetAnimation();
void update(Entity*);
private:
std::unordered_map<int, Animation*> animation_map;
Animation* currentAnimation;
SDL_Rect src;
bool bounce = false;
int frameDelay = 0;
int frameIndex = 0;
int x_offset = 0;
int y_offset = 0;
};