From d340d1c2974d678ad9609791fafa6cea42e942a1 Mon Sep 17 00:00:00 2001 From: Gulum Date: Tue, 1 Aug 2023 21:28:30 +0200 Subject: [PATCH] minor control fixes --- script.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index 48a4d6b..074e25d 100644 --- a/script.js +++ b/script.js @@ -180,12 +180,12 @@ window.addEventListener("load", () => { drawGrid(sparseWorld); }); - //window.addEventListener("click", (event) => { - // const x = Math.round(event.clientX / spacing); - // const y = Math.round(event.clientY / spacing); - // saveSetArray(y,x, 1); - // console.log(`Koordinaten: (${x}, ${y})`); - //}); + window.addEventListener("click", (event) => { + const x = Math.round(event.clientX / spacing); + const y = Math.round(event.clientY / spacing); + saveSetArray(sparseWorld, y,x, 1); + console.log(`Koordinaten: (${x}, ${y})`); + }); canvas.addEventListener("mousedown", (event) => { isDragging = true; @@ -216,6 +216,10 @@ window.addEventListener("load", () => { isDragging = false; }); + canvas.addEventListener("mouseout", () => { + isDragging = false; + }); + // Grid beim Laden der Seite zeichnen drawGrid(sparseWorld); });