Jagguar Game Engine

Loading...
Searching...
No Matches
Sprite.hpp
1#ifndef SPRITE_H
2#define SPRITE_H
3
4#include <string>
5
6#include "IGraphicsEngineRenderer.hpp"
7#include "TinyMath.hpp"
8#include "TransformComponent.hpp"
9#include <string>
10
14 class SpriteComponent : public Component
15{
16 public:
22 SpriteComponent(TransformComponent *transform);
23
27 ~SpriteComponent();
28
39 void LoadImage(std::string filePath, SDL_Renderer *ren, int w, int h, int frames, Vec2D targetDisplay);
40
46 Vec2D getDimensions();
47
52 void Update(SDL_Event e, int frame, std::vector<std::string> broadcastList) override;
53
59 void Render(SDL_Renderer *ren) override;
60
61 void ShowComponentEditor(bool *showEditor) override;
62
63 const char *ComponentTypeName() override { return "Sprite Component"; }
64
65 private:
66 unsigned int mCurrentFrame{0};
67 unsigned int mLastFrame{7};
68 // An SDL Surface contains pixel data to draw an image
69 SDL_Surface *mSpriteSheet = nullptr;
70 SDL_Texture *mTexture = nullptr;
71
72 SDL_Rect mSrc;
73 SDL_Rect mDest;
74
75 int width;
76 int height;
77 int frameCount;
78
79 Vec2D dimensions;
80
81 TransformComponent *transform;
82 SDL_Renderer *last_used = nullptr;
83};
84
85#endif
Component
Definition: Component.hpp:38
SpriteComponent
Definition: Sprite.hpp:15
SpriteComponent::ShowComponentEditor
void ShowComponentEditor(bool *showEditor) override
Definition: Sprite.cpp:51
SpriteComponent::LoadImage
void LoadImage(std::string filePath, SDL_Renderer *ren, int w, int h, int frames, Vec2D targetDisplay)
Definition: Sprite.cpp:72
SpriteComponent::Render
void Render(SDL_Renderer *ren) override
Definition: Sprite.cpp:46
SpriteComponent::ComponentTypeName
const char * ComponentTypeName() override
Definition: Sprite.hpp:63
SpriteComponent::~SpriteComponent
~SpriteComponent()
Definition: Sprite.cpp:10
SpriteComponent::Update
void Update(SDL_Event e, int frame, std::vector< std::string > broadcastList) override
Definition: Sprite.cpp:19
SpriteComponent::getDimensions
Vec2D getDimensions()
Definition: Sprite.cpp:98
TransformComponent
Definition: TransformComponent.hpp:12
Vec2D
Definition: TinyMath.hpp:14