fix(stack-tower): pan intro/loop strip BG with camera follow (zDraw)

Thai: แถบ BG intro+loop วาดเต็มจอเดิมไม่เลื่อนตามกล้อง — เลื่อนเพิ่มตาม boost*zoom ให้สอดคล้องบล็อก
English: Full-canvas scroll strip now offsets by stack camera follow in screen px.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-03 05:24:06 +00:00
parent adf0c72256
commit 6070a61432
2 changed files with 8 additions and 5 deletions
+7 -4
View File
@@ -382,17 +382,20 @@
}
}
function drawStackTowerScrollBgFullCanvas(cw, ch) {
/** zDrawPan = zoom ตอนวาด stack — ผูกเลื่อนแถบ BG กับกล้องโลก (px จอ = boostWorld * z) */
function drawStackTowerScrollBgFullCanvas(cw, ch, zDrawPan) {
const intro = stackTowerScrollBgIntroImg;
const loop = stackTowerScrollBgLoopImg;
if (!intro || !intro.complete || !loop || !loop.complete) return;
const zPan = Number(zDrawPan) > 0 ? zDrawPan : zoom;
const cwR = Math.max(1, Math.round(cw));
const chR = Math.max(1, Math.round(ch));
const scaleI = cwR / intro.naturalWidth;
const drawHIntro = Math.round(intro.naturalHeight * scaleI);
const scaleL = cwR / loop.naturalWidth;
const drawHLoop = Math.max(1, Math.round(loop.naturalHeight * scaleL));
const S = stackTowerScrollBgPx;
const camFollowScreen = isStackTowerMissionUiMapPlay() ? getStackTowerBgScrollHeightBoostPx() * zPan : 0;
const S = stackTowerScrollBgPx + camFollowScreen;
const vp0 = S;
const vp1 = S + chR;
const yLimit = vp1 + drawHLoop * 2;
@@ -453,7 +456,7 @@
const scaleL = cwR / loop.naturalWidth;
const drawHLoop = Math.max(1, Math.round(loop.naturalHeight * scaleL));
const skyScreenH = Math.min(chR, Math.ceil(-worldMinY * zDraw) + 4);
const scroll = (stackTowerScrollBgPx + getStackTowerBgScrollHeightBoostPx()) % drawHLoop;
const scroll = (stackTowerScrollBgPx + getStackTowerBgScrollHeightBoostPx() * zDraw) % drawHLoop;
let y = -scroll;
ctx.save();
ctx.imageSmoothingEnabled = false;
@@ -12965,7 +12968,7 @@
} else if (stackTowerScrollBgDrawActive()) {
ctx.fillStyle = '#0a0e22';
ctx.fillRect(0, 0, canvas.width, canvas.height);
drawStackTowerScrollBgFullCanvas(canvas.width, canvas.height);
drawStackTowerScrollBgFullCanvas(canvas.width, canvas.height, zDraw);
} else if (mapBackgroundImg && mapBackgroundImg.complete && mapBackgroundImg.naturalWidth) {
/* กล้องเห็นพื้นที่นอก [0,map] ได้ — ห้ามสุ่มต้นทาง drawImage เกินขอบภาพ (จะเกิดซ้ำ/เส้นตัด/ซ้อนกันที่ขอบจอ) */
ctx.fillStyle = (isSpaceShooter() || isBalloonBoss()) ? '#0a0e22' : '#1a1b26';
+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.272"></script>
<script src="js/play.js?v=0.273"></script>
<div class="version-tag">v —</div>
</body>
</html>