From 1a381822099af74bf6490aa509ad620f8316f18d Mon Sep 17 00:00:00 2001 From: syoul Date: Fri, 28 Nov 2025 18:55:20 +0100 Subject: [PATCH] Animation arc-en-ciel pour le personnage: clignotement multicolore --- game.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/game.js b/game.js index 937f414..2b06b41 100644 --- a/game.js +++ b/game.js @@ -142,6 +142,7 @@ class Pacman { this.speed = 0.15; this.pixelX = this.x * CELL_SIZE + CELL_SIZE / 2; this.pixelY = this.y * CELL_SIZE + CELL_SIZE / 2; + this.colorAnimation = 0; } update() { @@ -153,6 +154,11 @@ class Pacman { this.mouthOpen = !this.mouthOpen; } + this.colorAnimation += 0.3; + if (this.colorAnimation > Math.PI * 2) { + this.colorAnimation = 0; + } + const gridX = Math.floor(this.pixelX / CELL_SIZE); const gridY = Math.floor(this.pixelY / CELL_SIZE); @@ -243,7 +249,8 @@ class Pacman { const rotation = [Math.PI * 1.5, 0, Math.PI * 0.5, Math.PI]; ctx.rotate(rotation[this.direction]); - ctx.fillStyle = '#ffd700'; + const hue = (this.colorAnimation * 180 / Math.PI) % 360; + ctx.fillStyle = `hsl(${hue}, 100%, 50%)`; ctx.beginPath(); if (this.mouthOpen) {