diff --git a/script.js b/script.js index 7598de2..2accbff 100644 --- a/script.js +++ b/script.js @@ -295,9 +295,11 @@ async function startGame(gameID) { const headPos = snake[snake.length-1]; if(headPos[0] == y && headPos[1] == x) { - ctx.clearRect(x*cell_width, y*cell_height, cell_width, cell_height); - ctx.drawImage(imgGrass, x*cell_width, y*cell_height, cell_width, cell_height); + ctx.clearRect(x*cell_width+1, y*cell_height+1, cell_width-2, cell_height-2); + // Restore the background + ctx.drawImage(imgGrass, x*cell_width+1, y*cell_height+1, cell_width-2, cell_height-2); + // Head Orientation if(key == "ArrowDown") ctx.drawImage(imgSnakeHeadDown, x*cell_width, y*cell_height, cell_width, cell_height); if(key == "ArrowUp" || !key)