0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 12:33:43 +00:00
SDL_Minigame/include/SpriteComponent.h

38 lines
720 B
C++

#pragma once
#include "AnimationHandler.h"
#include "Component.h"
#include "Game.h"
#include <map>
class TransformComponent;
class SpriteComponent : public Component
{
public:
int animationIndex = 0;
std::map<AnimationType, Animation*> animations;
private:
TransformComponent* transform;
SDL_Texture* texture;
SDL_Rect srcRect, destRect;
bool animated = false;
int frames = 0;
int speed = 100;
public:
SpriteComponent() = default;
SpriteComponent(const char* path);
SpriteComponent(const char* path, bool isAnimated);
~SpriteComponent();
void setTexture(const char* path);
void init() override;
void update() override;
void draw() override;
void play(AnimationType type);
};