Code edit (2 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: 'targetX = this.rocherDestination.pushedByOrdi.sprite.x; //La cible principale est le Buldo ordi poussant' Line Number: 667
Code edit (4 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: 'targetX = this.rocherDestination.pushedByOrdi.sprite.x; //La cible principale est le Buldo ordi poussant' Line Number: 667
Code edit (1 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: 'targetX = this.rocherDestination.pushedByOrdi.sprite.x; //La cible principale est le Buldo ordi poussant' Line Number: 673
Code edit (7 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: 'targetX = this.rocherDestination.pushedByOrdi.sprite.x; //La cible principale est le Buldo ordi poussant' Line Number: 673
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'dxHotLeftSpot')' in or related to this line: 'dxHotSpotR = this.rocherrocherDestinationPushed.dxHotLeftSpot; //Le point chaud est le point chaud du rocher' Line Number: 654
Code edit (1 edits merged)
Please save this source code
Code edit (11 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: 'var xTarget = this.rocherDestination.sprite.x - this.camp * this.dxAvHotSpot + this.camp * this.rocherDestination.dxHotLeftSpot; //Abscisse x du point chaud AV du rocher' Line Number: 627
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: rocher is not defined' in or related to this line: 'this.setLigneHtoR(rocher);' Line Number: 526
Code edit (1 edits merged)
Please save this source code
Code edit (21 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: OrdiZone is not defined' in or related to this line: 'var outRight = this.sprite.x + this.dxHotLeftSpot >= OrdiZone.x; //L'abscisse du point chaud de gauche est superieur a l'abscisse de la zone ordi' Line Number: 377
User prompt
Please fix the bug: 'ReferenceError: scoreOrdiText is not defined' in or related to this line: 'scoreOrdiText.text = mettreAJourScore(scoreOrdiText, scoreOrdi);' Line Number: 781
User prompt
Please fix the bug: 'ReferenceError: scoreHumainText is not defined' in or related to this line: 'scoreHumainText.text = mettreAJourScore(scoreHumainText, scoreHumain);' Line Number: 776
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: buldorock_sprite is not defined' in or related to this line: 'buldos[i].sprite = buldorock_sprite;' Line Number: 681
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: 'TypeError: this.setLigneVtoY is not a function' in or related to this line: 'this.setLigneVtoY(y); //On effectue le deplacement vertical' Line Number: 469
Code edit (10 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.
@@ -75,8 +50,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;
@@ -215,8 +215,9 @@
var grosRocherDyHotRight = 0; //hotspot Y du sprite grosRocher
var typeRotation = 1; //Type 1 = rotation
var typeLigneHtoX = 2; //Type 2 = déplacement horizontal vers une position X
var typeLigneVtoY = 3; //Type 3 = déplacement vertical vers une position Y
+var typeLigneHtoR = 4; //Type 4 = déplacement horizontal vers un rocher
var scoreHumain = 0;
var scoreOrdi = 0;
var ScoreZone = {
x: 0,
@@ -343,9 +344,9 @@
sens = buldo.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)
buldo.addMoveToStack(typeRotation, sens * 90, 0); //Test rotation Buldo
buldo.addMoveToStack(typeLigneVtoY, 0, y); //Test mouvement Buldo
buldo.addMoveToStack(typeRotation, -sens * 90, 0); //Test rotation Buldo
- buldo.addMoveToStack(typeLigneHtoX, x, y); //Test mouvement Buldo
+ buldo.addMoveToStack(typeLigneHtoR, this, 0); //Test mouvement Buldo vers le rocher
}
}
}; //fin onClickRocherBuldo
this.destroy = function () {
@@ -432,8 +433,9 @@
this.vitesseEnCours = 0.0; //vitesse de deplacement en cours en pixels par secondes en cours de deplacement
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
this.xDestination = 0.0; //Abscisse x du point x,y destination
this.yDestination = 0.0; //Ordonnee y du point x,y destination
this.rocherDestination = null; //Rocher destination du Buldo
this.isPushing = false; //Flag qui indique si le Buldo est en train de pousser un rocher
@@ -465,14 +467,14 @@
}
}
}; //fin onClickBuldo
this.addMoveToStack = function (type, x, y) {
- //type = 1 : rotation, type = 2 : deplacement horizontal, type = 3 : deplacement vertical, type = 6 : combinaison
+ //type = 1 : rotation, type = 2 : deplacement horizontal, type = 3 : deplacement vertical, type = 4 : deplacement horizontal vers un rocher, type = 6 : combinaison
this.movesStack.push([type, x, y]); //On ajoute le mouvement a la pile des mouvements a effectuer
}; //fin addMoveToStack
this.checkMovesStack = function (delta) {
//Verification d'un mouvement en cours
- if (this.isRotating || this.isMovingH || this.isMovingV) {
+ if (this.isRotating || this.isMovingH || this.isMovingV || this.isMovingR) {
if (this.isRotating) {
this.tourneMoi(delta);
} //Si le Buldo est en rotation, on continue la rotation
if (this.isMovingH) {
@@ -480,8 +482,11 @@
} //Si le Buldo est en deplacement horizontal, on continue le deplacement
if (this.isMovingV) {
this.deplaceVtoY(delta);
} //Si le Buldo est en deplacement vertical, on continue le deplacement
+ if (this.isMovingR) {
+ this.deplaceHtoR(delta);
+ } //Si le Buldo est en deplacement horizontal vers un rocher, on continue le deplacement
return;
}
if (this.movesStack.length > 0) {
//Si la pile des mouvements a effectuer n'est pas vide
@@ -501,8 +506,11 @@
case typeLigneVtoY:
//Si le mouvement est un deplacement vertical, on effectue le deplacement
this.setLigneVtoY(y);
break;
+ case typeLigneHtoR:
+ //Si le mouvement est un deplacement horizontal vers un rocher, on effectue le deplacement
+ this.setLigneHtoR(this.rocherDestination);
default:
break;
}
}
@@ -550,20 +558,14 @@
// et on donne à l'abscisse du sprite la valeur qui superpose avec le point destination
var dx = Math.abs(this.xDestination - this.sprite.x);
if (dx < this.vitessePS * delta) {
this.sprite.x = this.xDestination;
- if (this.rocherDestination == this.rocherPushed) {
- this.isPushing = true; // on indique que le Buldo n'est plus en train de pousser un rocher
- } else {
- this.isPushing = false; // on indique que le Buldo n'est plus en train de pousser un rocher
- }
if (this.rocherDestination != null && !this.isPushing) {
this.isPushing = true; // on indique que le Buldo est en train de pousser un rocher
this.rocherPushed = this.rocherDestination; // on indique le rocher pousse par le Buldo
this.rocherPushed.totalPushers += this.camp; // on indique le Buldo qui pousse le rocher
this.rocherDestination.isBeingPushed = true; // on indique que le rocher est pousse par un Buldo
this.rocherDestination.pushedByHuman = this; // on indique le Buldo qui pousse le rocher
- this.isMovingH = this.rocherPushed.sprite.visible; // on continue a pousser tant que le rocher est visible
}
return;
} else {
// Sinon on déplace le sprite horizontalement
@@ -571,8 +573,13 @@
this.sprite.x += this.vitesseEnCours * delta;
return;
}
}
+ if (this.rocherDestination == this.rocherPushed) {
+ this.isMovingH = true; // on indique que le Buldo n'est plus en train de pousser un rocher
+ } else {
+ this.isMovingH = false; // on indique que le Buldo n'est plus en train de pousser un rocher
+ }
}; // fin deplaceHtoX
this.setLigneVtoY = function (y) {
this.isMovingV = true; //on indique que le Buldo est en mouvement
this.yDestination = y; //le point d'ancrage doit s'arreter sur y
@@ -599,8 +606,30 @@
return;
}
}
}; // fin deplaceVtoY
+ 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
+ this.vitesseEnCours = this.sprite.x < rocher.sprite.x ? this.vitessePS : -this.vitessePS; //on donne le sens du deplacement horizontal
+ }; //fin setLigneHtoR
+ this.deplaceHtoR = function (delta) {
+ // Vérifie si le Buldo est en mouvement
+ if (this.isMovingR) {
+ var AD = dist(this.sprite.x, 0, this.rocherDestination.sprite.x, 0);
+ if (AD <= Math.abs(this.vitesseEnCours * delta)) {
+ // Si la distance entre l'abscisse du sprite et l'abscisse x destination est inférieure à la vitesse en cours, on arrête le déplacement
+ this.sprite.x = this.rocherDestination.sprite.x; // on donne à l'abscisse du sprite la valeur x destination
+ this.isMovingR = false; // on indique que le Buldo n'est plus en mouvement
+ return;
+ } else {
+ // Sinon on déplace le sprite horizontalement
+ this.sprite.x += this.vitesseEnCours * delta;
+ return;
+ }
+ }
+ }; // fin deplaceHtoR
}); //fin constructor
function sensRotation(angleDegres) {
//03/03/2024//entre 0 et 180: 1, entre 180 et 360: -1, 0:0
var sens = Math.sin(angleDegres * Math.PI / 180);
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.