Skip to content

Commit 897e347

Browse files
committed
fix(piranhas): grid orientation
GridPane coordinates start at the top left, so for directions to match, the y coordinates need to be inverted.
1 parent a625176 commit 897e347

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/kotlin/sc/gui/view/game/PiranhasBoard.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ class PiranhasBoard: GameBoard<GameState>() {
5151
hovers.clear()
5252
}
5353

54+
fun addToGrid(child: Node, coordinates: Coordinates) {
55+
grid.add(child, coordinates.x, PiranhaConstants.BOARD_LENGTH - 1 - coordinates.y)
56+
}
57+
5458
override fun onNewState(oldState: GameState?, state: GameState?) {
5559
selected = grid
5660
logger.debug { "New State: $state" }
@@ -68,7 +72,7 @@ class PiranhasBoard: GameBoard<GameState>() {
6872
val piece = PieceImage(
6973
gridSize,
7074
field.team?.let { team -> "${team}_${field.size}" } ?: field.name.lowercase())
71-
grid.add(piece, pos.x, pos.y)
75+
addToGrid(piece, pos)
7276
if(field.team == null)
7377
return@forEach
7478
piece.hoverProperty().addListener { _, _, hover ->
@@ -118,7 +122,7 @@ class PiranhasBoard: GameBoard<GameState>() {
118122
hover.onLeftClick { sendHumanMove(move) }
119123

120124
hovers.add(hover)
121-
grid.add(hover, target.x, target.y)
125+
addToGrid(hover, target)
122126
}
123127
}
124128

0 commit comments

Comments
 (0)