Describes a game board placed in a window.
More...
#include <pboard.hpp>
|
| struct | BoardDims |
| | Describes the offset and scale of the board in reference to the window. More...
|
| |
|
|
| PlacedBoard (GameBoard &board, const BoardDims &dims) |
| |
|
| 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...
|
| |
|
| 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...
|
| |
|
| 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...
|
| |
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
◆ 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
-
| x | The absolute x float coordinate. |
| y | The 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
-
| x | The absolute x float coordinate. |
| y | The 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
-
| row | The row index. |
| col | The 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
-
- 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
-
| x | The relative x float coordinate. |
| y | The 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
-
| y | The 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: