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

extract magic numbers from hexboard into constants

parent c0c7a9a5
No related branches found
No related tags found
No related merge requests found
...@@ -19,31 +19,34 @@ ...@@ -19,31 +19,34 @@
#include "hexboard/scene.hpp" #include "hexboard/scene.hpp"
namespace demo::hexboard { namespace demo::hexboard {
constexpr float SCROLL_SPEED = 0.01F;
constexpr float HEX_SIZE = 64.0F;
constexpr std::array<fggl::grid::IntHex, 4> ISLAND_CENTERS {{
{2, 3},
{6, 7},
{9, 10},
{6, 3}
}};
Scene::Scene(fggl::App &app) : GameBase(app), m_board(nullptr), m_screen(1920.F, 1080.F) { Scene::Scene(fggl::App &app) : GameBase(app), m_board(nullptr), m_screen(1920.F, 1080.F) {
} }
void Scene::activate() { void Scene::activate() {
m_board = std::make_unique<fggl::grid::HexGrid>(); m_board = std::make_unique<fggl::grid::HexGrid>();
m_layout = std::make_unique<fggl::grid::Layout>( fggl::grid::Orientation::make_pointy(), 64.0F ); m_layout = std::make_unique<fggl::grid::Layout>( fggl::grid::Orientation::make_pointy(), HEX_SIZE );
//m_layout->m_origin = { 1920.0F * -0.5F, 1080.0F * -0.5F}; //m_layout->m_origin = { 1920.0F * -0.5F, 1080.0F * -0.5F};
m_selections = std::make_unique<SelectionModel>(); m_selections = std::make_unique<SelectionModel>();
fggl::grid::TerrainType grass{ const fggl::grid::TerrainType grass{
.data = std::make_shared<fggl::grid::MaterialData>() .data = std::make_shared<fggl::grid::MaterialData>()
}; };
grass.data->name = "grass"; grass.data->name = "grass";
grass.data->colour = {0.0F, 1.0F, 0.0}; grass.data->colour = {0.0F, 1.0F, 0.0};
std::array<fggl::grid::IntHex, 4> islands {{ for (auto islandPoint : ISLAND_CENTERS){
{3, 3},
{7, 7},
{10, 10},
{7, 3}
}};
for (auto islandPoint : islands){
auto island = islandPoint.hexesInRange(2); auto island = islandPoint.hexesInRange(2);
for (auto &hex : island) { for (auto &hex : island) {
m_board->setTerrain(hex, grass); m_board->setTerrain(hex, grass);
...@@ -88,7 +91,7 @@ namespace demo::hexboard { ...@@ -88,7 +91,7 @@ namespace demo::hexboard {
} }
auto offset = screenPos - m_dragging.value(); auto offset = screenPos - m_dragging.value();
m_camera->teleportBy(offset * 0.01F); m_camera->teleportBy(offset * SCROLL_SPEED);
} else if ( input.mouse.released(fggl::input::MouseButton::RIGHT) ) { } else if ( input.mouse.released(fggl::input::MouseButton::RIGHT) ) {
m_dragging = {}; m_dragging = {};
} }
......
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