changement de fruit a chaque niveau
This commit is contained in:
184
game.js
184
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user