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
Ball Class Reference

#include <GameObject.hpp>

Inheritance diagram for Ball:
MovingGUIElement GUIElement GameObject

Public Member Functions

bool Collide (GameObject &el2, bool angle)
 
bool Collide (Brick &el2, bool angle)
 
 MovingGUIElement (const std::shared_ptr< TextureWrapper > &texture, const Vector3D &startPosition, Vector3D direction)
 Blank moving element. More...
 
 MovingGUIElement (const std::shared_ptr< TextureWrapper > &texture, const Vector3D &startPosition, Vector3D direction, const std::string &tag)
 Blank moving element. More...
 
 MovingGUIElement ()
 Blank moving element. More...
 
- Public Member Functions inherited from MovingGUIElement
 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

The specialized Ball gui element. Represents a ball in a breakout game.

Member Function Documentation

bool Ball::Collide ( Brick 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

Plays a brick sound and score a point.

bool Ball::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

Plays a sound upon contact as it must be a paddle hit.

MovingGUIElement::MovingGUIElement ( )
usingdefault

Blank moving element.

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

Blank moving element.

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

Blank moving element.


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