Skip to content

Commit

Permalink
[bgw-gui] Fixed Rotation in hexagon grid. (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
abouzerda authored Nov 21, 2023
1 parent 10a371a commit bc71921
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package tools.aqua.bgw.components.container

import kotlin.math.sqrt
import tools.aqua.bgw.components.gamecomponentviews.HexagonView
import tools.aqua.bgw.visual.Visual

Expand Down Expand Up @@ -90,7 +91,8 @@ class HexagonGrid<T : HexagonView>(
CoordinateSystem.AXIAL -> x + (y - (y and 1)) / 2 to y
}
with(hexagon) {
posXProperty.setSilent(width * q + if (r % 2 == 0) 0.0 else width / 2)
val actualWidth = width / 2 * sqrt(3.0)
posXProperty.setSilent(actualWidth * q + if (r % 2 == 0) 0.0 else actualWidth / 2)
posYProperty.setSilent(height * r - r * height / 4)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package tools.aqua.bgw.components.gamecomponentviews

import kotlin.math.sqrt
import tools.aqua.bgw.core.DEFAULT_HEXAGON_SIZE
import tools.aqua.bgw.visual.Visual

Expand All @@ -41,6 +40,6 @@ open class HexagonView(
GameComponentView(
posX = posX,
posY = posY,
width = sqrt(3.0) * size.toDouble(),
width = 2 * size.toDouble(),
height = 2 * size.toDouble(),
visual = visual)

0 comments on commit bc71921

Please sign in to comment.