Files
Physilinks/scenes/scene-balanced.js
2025-12-13 14:03:52 +01:00

92 lines
2.3 KiB
JavaScript

(() => {
const { Bodies } = Matter;
const scenes =
(window.PhysilinksSceneDefs = window.PhysilinksSceneDefs || []);
scenes.push({
id: "scene1",
name: "Balanced",
config: {
gravity: 0.88,
spawnIntervalMs: 520,
minChain: 3,
palette: ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"],
ballRadius: 38,
link: {
stiffness: 0.85,
lengthScale: 1.05,
damping: 0.08,
lineWidth: 3,
rope: true,
renderType: "line",
maxLengthMultiplier: 3.2,
},
},
createBodies: (w, h) => {
const floorHeight = Math.max(60, h * 0.12);
const wallThickness = Math.max(32, w * 0.05);
const wallHeight = h * 1.6;
const platformHeight = Math.max(14, h * 0.025);
const smallPlatformWidth = Math.max(140, w * 0.18);
const largePlatformWidth = Math.max(180, w * 0.22);
return [
Bodies.rectangle(
w / 2,
h + floorHeight / 2,
w + wallThickness * 2,
floorHeight,
{
isStatic: true,
restitution: 0.8,
render: { fillStyle: "#0ea5e9", strokeStyle: "#0ea5e9" },
},
),
Bodies.rectangle(
-wallThickness / 2,
h / 2,
wallThickness,
wallHeight,
{
isStatic: true,
render: { fillStyle: "#f97316", strokeStyle: "#f97316" },
},
),
Bodies.rectangle(
w + wallThickness / 2,
h / 2,
wallThickness,
wallHeight,
{
isStatic: true,
render: { fillStyle: "#f97316", strokeStyle: "#f97316" },
},
),
Bodies.rectangle(
w * 0.25,
h * 0.55,
smallPlatformWidth,
platformHeight,
{
isStatic: true,
angle: -0.3,
render: { fillStyle: "#22c55e", strokeStyle: "#22c55e" },
plugin: { rotSpeed: 0.1 },
},
),
Bodies.rectangle(
w * 0.7,
h * 0.4,
largePlatformWidth,
platformHeight * 1.2,
{
isStatic: true,
angle: 0.26,
render: { fillStyle: "#a855f7", strokeStyle: "#a855f7" },
plugin: { rotSpeed: -0.08 },
},
),
];
},
});
})();