Breakout
Public Member Functions | Public Attributes | List of all members
Brick Class Reference

Represents the a single brick. More...

#include <Brick.h>

Public Member Functions

 Brick ()
 Constructor of the Brick Class. More...
 
 ~Brick ()
 Destructor for Brick class. More...
 
void init (int x, int y, SDL_Renderer *ren, int rowNumber)
 Method to initialize a brick by loading it's image. More...
 
void draw (SDL_Renderer *ren)
 Method used to render ball on screen. More...
 
void update ()
 Method used to update brick. More...
 
void setSelected ()
 Method used to update whether brick is selected. More...
 
bool getSelected ()
 Method used to get whether brick is selected. More...
 
bool CollisionWithBall (Ball &ball, float &dt)
 Method used to update brick and ball after a collision. More...
 
int getContactEdge (Ball &ball, float &dt)
 This method returns which edge of the brick is hit by the ball. More...
 
bool isUpperSideOfLine (Point *, Point *, Point *)
 This Method is used determie if the ball hit the upper side of the brick. More...
 

Public Attributes

bool hit = false
 Variable to keep state of whether brick was hit or not Initialized to false by default. More...
 

Detailed Description

Represents the a single brick.

Constructor & Destructor Documentation

◆ Brick()

Brick::Brick ( )

Constructor of the Brick Class.

Creates an object of Brick class.

Creates an object of Brick class

◆ ~Brick()

Brick::~Brick ( )

Destructor for Brick class.

Member Function Documentation

◆ CollisionWithBall()

bool Brick::CollisionWithBall ( Ball ball,
float &  dt 
)

Method used to update brick and ball after a collision.

◆ draw()

void Brick::draw ( SDL_Renderer *  ren)

Method used to render ball on screen.

Parameters
renobject of SDL_Renderer, used to render brick on screen

◆ getContactEdge()

int Brick::getContactEdge ( Ball ball,
float &  dt 
)

This method returns which edge of the brick is hit by the ball.

◆ getSelected()

bool Brick::getSelected ( )

Method used to get whether brick is selected.

◆ init()

void Brick::init ( int  xpo,
int  ypo,
SDL_Renderer *  ren,
int  rowNumber 
)

Method to initialize a brick by loading it's image.

Parameters
xx-coordinate of top left most corner of the brick
yy-coordinate of top left most corner of the brick
renobject of SDL_Renderer, used to render brick on screen
rowNumberThe current row number to be rendered, helps in sorting out color
xpox-coordinate of top left most corner of the brick
ypoy-coordinate of top left most corner of the brick
renobject of SDL_Renderer, used to render brick on screen

◆ isUpperSideOfLine()

bool Brick::isUpperSideOfLine ( Point corner1,
Point corner2,
Point ballCenter 
)

This Method is used determie if the ball hit the upper side of the brick.

◆ setSelected()

void Brick::setSelected ( )

Method used to update whether brick is selected.

◆ update()

void Brick::update ( )

Method used to update brick.

Member Data Documentation

◆ hit

bool Brick::hit = false

Variable to keep state of whether brick was hit or not Initialized to false by default.


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