changement de fruit a chaque niveau

This commit is contained in:
2025-12-01 23:29:23 +01:00
parent 393377d3fc
commit 34fd7d1f4e
2 changed files with 205 additions and 19 deletions

156
game.js
View File

@ -57,6 +57,23 @@ const ZONE_TELEPORT = 10;
const ZONE_BONUS = 11; const ZONE_BONUS = 11;
const ZONE_DANGER = 12; 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 = [ 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,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], [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,12 +808,17 @@ class Bonus {
ctx.scale(scale, scale); ctx.scale(scale, scale);
if (this.type === BONUS_CHERRY) { if (this.type === BONUS_CHERRY) {
ctx.fillStyle = '#ff0000'; 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.beginPath();
ctx.arc(0, 0, CELL_SIZE * 0.25, 0, Math.PI * 2); ctx.arc(0, 0, CELL_SIZE * 0.25, 0, Math.PI * 2);
ctx.fill(); ctx.fill();
ctx.fillStyle = '#00ff00'; ctx.fillStyle = fruit.stemColor;
ctx.beginPath(); ctx.beginPath();
ctx.arc(-CELL_SIZE * 0.15, -CELL_SIZE * 0.2, CELL_SIZE * 0.1, 0, Math.PI * 2); ctx.arc(-CELL_SIZE * 0.15, -CELL_SIZE * 0.2, CELL_SIZE * 0.1, 0, Math.PI * 2);
ctx.fill(); ctx.fill();
@ -807,6 +829,136 @@ class Bonus {
ctx.moveTo(-CELL_SIZE * 0.15, -CELL_SIZE * 0.3); ctx.moveTo(-CELL_SIZE * 0.15, -CELL_SIZE * 0.3);
ctx.lineTo(-CELL_SIZE * 0.25, -CELL_SIZE * 0.4); ctx.lineTo(-CELL_SIZE * 0.25, -CELL_SIZE * 0.4);
ctx.stroke(); 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) { } else if (this.type === BONUS_LUDO) {
const size = CELL_SIZE * 0.45; const size = CELL_SIZE * 0.45;

View File

@ -138,32 +138,66 @@
</div> </div>
<div class="rule-section"> <div class="rule-section">
<h3>🍒 Bonus</h3> <h3>🍒 Bonus de base</h3>
<ul> <ul>
<li><strong>Cerise rouge</strong> : Rend les fantômes vulnérables pendant quelques secondes</li> <li><strong>Cerise rouge</strong> : Rend les fantômes vulnérables pendant quelques secondes</li>
<li><strong>Manger un fantôme vulnérable</strong> : +200 points</li> <li><strong>Manger un fantôme vulnérable</strong> : +200 points</li>
<li><strong>4 cerises mangées</strong> : Passage au niveau suivant</li> <li><strong>4 cerises mangées</strong> : Passage au niveau suivant</li>
<li><strong>Étoile Ludo</strong> : +200 points (apparaît dès le niveau 1)</li>
</ul> </ul>
</div> </div>
<div class="rule-section">
<h3>⚡ Power-ups (Niveau 2+)</h3>
<ul>
<li><strong>⚡ Étoile de vitesse</strong> : Pacman devient 2x plus rapide pendant 10 secondes</li>
<li><strong>🛡 Bouclier</strong> : Protège d'une collision avec un fantôme (15 secondes)</li>
<li><strong>💣 Bombe</strong> : Repousse tous les fantômes proches (Niveau 3+)</li>
<li><strong>✨ Multiplicateur</strong> : Double tous les points pendant 30 secondes (Niveau 3+)</li>
</ul>
</div>
<div class="rule-section">
<h3>🔥 Mode Frenzy</h3>
<p>Toutes les <strong>30 secondes</strong>, le mode Frenzy s'active automatiquement : tous les fantômes deviennent vulnérables et vous gagnez <strong>3x plus de points</strong> pendant 10 secondes !</p>
</div>
<div class="rule-section">
<h3>💥 Système de Combo</h3>
<p>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.</p>
</div>
<div class="rule-section"> <div class="rule-section">
<h3>👻 Fantômes</h3> <h3>👻 Fantômes</h3>
<p>Évitez les fantômes ! Si vous les touchez, vous perdez une vie. Vous avez 3 vies au départ.</p> <p>Évitez les fantômes ! Si vous les touchez, vous perdez une vie. Vous avez 3 vies au départ.</p>
<ul>
<li><strong>Niveau 1-2</strong> : 4 fantômes normaux</li>
<li><strong>Niveau 3-4</strong> : 5 fantômes (dont des chasseurs et patrouilleurs)</li>
<li><strong>Niveau 5+</strong> : 6-7 fantômes (rapides, invisibles, etc.)</li>
</ul>
</div> </div>
<div class="rule-section"> <div class="rule-section">
<h3>⭐ Système de score</h3> <h3>⭐ Système de score</h3>
<ul> <ul>
<li>Pastille : <strong>10 points</strong></li> <li>Pastille : <strong>10 points</strong> (x combo x Frenzy x multiplicateur)</li>
<li>Fantôme vulnérable : <strong>200 points</strong></li> <li>Fantôme vulnérable : <strong>200 points</strong></li>
<li>Cerise : <strong>100 points</strong></li> <li>Cerise : <strong>100 points</strong></li>
<li>Étoile Ludo : <strong>200 points</strong></li> <li>Étoile Ludo : <strong>200 points</strong></li>
</ul> </ul>
</div> </div>
<div class="rule-section">
<h3>🌐 Zones spéciales (Niveau 4+)</h3>
<ul>
<li><strong>Zone de téléportation</strong> (violet) : Vous téléporte à un endroit aléatoire</li>
<li><strong>Zone bonus</strong> (doré) : Double les points dans cette zone</li>
</ul>
</div>
<div class="rule-section"> <div class="rule-section">
<h3>🏆 Niveaux</h3> <h3>🏆 Niveaux</h3>
<p>Le jeu devient plus difficile à chaque niveau : les fantômes sont plus rapides et plus intelligents !</p> <p>Le jeu devient plus difficile à chaque niveau : plus de fantômes, nouveaux types de fantômes, et de nouveaux power-ups apparaissent !</p>
</div> </div>
</div> </div>
</div> </div>