diff --git a/demo/demo/hexboard/board.cpp b/demo/demo/hexboard/board.cpp index 4c8c1c5eb7e98ca0a337d7a2ac8ec1c0c96162af..174826585af85f9670d3f603be0fc5fac8928b50 100644 --- a/demo/demo/hexboard/board.cpp +++ b/demo/demo/hexboard/board.cpp @@ -52,9 +52,9 @@ namespace demo::hexboard { void Scene::render(fggl::gfx::Graphics &gfx) { // if the board is not set, abort - /*if ( m_board == nullptr ){ + if ( m_board == nullptr ){ return; - }*/ + } // draw the grid // FIXME don't hard-code the screen size @@ -72,12 +72,15 @@ namespace demo::hexboard { auto rowBasis = hexPos; for(auto i=0; i<gridHeight; ++i) { for (auto j=0; j<gridWidth; ++j) { - auto pos = hexToScreen(hexPos, hexRadius, offset); - auto hex = fggl::gfx::make_shape(pos, hexRadius, 6); - paint.stroke(hex); - pos.x += hexRadius; - hexPos = hexPos.neighbour( fggl::grid::HexDirPointy::RIGHT ); + if ( m_board->isValidPos(hexPos) ) { + auto pos = hexToScreen(hexPos, hexRadius, offset); + auto hexShape = fggl::gfx::make_shape(pos, hexRadius, 6); + 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); diff --git a/include/fggl/grid/hexgrid.hpp b/include/fggl/grid/hexgrid.hpp index 31a36facaa14b87adeefb948a0673139ea84a97d..ae948db54667985a4f172438950620ef119117c5 100644 --- a/include/fggl/grid/hexgrid.hpp +++ b/include/fggl/grid/hexgrid.hpp @@ -24,7 +24,10 @@ namespace fggl::grid { class HexGrid { - + public: + inline bool isValidPos(const IntHex& pos) { + return true; + } }; } // namespace fggl::grid