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;