Game: stack tower — world camera follows height again (blocks move with scene)

Restore cy offset in getStackCameraCentersPx from stackTowerCameraFollow.
Remove duplicate BG-only offsets on strip S and mapBackgroundImg draw.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-03 05:01:36 +00:00
parent 01d801a8a5
commit 4a9755a4dc
3 changed files with 18 additions and 18 deletions
+5 -5
View File
@@ -264,13 +264,13 @@
<button type="button" id="btn-clear-bg">ลบรูปพื้นหลัง</button>
</div>
<div id="editor-stack-tower-cam-block" class="editor-bg-scroll-block" hidden>
<p class="legend" style="margin:0.5rem 0 0.35rem;line-height:1.45"><strong>พื้นหลังเลื่อนตามความสูงหอ</strong> (เฉพาะฉาก <code>mnn93hpi</code> + แถบ intro/loop ด้านบน) — บวก offset ในแถบ BG เมื่อสแต็กสูง · กล้องเกม/แพลตฟอร์ม<strong>ไม่</strong>เลื่อน · <em>English:</em> Extra scroll on BG strip only; world camera stays fixed; saved as <code>stackTowerCameraFollow</code>.</p>
<p class="legend" style="margin:0.5rem 0 0.35rem;line-height:1.45"><strong>กล้องตามความสูงหอ</strong> (เฉพาะฉาก <code>mnn93hpi</code>) — เลื่อนมุมมอง<strong>โลก</strong>ขึ้นเมื่อสแต็กสูง บล็อก+พื้นหลังแผนที่ไป<strong>ด้วยกัน</strong> · แถบ intro/loop ด้านล่างยังเลื่อนอัตโนมัติแยกต่างหาก · <em>English:</em> World camera pans up with stack height (blocks move with scene); saved as <code>stackTowerCameraFollow</code>.</p>
<div class="editor-card__row editor-card__row--wrap" style="align-items:center;gap:0.75rem 1rem">
<label class="editor-bg-scroll-check"><input type="checkbox" id="editor-stack-tower-cam-enabled" checked> เปิดตามชั้น / Follow stack (BG strip)</label>
<label title="พิกเซลในแถบ BG ต่อ 1 ชั้น (ไม่ใช่พิกเซลโลกเกม)">px ต่อชั้น (ในแถบ BG)
<label class="editor-bg-scroll-check"><input type="checkbox" id="editor-stack-tower-cam-enabled" checked> เปิดตามชั้น / Follow stack (camera)</label>
<label title="พิกเซลโลกต่อ 1 ชั้น">px ต่อชั้น
<input type="number" id="editor-stack-tower-cam-px-layer" min="0" max="80" step="1" value="12" style="width:4.2rem">
</label>
<label title="จำกัด offset สะสมสูงสุดในแถบ BG">สูงสุด (px ในแถบ BG)
<label title="จำกัดการเลื่อนกล้องสูงสุด (พิกเซลโลก)">เลื่อนสูงสุด (px)
<input type="number" id="editor-stack-tower-cam-max-px" min="0" max="800" step="4" value="260" style="width:4.5rem">
</label>
</div>
@@ -335,7 +335,7 @@
</div>
</div>
<script src="js/version.js?v=0.0169"></script>
<script src="js/editor.js?v=20260503-stack-bg-follow-only"></script>
<script src="js/editor.js?v=20260503-stack-camera-with-blocks"></script>
<div class="version-tag">v —</div>
</body>
</html>
+12 -12
View File
@@ -387,10 +387,7 @@
const drawHIntro = Math.round(intro.naturalHeight * scaleI);
const scaleL = cwR / loop.naturalWidth;
const drawHLoop = Math.max(1, Math.round(loop.naturalHeight * scaleL));
const worldBoost = getStackTowerBgScrollHeightBoostPx();
const mapHpxRef = (mapData && mapData.height ? mapData.height : 15) * (tileSize || 32);
const stripScale = Math.max(1.2, (drawHIntro + drawHLoop * 0.9) / Math.max(mapHpxRef * 0.32, 140));
const S = stackTowerScrollBgPx + worldBoost * stripScale;
const S = stackTowerScrollBgPx;
const vp0 = S;
const vp1 = S + chR;
const yLimit = vp1 + drawHLoop * 2;
@@ -6556,7 +6553,7 @@
return { enabled: raw.enabled !== false, pxPerLayer, maxPx };
}
/** เลื่อนเฉพาะแถบ BG (stackTowerScrollBg) — ไม่เลื่อนกล้องโลก */
/** world px ตามความสูงหอ (mnn93hpi) — ใช้เลื่อนกล้องให้บล็อก/ฉากไปกับมุมมอง */
function getStackTowerBgScrollHeightBoostPx() {
if (!isStackTowerMissionUiMapPlay() || !stackMini) return 0;
const cfg = getStackTowerCameraFollowPlayConfig();
@@ -6574,6 +6571,7 @@
function getStackCameraCentersPx() {
const w = mapData.width || 20, h = mapData.height || 15;
const ts = tileSize;
const mapHpx = h * ts;
const land = getStackAreaBoundsPlay(mapData.stackLandArea, w, h);
const rel = getStackAreaBoundsPlay(mapData.stackReleaseArea, w, h);
let cx = (w / 2) * ts;
@@ -6588,6 +6586,12 @@
cx = rel.cx * ts;
cy = rel.cy * ts;
}
if (isStackTowerMissionUiMapPlay() && stackMini) {
const shift = getStackTowerBgScrollHeightBoostPx();
if (shift > 0) {
cy = Math.max(ts * 1.5, Math.min(mapHpx - ts * 2, cy - shift));
}
}
return { px: cx, py: cy };
}
@@ -12919,21 +12923,17 @@
ctx.fillRect(0, 0, canvas.width, canvas.height);
const natW = mapBackgroundImg.naturalWidth;
const natH = mapBackgroundImg.naturalHeight;
const towerBgBoost = (isStackTowerMissionUiMapPlay() && stackMini) ? getStackTowerBgScrollHeightBoostPx() : 0;
const bgCamY = camY - towerBgBoost;
const worldMinYBg = bgCamY - halfH;
const worldMaxYBg = bgCamY + halfH;
const bgMinX = Math.max(0, worldMinX);
const bgMaxX = Math.min(mapWpx, worldMaxX);
const bgMinY = Math.max(0, worldMinYBg);
const bgMaxY = Math.min(mapHpx, worldMaxYBg);
const bgMinY = Math.max(0, worldMinY);
const bgMaxY = Math.min(mapHpx, worldMaxY);
if (bgMaxX > bgMinX && bgMaxY > bgMinY) {
const srcX = (bgMinX / mapWpx) * natW;
const srcY = (bgMinY / mapHpx) * natH;
const srcW = ((bgMaxX - bgMinX) / mapWpx) * natW;
const srcH = ((bgMaxY - bgMinY) / mapHpx) * natH;
const destX = (bgMinX - camX) * zDraw + canvas.width / 2;
const destY = (bgMinY - bgCamY) * zDraw + canvas.height / 2;
const destY = (bgMinY - camY) * zDraw + canvas.height / 2;
const destW = (bgMaxX - bgMinX) * zDraw;
const destH = (bgMaxY - bgMinY) * zDraw;
if (srcW > 0.25 && srcH > 0.25 && destW > 0.25 && destH > 0.25) {
+1 -1
View File
@@ -2009,7 +2009,7 @@
</div>
<script src="/Game/socket.io/socket.io.js"></script>
<script src="js/version.js?v=0.0184"></script>
<script src="js/play.js?v=0.269"></script>
<script src="js/play.js?v=0.270"></script>
<div class="version-tag">v —</div>
</body>
</html>