souleng
Game engine providing full Python scripting support
Loading...
Searching...
No Matches
Transform.hpp
1#pragma once
2#include "SDL3/SDL_rect.h"
3#include <SDL3/SDL.h>
4
5#include "Component.hpp"
6#include "util/Vector2.hpp"
7
10struct Transform : public Component {
11 Transform();
12
13 ~Transform();
14
16 static ComponentType GetType();
17
19 void Input() override;
20
22 void Update(float dt) override;
23
25 void Render() override;
26
28 void SetWidth(float w);
29
31 void SetHeight(float h);
32
35
37 bool ContainsPoint(float x, float y);
38
40 void MoveTo(float x, float y);
41
43 SDL_FRect GetRect() const;
44
45private:
46 SDL_FRect mRect{.x = 20.0f, .y = 20.0f, .w = 32.0f, .h = 32.0f};
47};
Definition Component.hpp:17
Definition Transform.hpp:10
void Update(float dt) override
Definition Transform.cpp:14
void Input() override
Called once per frame to handle any new input.
Definition Transform.cpp:12
static ComponentType GetType()
Returns the type of this component to make querying GetComponent easier.
Definition Transform.cpp:10
void MoveTo(float x, float y)
Moves this GameObject's top left corner to the specified coordinates.
Definition Transform.cpp:18
void Render() override
Definition Transform.cpp:16
void SetWidth(float w)
Sets the width of this GameObject.
Definition Transform.cpp:32
Vector2 GetPosition()
Retrieves the position of this GameObject's top left corner.
Definition Transform.cpp:23
bool ContainsPoint(float x, float y)
Checks if the coordinates specified are contained inside this GameObject.
Definition Transform.cpp:25
SDL_FRect GetRect() const
Returns the underlying rectangle for this GameObject's Transform.
Definition Transform.cpp:30
void SetHeight(float h)
Sets the height of this GameObject.
Definition Transform.cpp:34
Simple container for position data.
Definition Vector2.hpp:4