Bridges-Java  3.4.3
Bridges(Java API)
Public Member Functions | Package Attributes | List of all members
bridges.base.GameGrid Class Reference
Inheritance diagram for bridges.base.GameGrid:
bridges.base.Grid< GameCell >

Detailed Description

This class in BRIDGES is part of the BRIDGS Game API. It is for representing an (m x n) game grid. Each position in the grid will hold a GameCell object, each of which has a foreground color, background color, and a symbol.

The API supports 2D nonblocking games

See also
See the tutorial on making games in BRIDGES: https://bridgesuncc.github.io/tutorials/NonBlockingGame.html x *
Author
David Burlinson, Erik Saule

Public Member Functions

void setEncoding (String encoding)
 Enable changing the game grid encoding when building JSON representation. More...
 
String getDataStructType ()
 Get the data structure type (string) More...
 
 GameGrid ()
 
 GameGrid (int rows, int cols)
 
void setBGColor (Integer row, Integer col, NamedColor color)
 
NamedColor getBGColor (Integer row, Integer col)
 
NamedSymbol getSymbol (Integer row, Integer col)
 
NamedColor getSymbolColor (Integer row, Integer col)
 
void setFGColor (Integer row, Integer col, NamedColor color)
 
void setBGColor (Integer row, Integer col, String color)
 
void setFGColor (Integer row, Integer col, String color)
 
void drawSymbol (Integer row, Integer col, Integer symbol)
 
void drawSymbol (Integer row, Integer col, NamedSymbol symbol)
 
void drawSymbol (Integer row, Integer col, Integer symbol, String color)
 
void drawSymbol (Integer row, Integer col, NamedSymbol symbol, String color)
 
void drawSymbol (Integer row, Integer col, Integer symbol, NamedColor color)
 
void drawSymbol (Integer row, Integer col, NamedSymbol symbol, NamedColor color)
 
String getDataStructureRepresentation ()
 
- Public Member Functions inherited from bridges.base.Grid< GameCell >
String getDataStructType ()
 
 Grid ()
 
 Grid (int size)
 
 Grid (int rows, int cols)
 Construct a rows x cols size grid. More...
 
 Grid (int[] size)
 Construct a size[0] by size[1] sized grid. More...
 
void resize (int rows, int cols)
 
int[] getDimensions ()
 Get the grid dimensions. More...
 
get (Integer row, Integer col)
 Get the (row, col) element in the grid. More...
 
void set (Integer row, Integer col, E val)
 
String getDataStructureRepresentation ()
 Get data structure representation. More...
 

Package Attributes

ByteBuffer bf_bg
 
ByteBuffer bf_fg
 
ByteBuffer bf_symbols
 
String encoding = "raw"
 

Additional Inherited Members

- Protected Attributes inherited from bridges.base.Grid< GameCell >
ArrayList< ArrayList< E > > grid
 
int[] gridSize
 
- Static Protected Attributes inherited from bridges.base.Grid< GameCell >
static final int[] defaultGridSize
 
static int[] maxGridSize
 

Constructor & Destructor Documentation

◆ GameGrid() [1/2]

bridges.base.GameGrid.GameGrid ( )

Default Game Grid constructor Default size is 10 by 10

◆ GameGrid() [2/2]

bridges.base.GameGrid.GameGrid ( int  rows,
int  cols 
)

Grid constructor with grid size arguments

Parameters
rows- int representing the number of rows of the grid
cols- int representing the number of columns of the grid

Member Function Documentation

◆ drawSymbol() [1/6]

void bridges.base.GameGrid.drawSymbol ( Integer  row,
Integer  col,
Integer  symbol 
)

Draw a symbol at the specified location

Parameters
row,col- integer indices specifying the position to modify
symbol- Integer symbol argument to set the symbol at the chosen position

◆ drawSymbol() [2/6]

void bridges.base.GameGrid.drawSymbol ( Integer  row,
Integer  col,
Integer  symbol,
NamedColor  color 
)

Draw a symbol at the specified location

Parameters
row,col- integer indices specifying the position to modify
symbol- Integer symbol argument to set the symbol at the chosen position
color- Named Color enum argument to set the foreground at the chosen position

◆ drawSymbol() [3/6]

