Improve texture

wall and food
This commit is contained in:
Mathieu 2020-03-25 18:17:27 +01:00
parent 580e31a796
commit 278d13cfa1
3 changed files with 8 additions and 2 deletions

BIN
assets/apple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
assets/wall.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -72,6 +72,12 @@ const stopGameBtn = byId("stopGameBtn")
const canvasTarget = byId("canvasTarget")
const scoreTarget = byId("scoreTarget")
// Get images
const imgWall = new Image();
imgWall.src = './assets/wall.jpg';
const imgApple = new Image();
imgApple.src = './assets/apple.png';
/**
* Show main screen
@ -257,12 +263,12 @@ async function startGame(gameID) {
case WALL:
ctx.fillStyle = "darkRed";
ctx.fillRect(x*cell_width, y*cell_height, cell_width, cell_height)
ctx.drawImage(imgWall, x*cell_width, y*cell_height, cell_width, cell_height);
break;
case FOOD:
ctx.fillStyle = "darkGreen";
ctx.fillRect(x*cell_width, y*cell_height, cell_width, cell_height)
ctx.drawImage(imgApple, x*cell_width, y*cell_height, cell_width, cell_height);
break;
case SNAKE: