From 00e191f70f456893d31c332625a9c77dc83de83b Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Sun, 29 Aug 2021 01:37:51 -0400 Subject: [PATCH] fix even more buggy shit --- src/gamepkg/gui.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gamepkg/gui.nim b/src/gamepkg/gui.nim index 799a0f9..62aaaf8 100644 --- a/src/gamepkg/gui.nim +++ b/src/gamepkg/gui.nim @@ -147,8 +147,7 @@ proc getTilePos(mouseX: int, mouseY: int, board: Board): int = # Do search for the tile x and y coordinates using intervals # Return position in the set of tiles - const boardLength = (gameConf.boxStride+gameConf.boardOffset.int) * (gameConf.rowSize - 1) # How long is a side of the board - if mouseX.float32 > (boardLength + gameConf.borderWidth) or mouseY.float32 > (boardLength + gameConf.borderWidth): + if mouseX.float32 > board.xIntervals[^1].h or mouseY.float32 > board.yIntervals[^1].h: return -1 if mouseX < gameConf.boardOffset or mouseY < gameConf.boardOffset: @@ -156,6 +155,7 @@ proc getTilePos(mouseX: int, mouseY: int, board: Board): int = let x: int = board.xIntervals.binarySearch(mouseX, comparator) - 1 let y: int = board.yIntervals.binarySearch(mouseY, comparator) - 1 + return (y*gameConf.rowSize) + x proc drawTile(heightPos: int, widthPos: int, state: TileState, reveal: bool = false): Tile =