The Table Engine
Texture Class Reference

Component for handling textures in the game engine. More...

#include <texture.h>

+ Inheritance diagram for Texture:
+ Collaboration diagram for Texture:

Public Member Functions

 Texture ()
 Default constructor for the Texture class, initializes an empty texture. More...
 
 Texture (SDL_Texture *texture)
 Constructor with texture initialization. More...
 
SDL_Texture * getTexture ()
 Retrieves the SDL_Texture object. More...
 
virtual void setTexture (SDL_Texture *texture)
 Sets the SDL_Texture object. More...
 
virtual void setSizeInSpriteMap (int w, int h)
 Sets the size of the sprite in the sprite map. More...
 
virtual void setPositionInSpriteMap (int x, int y)
 Sets the position of the sprite in the sprite map. More...
 
virtual void setFlipHorizontal (bool flip)
 Sets horizontal flip status. More...
 
virtual void setFlipVertical (bool flip)
 Sets vertical flip status. More...
 
virtual void setAngle (float angle)
 Sets the rotation angle of the texture. More...
 
virtual void update () override
 Updates texture properties, used mainly for animations or transformations. More...
 
virtual void render () override
 Renders the texture to the screen based on current properties. More...
 
void setColorMod (const SDL_Color &color)
 Sets the color modulation for the texture. More...
 
- Public Member Functions inherited from Component
 Component ()
 Default constructor for the Component. More...
 
 Component (std::string name)
 Constructs a Component with a specified name. More...
 
virtual ~Component ()
 Virtual destructor for safe polymorphic use. More...
 
std::string getName ()
 Retrieves the name of the component. More...
 
GameObjectgetOwner ()
 Retrieves the GameObject that owns this component. More...
 
void setName (std::string name)
 Sets the name of the component. More...
 
void setOwner (GameObject *owner)
 Sets the GameObject owner of this component. More...
 
virtual void input ()
 Virtual method for handling input, intended to be overridden by derived components. More...
 

Protected Attributes

SDL_Texture * m_texture
 Pointer to the SDL_Texture object. More...
 
SDL_Renderer * m_renderer
 Pointer to the SDL_Renderer associated with this texture. More...
 
SDL_Rect * m_spriteBox
 Destination rectangle on the screen for rendering the texture. More...
 
SDL_Rect * m_spriteClip
 Source rectangle in the sprite sheet for slicing the texture. More...
 
bool m_flipHorizontal = false
 Flag for horizontal flipping of the texture. More...
 
bool m_flipVertical = false
 Flag for vertical flipping of the texture. More...
 
float m_angle = 0.0f
 Rotation angle of the texture in degrees. More...
 
- Protected Attributes inherited from Component
std::string m_name
 Name of the component, useful for identification or debugging. More...
 
GameObjectm_owner
 Pointer to the GameObject that owns this component. More...
 

Detailed Description

Component for handling textures in the game engine.

The Texture class extends the Component class, providing specific functionalities for texture management including handling sprite sheets, texture transformations, and rendering operations.

Definition at line 20 of file texture.h.

Constructor & Destructor Documentation

◆ Texture() [1/2]

Texture::Texture ( )

Default constructor for the Texture class, initializes an empty texture.

Definition at line 5 of file texture.cpp.

◆ Texture() [2/2]

Texture::Texture ( SDL_Texture *  texture)

Constructor with texture initialization.

Parameters
texturePointer to an SDL_Texture to be managed.

Definition at line 13 of file texture.cpp.

Member Function Documentation

◆ getTexture()

SDL_Texture * Texture::getTexture ( )

Retrieves the SDL_Texture object.

Returns
SDL_Texture* Pointer to the managed SDL_Texture object.

Definition at line 17 of file texture.cpp.

◆ render()

void Texture::render ( )
overridevirtual

Renders the texture to the screen based on current properties.

Reimplemented from Component.

Reimplemented in AnimationsManager.

Definition at line 59 of file texture.cpp.

◆ setAngle()

void Texture::setAngle ( float  angle)
virtual

Sets the rotation angle of the texture.

Parameters
angleRotation angle in degrees.

Reimplemented in AnimationsManager.

Definition at line 51 of file texture.cpp.

◆ setColorMod()

void Texture::setColorMod ( const SDL_Color &  color)

Sets the color modulation for the texture.

Parameters
colorSDL_Color structure containing the RGB values to modulate the texture.

Definition at line 71 of file texture.cpp.

◆ setFlipHorizontal()

void Texture::setFlipHorizontal ( bool  flip)
virtual

Sets horizontal flip status.

Parameters
flipTrue to flip the texture horizontally, false otherwise.

Reimplemented in AnimationsManager.

Definition at line 43 of file texture.cpp.

◆ setFlipVertical()

void Texture::setFlipVertical ( bool  flip)
virtual

Sets vertical flip status.

Parameters
flipTrue to flip the texture vertically, false otherwise.

Reimplemented in AnimationsManager.

Definition at line 47 of file texture.cpp.

◆ setPositionInSpriteMap()

void Texture::setPositionInSpriteMap ( int  x,
int  y 
)
virtual

Sets the position of the sprite in the sprite map.

Parameters
xHorizontal position of the sprite in the sprite sheet.
yVertical position of the sprite in the sprite sheet.

Reimplemented in AnimationsManager.

Definition at line 37 of file texture.cpp.

◆ setSizeInSpriteMap()

void Texture::setSizeInSpriteMap ( int  w,
int  h 
)
virtual

Sets the size of the sprite in the sprite map.

Parameters
wWidth of the sprite in the sprite sheet.
hHeight of the sprite in the sprite sheet.

Reimplemented in AnimationsManager.

Definition at line 31 of file texture.cpp.

◆ setTexture()

void Texture::setTexture ( SDL_Texture *  texture)
virtual

Sets the SDL_Texture object.

Parameters
texturePointer to the new SDL_Texture to be managed.

Reimplemented in AnimationsManager.

Definition at line 21 of file texture.cpp.

◆ update()

void Texture::update ( )
overridevirtual

Updates texture properties, used mainly for animations or transformations.

Reimplemented from Component.

Reimplemented in AnimationsManager, and Animation.

Definition at line 55 of file texture.cpp.

Member Data Documentation

◆ m_angle

float Texture::m_angle = 0.0f
protected

Rotation angle of the texture in degrees.

Definition at line 29 of file texture.h.

◆ m_flipHorizontal

bool Texture::m_flipHorizontal = false
protected

Flag for horizontal flipping of the texture.

Definition at line 27 of file texture.h.

◆ m_flipVertical

bool Texture::m_flipVertical = false
protected

Flag for vertical flipping of the texture.

Definition at line 28 of file texture.h.

◆ m_renderer

SDL_Renderer* Texture::m_renderer
protected

Pointer to the SDL_Renderer associated with this texture.

Definition at line 23 of file texture.h.

◆ m_spriteBox

SDL_Rect* Texture::m_spriteBox
protected

Destination rectangle on the screen for rendering the texture.

Definition at line 24 of file texture.h.

◆ m_spriteClip

SDL_Rect* Texture::m_spriteClip
protected

Source rectangle in the sprite sheet for slicing the texture.

Definition at line 25 of file texture.h.

◆ m_texture

SDL_Texture* Texture::m_texture
protected

Pointer to the SDL_Texture object.

Definition at line 22 of file texture.h.


The documentation for this class was generated from the following files: