SDL Breakout Engine  0.1.0
An implementation of a Breakout game using sdl, implemented with efficient resource management.
Public Member Functions | List of all members
MovingGUIElement Class Reference

#include <GameObject.hpp>

Inheritance diagram for MovingGUIElement:
GUIElement GameObject Ball

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)
 
- Public Member Functions inherited from GUIElement
 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...
 
- Public Member Functions inherited from GameObject
 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

- Public Attributes inherited from GameObject
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 inherited from GUIElement
std::shared_ptr< TextureWrappermTexture
 internal texture More...
 
SDL_Rect mDestination
 rectangle representing the bounding box More...
 
- Protected Attributes inherited from GameObject
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...
 

Detailed Description

Moving renderable game object. For more information on constructors refer to GUIElement documentation.

Constructor & Destructor Documentation

MovingGUIElement::MovingGUIElement ( const std::shared_ptr< TextureWrapper > &  texture,
const Vector3D startPosition,
Vector3D  direction 
)

constructs unnamed moving gui element with a given initial direction.

Parameters
directionthe direction this element is moving in
texturetexture
startPositionstartPosition
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.

Parameters
directionthe direction this element is moving in
texturetexture
startPositionstartPosition
tagtag
MovingGUIElement::MovingGUIElement ( )
default

Blank moving element.

Member Function Documentation

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.

Todo:

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.

Parameters
el2the object to check collision with
anglewhether 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.

Parameters
dtfixed time step
screenWidththe screen width bound
screenHeightthe screen height bound
void MovingGUIElement::UpdateDirection ( const Vector3D direction)

Change this objects direction by the given direction.

Parameters
directionwhat to change to

The documentation for this class was generated from the following files: