vitesse fantome parfait chasse ameliorer et logo souri chyanger en fantome

This commit is contained in:
2025-12-02 00:42:55 +01:00
parent 286cb2222e
commit fb95e88eed
2 changed files with 24 additions and 16 deletions

38
game.js
View File

@ -354,7 +354,7 @@ class Pacman {
cherryEatenTimer = Math.max(150, 300 - (level - 1) * 20);
// Rendre tous les fantômes vulnérables
const vulnerableTime = Math.max(180, 360 - (level - 1) * 30);
const vulnerableTime = Math.max(60, 180 - (level - 1) * 15);
for (let ghost of ghosts) {
ghost.isVulnerable = true;
ghost.vulnerableTimer = vulnerableTime;
@ -538,7 +538,7 @@ class Ghost {
}
}
this.moveInterval = Math.max(8, 20 - (level - 1) * 2);
this.moveInterval = Math.max(5, 15 - (level - 1) * 1.5);
this.moveCounter++;
@ -555,15 +555,20 @@ class Ghost {
// Fuir le joueur quand vulnérable
this.direction = this.getDirectionAwayFromPacman(possibleDirections);
} else {
// Comportement selon le type
if (this.type === GHOST_HUNTER) {
this.direction = this.getDirectionToPacman(possibleDirections);
} else if (this.type === GHOST_PATROL) {
this.direction = this.getPatrolDirection(possibleDirections);
} else if (this.type === GHOST_FAST || this.type === GHOST_INVISIBLE) {
this.direction = this.getDirectionToPacman(possibleDirections);
// Tous les fantômes chassent le joueur (sauf patrouilleurs qui patrouillent si très loin)
if (this.type === GHOST_PATROL) {
const distance = Math.sqrt(
Math.pow(pacman.x - this.x, 2) +
Math.pow(pacman.y - this.y, 2)
);
// Si proche, chasser, sinon patrouiller (seulement si très loin)
if (distance < 12) {
this.direction = this.getDirectionToPacman(possibleDirections);
} else {
this.direction = this.getPatrolDirection(possibleDirections);
}
} else {
// Normal : toujours poursuivre
// Tous les autres chassent directement
this.direction = this.getDirectionToPacman(possibleDirections);
}
}
@ -595,10 +600,13 @@ class Ghost {
let targetX = pacman.x;
let targetY = pacman.y;
// Prédiction améliorée pour tous les niveaux
const predictionSteps = level >= 3 ? 4 : 3;
// Si Pacman bouge, prédire où il sera
if (pacman.direction !== undefined) {
const futureX = pacman.x + dx[pacman.direction] * 2;
const futureY = pacman.y + dy[pacman.direction] * 2;
const futureX = pacman.x + dx[pacman.direction] * predictionSteps;
const futureY = pacman.y + dy[pacman.direction] * predictionSteps;
if (futureX >= 0 && futureX < COLS && futureY >= 0 && futureY < ROWS) {
targetX = futureX;
targetY = futureY;
@ -612,10 +620,8 @@ class Ghost {
const oppositeDirection = (this.direction + 2) % 4;
for (let dir of possibleDirections) {
// Éviter la direction opposée sauf si c'est la seule option
if (possibleDirections.length > 1 && dir === oppositeDirection) {
continue;
}
// Permettre le retour en arrière si c'est la meilleure direction
// (pas de restriction pour une poursuite plus agressive)
const nextX = this.x + dx[dir];
const nextY = this.y + dy[dir];