Bridges-C++  3.4.4
Bridges(C++ API)
Protected Member Functions | Protected Attributes | List of all members
bridges::game::GameBase Class Referenceabstract

#include <GameBase.h>

Inheritance diagram for bridges::game::GameBase:
bridges::game::NonBlockingGame

Detailed Description

The base class building and using the BRIDGES based games.

This class forms the infrastructure for the BRIDGES Game API and contains methods for input listener and drawing functions (symbols, characters, visual attributes).

See also
See the detailed Bridges game tutorial for examples at https://bridgesuncc.github.io/tutorials/NonBlockingGame.html
Author
David Burlinson, Erik Saule
Date
2018, 2019, 12/28/20

Protected Member Functions

 GameBase (int assignmentID, std::string username, std::string apikey, int nbRow=10, int nbColumn=10)
 Protected constructed prevens direct creation. More...
 
virtual ~GameBase ()=default
 
virtual void initialize ()=0
 This function is called once when the game starts. More...
 
virtual void gameLoop ()=0
 This function is called once per frame of the game. More...
 
void registerKeyListener (KeypressListener *p)
 register a new KeypressListener More...
 
void render ()
 Renders the game. More...
 
bool gameover () const
 
void quit ()
 calling this function causes the game to end. More...
 
void setBGColor (int row, int col, NamedColor nc)
 Change the background color of a cell. More...
 
void drawSymbol (int row, int col, NamedSymbol symb, NamedColor nc)
 Draw an object on the game. More...
 
void setTitle (std::string title)
 Set the title of the game. More...
 
void setDescription (std::string desc)
 Set a short description of the game. More...
 
NamedColor getBGColor (int row, int col)
 What color is this cell? More...
 
NamedSymbol getSymbol (int row, int col)
 What object is in this cell? More...
 
NamedColor getSymbolColor (int row, int col)
 What color is object in this cell? More...
 
int getBoardWidth ()
 How wide is the Game Board? More...
 
int getBoardHeight ()
 How tall is the Game Board? More...
 

Protected Attributes

bool debug = false
 

Constructor & Destructor Documentation

◆ GameBase()

bridges::game::GameBase::GameBase ( int  assignmentID,
std::string  username,
std::string  apikey,
int  nbRow = 10,
int  nbColumn = 10 
)
inlineprotected

Protected constructed prevens direct creation.

Having a protected constructor prevents the object from being directly created. Since GameBase is meant to be a purely internal class, that seems appropriate.

◆ ~GameBase()

virtual bridges::game::GameBase::~GameBase ( )
protectedvirtualdefault

Member Function Documentation

◆ drawSymbol()

void bridges::game::GameBase::drawSymbol ( int  row,
int  col,
NamedSymbol  symb,
NamedColor  nc 
)
inlineprotected

Draw an object on the game.

Parameters
rowrow of the cell to draw the object on
colcolumn of the cell to draw the object on
symbsymbol representing the object
nccolor of the object

◆ gameLoop()

virtual void bridges::game::GameBase::gameLoop ( )
protectedpure virtual

This function is called once per frame of the game.

Students write this function. It will be called at each frame of the game.

◆ gameover()

bool bridges::game::GameBase::gameover ( ) const
inlineprotected

◆ getBGColor()

NamedColor bridges::game::GameBase::getBGColor ( int  row,
int  col 
)
inlineprotected

What color is this cell?

Parameters
rowrow of the cell
colcolumn of the cell

◆ getBoardHeight()

int bridges::game::GameBase::getBoardHeight ( )
inlineprotected

How tall is the Game Board?

Returns
the number of rows of the board

◆ getBoardWidth()

int bridges::game::GameBase::getBoardWidth ( )
inlineprotected

How wide is the Game Board?

Returns
the number of columns of the board

◆ getSymbol()

NamedSymbol bridges::game::GameBase::getSymbol ( int  row,
int  col 
)
inlineprotected

What object is in this cell?

Parameters
rowrow of the cell
colcolumn of the cell

◆ getSymbolColor()

NamedColor bridges::game::GameBase::getSymbolColor ( int  row,
int  col 
)
inlineprotected

What color is object in this cell?

Parameters
rowrow of the cell
colcolumn of the cell

◆ initialize()

virtual void bridges::game::GameBase::initialize ( )
protectedpure virtual

This function is called once when the game starts.

Students write this function. It will be called once at the begining of the game.

◆ quit()

void bridges::game::GameBase::quit ( )
inlineprotected

calling this function causes the game to end.

That is to say, the current frame will be the last frame of the game.

◆ registerKeyListener()

void bridges::game::GameBase::registerKeyListener ( KeypressListener p)
inlineprotected

register a new KeypressListener

Students should not have to call this function directly. The KeypressListener listener will get notified of all keypresses (up and down) that happens in the game.

Parameters
pa KeypressListener to register

◆ render()

void bridges::game::GameBase::render ( )
inlineprotected

Renders the game.

Student should not have to call this function directly. It is called automatically by Bridges.

◆ setBGColor()

void bridges::game::GameBase::setBGColor ( int  row,
int  col,
NamedColor  nc 
)
inlineprotected

Change the background color of a cell.

Parameters
rowrow of the cell to set
colcolumn of the cell to set
ncNamedColor to set

◆ setDescription()

void bridges::game::GameBase::setDescription ( std::string  desc)
inlineprotected

Set a short description of the game.

Parameters
descDescription of the game

◆ setTitle()

void bridges::game::GameBase::setTitle ( std::string  title)
inlineprotected

Set the title of the game.

Parameters
titleTitle of the game

Member Data Documentation

◆ debug

bool bridges::game::GameBase::debug = false
protected

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