The Table Engine
transform.h
Go to the documentation of this file.
1 #pragma once
2 
10 #include "component.h"
11 #include "vec2.h"
12 #include "gameobject.h"
13 
14 #include "SDL2/SDL.h"
15 
23 class Transform : public Component {
24  private:
25  SDL_Rect* mTransform;
28 
29  public:
33  Transform();
34 
40  Transform(int x, int y);
41 
45  ~Transform();
46 
51  SDL_Rect* getScreenRect();
52 
58 
64 
70 
76  void setWorldPosition(float x, float y);
77 
82  void setWorldPosition(Vec2 pos);
83 
89  void updateWorldPosition(float dx, float dy);
90 
95  void updateWorldPosition(Vec2 dpos);
96 
102  void setWorldSize(float w, float h);
103 
108  void setWorldSize(Vec2 size);
109 
113  void update();
114 };
Base class for all game components, providing basic component functionalities.
Definition: component.h:25
Component for handling the transformation of game objects.
Definition: transform.h:23
void updateWorldPosition(float dx, float dy)
Update the world position by a delta value.
Definition: transform.cpp:69
Vec2 getScreenSize()
Get the size of the Transform in screen space.
Definition: transform.cpp:44
void update()
Render function for the Transform component, handling visual updates.
Definition: transform.cpp:81
Vec2 getScreenPosition()
Get the screen space position calculated from world space.
Definition: transform.cpp:39
void setWorldPosition(float x, float y)
Set the world space position of the Transform.
Definition: transform.cpp:49
Vec2 mPosition
Position in world space.
Definition: transform.h:26
Transform()
Default constructor.
Definition: transform.cpp:9
~Transform()
Destructor.
Definition: transform.cpp:24
Vec2 mSize
Size in world space.
Definition: transform.h:27
SDL_Rect * mTransform
Holds position and size relative to the screen.
Definition: transform.h:25
void setWorldSize(float w, float h)
Set the world space size of the Transform.
Definition: transform.cpp:59
Vec2 getWorldPosition()
Get the world space position of the Transform.
Definition: transform.cpp:34
SDL_Rect * getScreenRect()
Get the SDL_Rect describing the position and size on the screen.
Definition: transform.cpp:29
Defines the Component base class for all components in the game engine.
A structure to represent 2D vectors.
Definition: vec2.h:16
Definition of Vec2 structure for 2D vector operations.