Refactor ball shape dispatch

This commit is contained in:
Daddy32
2025-12-29 21:16:08 +01:00
parent 653710c8a8
commit a663aa3fbc

View File

@@ -265,6 +265,12 @@
return { bodies: [body], constraints: [], blobId: null };
};
const ballShapeFactories = {
gift: createGiftBall,
rect: createRectBall,
circle: createCircleBall,
};
const createBallBodies = (x, y, color) => {
const scene = getCurrentScene();
const ballPhysics = scene?.config?.ballPhysics || {};
@@ -287,13 +293,9 @@
if (scene?.config?.blobBalls === "jagged") {
return createJaggedBall(x, y, color, commonOpts);
}
if (scene?.config?.ballShape === "gift") {
return createGiftBall(x, y, color, commonOpts, scene, debugSpawn);
}
if (scene?.config?.ballShape === "rect") {
return createRectBall(x, y, color, commonOpts);
}
return createCircleBall(x, y, color, commonOpts);
const shape = scene?.config?.ballShape || "circle";
const factory = ballShapeFactories[shape] || createCircleBall;
return factory(x, y, color, commonOpts, scene, debugSpawn);
};
const spawnBall = () => {