Raylib Bubbles
C++11 Raylib bubble shooter game.
PlacedBoard Struct Reference

Describes a game board placed in a window. More...

#include <pboard.hpp>

Classes

struct  BoardDims
 Describes the offset and scale of the board in reference to the window. More...
 

Public Member Functions

 PlacedBoard (GameBoard &board, const BoardDims &dims)
 
Getters to produce the width and height of the board based on the board dimensions.
float getWidth () const
 Get the width of the board placed on the window. More...
 
float getHeight () const
 Get the height of the board placed on the window. More...
 
Sanity checks.
bool oob (const float x, const float y) const
 Check if an absolute coordinate pair is out of bounds of the PlacedBoard. More...
 
bool oow (const float x, const float y) const
 Check if an absolute coordinate pair is out of the parent window viewport of the PlacedBoard. More...
 
Hexagonal grid offset conversion tools (using relative coordinates based on the board dimensions).
int xyToCol (const float x, const float y) const
 Convert relative x, y coordinates to a column index. More...
 
int yToRow (const float y) const
 Convert relative y coordinate to a row index. More...
 
float rowColToX (const size_t row, const size_t col) const
 Convert row, column indices to an x coordinate. More...
 
float rowToY (const size_t row) const
 Convert row index to a y coordinate. More...
 

Public Attributes

GameBoardboard
 
BoardDims dims
 

Detailed Description

Describes a game board placed in a window.

This struct is used to describe a game board placed in a window, including its dimensions and position. It's a simple struct wrapper around a GameBoard object and a BoardDims object, which can be accessed directly.

Note
This struct does not own the GameBoard object, it only references it.
See also
GameBoard, GameWindow

Member Function Documentation

◆ getHeight()

float PlacedBoard::getHeight ( ) const
inline

Get the height of the board placed on the window.

Returns
The accurate height to fit the board rows.

◆ getWidth()

float PlacedBoard::getWidth ( ) const
inline

Get the width of the board placed on the window.

Returns
The accurate width to fit the board columns.

◆ oob()

bool PlacedBoard::oob ( const float  x,
const float  y 
) const
inline

Check if an absolute coordinate pair is out of bounds of the PlacedBoard.

Parameters
xThe absolute x float coordinate.
yThe absolute y float coordinate.
Todo:
Naming collides with GameBoard::oob() method, which has row, col arguments.
Returns
True if the coordinate is out of bounds, false otherwise.

◆ oow()

bool PlacedBoard::oow ( const float  x,
const float  y 
) const
inline

Check if an absolute coordinate pair is out of the parent window viewport of the PlacedBoard.

Parameters
xThe absolute x float coordinate.
yThe absolute y float coordinate.
Todo:
Naming collides with GameBoard::oob() method, which has row, col arguments.
Returns
True if the coordinate is out of bounds, false otherwise.

◆ rowColToX()

float PlacedBoard::rowColToX ( const size_t  row,
const size_t  col 
) const
inline

Convert row, column indices to an x coordinate.

Parameters
rowThe row index.
colThe column index.
Warning
Be sure to convert the result to relative by adding dims.x to the result if necessary.
Returns
The absolute x float coordinate.

◆ rowToY()

float PlacedBoard::rowToY ( const size_t  row) const
inline

Convert row index to a y coordinate.

Parameters
rowThe row index.
Warning
Be sure to convert the result to relative by adding dims.y to the result if necessary.
Returns
The absolute y float coordinate.

◆ xyToCol()

int PlacedBoard::xyToCol ( const float  x,
const float  y 
) const
inline

Convert relative x, y coordinates to a column index.

Parameters
xThe relative x float coordinate.
yThe relative y float coordinate.
Warning
Please use coordinates relative to the board dimensions. You can convert from absolute by subtracting dims.x and dims.y to the arguments.
Returns
The column index.

◆ yToRow()

int PlacedBoard::yToRow ( const float  y) const
inline

Convert relative y coordinate to a row index.

Parameters
yThe relative y float coordinate.
Warning
Please use coordinates relative to the board dimensions. You can convert from absolute by subtracting dims.x and dims.y to the arguments.
Returns
The row index.

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