Nox Engine
 
Loading...
Searching...
No Matches
Sprites.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "ECS.h"
9#include "TextureManager.h"
10#include "Transform.h"
11#include <SDL2/SDL.h>
12
18struct Sprites : public Component {
19 friend struct Animator;
20
21public:
26 Sprites(const char* tex);
34 Sprites(const char* tex, int nFrames, int mSpeed, bool loop);
35 ~Sprites();
36
40 void init() override;
44 void update() override;
48 void draw() override;
54
55private:
56 Transform* transform;
57 SDL_Texture* texture;
58 SDL_Rect srcRect, destRect;
59
64 void setTex(const char* tex);
65};
Defines the core classes for the Entity-Component-System (ECS) architecture.
ComponentID getComponentTypeID() noexcept
Gets the unique ID for a given component type.
Definition ECS.h:39
A static utility class for loading and drawing textures.
Defines the component for managing an entity's position, rotation, and scale.
Manages sprite sheet animations and transitions between them using a state machine.
Definition Animator.h:15
The base class for all components in the ECS.
Definition ECS.h:53
A component that gives an entity a visual representation using a texture.
Definition Sprites.h:18
void recalcSpriteDimensions()
Recalculates the sprite's on-screen dimensions based on texture size and transform scale.
Definition Sprites.cpp:32
void init() override
Initializes the sprite, getting the entity's transform and loading the texture.
Definition Sprites.cpp:14
void draw() override
Draws the sprite's current texture to the screen.
Definition Sprites.cpp:28
void update() override
Updates the destination rectangle for rendering based on the transform.
Definition Sprites.cpp:21
Sprites(const char *tex, int nFrames, int mSpeed, bool loop)
Constructs a sprite with simple, built-in animation capabilities.
Stores an entity's position, velocity, scale, and rotation.
Definition Transform.h:17