Retro_Gameboy
The purpose of this project is to create a GameBoy with classic games.
Public Member Functions | Private Member Functions | Private Attributes
Arkanoid Class Reference

#include <Arkanoid.h>

Inheritance diagram for Arkanoid:
Inheritance graph
[legend]
Collaboration diagram for Arkanoid:
Collaboration graph
[legend]

Public Member Functions

 Arkanoid ()
 Default Constructor. Calls the InitializeVars() function. More...
 
void InitializeVars ()
 Create Sprites. Load the Images and set the Sprites. Creates a block of titles with 100 tiles. Call PlayArkanoid() function to start the game. More...
 
- Public Member Functions inherited from GameGenerics
 GameGenerics ()
 Default Constructor for GameGenerics. This is a abstract class and you cannot instantiate this class. More...
 

Private Member Functions

void PlayArkanoid (RenderWindow &window, Sprite &s_Background, Sprite &s_Ball, Sprite &s_Paddle, Sprite *block, Sprite *lives, Texture &texture1)
 Start the game and call other helper functions. More...
 
void CheckCollisions (float &xAxis, float &xPos, float &yAxis, float &yPos, Sprite *block, const bool isVertical)
 This will check collisions with the tiles and the ball. Everytime the ball hit a tile, this record a collision and hide the tile by throwing it far away from the x axis. The collisions are recorded both x and y axises. More...
 
void SetBoundaries (float &xAxis, float &xPos, float &yAxis, float &yPos, Sprite *lives)
 Set the boundaries so ball will remian inside the window. Also, whenever the ball hits outside the paddel ( yAxis == width ), it will penalized the user by reducing one heart. Call the SetLives() function to remove one heartl. More...
 
void SetControls (Sprite &s_Paddle)
 Set the paddle to move right and left by pressing right and left arrow keys. More...
 
void SetLives (Sprite *lives)
 Remove a heart whenever user miss the ball and it hit outside the paddle. More...
 
virtual int CalculateScore ()
 Pure virtual function inherited from GameGenerics.h Each game calculate scores differently and therefore this function need to override in each game according to the game rules. More...
 

Private Attributes

const int LENGTH = 520
 Define the length of the window. If you want to change this you might need to change the background image too. Current length and width is match the background image. More...
 
const int WIDTH = 450
 Define the Width of the window. More...
 
const std::string IMAGEPATH = "images/Arkanoid_Img/"
 Define path where image are located. More...
 
int n
 The number of tiles in the block. Currently, it has 100 tiles. More...
 
int blocksRemain
 Remaining titls. More...
 
int remainingLives
 Player has 3 hearts and once it ran out game will be over. Remaining lives are multiple of 2. For example, 3 hearts means ( 3 x 2) remainning lives. Remaining lives get calculated in SetBoundaries() function and it get called two times for each calculation. This is why remaining live is a multiple of 2. More...
 
bool isGameOver
 Set true when user lost all the chances. This indicate time to display game over screen. More...
 

Additional Inherited Members

- Protected Member Functions inherited from GameGenerics
void GameOverScreen (RenderWindow &window)
 Display a game over screen at the end of the game alone with user's score. Currently, every game has the same game over screen. If each and every game needs a different screen, it might be a good idea to make it a pure virtual function. More...
 

Detailed Description

Definition at line 6 of file Arkanoid.h.

Constructor & Destructor Documentation

◆ Arkanoid()

Arkanoid::Arkanoid ( )

Default Constructor. Calls the InitializeVars() function.

Definition at line 5 of file Arkanoid.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ CalculateScore()

int Arkanoid::CalculateScore ( )
privatevirtual

Pure virtual function inherited from GameGenerics.h Each game calculate scores differently and therefore this function need to override in each game according to the game rules.

Implements GameGenerics.

Definition at line 134 of file Arkanoid.cpp.

◆ CheckCollisions()

void Arkanoid::CheckCollisions ( float &  xAxis,
float &  xPos,
float &  yAxis,
float &  yPos,
Sprite *  block,
const bool  isVertical = false 
)
private

This will check collisions with the tiles and the ball. Everytime the ball hit a tile, this record a collision and hide the tile by throwing it far away from the x axis. The collisions are recorded both x and y axises.

Definition at line 59 of file Arkanoid.cpp.

Here is the caller graph for this function:

◆ InitializeVars()

void Arkanoid::InitializeVars ( )

Create Sprites. Load the Images and set the Sprites. Creates a block of titles with 100 tiles. Call PlayArkanoid() function to start the game.

Definition at line 10 of file Arkanoid.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PlayArkanoid()

void Arkanoid::PlayArkanoid ( RenderWindow &  window,
Sprite &  s_Background,
Sprite &  s_Ball,
Sprite &  s_Paddle,
Sprite *  block,
Sprite *  lives,
Texture &  texture1 
)
private

Start the game and call other helper functions.

Definition at line 164 of file Arkanoid.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBoundaries()

void Arkanoid::SetBoundaries ( float &  xAxis,
float &  xPos,
float &  yAxis,
float &  yPos,
Sprite *  lives 
)
private

Set the boundaries so ball will remian inside the window. Also, whenever the ball hits outside the paddel ( yAxis == width ), it will penalized the user by reducing one heart. Call the SetLives() function to remove one heartl.

Definition at line 81 of file Arkanoid.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetControls()

void Arkanoid::SetControls ( Sprite &  s_Paddle)
private

Set the paddle to move right and left by pressing right and left arrow keys.

Definition at line 101 of file Arkanoid.cpp.

Here is the caller graph for this function:

◆ SetLives()

void Arkanoid::SetLives ( Sprite *  lives)
private

Remove a heart whenever user miss the ball and it hit outside the paddle.

Definition at line 114 of file Arkanoid.cpp.

Here is the caller graph for this function:

Field Documentation

◆ blocksRemain

int Arkanoid::blocksRemain
private

Remaining titls.

Definition at line 42 of file Arkanoid.h.

◆ IMAGEPATH

const std::string Arkanoid::IMAGEPATH = "images/Arkanoid_Img/"
private

Define path where image are located.

Definition at line 36 of file Arkanoid.h.

◆ isGameOver

bool Arkanoid::isGameOver
private

Set true when user lost all the chances. This indicate time to display game over screen.

Definition at line 52 of file Arkanoid.h.

◆ LENGTH

const int Arkanoid::LENGTH = 520
private

Define the length of the window. If you want to change this you might need to change the background image too. Current length and width is match the background image.

Definition at line 30 of file Arkanoid.h.

◆ n

int Arkanoid::n
private

The number of tiles in the block. Currently, it has 100 tiles.

Definition at line 39 of file Arkanoid.h.

◆ remainingLives

int Arkanoid::remainingLives
private

Player has 3 hearts and once it ran out game will be over. Remaining lives are multiple of 2. For example, 3 hearts means ( 3 x 2) remainning lives. Remaining lives get calculated in SetBoundaries() function and it get called two times for each calculation. This is why remaining live is a multiple of 2.

Definition at line 48 of file Arkanoid.h.

◆ WIDTH

const int Arkanoid::WIDTH = 450
private

Define the Width of the window.

Definition at line 33 of file Arkanoid.h.


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