Platformer
Platformer
|
A GameObject class. More...
#include <GameObject.hpp>
Public Member Functions | |
void | Update () |
Updates this GameObject. | |
void | Disable () |
Disables this GameObject. | |
void | Enable () |
Enables this GameObject. | |
bool | IsActive () const |
Gets whether this GameObject is active. More... | |
bool | IsColliding (const GameObject &other) const |
Gets whether this GameObject is colliding with another. More... | |
SDL_Rect | ScreenRegion () |
Determines the screen region this object takes up. More... | |
template<class C > | |
std::shared_ptr< C > | GetComponent () |
Gets the first component of type C in the component map or null if none are found. More... | |
template<class C > | |
std::shared_ptr< GameObject > | AddComponent (std::shared_ptr< C > comp) |
Adds a component of type C to the component map. More... | |
Static Public Member Functions | |
static std::shared_ptr< GameObject > | Create (int posX, int posY, int width, int height, bool isUI=false, bool isPermanent=false) |
Creates a GameObject. More... | |
static std::shared_ptr< GameObject > | CreateStandard (int posX, int posY, int width, int height) |
Creates a non-UI, non-permanent GameObject. More... | |
Public Attributes | |
Vector2 | position |
The position of this GameObject. | |
Vector2 | scale |
The scale of this GameObject. | |
Private Member Functions | |
GameObject (int posX, int posY, int width, int height, bool isUI) | |
Constructs a GameObject. More... | |
Static Private Member Functions | |
template<class Key > | |
static int | GetTypeID () |
Gets a new unused component id. More... | |
Private Attributes | |
std::unordered_map< int, std::shared_ptr< Component > > | componentMap |
The map of component ids and components for this GameObject. | |
bool | active |
Whether or not this GameObject is active. | |
bool | isUI |
Whether this GameObject should use direct screen coordinates. | |
Static Private Attributes | |
static int | lastTypeID = 0 |
The last component id used. | |
A GameObject class.
This represents a simple object within our game, having a position, dimensions, and an active state.
|
private |
Constructs a GameObject.
posX | The x coordinate of this GameObject |
posY | The y coordinate of this GameObject |
width | The width of this GameObject |
height | The height of this GameObject |
isUI | Whether this GameObject should use direct screen coordinates |
|
inline |
Adds a component of type C to the component map.
|
static |
Creates a GameObject.
posX | The x coordinate of this GameObject |
posY | The y coordinate of this GameObject |
width | The width of this GameObject |
height | The height of this GameObject |
isUI | Whether this GameObject should use direct screen coordinates |
isPermanent | Whether this GameObject should persist througt level load |
|
static |
Creates a non-UI, non-permanent GameObject.
posX | The x coordinate of this GameObject |
posY | The y coordinate of this GameObject |
width | The width of this GameObject |
height | The height of this GameObject |
|
inline |
Gets the first component of type C in the component map or null if none are found.
|
inlinestaticprivate |
Gets a new unused component id.
bool GameObject::IsActive | ( | ) | const |
Gets whether this GameObject is active.
bool GameObject::IsColliding | ( | const GameObject & | other | ) | const |
Gets whether this GameObject is colliding with another.
other | The GameObject to check for collisions |
SDL_Rect GameObject::ScreenRegion | ( | ) |
Determines the screen region this object takes up.
Uses the active camera.