diff --git a/LemmingSim.html b/LemmingSim.html index a297aed..578c4e8 100644 --- a/LemmingSim.html +++ b/LemmingSim.html @@ -53,6 +53,7 @@ along with this program. If not, see . +x diff --git a/lemming_sim_student.js b/lemming_sim_student.js index fe2d0ab..6fb6a52 100644 --- a/lemming_sim_student.js +++ b/lemming_sim_student.js @@ -170,10 +170,11 @@ class Simulation { color }); } + const [nBoxX, nBoxY] = ["boxX", "boxY"].map(x => +document.getElementById(x).value) - const startX = 100, startY = 100, - nBoxX = 5, nBoxY = 5, - gapX = 40, gapY = 30, + const gapX = 40, gapY = 30 + const startX = (width - (simInfo.boxSize * nBoxX + (nBoxX-1) * gapX)) / 2, + startY = (height - (simInfo.boxSize * nBoxY + (nBoxY-1) * gapY)) / 2, stack = Matter.Composites.stack(startX, startY, nBoxX, nBoxY, gapX, gapY, getBox);