You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because svelte can react to assignments within an object as well as to an object itself, perhaps it's best to replace this monstrosity with an object:
// Letting the state variables go uninitialized is safe,
// because they are initialized by resetGame before they are ever read
let apple;
let gameState;
let headDirection;
let headDirectionQueue;
let score;
let snake;
let willGrow;
function resetGame() {
const initialSnake = [
{ x: 4, y: 4 },
{ x: 4, y: 3 },
{ x: 4, y: 2 },
];
apple = drawRandomOpenSpace(BOARD_DIMENSIONS, initialSnake);
gameState = GAME_STATES.START_SCREEN;
headDirection = DIRECTION.SOUTH;
headDirectionQueue = [];
score = 0;
snake = initialSnake;
willGrow = false;
}
The text was updated successfully, but these errors were encountered:
Because svelte can react to assignments within an object as well as to an object itself, perhaps it's best to replace this monstrosity with an object:
The text was updated successfully, but these errors were encountered: