Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: game.playSound is not a function' in or related to this line: 'game.playSound(rock_appears);' Line Number: 959
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self is undefined' in or related to this line: 'rocher.sprite = self.rocher_split_sprite;' Line Number: 1160
Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: rocher_split_sprite is not defined' in or related to this line: 'rocher.sprite = rocher_split_sprite;' Line Number: 1159
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: animatinImageOn is not defined' in or related to this line: 'if (!animatinImageOn) {' Line Number: 1221
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: coupeVictoire is not defined' in or related to this line: 'var imageCoupeVictoire = {' Line Number: 856
Code edit (13 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: Score is not defined' in or related to this line: 'imageCoupeVictoire.yToReach = Score;' Line Number: 1236
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: nbTicksLeft is not defined' in or related to this line: 'nbTicksLeft = scrollRescaleImage(coupeVictoire, 1, game.width / 2, game.height / 2, nbTicksLeft);' Line Number: 1182
Code edit (1 edits merged)
Please save this source code
Code edit (22 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: victoireX is not defined' in or related to this line: 'var coupeVictoire = LK.getAsset('coupeVictoire', {' Line Number: 842
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: rocher_petit_sprite is not defined' in or related to this line: 'self.sprite = rocher_petit_sprite;' Line Number: 327
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: rocher_moyen_sprite is not defined' in or related to this line: 'self.sprite = rocher_moyen_sprite;' Line Number: 330
Code edit (11 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -232,8 +232,9 @@
var typeLigneVtoY = 3; //Type 3 = déplacement vertical vers une position Y
var typeLigneHtoR = 4; //Type 4 = déplacement horizontal vers un rocher
var gameHasStarted = false; //Flag qui indique si le jeu a commence (premiers clics buldo puis rocher)
var activeCamp = 0; //Camp selectionne par le joueur
+var lastActiveCamp = 0; //Camp selectionne dans la manche precedente pour garde le meme camp
var humanCamp = 1; //camp du joueur humain
var ordiCamp = -1; //camp du joueur ordinateur
var scoreHumain = 0;
var scoreOrdi = 0;
@@ -369,10 +370,16 @@
if (buldoCheck != null) {
if (buldoCheck.isSelected) {
buldo = buldoCheck;
if (activeCamp == 0) {
- //On fixe le camp actif choisi par le joueur
- activeCamp = buldo.camp;
+ //Si c'est la manche suivante, on garde le camp actif de la manche precedente
+ if (nbManchesRestantes < nbManches) {
+ activeCamp = lastActiveCamp;
+ } else {
+ //sinon on fixe le camp actif choisi par le joueur
+ activeCamp = buldo.camp;
+ lastActiveCamp = activeCamp;
+ }
}
}
}
});
@@ -526,8 +533,11 @@
//On exclu le clic sur l'autre camp si un camp est actif
if (activeCamp != 0 && this.camp != activeCamp) {
return;
}
+ if (lastActiveCamp != 0 && this.camp != lastActiveCamp) {
+ return;
+ }
//On deselectionne tous les sprites Buldo
for (var i = 0; i < buldos.length; i++) {
if (buldos[i].name != this.name) {
buldos[i].isSelected = false;
@@ -735,10 +745,11 @@
this.lastHD = 0; // on remet la dernière direction horizontale à 0
return;
}
if (this.isMovingR) {
+ var xTarget;
if (this.rocherDestination && this.rocherDestination.sprite != null) {
- var xTarget = this.checkTarget(); //Abscisse x du point chaud AV du rocher ou du point chaud arriere du Buldo allie poussant
+ 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
@@ -758,14 +769,14 @@
this.rocherDestination.pushedByOrdi = this; // on indique le Buldo qui pousse le rocher
}
}
} else {
- var isTooFar = this.camp == humanCamp ? this.sprite.x > this.rocherDestination.sprite.x : this.sprite.x < this.rocherDestination.sprite.x; //Le Buldo est trop loin du rocher
var AD = dist(this.sprite.x, 0, xTarget, 0); //Distance entre le centre du sprite et l'abscisse x destination
var Bh = this.sprite.x + this.camp * this.dxAvHotSpot; //Abscisse x du point chaud AV du sprite
var AH = dist(this.sprite.x, 0, this.sprite.x + this.camp * this.dxAvHotSpot, 0); //Distance entre le centre du sprite et le point chaud AV
var dxHotSpotR = this.camp == humanCamp ? this.rocherDestination.dxHotLeftSpot : this.rocherDestination.dxHotRightSpot; //Point chaud du rocher
var Rh = this.rocherDestination.sprite.x + dxHotSpotR; //Abscisse x du point chaud du rocher
+ var isTooFar = this.camp == humanCamp ? this.sprite.x > Rh : this.sprite.x < Rh; //Le Buldo est trop loin du rocher
if (AH <= AD && !isTooFar) {
//Securite au cas ou le point destination se trouve entre le centre du sprite et le point chaud AV du sprite
this.sprite.x += this.vitesseEnCours * delta; // Sinon on déplace le sprite horizontalement
} else if (AH > AD || Bh > Rh || isTooFar) {
@@ -823,23 +834,14 @@
} //fin updateScoreOrdi
function updateScoreTest(nouveauScore) {
scoreTestText.setText(nouveauScore);
} //fin updateScoreTest
-//Creation de l'objet coupe de la victoire a partir de l'image coupeVictoire entre les deux scores
-var victoireX = game.width / 2;
-var victoireY = ScoreZone.height / 2;
-var coupeVictoire = LK.getAsset('coupeVictoire', {
- anchorX: 0.5,
- anchorY: 0,
- scaleX: 4,
- scaleY: 4,
- x: victoireX,
- y: victoireY
-});
//Creation d'un objet imageCoupeVictoire a partir de l'image coupeVictoire avec un point (x,y) de destination
+// Removed the direct reference to coupeVictoire in imageCoupeVictoire object to avoid ReferenceError
var imageCoupeVictoire = {
animate: false,
- image: coupeVictoire,
+ image: null,
+ // Temporarily set to null, will be assigned a valid coupeVictoire asset later in the code
xToReach: 0,
yToReach: 0,
scaleToReach: 1,
nbTicksLeft: 0
@@ -847,9 +849,19 @@
// Fonction pour afficher la victoire d'une equipe en fonction de sa couleur
function afficheVictoire(camp) {
var victoireX = camp == humanCamp ? game.width / 5 : game.width - game.width / 3;
var victoireY = ScoreZone.height;
+ // Création d'une nouvelle instance de coupeVictoire à chaque appel de la fonction
+ var coupeVictoire = LK.getAsset('coupeVictoire', {
+ anchorX: 0.5,
+ anchorY: 0,
+ scaleX: 4,
+ scaleY: 4,
+ x: victoireX,
+ y: victoireY
+ });
game.addChild(coupeVictoire);
+ return coupeVictoire;
} //fin afficheVictoire
function scrollRescaleImage(imageToScroll, scaleToReach, xToReach, yToReach, nbTicksLeft) {
//Fonction de deplacement du point d'ancrage d'une image tout en la redimensionnant
//Le nbTicksLeft est le nombre de ticks restants pour atteindre la position et la taille finales
@@ -1199,23 +1211,27 @@
updateScoreHumain(scoreHumain);
updateScoreOrdi(scoreOrdi);
//updateScoreTest(scoreTest);
//Animation des images dont victoire
- if (animateImage) {
- nbTicksLeft = scrollRescaleImage(coupeVictoire, 1, game.width / 2, game.height / 2, nbTicksLeft);
- }
+ //if (animateImage) {
+ // nbTicksLeft = scrollRescaleImage(coupeVictoire, 1, game.width / 2, game.height / 2, nbTicksLeft);
scrollRescaleImages();
//Fin de partie
if (nbRochersRestants <= 0) {
if (scoreHumain >= scoreOrdi) {
- afficheVictoire(humanCamp);
+ var coupeVictoire = afficheVictoire(humanCamp);
+ imageCoupeVictoire.xToReach = coupeVictoire.x;
+ imageCoupeVictoire.yToReach = coupeVictoire.y;
+ imageCoupeVictoire.nbTicksLeft = 60;
+ imageCoupeVictoire.animate = true;
+ imagesToScrollRescale.push(imageCoupeVictoire);
imageCoupeVictoire.xToReach = game.width / 2 - nbManchesRestantes * game.width / 8;
imageCoupeVictoire.yToReach = ScoreZone.y;
imageCoupeVictoire.nbTicksLeft = 60;
imageCoupeVictoire.animate = true;
imagesToScrollRescale.push(imageCoupeVictoire);
} else {
- afficheVictoire(ordiCamp);
+ var coupeVictoire = afficheVictoire(ordiCamp);
imageCoupeVictoire.xToReach = game.width / 2 + nbManchesRestantes * game.width / 8;
imageCoupeVictoire.yToReach = ScoreZone.y;
imageCoupeVictoire.nbTicksLeft = 50;
imageCoupeVictoire.animate = true;
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.