Improve texture
wall and food
This commit is contained in:
parent
580e31a796
commit
278d13cfa1
BIN
assets/apple.png
Normal file
BIN
assets/apple.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
BIN
assets/wall.jpg
Normal file
BIN
assets/wall.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
10
script.js
10
script.js
@ -72,6 +72,12 @@ const stopGameBtn = byId("stopGameBtn")
|
|||||||
const canvasTarget = byId("canvasTarget")
|
const canvasTarget = byId("canvasTarget")
|
||||||
const scoreTarget = byId("scoreTarget")
|
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
|
* Show main screen
|
||||||
@ -257,12 +263,12 @@ async function startGame(gameID) {
|
|||||||
|
|
||||||
case WALL:
|
case WALL:
|
||||||
ctx.fillStyle = "darkRed";
|
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;
|
break;
|
||||||
|
|
||||||
case FOOD:
|
case FOOD:
|
||||||
ctx.fillStyle = "darkGreen";
|
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;
|
break;
|
||||||
|
|
||||||
case SNAKE:
|
case SNAKE:
|
||||||
|
Loading…
Reference in New Issue
Block a user