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
@@ -273,10 +273,8 @@
self.isBeingPushed = false; //Flag qui indique si le rocher est pousse par un buldo
self.isBlocked = false; //Flag qui indique si le rocher est bloque
self.vitesse = 0.0;
self.pushers = []; //Liste des buldos qui vont pousser ou qui poussent le rocher
- self.pushedByHuman = null; //BuldoRock qui pousse le rocher
- self.pushedByOrdi = null; //BuldoZer qui pousse le rocher
self.totalForce = 0; //Somme des forces qui poussent le rocher (+1 pour un buldoRock, -1 pour un buldoZer)
self.totalBuldos = 0; //Nombre de Buldos qui poussent le rocher
var rocher_petit_sprite = game.addChild(LK.getAsset('small_rock', {
anchorX: 0.5,
@@ -413,12 +411,10 @@
var nonPushers = []; //Liste des buldos qui ne poussent pas le rocher
this.pushers.forEach(function (buldo) {
if (buldo.isPushing) {
actualPushers.push(buldo);
- scoreHumain = actualPushers.length;
} else {
nonPushers.push(buldo);
- scoreOrdi = nonPushers.length;
}
});
actualPushers.sort(function (a, b) {
var distA = dist(a.sprite.x, a.sprite.y, self.sprite.x, self.sprite.y);
@@ -621,131 +617,35 @@
return;
}
}
}; // fin deplaceVtoY
- this.checkForce = function () {
- //Choix de la cible : point chaud du rocher ou point chaud arriere du Buldo allie poussant
+ this.checkTarget = function () {
+ //Meme role que checkForce mais en utilisant le tableau pushers du rocher destination
+ //Choix de la cible : point chaud du rocher ou point chaud arriere du Buldo (du meme camp) poussant (isPushing = true) situe avant dans le tableau pushers
var targetX = this.rocherDestination.sprite.x; //Cible principale par defaut
var dxHotSpotR = this.camp == humanCamp ? this.rocherDestination.dxHotLeftSpot : this.rocherDestination.dxHotRightSpot; //Point chaud du rocher
- switch (this.rocherDestination.totalForce) {
- case 999:
- //Rocher detruit
- targetX = this.sprite.x; //La cible principale est l'endroit ou se trouve le Buldo
- dxHotSpotR = this.camp * this.dxAvHotSpot;
- this.rocherDestination = null; //Plus de rocher a pousser
- this.isMovingR = false; //Fin du mouvement
- break;
- case 0:
- //Trois cas possibles : zero pousseur ou un pousseur de chaque cote ou deux pousseurs de chaque cotes
- if (this.rocherDestination.pushedByHuman == null && this.rocherDestination.pushedByOrdi == null) {
- //Aucun pousseur present quand j'arrive
+ if (this.rocherDestination.pushers) {
+ 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
break;
- } //On ne fait rien, on cible le point chaud du rocher par defaut
- else if (this.rocherDestination.pushedByHuman == this || this.rocherDestination.pushedByOrdi == this) {
- //Un pousseur de chaque cote dont moi
- break;
- } //On ne fait rien, on cible le point chaud du rocher par defaut
- else if (this.rocherDestination.pushedByHuman != null && this.rocherDestination.pushedByOrdi != null) {
- //Si un Buldo de chaque cote mais pas moi
- targetX = this.camp == humanCamp ? this.rocherDestination.pushedByHuman.sprite.x : this.rocherDestination.pushedByOrdi.sprite.x; //La cible principale est le Buldo allie poussant
- dxHotSpotR = this.camp == humanCamp ? this.rocherDestination.pushedByHuman.dxBkHotSpot : this.rocherDestination.pushedByOrdi.dxBkHotSpot;
}
- break;
- case 1:
- //Un pousseur cote humain ou bien deux pousseurs humains et un seul pousseur ordi
- if (this.camp == humanCamp && this.rocherDestination.pushedByHuman != this) {
- //Si le Buldo poussant le rocher est un Buldo humain mais pas this
- targetX = this.rocherDestination.pushedByHuman.sprite.x; //La cible principale est le Buldo humain poussant
- dxHotSpotR = this.rocherDestination.pushedByHuman.dxBkHotSpot; //Le point chaud est l'arriere du Buldo humain poussant
- } else if (this.camp == humanCamp && this.rocherDestination.pushedByHuman == this) {
- //Si le Buldo poussant le rocher est this
- break; //La cible est le point chaud du rocher
- } else if (this.camp == ordiCamp && this.rocherDestination.pushedByOrdi == null) {
- //Si il n'y a pas encore de Buldo ordi poussant le rocher
- break; //La cible principale est le rocher
- } else if (this.camp == ordiCamp && this.rocherDestination.pushedByOrdi == this) {
- //Si le Buldo poussant le rocher est this
- break; //Le point chaud est le point chaud du rocher
- } else if (this.camp == ordiCamp && this.rocherDestination.pushedByOrdi != this) {
- //Si le Buldo poussant le rocher est un autre Buldo ordi
- targetX = this.rocherDestination.pushedByOrdi.sprite.x; //La cible principale est le Buldo ordi poussant
- dxHotSpotR = this.rocherDestination.pushedByOrdi.dxBkHotSpot; //Le point chaud est l'arriere du Buldo ordi poussant
+ if (pushers[i] != null && pushers[i].camp == this.camp && pushers[i] != this) {
+ if (pushers[i].isPushing) {
+ pusher = pushers[i];
+ break;
+ }
}
- break;
- case -1:
- //Un pousseur cote ordi ou bien deux pousseurs ordi et un seul pousseur humain
- if (this.camp == ordiCamp && this.rocherDestination.pushedByOrdi != this) {
- //Si le Buldo poussant le rocher est un Buldo ordi mais pas this
- targetX = this.rocherDestination.pushedByOrdi.sprite.x; //La cible principale est le Buldo ordi poussant
- dxHotSpotR = this.rocherDestination.pushedByOrdi.dxBkHotSpot; //Le point chaud est l'arriere du Buldo ordi poussant
- } else if (this.camp == ordiCamp && this.rocherDestination.pushedByOrdi == this) {
- //Si le Buldo poussant le rocher est this
- break; //La cible est le point chaud du rocher
- } else if (this.camp == humanCamp && this.rocherDestination.pushedByHuman == null) {
- //Si il n'y a pas encore de Buldo humain poussant le rocher
- break; //Le point chaud est le point chaud du rocher
- } else if (this.camp == humanCamp && this.rocherDestination.pushedByHuman == this) {
- //Si le Buldo poussant le rocher est deja this
- break; //Le point chaud est le point chaud du rocher
- } else if (this.camp == humanCamp && this.rocherDestination.pushedByHuman != this) {
- //Si le Buldo poussant le rocher est un autre Buldo humain
- targetX = this.rocherDestination.pushedByHuman.sprite.x; //La cible principale est le Buldo humain poussant
- dxHotSpotR = this.rocherDestination.pushedByHuman.dxBkHotSpot; //Le point chaud est l'arriere du Buldo humain poussant
- }
- break;
- case 2:
- //Deux pousseurs humains : on cible le point chaud du rocher si on est le pousseur principal, sinon on cible le point chaud arriere du Buldo allie poussant
- if (this.camp == humanCamp && this.rocherDestination.pushedByHuman != this) {
- //Si le Buldo poussant est un autre Buldo humain
- targetX = this.rocherDestination.pushedByHuman.sprite.x; //La cible principale est le buldo allie poussant
- dxHotSpotR = this.rocherDestination.pushedByHuman.dxBkHotSpot; //Le point chaud est l'arriere du Buldo allie poussant
- }
- break;
- case -2:
- //Deux pousseurs ordi : on cible le point chaud du rocher si on est le pousseur principal, sinon on cible le point chaud arriere du Buldo allie poussant
- if (this.camp == ordiCamp && this.rocherDestination.pushedByOrdi != this) {
- //Si le Buldo poussant est un autre Buldo ordi
- targetX = this.rocherDestination.pushedByOrdi.sprite.x; //La cible principale est le buldo allie poussant
- dxHotSpotR = this.rocherDestination.pushedByOrdi.dxBkHotSpot; //Le point chaud est l'arriere du Buldo allie poussant
- }
- break;
- default:
- //Cas impossible pour l'instant car on ne peut pas avoir plus de deux pousseurs du meme camp
- break;
- //On ne fait rien, on cible le point chaud du rocher par defaut
- }
- return targetX + dxHotSpotR;
- }; //fin checkForce
- this.checkPushers = function () {
- //Meme fonction que checkForce mais en utilisant le tableau pushers
- if (this.rocherDestination != null && this.rocherDestination.pushers != null) {
- if (this.rocherDestination.pushers.length == 0) {
- return;
}
- var targetX = this.rocherDestination.sprite.x; //Cible principale par defaut
- var dxHotSpotR = this.camp == humanCamp ? this.rocherDestination.dxHotLeftSpot : this.rocherDestination.dxHotRightSpot; //Point chaud du rocher
- if (this.rocherDestination.pushers.length == 1) {
- scoreHumain += 1; //Test passage dans la fonction
- if (this.rocherDestination.pushers[0] == this) {
- //Si le Buldo poussant le rocher est this
- return targetX + dxHotSpotR; //La cible est le point chaud du rocher
- }
- if (this.rocherDestination.pushers[0].camp == this.camp) {
- //Si le Buldo poussant le rocher est du meme camp
- targetX = this.rocherDestination.pushers[0].sprite.x; //La cible principale est le Buldo allie poussant
- dxHotSpotR = this.rocherDestination.pushers[0].dxBkHotSpot; //Le point chaud est l'arriere du Buldo allie poussant
- }
+ if (pusher != null) {
+ targetX = pusher.sprite.x; //La cible principale est le Buldo allie poussant
+ dxHotSpotR = pusher.dxBkHotSpot; //Le point chaud est l'arriere du Buldo allie poussant
}
- if (this.rocherDestination.pushers.length == 2) {
- if (this.rocherDestination.pushers[0].camp == this.camp) {
- //Si le Buldo poussant le rocher est du meme camp
- targetX = this.rocherDestination.pushers[0].sprite.x; //La cible principale est le buldo allie poussant
- dxHotSpotR = this.rocherDestination.pushers[0].dxBkHotSpot; //Le point chaud est l'arriere du Buldo allie poussant
- }
- }
- return targetX + dxHotSpotR;
}
- }; //fin checkPushers
+ return targetX + dxHotSpotR;
+ }; //fin checkTarget
this.setLigneHtoR = function (rocher) {
this.isMovingR = true; //on indique que le Buldo est en mouvement
this.rocherDestination = rocher; //le point d'ancrage doit s'arreter sur le rocher
//Calcul du sens du deplacement horizontale : 1=droite, -1=gauche
@@ -764,10 +664,10 @@
return;
}
if (this.isMovingR) {
if (this.rocherDestination && this.rocherDestination.sprite != null) {
- var xTarget = this.checkForce(); //Abscisse x du point chaud AV du rocher ou du point chaud arriere du Buldo allie poussant
- //var xTarget = this.checkPushers(); //Abscisse x du point chaud AV du rocher ou du point chaud arriere du Buldo allie poussant
+ //var xTarget = this.checkForce(); //Abscisse x du point chaud AV du rocher ou du point chaud arriere du Buldo allie poussant
+ var xTarget = this.checkTarget(); //Abscisse x du point chaud AV du rocher ou du point chaud arriere du Buldo allie poussant
} else {
return; // Exit the function if rocherDestination or its sprite is null
}
var HD = dist(this.sprite.x + this.camp * this.dxAvHotSpot, 0, xTarget, 0); //Distance entre le point chaud AV du sprite et l'abscisse x destination
@@ -798,18 +698,18 @@
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é
rocher.pushers.push(this); //On ajoute le Buldo a la liste des Buldos qui poussent le rocher
- scoreTest = rocher.pushers ? rocher.pushers.length : 0;
- var sens = this.sprite.y < y ? 1 : -1; //Test Calcul du sens de deplacement horizontale : 1=droite, -1=gauche
+ scoreTest = rocher.pushers ? rocher.pushers.length : 0; //Controle du contenu de pushers
+ var sens = this.sprite.y < y ? 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); //Test rotation Buldo
- this.addMoveToStack(typeLigneVtoY, 0, y); //Test mouvement Buldo
- this.addMoveToStack(typeRotation, -sens * 90, 0); //Test rotation Buldo
- this.addMoveToStack(typeLigneHtoR, rocher, 0); //Test mouvement Buldo vers le rocher
- this.addMoveToStack(typeRotation, 180, 0); //Test rotation Buldo
- this.addMoveToStack(typeLigneHtoX, this.xBase + this.camp * this.dxAvHotSpot, 0); //Test mouvement Buldo vers la position de base
- this.addMoveToStack(typeRotation, -180, 0); //Test rotation Buldo;
+ this.addMoveToStack(typeRotation, sens * 90, 0); //Rotation de 90 degres vers l'ordonnee du rocher
+ this.addMoveToStack(typeLigneVtoY, 0, y); //Deplacement vertical vers l'ordonnee du rocher
+ this.addMoveToStack(typeRotation, -sens * 90, 0); //Rotation de 90 degres vers le rocher
+ 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
}; //fin moveToRock
}); //fin constructor
function sensRotation(angleDegres) {
//03/03/2024//entre 0 et 180: 1, entre 180 et 360: -1, 0:0
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.