From 34fd7d1f4e89b2e41c8d78a5387e8a78455d475b Mon Sep 17 00:00:00 2001 From: thedevilbox Date: Mon, 1 Dec 2025 23:29:23 +0100 Subject: [PATCH] changement de fruit a chaque niveau --- game.js | 184 ++++++++++++++++++++++++++++++++++++++++++++++++----- index.html | 40 +++++++++++- 2 files changed, 205 insertions(+), 19 deletions(-) diff --git a/game.js b/game.js index 5d0dbac..5e2dc9b 100644 --- a/game.js +++ b/game.js @@ -57,6 +57,23 @@ const ZONE_TELEPORT = 10; const ZONE_BONUS = 11; const ZONE_DANGER = 12; +// Fonction pour obtenir le type de fruit selon le niveau +function getFruitType() { + const fruits = [ + { name: 'cerise', color: '#ff0000', stemColor: '#00ff00', level: 1 }, + { name: 'banane', color: '#ffff00', stemColor: '#00aa00', level: 2 }, + { name: 'orange', color: '#ff8800', stemColor: '#00aa00', level: 3 }, + { name: 'pomme', color: '#ff0000', stemColor: '#8b4513', level: 4 }, + { name: 'raisin', color: '#8b00ff', stemColor: '#00aa00', level: 5 }, + { name: 'fraise', color: '#ff0066', stemColor: '#00ff00', level: 6 }, + { name: 'ananas', color: '#ffd700', stemColor: '#228b22', level: 7 } + ]; + + // Trouver le fruit correspondant au niveau (avec rotation pour les niveaux élevés) + const fruitIndex = Math.min(level - 1, fruits.length - 1); + return fruits[fruitIndex]; +} + const originalMaze1 = [ [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], [1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1], @@ -791,22 +808,157 @@ class Bonus { ctx.scale(scale, scale); if (this.type === BONUS_CHERRY) { - ctx.fillStyle = '#ff0000'; - ctx.beginPath(); - ctx.arc(0, 0, CELL_SIZE * 0.25, 0, Math.PI * 2); - ctx.fill(); - - ctx.fillStyle = '#00ff00'; - ctx.beginPath(); - ctx.arc(-CELL_SIZE * 0.15, -CELL_SIZE * 0.2, CELL_SIZE * 0.1, 0, Math.PI * 2); - ctx.fill(); - - ctx.strokeStyle = '#00aa00'; - ctx.lineWidth = 2; - ctx.beginPath(); - ctx.moveTo(-CELL_SIZE * 0.15, -CELL_SIZE * 0.3); - ctx.lineTo(-CELL_SIZE * 0.25, -CELL_SIZE * 0.4); - ctx.stroke(); + const fruit = getFruitType(); + + // Dessiner le fruit selon le type + if (fruit.name === 'cerise') { + // Cerise (rouge avec feuille verte) + ctx.fillStyle = fruit.color; + ctx.beginPath(); + ctx.arc(0, 0, CELL_SIZE * 0.25, 0, Math.PI * 2); + ctx.fill(); + + ctx.fillStyle = fruit.stemColor; + ctx.beginPath(); + ctx.arc(-CELL_SIZE * 0.15, -CELL_SIZE * 0.2, CELL_SIZE * 0.1, 0, Math.PI * 2); + ctx.fill(); + + ctx.strokeStyle = '#00aa00'; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(-CELL_SIZE * 0.15, -CELL_SIZE * 0.3); + ctx.lineTo(-CELL_SIZE * 0.25, -CELL_SIZE * 0.4); + ctx.stroke(); + } else if (fruit.name === 'banane') { + // Banane (jaune courbée) + ctx.fillStyle = fruit.color; + ctx.beginPath(); + // Dessiner une forme de banane courbée + ctx.moveTo(-CELL_SIZE * 0.25, -CELL_SIZE * 0.1); + ctx.quadraticCurveTo(0, CELL_SIZE * 0.2, CELL_SIZE * 0.25, -CELL_SIZE * 0.1); + ctx.quadraticCurveTo(0, -CELL_SIZE * 0.3, -CELL_SIZE * 0.25, -CELL_SIZE * 0.1); + ctx.closePath(); + ctx.fill(); + + ctx.strokeStyle = '#ffaa00'; + ctx.lineWidth = 2; + ctx.stroke(); + + // Tige + ctx.strokeStyle = fruit.stemColor; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(-CELL_SIZE * 0.2, -CELL_SIZE * 0.15); + ctx.lineTo(-CELL_SIZE * 0.25, -CELL_SIZE * 0.25); + ctx.stroke(); + } else if (fruit.name === 'orange') { + // Orange (cercle orange) + ctx.fillStyle = fruit.color; + ctx.beginPath(); + ctx.arc(0, 0, CELL_SIZE * 0.25, 0, Math.PI * 2); + ctx.fill(); + + ctx.strokeStyle = '#ff6600'; + ctx.lineWidth = 2; + ctx.stroke(); + + // Tige + ctx.strokeStyle = fruit.stemColor; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(0, -CELL_SIZE * 0.25); + ctx.lineTo(0, -CELL_SIZE * 0.35); + ctx.stroke(); + } else if (fruit.name === 'pomme') { + // Pomme (rouge avec tige brune) + ctx.fillStyle = fruit.color; + ctx.beginPath(); + ctx.arc(0, CELL_SIZE * 0.05, CELL_SIZE * 0.25, 0, Math.PI * 2); + ctx.fill(); + + // Feuille (ovale) + ctx.fillStyle = '#00ff00'; + ctx.beginPath(); + ctx.scale(1, 1.5); + ctx.arc(CELL_SIZE * 0.15, -CELL_SIZE * 0.07, CELL_SIZE * 0.08, 0, Math.PI * 2); + ctx.scale(1, 1/1.5); + ctx.fill(); + + // Tige + ctx.strokeStyle = fruit.stemColor; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(0, -CELL_SIZE * 0.2); + ctx.lineTo(0, -CELL_SIZE * 0.3); + ctx.stroke(); + } else if (fruit.name === 'raisin') { + // Raisin (grappes violettes) + ctx.fillStyle = fruit.color; + for (let i = 0; i < 3; i++) { + for (let j = 0; j < 2; j++) { + ctx.beginPath(); + ctx.arc((i - 1) * CELL_SIZE * 0.15, (j - 0.5) * CELL_SIZE * 0.15, CELL_SIZE * 0.1, 0, Math.PI * 2); + ctx.fill(); + } + } + + // Tige + ctx.strokeStyle = fruit.stemColor; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(0, -CELL_SIZE * 0.3); + ctx.lineTo(0, -CELL_SIZE * 0.4); + ctx.stroke(); + } else if (fruit.name === 'fraise') { + // Fraise (rouge avec graines) + ctx.fillStyle = fruit.color; + ctx.beginPath(); + ctx.arc(0, CELL_SIZE * 0.05, CELL_SIZE * 0.25, 0, Math.PI * 2); + ctx.fill(); + + // Graines + ctx.fillStyle = '#ffff00'; + for (let i = 0; i < 5; i++) { + ctx.beginPath(); + ctx.arc((i - 2) * CELL_SIZE * 0.1, CELL_SIZE * 0.05, 2, 0, Math.PI * 2); + ctx.fill(); + } + + // Feuilles + ctx.fillStyle = fruit.stemColor; + ctx.beginPath(); + ctx.arc(-CELL_SIZE * 0.15, -CELL_SIZE * 0.1, CELL_SIZE * 0.08, 0, Math.PI * 2); + ctx.arc(CELL_SIZE * 0.15, -CELL_SIZE * 0.1, CELL_SIZE * 0.08, 0, Math.PI * 2); + ctx.fill(); + } else if (fruit.name === 'ananas') { + // Ananas (jaune avec texture) + ctx.fillStyle = fruit.color; + ctx.beginPath(); + // Forme ovale pour l'ananas + ctx.scale(0.7, 1); + ctx.arc(0, 0, CELL_SIZE * 0.3, 0, Math.PI * 2); + ctx.scale(1/0.7, 1); + ctx.fill(); + + // Texture + ctx.strokeStyle = '#ffaa00'; + ctx.lineWidth = 1; + for (let i = -2; i <= 2; i++) { + ctx.beginPath(); + ctx.moveTo(i * CELL_SIZE * 0.08, -CELL_SIZE * 0.3); + ctx.lineTo(i * CELL_SIZE * 0.08, CELL_SIZE * 0.3); + ctx.stroke(); + } + + // Feuilles + ctx.fillStyle = fruit.stemColor; + ctx.beginPath(); + ctx.moveTo(0, -CELL_SIZE * 0.3); + ctx.lineTo(-CELL_SIZE * 0.1, -CELL_SIZE * 0.4); + ctx.lineTo(CELL_SIZE * 0.1, -CELL_SIZE * 0.4); + ctx.closePath(); + ctx.fill(); + } } else if (this.type === BONUS_LUDO) { const size = CELL_SIZE * 0.45; diff --git a/index.html b/index.html index 488a6e9..592f37c 100644 --- a/index.html +++ b/index.html @@ -138,32 +138,66 @@
-

🍒 Bonus

+

🍒 Bonus de base

+
+

⚡ Power-ups (Niveau 2+)

+ +
+ +
+

🔥 Mode Frenzy

+

Toutes les 30 secondes, le mode Frenzy s'active automatiquement : tous les fantômes deviennent vulnérables et vous gagnez 3x plus de points pendant 10 secondes !

+
+ +
+

💥 Système de Combo

+

Collectez les pastilles rapidement pour créer un combo ! Chaque combo augmente votre multiplicateur de score (jusqu'à x5). Le combo se réinitialise si vous attendez trop longtemps entre deux collectes.

+
+

👻 Fantômes

Évitez les fantômes ! Si vous les touchez, vous perdez une vie. Vous avez 3 vies au départ.

+

⭐ Système de score

+
+

🌐 Zones spéciales (Niveau 4+)

+ +
+

🏆 Niveaux

-

Le jeu devient plus difficile à chaque niveau : les fantômes sont plus rapides et plus intelligents !

+

Le jeu devient plus difficile à chaque niveau : plus de fantômes, nouveaux types de fantômes, et de nouveaux power-ups apparaissent !