42 return 2.0f * dims.radius * board.
getCols() + (board.
getCols() % 2) * dims.radius;
50 return 2.0f * dims.radius * board.
getRows();
65 inline bool oob(
const float x,
const float y)
const {
81 inline bool oow(
const float x,
const float y)
const {
84 or x > dims.viewportWidth
86 or y > dims.viewportHeight
102 inline int xyToCol(
const float x,
const float y)
const {
103 return static_cast<int>(((x - (
yToRow(y) % 2 == 0 ? 0.0f : dims.radius)) / (2.0f * dims.radius)));
113 return static_cast<int>(y / (2.0f * dims.radius));
123 inline float rowColToX(
const size_t row,
const size_t col)
const {
124 return static_cast<float>(col * 2) * dims.radius + (row % 2) * dims.radius;
133 inline float rowToY(
const size_t row)
const {
134 return static_cast<float>(row * 2) * dims.radius;
140 : board(board), dims(dims) {}
Represents the game board and provides public methods to interact with it.
Definition: board.hpp:47
size_t getCols() const
Getter for the maximum number of columns in the game board (column amount alternates on row index).
Definition: board.cpp:9
size_t getRows() const
Getter for the number of rows in the game board.
Definition: board.cpp:5
Describes the offset and scale of the board in reference to the window.
Definition: pboard.hpp:26
Describes a game board placed in a window.
Definition: pboard.hpp:16
float getHeight() const
Get the height of the board placed on the window.
Definition: pboard.hpp:49
bool oob(const float x, const float y) const
Check if an absolute coordinate pair is out of bounds of the PlacedBoard.
Definition: pboard.hpp:65
float rowColToX(const size_t row, const size_t col) const
Convert row, column indices to an x coordinate.
Definition: pboard.hpp:123
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.
Definition: pboard.hpp:81
float getWidth() const
Get the width of the board placed on the window.
Definition: pboard.hpp:41
int yToRow(const float y) const
Convert relative y coordinate to a row index.
Definition: pboard.hpp:112
float rowToY(const size_t row) const
Convert row index to a y coordinate.
Definition: pboard.hpp:133
int xyToCol(const float x, const float y) const
Convert relative x, y coordinates to a column index.
Definition: pboard.hpp:102