From 2061b39c11133253610db2da6694f0d9c9caf535 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Mon, 24 Mar 2025 14:15:20 +0100 Subject: [PATCH] fixe position issue --- Makefile | 5 +++++ src/button.ts | 2 +- src/game.ts | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index acd7fcf..7d5f5fe 100644 --- a/Makefile +++ b/Makefile @@ -6,3 +6,8 @@ all: clean: rm -rf build/ + +hard-clean: + rm -rf build/ + rm -rf node_modules/ + rm -f package-lock.json diff --git a/src/button.ts b/src/button.ts index 3712dbe..7da160f 100644 --- a/src/button.ts +++ b/src/button.ts @@ -26,7 +26,7 @@ export function clickAction( return -1; } let xmin = 960 - buttons.filter(c => c[0]).length * 120; - let inside = 492 < y && y < 544; + let inside = 838 < y && y < 888; let q = Math.floor((x - xmin) / 120); let r = (x - xmin) - 120 * q; if ( diff --git a/src/game.ts b/src/game.ts index b9776e1..4759e9b 100644 --- a/src/game.ts +++ b/src/game.ts @@ -93,9 +93,10 @@ export class Game { public click( mp: mousePos, ): void { + const rect = this.cv.getBoundingClientRect(); let action = clickAction( - mp.x, - mp.y, + mp.x - rect.left, + mp.y - rect.top, this.canDoAChii().length > 0, this.canDoAPon(), false && this.level > 1,