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

Function simulate

packages/melonjs/tests/camera.spec.js:1661–1676  ·  view source on GitHub ↗
(actualHz)

Source from the content-addressed store, hash-verified

1659 timer.maxfps = 60;
1660 try {
1661 const simulate = (actualHz) => {
1662 const { camera } = setup();
1663 const target = new Vector2d(100, 100);
1664 camera.setBounds(0, 0, 5000, 5000);
1665 camera.setDeadzone(0, 0);
1666 camera.deadzone.pos.set(0, 0);
1667 camera.pos.set(0, 0, 0);
1668 camera.follow(target, camera.AXIS.BOTH, 0.1);
1669 camera.pos.set(0, 0, 0);
1670 const frames = actualHz;
1671 const dt = 1000 / actualHz;
1672 for (let i = 0; i < frames; i++) {
1673 camera.updateTarget(dt);
1674 }
1675 return camera.pos.x;
1676 };
1677
1678 const slow = simulate(30);
1679 const matched = simulate(60);

Callers 1

camera.spec.jsFile · 0.85

Calls 6

setBoundsMethod · 0.80
setDeadzoneMethod · 0.80
followMethod · 0.80
setupFunction · 0.70
setMethod · 0.45
updateTargetMethod · 0.45

Tested by

no test coverage detected