Skip to content

Instantly share code, notes, and snippets.

@KartikShrivastava
Created July 28, 2022 08:17
Show Gist options
  • Save KartikShrivastava/760f1f0828e6d6066d8a2f998f32e8e0 to your computer and use it in GitHub Desktop.
Save KartikShrivastava/760f1f0828e6d6066d8a2f998f32e8e0 to your computer and use it in GitHub Desktop.
unsigned int nHoriTiles = resNode->room().width();
unsigned int nVertTiles = resNode->room().height();
unsigned int tileWidthPixels = resNode->room().hsnap();
unsigned int tileHeightPixels = resNode->room().vsnap();
if(resNode->mutable_room()->orientation() == "hexagonal") {
hexMapUtil = std::make_unique<HexMapUtil>();
hexMapUtil->hexSideLength = resNode->room().hexsidelength();
hexMapUtil->staggerAxis = resNode->room().staggeraxis();
hexMapUtil->staggerIndex = resNode->room().staggerindex();
if(hexMapUtil->staggerAxis == "x") {
resNode->mutable_room()->set_width((3 * nHoriTiles + 1) * hexMapUtil->hexSideLength / 2);
resNode->mutable_room()->set_height((nVertTiles * tileHeightPixels) + hexMapUtil->hexSideLength);
}
else {
resNode->mutable_room()->set_width((nHoriTiles * tileWidthPixels) + hexMapUtil->hexSideLength);
resNode->mutable_room()->set_height((3 * nVertTiles + 1) * hexMapUtil->hexSideLength / 2);
}
}
else {
resNode->mutable_room()->set_width(nHoriTiles * tileWidthPixels);
resNode->mutable_room()->set_height(nVertTiles * tileHeightPixels);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment