SDL Breakout Engine
0.1.0
An implementation of a Breakout game using sdl, implemented with efficient resource management.
|
#include <GameObject.hpp>
Public Member Functions | |
GameObject (const std::string &tag) | |
GameObject (const Vector3D &position) | |
GameObject (const Vector3D &position, const std::string &tag) | |
GameObject (const Vector3D &position, const Vector3D &size) | |
GameObject (const Vector3D &position, const Vector3D &size, const std::string &tag) | |
void | Update (const Vector3D &position) |
Vector3D | GetSize () |
Vector3D | GetSize () const |
const Vector3D & | _GetPosition () const |
void | DebugRender (SDL_Renderer *renderer) |
virtual void | Hit (const std::string &tag) |
GameObject () | |
default constructor for a gameobject More... | |
Public Attributes | |
std::string | mTag = "" |
the name of this object, should be unique to other objects unless grouping is desired. More... | |
bool | alive = true |
whether this object is alive or not. More... | |
Protected Attributes | |
int | mWidth = 0 |
internal width More... | |
int | mHeight = 0 |
internal height More... | |
Vector3D | mPosition = Vector3D(0, 0, 0) |
internal position More... | |
Vector3D | startPosition |
start position More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const GameObject &obj) |
overload for << operator More... | |
Describes a general GameObject which can either be subclassed to override functionality, or instantiated in its own right.
A GameObject is solely aware of its position and size. If needed it can be rendered to the screen in the form of a rectangle (the objects bounding box), however this is solely for debugging and is not recommended as an actual drawing method.
A GameObject is allowed to start with no position or size for convenience. Attempting to draw said object is undefined behavior.
GameObject supports 3D space.
GameObject::GameObject | ( | const std::string & | tag | ) |
the simplest constructor, just tag the object.
tag | what to name it. |
GameObject::GameObject | ( | const Vector3D & | position | ) |
Give the object a position, unnamed.
position | the objects position |
GameObject::GameObject | ( | const Vector3D & | position, |
const std::string & | tag | ||
) |
Give the named object a position.
position | position |
tag | tag |
Give the unnamed object a position and size.
position | position |
size | the width, height, and depth that the object occupies. |
GameObject::GameObject | ( | const Vector3D & | position, |
const Vector3D & | size, | ||
const std::string & | tag | ||
) |
Give the named object a position and size.
position | position |
size | size |
tag | tag |
|
default |
default constructor for a gameobject
const Vector3D & GameObject::_GetPosition | ( | ) | const |
Return the position of this object.
It is uncommon to need this method, in general, try to implement logic within subclasses of GameObject, rather than in an outer graphics program class.
void GameObject::DebugRender | ( | SDL_Renderer * | renderer | ) |
Render the object to the screen
renderer | the renderer to use |
Vector3D GameObject::GetSize | ( | ) |
Return the size of this object.
Vector3D GameObject::GetSize | ( | ) | const |
Return the size of this object.
|
virtual |
void GameObject::Update | ( | const Vector3D & | position | ) |
Update the GameObject with a given position. Does a direct jump, no interpolation.
position | where to move to. |
|
friend |
overload for << operator
bool GameObject::alive = true |
whether this object is alive or not.
|
protected |
internal height
std::string GameObject::mTag = "" |
the name of this object, should be unique to other objects unless grouping is desired.
|
protected |
internal width
|
protected |
start position