void bridges.base.GameGrid.drawSymbol ( Integer  row,
Integer  col,
Integer  symbol,
String  color 
)

Draw a symbol at the specified location

Parameters
row,col- integer indices specifying the position to modify
symbol- Integer symbol argument to set the symbol at the chosen position
color- String color argument to set the background at the chosen position

◆ drawSymbol() [4/6]

void bridges.base.GameGrid.drawSymbol ( Integer  row,
Integer  col,
NamedSymbol  symbol 
)

Draw a symbol at the specified location

Parameters
row,col- integer indices specifying the position to modify
symbol- Named symbol enum argument to set the symbol at the chosen position

◆ drawSymbol() [5/6]

void bridges.base.GameGrid.drawSymbol ( Integer  row,
Integer  col,
NamedSymbol  symbol,
NamedColor  color 
)

Draw a symbol at the specified location

Parameters
row,col- integer indices specifying the position to modify
symbol- Named Symbol enum argument to set the symbol at the chosen position
color- Named Color enum argument to set the foreground at the chosen position

◆ drawSymbol() [6/6]

void bridges.base.GameGrid.drawSymbol ( Integer  row,
Integer  col,
NamedSymbol  symbol,
String  color 
)

Draw a symbol at the specified location

Parameters
row,col- integer indices specifying the position to modify
symbol- Named Symbol enum argument to set the symbol at the chosen position
color- String color argument to set the background at the chosen position

◆ getBGColor()

NamedColor bridges.base.GameGrid.getBGColor ( Integer  row,
Integer  col 
)

Get background color of a cell

Parameters
row,col- integer indices specifying the position
Returns
background color of cell

◆ getDataStructType()

String bridges.base.GameGrid.getDataStructType ( )

Get the data structure type (string)

Returns
data structure type

◆ getDataStructureRepresentation()

String bridges.base.GameGrid.getDataStructureRepresentation ( )

get the JSON representation of the game grid. Contains separate foreground, background, and symbol arrays

Returns
the JSON representation of the game grid

◆ getSymbol()

NamedSymbol bridges.base.GameGrid.getSymbol ( Integer  row,
Integer  col 
)

Get symbol at a cell

Parameters
row,col- integer indices specifying the position
Returns
cell symbol

◆ getSymbolColor()

NamedColor bridges.base.GameGrid.getSymbolColor ( Integer  row,
Integer  col 
)

Get symbol color of a cell

Parameters
row,col- integer indices specifying the position
Returns
cell symbol color

◆ setBGColor() [1/2]

void bridges.base.GameGrid.setBGColor ( Integer  row,
Integer  col,
NamedColor  color 
)

Set background color of a cell using an enum argument

Parameters
row,col- integer indices specifying the position to modify
color- Named Color enum argument to set the background at the chosen position

◆ setBGColor() [2/2]

void bridges.base.GameGrid.setBGColor ( Integer  row,
Integer  col,
String  color 
)

Set background color of a cell using an enum argument

Parameters
row,col- integer indices specifying the position to modify
color- String color argument to set the background at the chosen position

◆ setEncoding()

void bridges.base.GameGrid.setEncoding ( String  encoding)

Enable changing the game grid encoding when building JSON representation.

Parameters
encodingtype of encoding. Supports "raw" and "rle"

◆ setFGColor() [1/2]

void bridges.base.GameGrid.setFGColor ( Integer  row,
Integer  col,
NamedColor  color 
)

Set foreground color of a cell using an enum argument

Parameters
row,col- integer indices specifying the position to modify
color- Named Color enum argument to set the foreground at the chosen position

◆ setFGColor() [2/2]

void bridges.base.GameGrid.setFGColor ( Integer  row,
Integer  col,
String  color 
)

Set foreground color of a cell using an enum argument

Parameters
row,col- integer indices specifying the position to modify
color- String color argument to set the foreground at the chosen position

Member Data Documentation

◆ bf_bg

ByteBuffer bridges.base.GameGrid.bf_bg
package

◆ bf_fg

ByteBuffer bridges.base.GameGrid.bf_fg
package

◆ bf_symbols

ByteBuffer bridges.base.GameGrid.bf_symbols
package

◆ encoding

String bridges.base.GameGrid.encoding = "raw"
package

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