Add stack blocks scene with column spawning

This commit is contained in:
Daddy32
2025-12-14 21:05:33 +01:00
parent e500380a7e
commit 9bed2f6125

View File

@@ -0,0 +1,71 @@
(() => {
const { Bodies } = Matter;
const scenes = (window.PhysilinksSceneDefs =
window.PhysilinksSceneDefs || []);
scenes.push({
id: "stack-blocks",
name: "Stack Blocks",
config: {
gravity: 1.05,
spawnIntervalMs: 900,
autoSpawn: true,
minChain: 3,
palette: ["#38bdf8", "#f97316", "#facc15", "#22c55e"],
ballRadius: 18,
ballShape: "rect",
spawnColumns: 10,
initialRows: 3,
winCondition: {
type: "clearCount",
target: 100,
},
link: {
stiffness: 0.85,
lengthScale: 1.05,
damping: 0.08,
lineWidth: 3,
rope: true,
renderType: "line",
maxLengthMultiplier: 3.1,
},
},
createBodies: (w, h) => {
const wallThickness = Math.max(20, w * 0.02);
const floorHeight = Math.max(30, h * 0.06);
return [
Bodies.rectangle(
-wallThickness / 2,
h / 2,
wallThickness,
h * 2,
{
isStatic: true,
render: { fillStyle: "#0b1222", strokeStyle: "#0b1222" },
},
),
Bodies.rectangle(
w + wallThickness / 2,
h / 2,
wallThickness,
h * 2,
{
isStatic: true,
render: { fillStyle: "#0b1222", strokeStyle: "#0b1222" },
},
),
Bodies.rectangle(
w / 2,
h + floorHeight / 2,
w + wallThickness * 2,
floorHeight,
{
isStatic: true,
restitution: 0.2,
render: { fillStyle: "#0b1222", strokeStyle: "#0b1222" },
},
),
];
},
});
})();