From d16d3440bcfe0ae78538aff32f26f05a6e84e714 Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Sun, 3 Dec 2017 19:45:13 +0100 Subject: [PATCH] Box size param --- LemmingSim.html | 1 + lemming_sim_student.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) 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);