From 2d6b967a29220ad85d843af9b5ba7482f11376f1 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Thu, 21 May 2026 10:05:58 -0700 Subject: [PATCH] Fix direction arrow hidden behind controller in portrait mode by offsetting for controller height --- game.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/game.js b/game.js index 4dbea35..805047d 100644 --- a/game.js +++ b/game.js @@ -498,6 +498,12 @@ class Game { } else { pd = dy >= 0 ? 'down' : 'up'; } + + const isLandscape = window.innerWidth > window.innerHeight; + const ctrlH = isLandscape ? 0 : Math.round(Math.min(148, Math.max(110, window.innerWidth * 0.22))); + const safeBottom = ctrlH + 12; + const midY = (viewH - ctrlH) / 2 - 16; + const glyphs = { right:'▶', left:'◀', up:'▲', down:'▼' }; arrow.textContent = glyphs[pd]; arrow.style.display = 'block'; @@ -505,19 +511,19 @@ class Game { if (pd === 'right') { arrow.style.removeProperty('left'); arrow.style.right = '12px'; - arrow.style.bottom = (viewH / 2 - 16) + 'px'; + arrow.style.bottom = midY + 'px'; } else if (pd === 'left') { arrow.style.removeProperty('right'); arrow.style.left = '12px'; - arrow.style.bottom = (viewH / 2 - 16) + 'px'; + arrow.style.bottom = midY + 'px'; } else if (pd === 'up') { arrow.style.removeProperty('right'); arrow.style.left = (viewW / 2 - 16) + 'px'; - arrow.style.bottom = (viewH - 48) + 'px'; + arrow.style.bottom = (viewH - ctrlH - 48) + 'px'; } else { arrow.style.removeProperty('right'); arrow.style.left = (viewW / 2 - 16) + 'px'; - arrow.style.bottom = '12px'; + arrow.style.bottom = safeBottom + 'px'; } }