diff --git a/src/spawn.js b/src/spawn.js index 3a2076d..f922c1d 100644 --- a/src/spawn.js +++ b/src/spawn.js @@ -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 = () => {