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

#include <Tetris.h>

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

Data Structures

struct  Point
 Denotes x and y points. More...
 

Public Member Functions

 Tetris ()
 Default constructor. Used to intialize arrays. More...
 
void PlayTetris ()
 Play Tetris 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

bool Check ()
 Check the boundaries. More...
 
void MoveTile (const int position=0)
 Move shapes horizontally. More...
 
void RotateTile (const bool rotate=false)
 Allow user to rotate shapes. More...
 
float MoveDownTilePerClick (float timer, const float delay, int &colorNum)
 Move shapes down for each tick. More...
 
void CheckLines ()
 Reduce line upon completion. More...
 
void Draw (Sprite &sprite, Sprite &background, Sprite &frame, RenderWindow &window, const int &colorNum)
 Draw UI and shapes. More...
 
void EventHandler (bool &rotate, int &dx, RenderWindow &window)
 
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

int field [M][N]
 Define a 10 x 20 rectangle. This is use as the background for the game. More...
 
const int figures [7][4]
 Define 7 x 4 rectangle[ 7 rows, 4 coloumns] This defines the shapes. For example, these are the following shapes. 1,3,5,7, -> denotes I 2,4,5,7, -> denotes Z 3,5,4,6, -> denotes S 3,5,4,7, -> denotes T 2,3,5,7, -> denotes L 3,5,7,6, -> denotes J 2,3,4,5, -> denotes O. More...
 
Point a [4]
 Use to move shapes. More...
 
Point b [4]
 Keep a backup. More...
 

Static Private Attributes

static const int M = 20
 Define width of a rectangle. More...
 
static const int N = 10
 Define length of a rectangle. 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 5 of file Tetris.h.

Constructor & Destructor Documentation

◆ Tetris()

Tetris::Tetris ( )

Default constructor. Used to intialize arrays.

Definition at line 3 of file Tetris.cpp.

Member Function Documentation

◆ CalculateScore()

int Tetris::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 235 of file Tetris.cpp.

◆ Check()

bool Tetris::Check ( )
private

Check the boundaries.

Definition at line 112 of file Tetris.cpp.

Here is the caller graph for this function:

◆ CheckLines()

void Tetris::CheckLines ( )
private

Reduce line upon completion.

Definition at line 208 of file Tetris.cpp.

Here is the caller graph for this function:

◆ Draw()

void Tetris::Draw ( Sprite &  sprite,
Sprite &  background,
Sprite &  frame,
RenderWindow &  window,
const int &  colorNum 
)
private

Draw UI and shapes.

Definition at line 242 of file Tetris.cpp.

Here is the caller graph for this function:

◆ EventHandler()

void Tetris::EventHandler ( bool &  rotate,
int &  dx,
RenderWindow &  window 
)
private

Definition at line 83 of file Tetris.cpp.

Here is the caller graph for this function:

◆ MoveDownTilePerClick()

float Tetris::MoveDownTilePerClick ( float  timer,
const float  delay,
int &  colorNum 
)
private

Move shapes down for each tick.

Definition at line 175 of file Tetris.cpp.

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

◆ MoveTile()

void Tetris::MoveTile ( const int  position = 0)
private

Move shapes horizontally.

Definition at line 130 of file Tetris.cpp.

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

◆ PlayTetris()

void Tetris::PlayTetris ( )

Play Tetris Game.

Definition at line 25 of file Tetris.cpp.

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

◆ RotateTile()

void Tetris::RotateTile ( const bool  rotate = false)
private

Allow user to rotate shapes.

Definition at line 148 of file Tetris.cpp.

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

Field Documentation

◆ a

Point Tetris::a[4]
private

Use to move shapes.

Definition at line 59 of file Tetris.h.

◆ b

Point Tetris::b[4]
private

Keep a backup.

Definition at line 62 of file Tetris.h.

◆ field

int Tetris::field[M][N]
private

Define a 10 x 20 rectangle. This is use as the background for the game.

Definition at line 18 of file Tetris.h.

◆ figures

const int Tetris::figures[7][4]
private
Initial value:
=
{
1,3,5,7,
2,4,5,7,
3,5,4,6,
3,5,4,7,
2,3,5,7,
3,5,7,6,
2,3,4,5,
}

Define 7 x 4 rectangle[ 7 rows, 4 coloumns] This defines the shapes. For example, these are the following shapes. 1,3,5,7, -> denotes I 2,4,5,7, -> denotes Z 3,5,4,6, -> denotes S 3,5,4,7, -> denotes T 2,3,5,7, -> denotes L 3,5,7,6, -> denotes J 2,3,4,5, -> denotes O.

Definition at line 40 of file Tetris.h.

◆ M

const int Tetris::M = 20
staticprivate

Define width of a rectangle.

Definition at line 11 of file Tetris.h.

◆ N

const int Tetris::N = 10
staticprivate

Define length of a rectangle.

Definition at line 14 of file Tetris.h.


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