#include <GameBase.h>
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
|
| 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...
|
|
◆ 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 |
◆ drawSymbol()
Draw an object on the game.
- Parameters
-
row | row of the cell to draw the object on |
col | column of the cell to draw the object on |
symb | symbol representing the object |
nc | color 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
-
row | row of the cell |
col | column 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
-
row | row of the cell |
col | column of the cell |
◆ getSymbolColor()
NamedColor bridges::game::GameBase::getSymbolColor |
( |
int |
row, |
|
|
int |
col |
|
) |
| |
|
inlineprotected |
What color is object in this cell?
- Parameters
-
row | row of the cell |
col | column 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()
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
-
◆ 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
-
row | row of the cell to set |
col | column of the cell to set |
nc | NamedColor to set |
◆ setDescription()
void bridges::game::GameBase::setDescription |
( |
std::string |
desc | ) |
|
|
inlineprotected |
Set a short description of the game.
- Parameters
-
desc | Description of the game |
◆ setTitle()
void bridges::game::GameBase::setTitle |
( |
std::string |
title | ) |
|
|
inlineprotected |
Set the title of the game.
- Parameters
-
◆ debug
bool bridges::game::GameBase::debug = false |
|
protected |
The documentation for this class was generated from the following file:
- /home/erik/work/bridges/bridges-cxx/src/GameBase.h