From 707075503a39ffeb6bbbc8334d740a9652e66ee3 Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Sun, 23 Feb 2025 20:19:00 +0100 Subject: [PATCH] ca me coute des token --- projects/snake.html | 458 ++++++++++++++++++++++++-------------------- 1 file changed, 247 insertions(+), 211 deletions(-) diff --git a/projects/snake.html b/projects/snake.html index dd9b6ea..18c1688 100644 --- a/projects/snake.html +++ b/projects/snake.html @@ -1,231 +1,267 @@ - -

+ + snake + + + + + + +

- - - + for (let x = 0; x <= this.canvasHeight; x += this.boxSize) { + this.context.moveTo(this.p, 0 + x + this.p); + this.context.lineTo( + this.canvasWidth + this.p, + 0 + x + this.p, + ); + } + this.context.strokeStyle = "#44475a"; + this.context.stroke(); + } + fillBox(x, y, color) { + this.context.fillStyle = color; + this.context.fillRect( + x * this.boxSize + this.p, + y * this.boxSize + this.p, + this.boxSize, + this.boxSize, + ); + } + drawScore(score) { + this.context.font = "200px serif"; + this.context.strokeText(score, 280, 370); + } + drawApple(apple) { + this.fillBox(apple.position[0], apple.position[1], apple.color); + } + drawSnake(snake) { + this.fillBox(snake.head[0], snake.head[1], snake.color); + snake.tail.forEach((box) => { + this.fillBox(box[0], box[1], snake.color); + }); + } + } + + g = new Game(); + g.init(); + +