Fixed grid to correctly loop
This commit is contained in:
@ -308,8 +308,10 @@ function animate() {
|
|||||||
// Animate the grid with robot movement
|
// Animate the grid with robot movement
|
||||||
let offsetSpeedDivisor = (100 - gridSquareSize <= 0 ? 1 : 100 - gridSquareSize);
|
let offsetSpeedDivisor = (100 - gridSquareSize <= 0 ? 1 : 100 - gridSquareSize);
|
||||||
console.log(offsetSpeedDivisor);
|
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)
|
// Accumulate robot rotation based on turn speed (convert to radians)
|
||||||
robotRotation += turnSpeed * 0.01; // Scale factor for reasonable rotation speed
|
robotRotation += turnSpeed * 0.01; // Scale factor for reasonable rotation speed
|
||||||
|
|||||||
Reference in New Issue
Block a user