From 1f59aa354df6c8e9573d906ef075141e45ddb0f8 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 30 Mar 2021 09:42:18 +0200 Subject: [PATCH] Add life sprite --- README.md | 2 ++ sources/js/Tile.js | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 24722c6..ee03b4d 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,5 @@ - [x] Power up to decrease the snake size - [x] Pause game when press escape + +- [x] Sprites diff --git a/sources/js/Tile.js b/sources/js/Tile.js index 96cd92e..33bdb61 100644 --- a/sources/js/Tile.js +++ b/sources/js/Tile.js @@ -222,8 +222,36 @@ export class Tile { } break; case tiles.ORANGE: - this.game.ctx.fillStyle = "#ff7500"; - this.game.ctx.fillRect(...canvasPos, ...size); + if (!pxsize) { + this.game.ctx.fillStyle = "#ff7500"; + this.game.ctx.fillRect(...canvasPos, ...size); + } else { + this.game.ctx.fillStyle = "#04c444"; + + this.game.ctx.fillRect(width+3*pxsize, height+2*pxsize, 6*pxsize, 2*pxsize); + + this.game.ctx.fillStyle = "#ffae00"; + + this.game.ctx.fillRect(width+2*pxsize, height+4*pxsize, 8*pxsize, 6*pxsize); + + this.game.ctx.fillStyle = "#000000"; + + this.game.ctx.fillRect(width+pxsize, height+5*pxsize, pxsize, 4*pxsize); + this.game.ctx.fillRect(width+10*pxsize, height+5*pxsize, pxsize, 4*pxsize); + this.game.ctx.fillRect(width+2*pxsize, height+9*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+9*pxsize, height+9*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+3*pxsize, height+10*pxsize, 6*pxsize, pxsize); + this.game.ctx.fillRect(width+2*pxsize, height+4*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+9*pxsize, height+4*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+4*pxsize, height+4*pxsize, 4*pxsize, pxsize); + this.game.ctx.fillRect(width+3*pxsize, height+3*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+7*pxsize, height+3*pxsize, 2*pxsize, pxsize); + this.game.ctx.fillRect(width+2*pxsize, height+2*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+5*pxsize, height+2*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+9*pxsize, height+2*pxsize, pxsize, pxsize); + this.game.ctx.fillRect(width+3*pxsize, height+pxsize, 2*pxsize, pxsize); + this.game.ctx.fillRect(width+6*pxsize, height+pxsize, 3*pxsize, pxsize); + } break; }