|
Turbo Engine 0.3
A C++ game engine using Allegro 5
|
Basic scene object. More...
#include <GameObject.hpp>
Public Member Functions | |
| GameObject (GameObject *parent, std::string name) | |
| Construct a new GameObject object. | |
| ~GameObject () | |
| GameObject (const GameObject &)=delete | |
| GameObject & | operator= (const GameObject &)=delete |
| void | add_component (Component *comp) |
| Add a component to the GameObject. | |
| void | remove_component (Component *comp) |
| Remove a component to the GameObject. | |
| unsigned short | get_component_amount () const |
| void | render (void *transform) |
| void | update (int delta_time) |
| void | set_drawable (Drawable *drawable) |
| Drawable * | get_drawable () const |
| void | set_material (Material *material) |
| Material applied to the drawable when rendering (null = default). Not owned: materials are shared and owned by the ShaderLibrary. | |
| Material * | get_material () const |
| Material currently applied to the drawable (null = default). | |
| std::string | get_name () const |
| bool | set_name (const std::string &name) |
| Rename the object. Fails (returns false) if a sibling already uses that name or the name is empty. | |
| GameObject * | get_parent () const |
| Get the parent GameObject (null for the scene root). | |
| void | attach_to (GameObject *parent) |
| Re-parent this object (detaching from its current parent first). Passing nullptr detaches it from the hierarchy without destroying it. | |
| template<typename T, typename = std::enable_if_t<std::is_base_of_v<Component, T>>> | |
| T * | get_component () |
| Get the component object. | |
| Public Member Functions inherited from turbo::Transform | |
| Transform ()=default | |
| Transform (const Vector2< float > &position, float angle=0, const Vector2< float > &scale=Vector2< float >(1, 1), const Vector2< int > ¢er=Vector2< int >()) | |
| Transform (float x, float y=0, int scaleX=1, int scaleY=1, float angle=0, int centerX=0, int centerY=0) | |
| ~Transform ()=default | |
| void | translate (float x, float y) |
| Translate the object in 2D. | |
| void | translate (const Vector2< float > &offset) |
| Translate the object in 22. | |
| void | set_position (float x, float y) |
| Set the position of the object. | |
| void | set_position (const Vector2< float > &pos) |
| Set the position of the object. | |
| void | rotate (float deg) |
| Rotate the current object by deg degrees. | |
| void | set_rotation (float deg) |
| Set the rotation of the object. | |
| void | set_center (int x, int y) |
| Set the center of rotation of the object (Start in 0,0 , position in pixel). | |
| void | set_center (const Vector2< int > ¢er) |
| Set the center of rotation of the object (Start in 0,0 , position in pixel). | |
| void | set_scale (const Vector2< float > &scale) |
| Set the scale of the object (base scale == 1.0). | |
| void | set_scale (float scale_x, float scale_y) |
| Set the scale of the object (base scale == 1.0). | |
| const Vector2< float > & | get_position () const |
| const Vector2< float > & | get_scale () const |
| const Vector2< int > & | get_center () const |
| float | get_angle () const |
Public Attributes | |
| bool | show = true |
| std::vector< GameObject * > | childs {} |
| std::vector< Component * > | components {} |
Additional Inherited Members | |
| Protected Member Functions inherited from turbo::Transform | |
| ALLEGRO_TRANSFORM * | get_transformer () |
| Protected Attributes inherited from turbo::Transform | |
| float | angle = 0 |
| angle of the object | |
| Vector2< float > | position = Vector2<float>() |
| Vector2< float > | scale = Vector2<float>(1, 1) |
| Vector2< int > | center = Vector2<int>() |
| ALLEGRO_TRANSFORM | transform {} |
| bool | property_has_changed = true |
| Static Protected Attributes inherited from turbo::Transform | |
| static ALLEGRO_TRANSFORM | default_transform = ALLEGRO_TRANSFORM() |
Basic scene object.
|
explicit |
Construct a new GameObject object.
| parent | parent GameObject or null if root node |
| name | GameObject name |
| turbo::GameObject::~GameObject | ( | ) |
|
delete |
| void turbo::GameObject::add_component | ( | Component * | comp | ) |
Add a component to the GameObject.
| comp | component instance |
| void turbo::GameObject::attach_to | ( | GameObject * | parent | ) |
Re-parent this object (detaching from its current parent first). Passing nullptr detaches it from the hierarchy without destroying it.
|
inline |
Get the component object.
| T | Type of component |
| unsigned short turbo::GameObject::get_component_amount | ( | ) | const |
| Drawable * turbo::GameObject::get_drawable | ( | ) | const |
| Material * turbo::GameObject::get_material | ( | ) | const |
Material currently applied to the drawable (null = default).
| std::string turbo::GameObject::get_name | ( | ) | const |
| GameObject * turbo::GameObject::get_parent | ( | ) | const |
Get the parent GameObject (null for the scene root).
|
delete |
| void turbo::GameObject::remove_component | ( | Component * | comp | ) |
Remove a component to the GameObject.
| comp | component instance |
| void turbo::GameObject::render | ( | void * | transform | ) |
| void turbo::GameObject::set_drawable | ( | Drawable * | drawable | ) |
| void turbo::GameObject::set_material | ( | Material * | material | ) |
Material applied to the drawable when rendering (null = default). Not owned: materials are shared and owned by the ShaderLibrary.
| bool turbo::GameObject::set_name | ( | const std::string & | name | ) |
Rename the object. Fails (returns false) if a sibling already uses that name or the name is empty.
| void turbo::GameObject::update | ( | int | delta_time | ) |
| std::vector<GameObject*> turbo::GameObject::childs {} |
| std::vector<Component*> turbo::GameObject::components {} |
| bool turbo::GameObject::show = true |