Fixed grid to correctly loop

This commit is contained in:
2025-10-27 22:18:48 -04:00
parent 052429a724
commit 6a7f071c17

View File

@ -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