From b7d12114d33d5ed0f6e97db8c62402211de1e8be Mon Sep 17 00:00:00 2001 From: Kacper Kostka Date: Sat, 5 Apr 2025 16:28:42 +0200 Subject: [PATCH] Revert "fix: Resolve canvas reference and duplicate currentTool declaration" This reverts commit a948fab6194aa2f7bfd1039cba4d44191d1844fe. --- js/input.js | 8 -------- js/main.js | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/js/input.js b/js/input.js index a4e53e8..548b529 100644 --- a/js/input.js +++ b/js/input.js @@ -38,7 +38,6 @@ function setTool(tool) { } function handleMouseDown(e) { - const canvas = document.getElementById('simulation-canvas'); const rect = canvas.getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; @@ -58,7 +57,6 @@ function handleMouseDown(e) { } function handleMouseMove(e) { - const canvas = document.getElementById('simulation-canvas'); const rect = canvas.getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; @@ -156,8 +154,6 @@ function draw(x, y) { function handleTouchStart(e) { e.preventDefault(); - const canvas = document.getElementById('simulation-canvas'); - // Check if we have multiple touch points (for dragging) if (e.touches.length > 1) { isDragging = true; @@ -180,7 +176,6 @@ function handleTouchStart(e) { function handleTouchMove(e) { e.preventDefault(); - const canvas = document.getElementById('simulation-canvas'); const rect = canvas.getBoundingClientRect(); if (isDragging && e.touches.length > 1) { @@ -208,9 +203,6 @@ function handleTouchMove(e) { // Set up event listeners window.addEventListener('load', function() { - // Get canvas reference after it's defined - const canvas = document.getElementById('simulation-canvas'); - canvas.addEventListener('mousedown', handleMouseDown); canvas.addEventListener('mousemove', handleMouseMove); window.addEventListener('mouseup', handleMouseUp); diff --git a/js/main.js b/js/main.js index dcd2ed2..3590d2a 100644 --- a/js/main.js +++ b/js/main.js @@ -1,6 +1,6 @@ // Main game variables and initialization let canvas, ctx; -// currentTool is already defined in input.js +let currentTool = SAND; let lastFrameTime = 0; let fps = 0; let debugMode = false;