From 6a7f071c1787251246fddf31089d0afd8e20f96c Mon Sep 17 00:00:00 2001 From: Moonlit Productions Date: Mon, 27 Oct 2025 22:18:48 -0400 Subject: [PATCH] Fixed grid to correctly loop --- script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index ed35737..35be137 100644 --- a/script.js +++ b/script.js @@ -308,8 +308,10 @@ function animate() { // Animate the grid with robot movement let offsetSpeedDivisor = (100 - gridSquareSize <= 0 ? 1 : 100 - gridSquareSize); console.log(offsetSpeedDivisor); - xGridOffset = (xGridOffset + (xSpeed / offsetSpeedDivisor) % gridSquareSize); - yGridOffset = (yGridOffset + (ySpeed / offsetSpeedDivisor) % gridSquareSize); + + // Accumulate grid offset and wrap it to create infinite grid effect + xGridOffset = (xGridOffset + (xSpeed / offsetSpeedDivisor)) % gridSquareSize; + yGridOffset = (yGridOffset + (ySpeed / offsetSpeedDivisor)) % gridSquareSize; // Accumulate robot rotation based on turn speed (convert to radians) robotRotation += turnSpeed * 0.01; // Scale factor for reasonable rotation speed