Code edit (18 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.getTick is not a function' in or related to this line: 'rocher.sprite.alpha = Math.abs(Math.sin(LK.getTick() / 100)); //Clignotement du rocher' Line Number: 991
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: rocher is undefined' in or related to this line: 'var sens = this.yBase < rocher.sprite.y ? 1 : -1; //Calcul du sens de deplacement verticale : 1=bas, -1=haut' Line Number: 735
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: rochersCibles is not defined' in or related to this line: 'scoreTest = rochersCibles.length;' Line Number: 750
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: this.srite is undefined' in or related to this line: 'if (this.rochersCibles.length == 0 && this.srite.y != this.yBase) {' Line Number: 745
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: yBase is not defined' in or related to this line: 'sens = this.sprite.y == yBase ? -sens : sens; //Si le Buldo par face a la route, il doit se tourner vers le rocher' Line Number: 737
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'scoreTest = this.pushers.length;' Line Number: 816
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: scoreTest is not defined' in or related to this line: 'updateScoreTest(scoreTest);' Line Number: 1028
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'sprite')' in or related to this line: 'this.vitesseEnCours = this.sprite.x < rocher.sprite.x ? this.vitessePS : -this.vitessePS; //on donne le sens du deplacement horizontal' Line Number: 765
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: rocher is not defined' in or related to this line: 'rocher[i].sortPushers();' Line Number: 1003
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -345,11 +345,11 @@
buldo = buldoCheck;
}
}
});
- //Si le buldo selectionne est trouve, on le deplace vers le sprite rocher
- if (buldo != null && !buldo.isMoving) {
- buldo.moveToRock(this); //On deplace le buldo vers le rocher
+ //Si le buldo selectionne est trouve, on le deplace vers le sprite rocher ou on stock le prochain rocher cible
+ if (buldo != null) {
+ buldo.rochersCibles.push(this); //On stock le prochain rocher cible
}
}
}; //fin onClickRocherBuldo
this.destroy = function () {
@@ -460,8 +460,9 @@
this.isMovingV = false; //Flag qui indique si le Buldo est en mouvement vertical
this.isMovingR = false; //Flag qui indique si le Buldo est en mouvement horizontal vers un rocher
this.xDestination = 0.0; //Abscisse x du point x,y destination
this.yDestination = 0.0; //Ordonnee y du point x,y destination
+ this.rochersCibles = []; //Liste des rochers cibles
this.rocherDestination = null; //Rocher destination du Buldo
this.isPushing = false; //Flag qui indique si le Buldo est en train de pousser un rocher
this.rocherPushed = null; //Rocher pousse par le Buldo
this.isRotating = false; //Flag qui indique si le Buldo est en rotation
@@ -482,14 +483,11 @@
//Si le sprite est deja selectionne, on le deselectionne
this.isSelected = false;
this.sprite.tint = 0xFFFFFF; //on enleve le filtre coloré
} else {
- //Sinon on le selectionne s'il n'est pas en mouvement ou en rotation
- var isNotMoving = !this.isRotating && !this.isMovingH && !this.isMovingV;
- if (isNotMoving) {
- this.isSelected = true;
- this.sprite.tint = 0xD0D00D; //on ajoute un filtre coloré
- }
+ //Sinon on le selectionne
+ this.isSelected = true;
+ this.sprite.tint = 0xD0D00D; //on ajoute un filtre coloré
}
}; //fin onClickBuldo
this.addMoveToStack = function (type, x, y) {
//type = 1 : rotation, type = 2 : deplacement horizontal, type = 3 : deplacement vertical, type = 4 : deplacement horizontal vers un rocher, type = 6 : combinaison
@@ -536,9 +534,20 @@
this.setLigneHtoR(this.rocherDestination);
default:
break;
}
+ return;
}
+ //Si la pile des mouvements (movesStack) est vide, on verifie la pile des rochers cibles et on deplace le Buldo vers le prochain rocher cible
+ if (this.rochersCibles.length > 0) {
+ var rocher = this.rochersCibles.shift(); //On recupere le premier rocher de la pile des rochers cibles
+ if (rocher != null && rocher.sprite.visible) {
+ //Si le rocher est visible
+ if (!this.isMoving) {
+ this.moveToRock(rocher); //On deplace le Buldo vers le rocher
+ }
+ }
+ }
}; //fin checkMovesStack
this.setRotation = function (alphaDegres) {
//Fonction d'initialisation de la rotation
this.isRotating = true; //on indique que le Buldo est en rotation
@@ -627,15 +636,15 @@
var pushers = this.rocherDestination.pushers;
var pusher = null;
for (var i = 0; i < pushers.length; i++) {
if (pushers[i] != null && pushers[i] == this) {
- //Si pas de pousseur du meme camp avant dans le tableau pushers
+ //Si pas de pousseur du meme camp avant dans le tableau pushers, la cible est le rocher
break;
}
if (pushers[i] != null && pushers[i].camp == this.camp && pushers[i] != this) {
if (pushers[i].isPushing) {
+ //Si pousseur du meme camp avant dans le tableau pushers, la cible principale est le pousseur precedent
pusher = pushers[i];
- break;
}
}
}
if (pusher != null) {
@@ -693,8 +702,19 @@
}
}
return;
}; // fin deplaceHtoR
+ this.moveBackToBase = function () {
+ //Deplacement du Buldo vers sa position de base lors du retour au camp ()
+ //D'abord il se tourne verticalement vers sa position de base
+ //Puis il se deplace verticalement vers sa position de base
+ //Puis il se tourne pour faire face a la route
+ var sens = this.sprite.y < this.yBase ? 1 : -1; //Calcul du sens de deplacement horizontale : 1=droite, -1=gauche
+ sens = this.camp == humanCamp ? sens : -sens; //Test Si le Buldo est humain, il doit arriver horizontalement par la gauche (abscisse croissante), sinon par la droite (abscisse decroissante)
+ this.addMoveToStack(typeRotation, sens * 90, 0); //Rotation de 90 degres vers l'ordonnee de la position de base
+ this.addMoveToStack(typeLigneVtoY, this.xBase, this.yBase); //Deplacement vertical vers l'ordonnee de la position de base
+ this.addMoveToStack(typeRotation, sens * 90, 0); //Rotation de 90 degres vers la route
+ }; //fin moveBackToBase
this.moveToRock = function (rocher) {
x = this.camp == humanCamp ? x + rocher.dxHotLeftSpot : x + rocher.dxHotRightSpot;
y = rocher.sprite.y;
this.rocherDestination = rocher; //Le buldo a pour destination le sprite rocher cliqué
@@ -708,8 +728,9 @@
this.addMoveToStack(typeLigneHtoR, rocher, 0); //Deplacement vers le rocher jusqu'au contact s'il n'est pas detruit avant
this.addMoveToStack(typeRotation, 180, 0); //Demi tour vers le camp de base
this.addMoveToStack(typeLigneHtoX, this.xBase + this.camp * this.dxAvHotSpot, 0); //Deplacement jusqu'au camp de base
//this.addMoveToStack(typeRotation, -180, 0); //Demi tour pret a repartir
+ this.moveBackToBase(); //Retour au camp de base
}; //fin moveToRock
}); //fin constructor
function sensRotation(angleDegres) {
//03/03/2024//entre 0 et 180: 1, entre 180 et 360: -1, 0:0
@@ -808,10 +829,10 @@
function createSingleBuldo(x, y, camp) {
//CREATION D'OBJETS A PARTIR DES SPRITES //constructor(x, y, camp)
var buldo = new Buldo(x, y, camp);
buldo.sprite.anchor.set(0.5, 0.5);
- buldo.xBase = buldo.sprite.x;
- buldo.yBase = buldo.sprite.y;
+ buldo.xBase = x;
+ buldo.yBase = y;
buldo.vitessePS = vitesseBuldo;
buldo.sprite.visible = true;
//On ajoute les evenements de clic sur le sprite Buldo
buldo.sprite.on('down', function () {
@@ -838,14 +859,16 @@
} //fin createSingleBuldo
function createBuldos() {
//CREATION D'OBJETS A PARTIR DES SPRITES //constructor(x, y, camp)
var buldoRock1 = createSingleBuldo(HumanZone.x + HumanZone.width / 2, HumanZone.y + HumanZone.height / 3, humanCamp);
+ var buldoRockTest = createSingleBuldo(HumanZone.x + HumanZone.width / 2, HumanZone.y + HumanZone.height / 2, humanCamp); //Position : milieu de la zone humaine, 1/2 de la hauteur
var buldoRock2 = createSingleBuldo(HumanZone.x + HumanZone.width / 2, HumanZone.y + 2 * HumanZone.height / 3, humanCamp);
var buldoZer1 = createSingleBuldo(ComputerZone.x + ComputerZone.width / 2, ComputerZone.y + ComputerZone.height / 3, ordiCamp);
var buldoZer2 = createSingleBuldo(ComputerZone.x + ComputerZone.width / 2, ComputerZone.y + 2 * ComputerZone.height / 3, ordiCamp);
//On stocke les objets dans un tableau
var buldos = [];
buldos.push(buldoRock1);
+ buldos.push(buldoRockTest);
buldos.push(buldoRock2);
buldos.push(buldoZer1);
buldos.push(buldoZer2);
//On donne un nom aux objets
@@ -912,9 +935,9 @@
}
//Mise à jour des scores
updateScoreHumain(scoreHumain);
updateScoreOrdi(scoreOrdi);
- updateScoreTest(scoreTest);
+ //updateScoreTest(scoreTest);
//Fin de partie
if (nbRochers <= 0) {
if (scoreHumain >= scoreOrdi) {
afficheVictoire(humanCamp);
A small rock
a rock without any shadow and four time smaller than the original.
Blue color
a rock is being crunched so there is smoke and peaces of rocks viewed from top.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Un trophée de victoire sous forme d'une coupe d'où s'échappe un feu d'artifice.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Red bulldozer viewed strictly from top. Top view as if we are a drone.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Remove yellow lines.