![]() |
KTech 1.1.0
C++ 2D terminal game engine library
|
World structure that comprises Textures and Colliders, and exists within Layer.
More...
#include <object.hpp>
Public Member Functions | |
| Object (Engine &engine, Point position=Point(0, 0), std::string name="") | |
Construct an Object. | |
| Object (Engine &engine, const ID< Layer > &parentLayer, Point position=Point(0, 0), std::string name="") | |
Construct an Object and immediately enter a Layer. | |
| virtual | ~Object () |
Leave parent Layer (if in one) and remove itself from Memory. | |
| auto | EnterLayer (const ID< Layer > &layer) -> bool |
Enter a Layer. | |
| auto | LeaveLayer () -> bool |
Leave the parent Layer. | |
| auto | Move (Point direction) -> bool |
Move in relation to other Objects in the Layer and their Colliders. | |
Public Attributes | |
| Engine & | engine |
Parent Engine. | |
| const ID< Object > | m_id {ID<Object>::Unique()} |
Personal ID. | |
| std::string | m_name |
| String name. | |
| ID< Layer > | m_parentLayer |
Parent Layer. | |
| Point | m_pos |
| World position. | |
| std::vector< Texture > | m_textures = {} |
Textures. | |
| std::vector< Collider > | m_colliders = {} |
Colliders. | |
Protected Member Functions | |
| virtual auto | OnTick () -> bool |
| Virtual function called once each tick. | |
| virtual void | OnMove (Point direction) |
Called by Collision::MoveObject() as a result of this Object moving (voluntarily or passively). | |
| virtual void | OnPushed (Point direction, size_t collider, ID< Object > otherObject, size_t otherCollider) |
Called by Collision::MoveObject() as a result of this Object getting pushed. | |
| virtual void | OnPush (Point direction, size_t collider, ID< Object > otherObject, size_t otherCollider) |
Called by Collision::MoveObject() as a result of this Object pushing another Object. | |
| virtual void | OnBlocked (Point direction, size_t collider, ID< Object > otherObject, size_t otherCollider) |
Called by Collision::MoveObject() as a result of this Object getting blocked by another Object. | |
| virtual void | OnBlock (Point direction, size_t collider, ID< Object > otherObject, size_t otherCollider) |
Called by Collision::MoveObject() as a result of this Object blocking another Object. | |
| virtual void | OnOverlap (Point direction, size_t collider, ID< Object > otherObject, size_t otherCollider) |
Called by Collision::MoveObject() as a result of this Object overlapping into another Object. | |
| virtual void | OnOverlapExit (Point direction, size_t collider, ID< Object > otherObject, size_t otherCollider) |
Called by Collision::MoveObject() as a result of this Object leaving an overlap with another Object. | |
| virtual void | OnOverlapped (Point direction, size_t collider, ID< Object > otherObject, size_t otherCollider) |
Called by Collision::MoveObject() as a result of this Object getting overlapped into by another Object. | |
| virtual void | OnOverlappedExit (Point direction, size_t collider, ID< Object > otherObject, size_t otherCollider) |
Called by Collision::MoveObject() as a result of another Object leaving an overlap with this Object. | |
Friends | |
| class | KTech::Collision |
| class | KTech::Memory |
World structure that comprises Textures and Colliders, and exists within Layer.
This and Widget are the most commonly inherited-from world structures. It differs from Widget because it can contain Colliders, while Widget is limited to Textures. Widget also has some additional features which are useful for user-interfaces. You can conveniently make player-controlled classes based on Object, such as walking characters (see "simpleplatform" game example).
| auto KTech::Object::LeaveLayer | ( | ) | -> bool |
| auto KTech::Object::Move | ( | Point | direction | ) | -> bool |
Move in relation to other Objects in the Layer and their Colliders.
This function calls Collision::MoveObject() on itself (on the calling Object; this).
true if moved. false if blocked.Collision::MoveObject()
|
protectedvirtual |
Called by Collision::MoveObject() as a result of this Object blocking another Object.
| direction | The attempted movement's direction. |
| collider | The index of this Object's collider that collided (this->Object::m_colliders[collider]). |
| otherObject | The Object that collided with this Object. |
| otherCollider | The index of otherObject's collider that collided (engine.memory.objects[otherObject]->Object::m_colliders[otherCollider]). |
|
protectedvirtual |
Called by Collision::MoveObject() as a result of this Object getting blocked by another Object.
| direction | The attempted movement's direction. |
| collider | The index of this Object's collider that collided (this->Object::m_colliders[collider]). |
| otherObject | The Object that collided with this Object. |
| otherCollider | The index of otherObject's collider that collided (engine.memory.objects[otherObject]->Object::m_colliders[otherCollider]). |
|
protectedvirtual |
Called by Collision::MoveObject() as a result of this Object moving (voluntarily or passively).
| direction | The movement's direction. |
|
protectedvirtual |
Called by Collision::MoveObject() as a result of this Object overlapping into another Object.
| direction | The movement's direction. |
| collider | The index of this Object's collider that collided (this->Object::m_colliders[collider]). |
| otherObject | The Object that collided with this Object. |
| otherCollider | The index of otherObject's collider that collided (engine.memory.objects[otherObject]->Object::m_colliders[otherCollider]). |
|
protectedvirtual |
Called by Collision::MoveObject() as a result of this Object leaving an overlap with another Object.
| direction | The movement's direction. |
| collider | The index of this Object's collider that collided (this->Object::m_colliders[collider]). |
| otherObject | The Object that collided with this Object. |
| otherCollider | The index of otherObject's collider that collided (engine.memory.objects[otherObject]->Object::m_colliders[otherCollider]). |
|
protectedvirtual |
Called by Collision::MoveObject() as a result of this Object getting overlapped into by another Object.
| direction | The movement's direction. |
| collider | The index of this Object's collider that collided (this->Object::m_colliders[collider]). |
| otherObject | The Object that collided with this Object. |
| otherCollider | The index of otherObject's collider that collided (engine.memory.objects[otherObject]->Object::m_colliders[otherCollider]). |
|
protectedvirtual |
Called by Collision::MoveObject() as a result of another Object leaving an overlap with this Object.
| direction | The movement's direction. |
| collider | The index of this Object's collider that collided (this->Object::m_colliders[collider]). |
| otherObject | The Object that collided with this Object. |
| otherCollider | The index of otherObject's collider that collided (engine.memory.objects[otherObject]->Object::m_colliders[otherCollider]). |
|
protectedvirtual |
Called by Collision::MoveObject() as a result of this Object pushing another Object.
| direction | The movement's direction. |
| collider | The index of this Object's collider that collided (this->Object::m_colliders[collider]). |
| otherObject | The Object that collided with this Object. |
| otherCollider | The index of otherObject's collider that collided (engine.memory.objects[otherObject]->Object::m_colliders[otherCollider]). |
|
protectedvirtual |
Called by Collision::MoveObject() as a result of this Object getting pushed.
| direction | The movement's direction. |
| collider | The index of this Object's collider that collided (this->Object::m_colliders[collider]). |
| otherObject | The Object that collided with this Object. |
| otherCollider | The index of otherObject's collider that collided (engine.memory.objects[otherObject]->Object::m_colliders[otherCollider]). |
|
protectedvirtual |
Virtual function called once each tick.
Called by Memory::CallOnTicks().
bool value, which is explained in Output::ShouldRenderThisTick().