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
board_locations.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPBOARDLOCATIONS_H
13#define ZOAPPBOARDLOCATIONS_H
14
15#include "toymaker/sim_system.hpp"
16
19
20
26class BoardLocations: public ToyMaker::SimObjectAspect<BoardLocations>, public ILeftClickable {
27public:
33 inline static std::string getSimObjectAspectTypeName() { return "BoardLocations"; }
34
50 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
51
57 std::shared_ptr<BaseSimObjectAspect> clone() const override;
58
66 bool onPointerLeftClick(glm::vec4 clickLocation) override;
67
75 inline bool onPointerLeftRelease(glm::vec4 clickLocation) override { (void)clickLocation;/*prevent unused parameter warnings*/ return false; }
76
82
89 glm::uvec2 boardPointToGridIndices (glm::vec2 point) const;
90
97 glm::vec4 gridIndicesToBoardPoint(glm::u8vec2 gridIndices) const;
98
99private:
104 BoardLocations(): SimObjectAspect<BoardLocations>{0} {}
105
110 std::array<uint8_t, 3> mRowLengths {4, 12, 4};
111};
112
113#endif
static std::string getSimObjectAspectTypeName()
Gets the aspect type string associated with this class.
Definition board_locations.hpp:33
std::shared_ptr< BaseSimObjectAspect > clone() const override
Uses this aspect's data to construct a new aspect.
Definition board_locations.cpp:24
bool onPointerLeftRelease(glm::vec4 clickLocation) override
Responds to a full left click by emitting mSigBoardClicked with the clicked location's equivalent gam...
Definition board_locations.hpp:75
ToyMaker::Signal< glm::u8vec2 > mSigBoardClicked
The event emitted signalling to the 3D viewport controller that a location on the board was clicked.
Definition board_locations.hpp:81
static std::shared_ptr< BaseSimObjectAspect > create(const nlohmann::json &jsonAspectProperties)
Constructs this aspect from its JSON description.
Definition board_locations.cpp:19
bool onPointerLeftClick(glm::vec4 clickLocation) override
Responds to left click events by logging them to the console, translating the location of the click t...
Definition board_locations.cpp:6
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 ...
Definition board_locations.cpp:28
BoardLocations()
Constructs a new Board Locations object.
Definition board_locations.hpp:104
std::array< uint8_t, 3 > mRowLengths
The lengths of the 3 rows of the game board representing the number of valid houses on it.
Definition board_locations.hpp:110
glm::vec4 gridIndicesToBoardPoint(glm::u8vec2 gridIndices) const
Translates game board data model grid coordinates to their real world 3D coordinates equivalent.
Definition board_locations.cpp:42
The interface used by aspects which wish to respond to mouse left click events (or equivalent).
Definition interface_pointer_callback.hpp:88
A Signal object, designed to emit signals matching some data signature to be received by all the Sign...
Definition signals.hpp:323
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
Contains classes and enums that define a house and describe its state.
Contains classes that serve as interfaces for sim objects that wish to respond to click events.