Fixed grid to correctly loop
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user