From cf64b6db48a3d6900dccd7cae0a4451502045e63 Mon Sep 17 00:00:00 2001 From: "Kacper Kostka (aider)" Date: Sat, 5 Apr 2025 17:16:45 +0200 Subject: [PATCH] fix: Remove duplicate constants and add null check for updatePhysicsObjects --- js/elements/physics_objects.js | 4 +--- js/main.js | 5 +++++ js/physics.js | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/elements/physics_objects.js b/js/elements/physics_objects.js index 8c64522..cd2c8e9 100644 --- a/js/elements/physics_objects.js +++ b/js/elements/physics_objects.js @@ -1,7 +1,5 @@ // Physics objects (square, circle, triangle) -const SQUARE = 16; -const CIRCLE = 17; -const TRIANGLE = 18; +// Constants are already defined in constants.js // Physics object properties const PHYSICS_OBJECT_COLORS = ['#FF5733', '#33FF57', '#3357FF', '#F3FF33', '#FF33F3']; diff --git a/js/main.js b/js/main.js index f2ffe82..dbef5cd 100644 --- a/js/main.js +++ b/js/main.js @@ -64,6 +64,11 @@ window.onload = function() { // Start the simulation loop requestAnimationFrame(simulationLoop); + + // Initialize physics variables + window.physicsUpdateRate = 16; // ms between physics updates + window.lastPhysicsTime = 0; + window.fireUpdateCounter = 0; }; function resizeCanvas() { diff --git a/js/physics.js b/js/physics.js index 4420747..75a0ed4 100644 --- a/js/physics.js +++ b/js/physics.js @@ -8,7 +8,9 @@ function updatePhysics(timestamp) { lastPhysicsTime = timestamp || 0; // Update physics objects - updatePhysicsObjects(); + if (typeof updatePhysicsObjects === 'function') { + updatePhysicsObjects(); + } // Get visible chunks const visibleChunks = getVisibleChunks();