diff options
-rw-r--r-- | test-client/main.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index 103212e4..605bca5e 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -374,10 +374,15 @@ export function get_interact_target(): V2 | undefined { const t = tiles.get([bx + ox, by + oy] + "") if (!t) continue if (data.tile_interact[t.kind]) { - const dx = rx - (bx + ox + 0.5) - const dy = ry - (by + oy + 0.5) + const cx = (bx + ox + 0.5) + const cy = (by + oy + 0.5) + const dx = rx - cx + const dy = ry - cy + const pdx = me.position.x - cx + const pdy = me.position.y - cy const d = Math.sqrt(dx * dx + dy * dy) - if (d < 1.5 && d < best_d) { + const pd = Math.sqrt(pdx * pdx + pdy * pdy) + if (pd < 2 && d < best_d) { best_d = d best = { x: bx + ox, y: by + oy } } |