MCPcopy Create free account
hub / github.com/melonjs/melonJS / computeParallaxPos

Function computeParallaxPos

packages/melonjs/tests/tmxutils.spec.js:607–618  ·  view source on GitHub ↗
(
			offset,
			ratio,
			camPos,
			anchorPoint,
			boundsW,
			viewportW,
		)

Source from the content-addressed store, hash-verified

605 describe("parallax origin offset baking", () => {
606 // Helper: compute parallax position the way ImageLayer.draw does
607 function computeParallaxPos(
608 offset,
609 ratio,
610 camPos,
611 anchorPoint,
612 boundsW,
613 viewportW,
614 ) {
615 const ax = anchorPoint;
616 const rx = ratio;
617 return ax * (rx - 1) * (boundsW - viewportW) + offset - rx * camPos;
618 }
619
620 it("baked offset matches explicit parallax origin (ax=0, ratio=0.5)", () => {
621 const layerOffset = 100;

Callers 1

tmxutils.spec.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected