PROTO::KLUDGE  0.1
Quick prototyping library for games using SDL and OpenGL.
pk::Sprite Class Reference

Drawable sprite using a Texture as its drawable resource. Part of the Decorator pattern along with the Drawable class. More...

#include <Sprite.hpp>

Inheritance diagram for pk::Sprite:
Inheritance graph
Collaboration diagram for pk::Sprite:
Collaboration graph

Public Member Functions

 Sprite ()
 Default constructor. More...
 
 Sprite (Texture *const texture)
 
 Sprite (Texture *const texture, const SDL_Rect &rect)
 
virtual ~Sprite ()
 
void setSpriteData (spriteData &s)
 Set the data for the Sprite object. More...
 
spriteDatagetSpriteData ()
 Get the current spriteData for the Sprite object. More...
 
void setTexture (Texture *const texture)
 Set the Sprite texture. More...
 
Texture *const getTexture ()
 Get the Sprite texture. More...
 
void setBoundsRect (SDL_Rect &rect)
 Set the bounding rectangle for the Sprite. More...
 
const SDL_Rect & getBoundsRect ()
 Get the current bounding rectangle of the Sprite. More...
 
const SDL_Point & getCenter ()
 Get the current center point of the Sprite. More...
 
void setFlip (SDL_RendererFlip &type)
 Set the flip type for the Sprite (SDL_FLIP_NONE, SDL_FLIP_HORIZONTAL, SDL_FLIP_VERTICAL). More...
 
const SDL_RendererFlip & getFlip ()
 Get the current flip type for the Sprite (default is SDL_FLIP_NONE). More...
 
void draw (SDL_Renderer *const renderTarget, SDL_Rect *const renderTargetRect) override
 Draw the Sprite to a render target. More...
 
- Public Member Functions inherited from pk::Drawable
 Drawable ()
 Drawable constructor. Call explicitly in inherited classes. More...
 
virtual ~Drawable ()
 

Private Member Functions

void updateSprite ()
 Used internally when the render mode is initialized or changed. More...
 

Private Attributes

spriteData m_data
 Data important to the construction and state maintenance of a Sprite. More...
 

Detailed Description

Drawable sprite using a Texture as its drawable resource. Part of the Decorator pattern along with the Drawable class.

Constructor & Destructor Documentation

◆ Sprite() [1/3]

pk::Sprite::Sprite ( )

Default constructor.

◆ Sprite() [2/3]

pk::Sprite::Sprite ( Texture *const  texture)

◆ Sprite() [3/3]

pk::Sprite::Sprite ( Texture *const  texture,
const SDL_Rect &  rect 
)

◆ ~Sprite()

virtual pk::Sprite::~Sprite ( )
virtual

Member Function Documentation

◆ draw()

void pk::Sprite::draw ( SDL_Renderer *const  renderTarget,
SDL_Rect *const  renderTargetRect 
)
overridevirtual

Draw the Sprite to a render target.

Parameters
SDL_Renderer* const renderTarget - the renderer to draw with.
SDL_Rect* const renderTargetRect - the area of the render target to draw to.

Implements pk::Drawable.

◆ getBoundsRect()

const SDL_Rect & pk::Sprite::getBoundsRect ( )
inline

Get the current bounding rectangle of the Sprite.

Returns
SDL_Point - an SDL_Rect corresponding to the bounding rectangle of the Sprite.
Here is the call graph for this function:

◆ getCenter()

SDL_Point pk::Sprite::getCenter ( )
inline

Get the current center point of the Sprite.

Returns
SDL_Point - an SDL_Point corresponding to the current center point of the Sprite.
Here is the call graph for this function:

◆ getFlip()

const SDL_RendererFlip & pk::Sprite::getFlip ( )
inline

Get the current flip type for the Sprite (default is SDL_FLIP_NONE).

Returns
SDL_RendererFlip & - a const reference to an SDL_RendererFlip constant (SDL_FLIP_NONE, SDL_FLIP_HORIZONTAL, SDL_FLIP_VERTICAL).

◆ getSpriteData()

spriteData & pk::Sprite::getSpriteData ( )
inline

Get the current spriteData for the Sprite object.

Returns
spriteData & - sprite data for the Sprite object.

◆ getTexture()

Texture *const pk::Sprite::getTexture ( )
inline

Get the Sprite texture.

◆ setBoundsRect()

void pk::Sprite::setBoundsRect ( SDL_Rect &  rect)
inline

Set the bounding rectangle for the Sprite.

Parameters
SDL_Rect&rect - an SDL_Rect you want to set the bounding rectangle of the Sprite to.
Here is the call graph for this function:

◆ setFlip()

void pk::Sprite::setFlip ( SDL_RendererFlip &  type)
inline

Set the flip type for the Sprite (SDL_FLIP_NONE, SDL_FLIP_HORIZONTAL, SDL_FLIP_VERTICAL).

Parameters
SDL_RendererFliptype - an integer corresponding to an SDL_RendererFlip constant.

◆ setSpriteData()

void pk::Sprite::setSpriteData ( spriteData s)
inline

Set the data for the Sprite object.

Parameters
spriteData&s - a spriteData struct to set for the Sprite object.

◆ setTexture()

pk::Sprite::setTexture ( Texture *const  texture)
inline

Set the Sprite texture.

Parameters
Texture* const texture - the texture for the Sprite.

◆ updateSprite()

pk::Sprite::updateSprite ( )
private

Used internally when the render mode is initialized or changed.

Member Data Documentation

◆ m_data

spriteData pk::Sprite::m_data
private

Data important to the construction and state maintenance of a Sprite.


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