VEGO-Engine  0.1
Loading...
Searching...
No Matches
SpriteComponent.h
1#pragma once
2
3#include <map>
4#include <SDL3/SDL_render.h>
5#include <memory>
6#include <string>
7
8#include "Textures.h"
9#include "AnimationHandler.h"
10#include "Component.h"
11#include "Direction.h"
12#include "RenderObject.h"
13
16
17class SpriteComponent : public Component, public RenderObject
18{
19public:
20 int animationIndex = 0;
21
22 std::map<std::string, std::unique_ptr<Animation>>* animations = nullptr;
23
24private:
25 TransformComponent* transform;
26 SDL_Texture* texture;
27 SDL_FRect srcRect, destRect;
28
29 Textures textureEnum;
30
31 bool animated = false;
32 uint8_t frames = 0;
33 uint8_t speed = 100;
34 bool flipped = false;
35
36 int textureXOffset;
37 int textureYOffset;
38
39 //there should be a better solution as this variable is only used for the loading of the tmx map
40 //TODO: improve this in the future and also remove it from the scope of the developer
41 const char* path;
42
43public:
44 //debug
45 Textures getTexture() { return this->textureEnum; }
46
47
48
52 SpriteComponent(Textures texture, int zIndex);
53
58 SpriteComponent(Textures texture, int xOffset, int yOffset, int zIndex);
63 SpriteComponent(const char* path, int xOffset, int yOffset, int zIndex);
71 Textures texture,
72 bool isAnimated,
73 std::map<std::string, std::unique_ptr<Animation>>* animationList,
74 std::string defaultAnimation,
75 int zIndex);
77
78 void setTexture(Textures texture);
79 void setMapTileTexture(const char* path);
80
81 void init() override;
82 void update(uint_fast16_t diffTime) override;
83 void draw() override;
84 void playAnimation(std::string type);
85 void setDirection(Direction direction);
86};
SpriteComponent(Textures texture, int zIndex)
Constructor for SpriteComponent.
Definition SpriteComponent.cpp:18
Forward declaration of the Textures enum class.
Adds a transform to an entity when added via entity.addComponent()
Definition TransformComponent.h:11