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
@@ -7,9 +7,8 @@
/****
* Game Code
****/
-//PARAMETRES DIVERS DU JEU
/*
Game Zones:
- The game is played on a 2048x2732 pixels screen.
0. let playersZoneWidth = 200;
@@ -17,32 +16,8 @@
2. let OptionsZone = {x: 0, y: app.screen.height-200, width: app.screen.width, height: 200};
3. let HumanZone = {x: 0, y: 200, width: playersZoneWidth, height: app.screen.height-OptionsZone.height-ScoreZone.height};
4. let ComputerZone = {x: app.screen.width-playersZoneWidth, y: 200, width: playersZoneWidth, height: app.screen.height-OptionsZone.height-ScoreZone.height};
5. let RoadZone = {x: playersZoneWidth, y: 200, width: app.screen.width-HumanZone.width-OrdiZone.width, height: app.screen.height-OptionsZone.height-ScoreZone.height};
-- At the start of the game, 10 rocks of three different sizes are randomly placed in the RoadZone.
-- Each player has two bulldozers to move the rocks.
-- A bulldozer moving without pushing anything has a base speed V.
-- When a bulldozer pushes a small rock, the combined speed is V/2.
-- When a bulldozer pushes a medium rock, the combined speed is V/4.
-- When a bulldozer pushes a large rock, the combined speed is V/8.
-- When two bulldozers push a rock together, one behind the other, the pushing speeds are doubled compared to the speed of a single bulldozer.
-- The human player clicks on a rock to command the nearest free bulldozer to push it towards the ComputerZone.
-- The computer-controlled bulldozers randomly choose a rock and push it towards the HumanZone.
-- If a human bulldozer is free, the player can click on a rock already being pushed to have the bulldozer move behind the first one and push the rock faster.
-- It is possible to push a rock that is being pushed by the opponent to block or slow down its movement. If a second bulldozer is added in this situation, the rock will be pushed in the direction where there are fewer bulldozers.
-- The game ends when all rocks have been moved out of the RoadZone. The winner is the one with the highest score, based on the number and size of rocks successfully moved to the opposing zone.
-- The goal for the human player is to move all the rocks to the ComputerZone while preventing the computer from doing the same. Effective strategy and skillful bulldozer management are necessary to maximize the score.
-There is no time limit in this game, and players must use their judgment to determine the best way to move rocks and use their bulldozers to win the game.
-*/
-/*
-Game Zones:
-- The game is played on a 2048x2732 pixels screen.
-0. let playersZoneWidth = 200;
-1. let ScoreZone = {x: 0, y: 0, width: app.screen.width, height: 200};
-2. let OptionsZone = {x: 0, y: app.screen.height-200, width: app.screen.width, height: 200};
-3. let HumanZone = {x: 0, y: 200, width: playersZoneWidth, height: app.screen.height-OptionsZone.height-ScoreZone.height};
-4. let ComputerZone = {x: app.screen.width-playersZoneWidth, y: 200, width: playersZoneWidth, height: app.screen.height-OptionsZone.height-ScoreZone.height};
-5. let RoadZone = {x: playersZoneWidth, y: 200, width: app.screen.width-HumanZone.width-OrdiZone.width, height: app.screen.height-OptionsZone.height-ScoreZone.height};
Game settings:
- At the start of the game, 10 rocks of three different sizes (small, medium, large) are randomly placed in the RoadZone.
- The rocks have square 100x100 pixels sprites centered (anchor 0.5, 0.5).
- The Rocks have a front and a back zone to simulate a contact area with the Buldos.
@@ -80,8 +55,33 @@
- The winner is the one with the highest score, based on the number and size of rocks successfully moved to the opposing zone (small rock is 1 point, medium rock is 2 points, large rock is 3 points).
- The goal for the human player is to move all the rocks to the ComputerZone while preventing the computer from doing the same.
- There is no time limit in this game, and players must use their judgment to determine the best way to move rocks and use their Buldos to win the game.
*/
+/*
+Game Zones:
+- The game is played on a 2048x2732 pixels screen.
+0. let playersZoneWidth = 200;
+1. let ScoreZone = {x: 0, y: 0, width: app.screen.width, height: 200};
+2. let OptionsZone = {x: 0, y: app.screen.height-200, width: app.screen.width, height: 200};
+3. let HumanZone = {x: 0, y: 200, width: playersZoneWidth, height: app.screen.height-OptionsZone.height-ScoreZone.height};
+4. let ComputerZone = {x: app.screen.width-playersZoneWidth, y: 200, width: playersZoneWidth, height: app.screen.height-OptionsZone.height-ScoreZone.height};
+5. let RoadZone = {x: playersZoneWidth, y: 200, width: app.screen.width-HumanZone.width-OrdiZone.width, height: app.screen.height-OptionsZone.height-ScoreZone.height};
+- At the start of the game, 10 rocks of three different sizes are randomly placed in the RoadZone.
+- Each player has two bulldozers to move the rocks.
+- A bulldozer moving without pushing anything has a base speed V.
+- When a bulldozer pushes a small rock, the combined speed is V/2.
+- When a bulldozer pushes a medium rock, the combined speed is V/4.
+- When a bulldozer pushes a large rock, the combined speed is V/8.
+- When two bulldozers push a rock together, one behind the other, the pushing speeds are doubled compared to the speed of a single bulldozer.
+- The human player clicks on a rock to command the nearest free bulldozer to push it towards the ComputerZone.
+- The computer-controlled bulldozers randomly choose a rock and push it towards the HumanZone.
+- If a human bulldozer is free, the player can click on a rock already being pushed to have the bulldozer move behind the first one and push the rock faster.
+- It is possible to push a rock that is being pushed by the opponent to block or slow down its movement. If a second bulldozer is added in this situation, the rock will be pushed in the direction where there are fewer bulldozers.
+- The game ends when all rocks have been moved out of the RoadZone. The winner is the one with the highest score, based on the number and size of rocks successfully moved to the opposing zone.
+- The goal for the human player is to move all the rocks to the ComputerZone while preventing the computer from doing the same. Effective strategy and skillful bulldozer management are necessary to maximize the score.
+There is no time limit in this game, and players must use their judgment to determine the best way to move rocks and use their bulldozers to win the game.
+*/
+//PARAMETRES DIVERS DU JEU
function _typeof2(o) {
"@babel/helpers - typeof";
return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
@@ -348,9 +348,8 @@
});
//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
- scoreTest = buldo.rochersCibles.length;
}
}
}; //fin onClickRocherBuldo
this.destroy = function () {
@@ -364,9 +363,8 @@
//On supprime eventuellement le rocher de la liste des rochers cibles
var index = buldo.rochersCibles.indexOf(this);
if (index > -1) {
buldo.rochersCibles.splice(index, 1);
- scoreTest = buldo.rochersCibles.length;
}
}
});
}
@@ -461,8 +459,9 @@
this.stack = []; //Pile des points x,y destination cliqués par la souris
this.movesStack = []; //Pile des mouvements a effectuer (types de mouvements : 1 : rotation, 2 : horizontal, 3 : vertical, 4 : xy)
this.vitessePS = vitesseBuldo; //vitesse de deplacement du sprite en pixels par secondes
this.vitesseEnCours = 0.0; //vitesse de deplacement en cours en pixels par secondes en cours de deplacement
+ this.isOnBase = true; //Flag qui indique si le Buldo est sur sa base
this.isMoving = false; //Flag qui indique si le Buldo est en mouvement
this.isMovingH = false; //Flag qui indique si le Buldo est en mouvement horizontal
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
@@ -518,8 +517,9 @@
return;
}
if (this.movesStack.length > 0) {
//Si la pile des mouvements a effectuer n'est pas vide
+ this.isOnBase = false; //Le Buldo n'est plus sur sa base
var move = this.movesStack.shift(); //On recupere le premier mouvement de la pile
var type = move[0]; //Type de mouvement (1 : rotation, 2 : deplacement horizontal, 3 : deplacement vertical)
var x = move[1]; //Abscisse x du point x,y destination ou angle de rotation ou fonction de deplacement
var y = move[2]; //Ordonnee y du point x,y destination ou fonction de deplacement
@@ -546,18 +546,20 @@
}
//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
- scoreTest = this.rochersCibles.length;
if (rocher != null && rocher.sprite.visible) {
//Si le rocher est visible
if (!this.isMoving) {
- this.moveToRock(); //On deplace le Buldo vers le rocher
+ this.moveToRock(rocher); //On deplace le Buldo vers le rocher
}
}
- } else {
+ } else if (this.sprite.y != this.yBase) {
//Si la liste des rochers a pousser est vide, on retourne au point de base
- this.moveBackToBase(rocher);
+ this.moveBackToBase();
+ } else {
+ //Si le Buldo est a son point de base
+ this.isOnBase = true;
}
}; //fin checkMovesStack
this.setRotation = function (alphaDegres) {
//Fonction d'initialisation de la rotation
@@ -706,10 +708,13 @@
this.rocherDestination.pushedByOrdi = this; // on indique le Buldo qui pousse le rocher
}
}
} else {
- // Sinon on déplace le sprite horizontalement
- this.sprite.x += this.vitesseEnCours * delta;
+ var AD = dist(this.sprite.x, 0, xTarget, 0); //Distance entre le centre du sprite et l'abscisse x destination
+ if (AD >= HD) {
+ //Securite au cas ou le point destination se trouve entre le centre du sprite et le point chaud AV : on arrete ponctuellement le deplacement
+ this.sprite.x += this.vitesseEnCours * delta; // Sinon on déplace le sprite horizontalement
+ }
}
}
return;
}; // fin deplaceHtoR
@@ -934,26 +939,35 @@
if (rochers[i] == null || rochers[i].sprite.visible == false) {
//si le rocher n'existe pas, ou est sorti de la route on passe au suivant
continue;
}
- rochers[i].sortPushers();
+ rochers[i].sortPushers(); //On trie les pousseurs par ordre de distance croissante au rocher
rochers[i].vitesse = rochers[i].totalForce * vitesseBuldo / rochers[i].tailleRocher; //vitesse de déplacement du rocher
if (rochers[i].isBeingPushed) {
rochers[i].checkPushed();
} //déplacement du rocher
}
//Mise à jour des scores
updateScoreHumain(scoreHumain);
updateScoreOrdi(scoreOrdi);
- updateScoreTest(scoreTest);
+ //updateScoreTest(scoreTest);
//Fin de partie
if (nbRochers <= 0) {
if (scoreHumain >= scoreOrdi) {
afficheVictoire(humanCamp);
} else {
afficheVictoire(ordiCamp);
}
- LK.setTimeout(function () {
+ //On attend que tous les Buldos soient revenus a leur position de base pour afficher le message de fin de partie
+ var allBack = true;
+ if (buldos) {
+ buldos.forEach(function (buldo) {
+ if (buldo.isMoving || buldo.sprite.x != buldo.xBase || buldo.sprite.y != buldo.yBase || !buldo.isOnBase) {
+ allBack = false;
+ }
+ });
+ }
+ if (allBack) {
LK.showGameOver();
- }, 8000);
+ }
}
});
\ No newline at end of file
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.