Skip to content
Snippets Groups Projects
Commit 3c238651 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

make use of board object

parent 9aa636c6
No related branches found
No related tags found
No related merge requests found
...@@ -52,9 +52,9 @@ namespace demo::hexboard { ...@@ -52,9 +52,9 @@ namespace demo::hexboard {
void Scene::render(fggl::gfx::Graphics &gfx) { void Scene::render(fggl::gfx::Graphics &gfx) {
// if the board is not set, abort // if the board is not set, abort
/*if ( m_board == nullptr ){ if ( m_board == nullptr ){
return; return;
}*/ }
// draw the grid // draw the grid
// FIXME don't hard-code the screen size // FIXME don't hard-code the screen size
...@@ -72,12 +72,15 @@ namespace demo::hexboard { ...@@ -72,12 +72,15 @@ namespace demo::hexboard {
auto rowBasis = hexPos; auto rowBasis = hexPos;
for(auto i=0; i<gridHeight; ++i) { for(auto i=0; i<gridHeight; ++i) {
for (auto j=0; j<gridWidth; ++j) { for (auto j=0; j<gridWidth; ++j) {
auto pos = hexToScreen(hexPos, hexRadius, offset);
auto hex = fggl::gfx::make_shape(pos, hexRadius, 6); if ( m_board->isValidPos(hexPos) ) {
paint.stroke(hex); auto pos = hexToScreen(hexPos, hexRadius, offset);
pos.x += hexRadius; auto hexShape = fggl::gfx::make_shape(pos, hexRadius, 6);
hexPos = hexPos.neighbour( fggl::grid::HexDirPointy::RIGHT ); paint.stroke(hexShape);
}
// next hexagon
hexPos = hexPos.neighbour(fggl::grid::HexDirPointy::RIGHT);
} }
rowBasis = i % 2 == 0 ? rowBasis.neighbour(fggl::grid::HexDirPointy::BOTTOM_RIGHT) : rowBasis.neighbour(fggl::grid::HexDirPointy::BOTTOM_LEFT); rowBasis = i % 2 == 0 ? rowBasis.neighbour(fggl::grid::HexDirPointy::BOTTOM_RIGHT) : rowBasis.neighbour(fggl::grid::HexDirPointy::BOTTOM_LEFT);
......
...@@ -24,7 +24,10 @@ ...@@ -24,7 +24,10 @@
namespace fggl::grid { namespace fggl::grid {
class HexGrid { class HexGrid {
public:
inline bool isValidPos(const IntHex& pos) {
return true;
}
}; };
} // namespace fggl::grid } // namespace fggl::grid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment