diff --git a/sources/js/Tile.js b/sources/js/Tile.js index 714b936..55b28ba 100644 --- a/sources/js/Tile.js +++ b/sources/js/Tile.js @@ -48,8 +48,53 @@ export class Tile { this.game.ctx.rect(...canvasPos, ...size); break; case tiles.APPLE: - this.game.ctx.fillStyle = "#ff0000"; - this.game.ctx.fillRect(...canvasPos, ...size); + let pxsize = Math.round(size[0]/12); + if (!pxsize) { + this.game.ctx.fillStyle = "#ff0000"; + this.game.ctx.fillRect(...canvasPos, ...size); + } else { + let width = canvasPos[0]; + let height = canvasPos[1]; + + this.game.ctx.fillStyle = "#00ffff"; + this.game.ctx.fillRect(width+pxsize, height+pxsize, 10*pxsize, 10*pxsize); + + this.game.ctx.fillStyle = "#000000"; + + this.game.ctx.fillRect(width+4*pxsize, height, pxsize*4, pxsize); + this.game.ctx.fillRect(width+4*pxsize, height+11*pxsize, pxsize*4, pxsize); + + for (const i of [2,5,8]) + this.game.ctx.fillRect(width+i*pxsize, height+pxsize, pxsize*2, pxsize); + + for (const i of [1,4,7,10]) + this.game.ctx.fillRect(width+i*pxsize, height+2*pxsize, pxsize, pxsize*2); + + this.game.ctx.fillRect(width, height+4*pxsize, pxsize, pxsize*4); + this.game.ctx.fillRect(width+11*pxsize, height+4*pxsize, pxsize, pxsize*4); + + for (const i of [1,5,6,10]) + this.game.ctx.fillRect(width+i*pxsize, height+8*pxsize, pxsize, pxsize*2); + + for (const i of [2,5,8]) + this.game.ctx.fillRect(width+i*pxsize, height+10*pxsize, pxsize*2, pxsize); + + for (const i of [3,8,2,9]) + this.game.ctx.fillRect(width+i*pxsize, height+4*pxsize, pxsize, pxsize); + + for (const i of [1,3,8,10]) + this.game.ctx.fillRect(width+i*pxsize, height+6*pxsize, pxsize, pxsize); + + for (const i of [4,7]) + this.game.ctx.fillRect(width+i*pxsize, height+7*pxsize, pxsize, pxsize); + + this.game.ctx.globalCompositeOperation = "destination-out"; + this.game.ctx.fillRect(width+1*pxsize, height+1*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+10*pxsize, height+1*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+1*pxsize, height+10*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+10*pxsize, height+10*pxsize, pxsize, pxsize); + this.game.ctx.globalCompositeOperation = "source-over"; + } break; case tiles.SNAKE: this.game.ctx.fillStyle = "#00ff5f";