Add stack blocks scene with column spawning
This commit is contained in:
71
src/scenes/scene-stack-blocks.js
Normal file
71
src/scenes/scene-stack-blocks.js
Normal 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" },
|
||||||
|
},
|
||||||
|
),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
});
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user