Skip to content

Commit

Permalink
Fixed Rotation in hexagon grid.
Browse files Browse the repository at this point in the history
  • Loading branch information
abouzerda committed Nov 21, 2023
1 parent e8deb9b commit 5ca9bda
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)

Check warning on line 94 in bgw-gui/src/main/kotlin/tools/aqua/bgw/components/container/HexagonGrid.kt

View check run for this annotation

Codecov / codecov/patch

bgw-gui/src/main/kotlin/tools/aqua/bgw/components/container/HexagonGrid.kt#L94

Added line #L94 was not covered by tests
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(),

Check warning on line 43 in bgw-gui/src/main/kotlin/tools/aqua/bgw/components/gamecomponentviews/HexagonView.kt

View check run for this annotation

Codecov / codecov/patch

bgw-gui/src/main/kotlin/tools/aqua/bgw/components/gamecomponentviews/HexagonView.kt#L43

Added line #L43 was not covered by tests
height = 2 * size.toDouble(),
visual = visual)

0 comments on commit 5ca9bda

Please sign in to comment.