Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
BoardLocations Class Reference

The aspect responsible for mapping points on the 3D game board to their equivalent coordinates on the game board data model. More...

#include <board_locations.hpp>

Inheritance diagram for BoardLocations:

Public Member Functions

std::shared_ptr< BaseSimObjectAspect > clone () const override
 Uses this aspect's data to construct a new aspect.
 
bool onPointerLeftClick (glm::vec4 clickLocation) override
 Responds to left click events by logging them to the console, translating the location of the click to their game board grid coordinates.
 
bool onPointerLeftRelease (glm::vec4 clickLocation) override
 Responds to a full left click by emitting mSigBoardClicked with the clicked location's equivalent game board coordinates, if possible.
 
glm::uvec2 boardPointToGridIndices (glm::vec2 point) const
 Given the 2D coordinates of a point relative to the top surface of the board, returns the equivalent game board data model grid coordinates.
 
glm::vec4 gridIndicesToBoardPoint (glm::u8vec2 gridIndices) const
 Translates game board data model grid coordinates to their real world 3D coordinates equivalent.
 

Static Public Member Functions

static std::string getSimObjectAspectTypeName ()
 Gets the aspect type string associated with this class.
 
static std::shared_ptr< BaseSimObjectAspect > create (const nlohmann::json &jsonAspectProperties)
 Constructs this aspect from its JSON description.
 

Public Attributes

ToyMaker::Signal< glm::u8vec2 > mSigBoardClicked { *this, "BoardClicked" }
 The event emitted signalling to the 3D viewport controller that a location on the board was clicked.
 

Private Member Functions

 BoardLocations ()
 Constructs a new Board Locations object.
 

Private Attributes

std::array< uint8_t, 3 > mRowLengths {4, 12, 4}
 The lengths of the 3 rows of the game board representing the number of valid houses on it.
 

Detailed Description

The aspect responsible for mapping points on the 3D game board to their equivalent coordinates on the game board data model.

Member Function Documentation

◆ boardPointToGridIndices()

glm::uvec2 BoardLocations::boardPointToGridIndices ( glm::vec2 point) const

Given the 2D coordinates of a point relative to the top surface of the board, returns the equivalent game board data model grid coordinates.

Parameters
pointThe 2D coordinates of a point on the surface of the board.
Returns
glm::uvec2 The game board grid coordinates.

◆ clone()

std::shared_ptr< ToyMaker::BaseSimObjectAspect > BoardLocations::clone ( ) const
override

Uses this aspect's data to construct a new aspect.

Returns
std::shared_ptr<BaseSimObjectAspect> The newly constructed aspect.

◆ create()

std::shared_ptr< ToyMaker::BaseSimObjectAspect > BoardLocations::create ( const nlohmann::json & jsonAspectProperties)
static

Constructs this aspect from its JSON description.

This is its appearance in JSON:

{ "type": "BoardLocations" }
Parameters
jsonAspectPropertiesThis aspect's description in JSON.
Returns
std::shared_ptr<BaseSimObjectAspect> The newly constructed aspect.

◆ getSimObjectAspectTypeName()

static std::string BoardLocations::getSimObjectAspectTypeName ( )
inlinestatic

Gets the aspect type string associated with this class.

Returns
std::string This class' aspect type string.

◆ gridIndicesToBoardPoint()

glm::vec4 BoardLocations::gridIndicesToBoardPoint ( glm::u8vec2 gridIndices) const

Translates game board data model grid coordinates to their real world 3D coordinates equivalent.

Parameters
gridIndicesThe game board data model grid location.
Returns
glm::vec4 The equivalent 3D coordinates.

◆ onPointerLeftClick()

bool BoardLocations::onPointerLeftClick ( glm::vec4 clickLocation)
override

Responds to left click events by logging them to the console, translating the location of the click to their game board grid coordinates.

Parameters
clickLocationThe 3D coordinates of the location on the board that was clicked.
Return values
trueThe location clicked corresponded to a real game board grid location.
falseThe location clicked did not correspond to a real game board grid location.

◆ onPointerLeftRelease()

bool BoardLocations::onPointerLeftRelease ( glm::vec4 clickLocation)
inlineoverride

Responds to a full left click by emitting mSigBoardClicked with the clicked location's equivalent game board coordinates, if possible.

Parameters
clickLocationThe 3D coordinates of the point on the board that was clicked.
Return values
trueThe clicked location caused mSigBoardClicked to be emitted.
falseNo signal was emitted as a result of this click.

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