diff --git a/www/html/Game/public/js/play.js b/www/html/Game/public/js/play.js index d885237..e022751 100644 --- a/www/html/Game/public/js/play.js +++ b/www/html/Game/public/js/play.js @@ -4019,10 +4019,18 @@ let py = sumCy / ents.length; const minCamX = halfW; const maxCamX = Math.max(minCamX, mapWpx - halfW); - px = Math.max(minCamX, Math.min(maxCamX, px)); const minCamY = halfH; const maxCamY = Math.max(minCamY, mapHpx - halfH); - py = Math.max(minCamY, Math.min(maxCamY, py)); + const viewW = halfW * 2; + const viewH = halfH * 2; + /* + * ถ้ามุมมองกว้าง/สูงกว่าแมป: อย่าใช้ clamp แบบ minCamX (= กล้องชิดซ้ายโลก) — จะดูเหมือนแมปติดมุมซ้ายบน (เด่นใน embed / ซูมออก) + * ให้จัดกลางแมปแทน — ต่างจาก mng8a80o ที่กล้องตาม me อยู่แล้ว + */ + if (viewW >= mapWpx) px = mapWpx * 0.5; + else px = Math.max(minCamX, Math.min(maxCamX, px)); + if (viewH >= mapHpx) py = mapHpx * 0.5; + else py = Math.max(minCamY, Math.min(maxCamY, py)); return { px, py }; } @@ -13538,6 +13546,7 @@ const header = document.querySelector('.game-header'); const headerH = header && header.offsetHeight ? header.offsetHeight : 48; const stage = document.getElementById('play-canvas-stage'); + const stackEl = document.getElementById('play-canvas-stack'); const parent = stage || (canvas && canvas.parentElement); let cw = canvas.clientWidth || 0; let ch = canvas.clientHeight || 0; @@ -13550,8 +13559,20 @@ if (ow > 80) cw = Math.max(cw, ow); if (oh > 80) ch = Math.max(ch, oh); } + /* embed: stage อาจยัง 0 แต่ stack วัดได้แล้ว — อย่าให้ fallback เป็น vw/vh เต็มจอแล้ว CSS ย่อเข้า stage = ดูชิดมุม */ + if (previewMode && editorEmbedReturn && stackEl) { + const sw = Math.max(stackEl.clientWidth || 0, stackEl.offsetWidth || 0); + const sh = Math.max(stackEl.clientHeight || 0, stackEl.offsetHeight || 0); + if (sw > 80) cw = Math.max(cw, sw); + if (sh > 80) ch = Math.max(ch, sh); + } if (ch < 120) ch = Math.max(240, vh - headerH - 6); - if (cw < 120) cw = Math.max(320, vw); + if (cw < 120) { + if (previewMode && editorEmbedReturn && stackEl) { + const sw = Math.max(stackEl.clientWidth || 0, stackEl.offsetWidth || 0); + cw = sw > 80 ? Math.max(320, sw) : Math.max(320, vw); + } else cw = Math.max(320, vw); + } canvas.width = Math.max(320, cw); canvas.height = Math.max(240, ch); syncQuizCarryEmbedCountdownLayout(); diff --git a/www/html/Game/public/js/version.js b/www/html/Game/public/js/version.js index 866681f..ad5a230 100644 --- a/www/html/Game/public/js/version.js +++ b/www/html/Game/public/js/version.js @@ -1,6 +1,6 @@ // ทุกครั้งที่มีการเพิ่มหรือเปลี่ยน ให้เพิ่ม v +0.0001 // หลังแก้ค่าแล้วต้อง copy ไป path ที่ Nginx ชี้ (หรือรัน copy-frogger-files-only.sh) ถึงจะเห็นบนเว็บ -window.APP_VERSION = '0.0286'; +window.APP_VERSION = '0.0292'; document.addEventListener('DOMContentLoaded', function () { var t = document.querySelector('.version-tag'); if (t) t.textContent = 'v ' + window.APP_VERSION; diff --git a/www/html/Game/public/play.html b/www/html/Game/public/play.html index 987bef7..4d6a154 100644 --- a/www/html/Game/public/play.html +++ b/www/html/Game/public/play.html @@ -5,6 +5,17 @@