From 84a05355d9d72d0a2ef5a86a84279661d6b734dd Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 7 Oct 2023 22:14:18 +0200 Subject: [PATCH] Fixed cursor going out of bounds --- states/game.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/states/game.lua b/states/game.lua index cc6f4a8..0a4b025 100644 --- a/states/game.lua +++ b/states/game.lua @@ -79,6 +79,10 @@ function state_game() moved = true x += 1 end + + x = mid(1, x, size) + y = mid(1, y, size) + if moved then selected_id = board:xy_idx(x, y) end @@ -88,10 +92,6 @@ function state_game() show_clues() end - if (x < 1) x = size - if (x > size) x = 1 - if (y < 1) y = size - if (y > size) y = 1 check_endgame() end