The Table Engine
|
Component for handling the transformation of game objects. More...
#include <transform.h>
Public Member Functions | |
Transform () | |
Default constructor. More... | |
Transform (int x, int y) | |
Constructor that initializes the Transform with position. More... | |
~Transform () | |
Destructor. More... | |
SDL_Rect * | getScreenRect () |
Get the SDL_Rect describing the position and size on the screen. More... | |
Vec2 | getWorldPosition () |
Get the world space position of the Transform. More... | |
Vec2 | getScreenPosition () |
Get the screen space position calculated from world space. More... | |
Vec2 | getScreenSize () |
Get the size of the Transform in screen space. More... | |
void | setWorldPosition (float x, float y) |
Set the world space position of the Transform. More... | |
void | setWorldPosition (Vec2 pos) |
Set the world space position of the Transform using a Vec2. More... | |
void | updateWorldPosition (float dx, float dy) |
Update the world position by a delta value. More... | |
void | updateWorldPosition (Vec2 dpos) |
Update the world position by a delta position. More... | |
void | setWorldSize (float w, float h) |
Set the world space size of the Transform. More... | |
void | setWorldSize (Vec2 size) |
Set the world space size of the Transform using a Vec2. More... | |
void | update () |
Render function for the Transform component, handling visual updates. More... | |
![]() | |
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... | |
GameObject * | getOwner () |
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... | |
virtual void | render () |
Virtual method for rendering, intended to be overridden by derived components. More... | |
Private Attributes | |
SDL_Rect * | mTransform |
Holds position and size relative to the screen. More... | |
Vec2 | mPosition |
Position in world space. More... | |
Vec2 | mSize |
Size in world space. More... | |
Additional Inherited Members | |
![]() | |
std::string | m_name |
Name of the component, useful for identification or debugging. More... | |
GameObject * | m_owner |
Pointer to the GameObject that owns this component. More... | |
Component for handling the transformation of game objects.
This class manages both the world and screen transformations of game objects, allowing them to be positioned and sized accurately in the game world.
Definition at line 23 of file transform.h.
Transform::Transform | ( | ) |
Default constructor.
Definition at line 9 of file transform.cpp.
Transform::Transform | ( | int | x, |
int | y | ||
) |
Constructor that initializes the Transform with position.
x | Initial x-coordinate of the world position. |
y | Initial y-coordinate of the world position. |
Definition at line 16 of file transform.cpp.
Transform::~Transform | ( | ) |
Destructor.
Definition at line 24 of file transform.cpp.
Vec2 Transform::getScreenPosition | ( | ) |
Get the screen space position calculated from world space.
Definition at line 39 of file transform.cpp.
SDL_Rect * Transform::getScreenRect | ( | ) |
Get the SDL_Rect describing the position and size on the screen.
Definition at line 29 of file transform.cpp.
Vec2 Transform::getScreenSize | ( | ) |
Get the size of the Transform in screen space.
Definition at line 44 of file transform.cpp.
Vec2 Transform::getWorldPosition | ( | ) |
Get the world space position of the Transform.
Definition at line 34 of file transform.cpp.
void Transform::setWorldPosition | ( | float | x, |
float | y | ||
) |
Set the world space position of the Transform.
x | New x-coordinate of the world position. |
y | New y-coordinate of the world position. |
Definition at line 49 of file transform.cpp.
void Transform::setWorldPosition | ( | Vec2 | pos | ) |
Set the world space position of the Transform using a Vec2.
pos | Vec2 representing the new world position. |
Definition at line 54 of file transform.cpp.
void Transform::setWorldSize | ( | float | w, |
float | h | ||
) |
Set the world space size of the Transform.
w | Width in world space. |
h | Height in world space. |
Definition at line 59 of file transform.cpp.
void Transform::setWorldSize | ( | Vec2 | size | ) |
Set the world space size of the Transform using a Vec2.
size | Vec2 representing the new size in world space. |
Definition at line 64 of file transform.cpp.
|
virtual |
Render function for the Transform component, handling visual updates.
Reimplemented from Component.
Definition at line 81 of file transform.cpp.
void Transform::updateWorldPosition | ( | float | dx, |
float | dy | ||
) |
Update the world position by a delta value.
dx | Change in the x-coordinate. |
dy | Change in the y-coordinate. |
Definition at line 69 of file transform.cpp.
void Transform::updateWorldPosition | ( | Vec2 | dpos | ) |
Update the world position by a delta position.
dpos | Vec2 representing the change in position. |
Definition at line 75 of file transform.cpp.
|
private |
Position in world space.
Definition at line 26 of file transform.h.
|
private |
Size in world space.
Definition at line 27 of file transform.h.
|
private |
Holds position and size relative to the screen.
Definition at line 25 of file transform.h.