Grid around the snake head fixed
This commit is contained in:
parent
655008ee68
commit
86b992bbc1
@ -295,9 +295,11 @@ async function startGame(gameID) {
|
|||||||
const headPos = snake[snake.length-1];
|
const headPos = snake[snake.length-1];
|
||||||
|
|
||||||
if(headPos[0] == y && headPos[1] == x) {
|
if(headPos[0] == y && headPos[1] == x) {
|
||||||
ctx.clearRect(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);
|
||||||
ctx.drawImage(imgGrass, x*cell_width, y*cell_height, cell_width, cell_height);
|
// 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")
|
if(key == "ArrowDown")
|
||||||
ctx.drawImage(imgSnakeHeadDown, x*cell_width, y*cell_height, cell_width, cell_height);
|
ctx.drawImage(imgSnakeHeadDown, x*cell_width, y*cell_height, cell_width, cell_height);
|
||||||
if(key == "ArrowUp" || !key)
|
if(key == "ArrowUp" || !key)
|
||||||
|
Loading…
Reference in New Issue
Block a user