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 | |
MovingGUIElement (const std::shared_ptr< TextureWrapper > &texture, const Vector3D &startPosition, Vector3D direction) | |
MovingGUIElement (const std::shared_ptr< TextureWrapper > &texture, const Vector3D &startPosition, Vector3D direction, const std::string &tag) | |
void | Move (float dt, int screenWidth, int screenHeight) |
void | UpdateDirection (const Vector3D &direction) |
MovingGUIElement () | |
Blank moving element. More... | |
const Vector3D & | _GetDirection () const |
bool | Collide (GameObject &el2, bool angle) |
![]() | |
GUIElement (const std::shared_ptr< TextureWrapper > &texture) | |
GUIElement (const std::shared_ptr< TextureWrapper > &texture, const std::string &tag) | |
GUIElement (const std::shared_ptr< TextureWrapper > &texture, const Vector3D &startPosition) | |
GUIElement (const std::shared_ptr< TextureWrapper > &texture, const Vector3D &startPosition, const std::string &tag) | |
void | Render (SDL_Renderer *renderer) |
GUIElement () | |
blank GUIElement More... | |
![]() | |
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... | |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
std::shared_ptr< TextureWrapper > | mTexture |
internal texture More... | |
SDL_Rect | mDestination |
rectangle representing the bounding box More... | |
![]() | |
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... | |
Moving renderable game object. For more information on constructors refer to GUIElement documentation.
MovingGUIElement::MovingGUIElement | ( | const std::shared_ptr< TextureWrapper > & | texture, |
const Vector3D & | startPosition, | ||
Vector3D | direction | ||
) |
constructs unnamed moving gui element with a given initial direction.
direction | the direction this element is moving in |
texture | texture |
startPosition | startPosition |
MovingGUIElement::MovingGUIElement | ( | const std::shared_ptr< TextureWrapper > & | texture, |
const Vector3D & | startPosition, | ||
Vector3D | direction, | ||
const std::string & | tag | ||
) |
constructs named moving gui element with a given initial direction.
direction | the direction this element is moving in |
texture | texture |
startPosition | startPosition |
tag | tag |
|
default |
Blank moving element.
const Vector3D & MovingGUIElement::_GetDirection | ( | ) | const |
Available mainly for callbacks, if you find yourself using this within a higher scope graphics program, consider implementing subclass(es) of MovingGUIElement instead.
bool MovingGUIElement::Collide | ( | GameObject & | el2, |
bool | angle | ||
) |
Attempts collision with the given object, if angle is true then perform a range of movement.
angle is too specific for a general API class like this, should be abstracted into the Ball class.
use vector math to determine the angle between the two objects, and then the distance, for more effective collision checking
Currently calculates overlap between the two bounding boxes and compares them to determine what type of collision happened. This is effective for rectangles but is a very elaborate implementation.
el2 | the object to check collision with |
angle | whether to change this objects direction relative to where it hit el2 |
void MovingGUIElement::Move | ( | float | dt, |
int | screenWidth, | ||
int | screenHeight | ||
) |
Move the element within the given bounds, the fixed step dt is available.
dt | fixed time step |
screenWidth | the screen width bound |
screenHeight | the screen height bound |
void MovingGUIElement::UpdateDirection | ( | const Vector3D & | direction | ) |
Change this objects direction by the given direction.
direction | what to change to |