Fix gravity reset and add spawn cap for swirl arena

This commit is contained in:
Daddy32
2025-12-13 23:21:27 +01:00
parent 91ed6c6202
commit ea2446e36b
5 changed files with 186 additions and 13 deletions

View File

@@ -0,0 +1,88 @@
(() => {
const { Bodies } = Matter;
const scenes = (window.PhysilinksSceneDefs =
window.PhysilinksSceneDefs || []);
scenes.push({
id: "swirl-arena",
name: "Swirl Arena",
config: {
gravity: 0,
gravityScale: 0.0007,
timeScale: 0.9,
spawnIntervalMs: 520,
initialSpawnCount: 90,
spawnLimit: 500,
autoSpawn: true,
minChain: 3,
palette: ["#f472b6", "#22c55e"],
ballRadius: 20,
spawnOrigin: "center",
spawnJitter: 120,
blobBalls: false,
noGameOver: true,
winCondition: {
type: "colorClear",
targets: [{ color: "#22c55e", count: 100 }],
},
negativeScoreColors: ["#f472b6"],
negativeProgressColors: ["#f472b6"],
link: {
stiffness: 0.82,
lengthScale: 1.08,
damping: 0.06,
lineWidth: 3,
rope: true,
renderType: "line",
maxLengthMultiplier: 3.6,
},
onBeforeUpdate: ({ engine }) => {
const t = (engine.timing?.timestamp || 0) * 0.0005;
engine.gravity.x = Math.cos(t);
engine.gravity.y = Math.sin(t);
},
},
createBodies: (w, h) => {
const wallThickness = Math.max(36, Math.min(w, h) * 0.05);
const innerW = w - wallThickness * 2;
const innerH = h - wallThickness * 2;
const cx = w / 2;
const cy = h / 2;
const wallOptions = {
isStatic: true,
restitution: 0.3,
render: { fillStyle: "#0b1222", strokeStyle: "#0b1222" },
};
return [
Bodies.rectangle(
cx,
cy - innerH / 2 - wallThickness / 2,
innerW + wallThickness * 2,
wallThickness,
wallOptions,
),
Bodies.rectangle(
cx,
cy + innerH / 2 + wallThickness / 2,
innerW + wallThickness * 2,
wallThickness,
wallOptions,
),
Bodies.rectangle(
cx - innerW / 2 - wallThickness / 2,
cy,
wallThickness,
innerH + wallThickness * 2,
wallOptions,
),
Bodies.rectangle(
cx + innerW / 2 + wallThickness / 2,
cy,
wallThickness,
innerH + wallThickness * 2,
wallOptions,
),
];
},
});
})();