Game: stack tower BG follow — scale strip offset + parallax mapBackgroundImg

World px/layer was too weak on intro/loop strip; scale boost into strip space.
When using editor map background image, shift BG sample window with effCamY only.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-03 04:58:34 +00:00
parent f9b51fc7ce
commit 01d801a8a5
2 changed files with 12 additions and 5 deletions
+11 -4
View File
@@ -387,7 +387,10 @@
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 + getStackTowerBgScrollHeightBoostPx();
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 vp0 = S;
const vp1 = S + chR;
const yLimit = vp1 + drawHLoop * 2;
@@ -12916,17 +12919,21 @@
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, worldMinY);
const bgMaxY = Math.min(mapHpx, worldMaxY);
const bgMinY = Math.max(0, worldMinYBg);
const bgMaxY = Math.min(mapHpx, worldMaxYBg);
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 - camY) * zDraw + canvas.height / 2;
const destY = (bgMinY - bgCamY) * 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.268"></script>
<script src="js/play.js?v=0.269"></script>
<div class="version-tag">v —</div>
</body>
</html>