Very cool. You might want to update placeFood with a validation loop to check if the food coincides with any part of the snake function placeFood() { let isOnSnake = true; while (isOnSnake) { food.x = Math.floor(Math.random() * (boardSize / 20)) * 20; food.y = Math.floor(Math.random() * (boardSize / 20)) * 20; // Check if the food position overlaps with any part of the snake isOnSnake = snake.some(segment => segment.x === food.x && segment.y === food.y); } }
@CST-TipsАй бұрын
Thanks for the suggestion! I'll definitely consider adding that feature in a future update.