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
Code edit (10 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: 634
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: 'Uncaught TypeError: Cannot set properties of undefined (setting 'x')' in or related to this line: 'this.sprite.x = x;' Line Number: 439
Code edit (1 edits merged)
Please save this source code
Code edit (21 edits merged)
Please save this source code
User prompt
Migrate to the latest version of LK
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: rochers is not defined' in or related to this line: 'for (var i = 0; i < rochers.length; i++) {' Line Number: 956
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: scoreZone is not defined' in or related to this line: 'victoireText.y = scoreZone.height;' Line Number: 798
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -7,8 +7,9 @@
/****
* Game Code
****/
+//PARAMETRES DIVERS DU JEU
/*
Game Zones:
- The game is played on a 2048x2732 pixels screen.
0. let playersZoneWidth = 200;
@@ -16,8 +17,32 @@
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.
@@ -55,33 +80,8 @@
- 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;
@@ -189,8 +189,10 @@
throw new TypeError("Cannot call a class as a function");
}
}
var nbRochers = 10; //nombre de rochers
+var nbBuldoRocks = 0; //nombre de buldoRocks
+var nbBuldoZers = 0; //nombre de buldoZers
var delta = 1;
var vitesseBuldo = 8.0; //vitesse de déplacement des buldos a vide, vitesse/2 quand ils poussent un petit rocher, vitesse/4 pour un moyen, vitesse/8 pour un gros
var humanCamp = 1; //camp du joueur humain
var ordiCamp = -1; //camp du joueur ordinateur
@@ -267,12 +269,14 @@
self.dyHotLeftSpot = petitRocherDyHotLeft;
self.dxHotRightSpot = petitRocherDxHotRight; //Offset du point chaud du sprite (point de contact avec le rocher a droite) décalage par rapport au point d'ancrage
self.dyHotRightSpot = petitRocherDyHotRight;
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.pushedByHuman = null; //BuldoRock qui pousse le rocher
self.pushedByOrdi = null; //BuldoZer qui pousse le rocher
- self.totalPushers = 0; //Nombre de buldos qui poussent le rocher (+1 pour un buldoRock, -1 pour un buldoZer)
+ 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,
anchorY: 0.5
}));
@@ -296,9 +300,9 @@
}
self.sprite.x = x;
self.sprite.y = y;
self.sprite.anchor.set(0.5);
- self.sprite.scale.set(1.0);
+ self.sprite.scale.set(1.5);
self.sprite.visible = false;
if (self.tailleRocher == petitRocher) {
self.dxHotLeftSpot = petitRocherDxHotLeft;
self.dyHotLeftSpot = petitRocherDyHotLeft;
@@ -382,9 +386,10 @@
scoreOrdi = Number(scoreOrdi) + Math.log2(this.tailleRocher);
}
this.vitesse = 0.0; //Arret du rocher (et donc des buldos qui le poussent)
this.isBeingPushed = false; //Le rocher n'est plus pousse
- this.totalPushers = 999; //Plus aucun buldo ne pousse le rocher
+ this.totalForce = 999; //On annule la poussee
+ this.totalBuldos = 0; //Plus aucun Buldo ne pousse le rocher
//Destruction du sprite rocher
this.destroy();
}
}; //fin onOutRocher
@@ -432,9 +437,9 @@
}
this.sprite.x = x;
this.sprite.y = y;
this.sprite.anchor.set(0.5);
- this.sprite.scale.set(1.0);
+ this.sprite.scale.set(1.5);
this.sprite.visible = false;
this.xBase = x; //Position de base du sprite
this.yBase = y;
this.stack = []; //Pile des points x,y destination cliqués par la souris
@@ -609,30 +614,32 @@
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.checkPusher = function () {
+ this.checkForce = function () {
//Choix de la cible : point chaud du rocher ou point chaud arriere du Buldo allie poussant
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.totalPushers) {
+ 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 = null; //Fin du mouvement
break;
case 0:
- //Deux cas possibles : zero pousseur ou un pousseur de chaque cote
+ //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
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
+ //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;
@@ -699,9 +706,9 @@
break;
//On ne fait rien, on cible le point chaud du rocher par defaut
}
return targetX + dxHotSpotR;
- }; //fin checkPusher
+ }; //fin checkForce
this.deplaceHtoR = function (delta) {
// Vérifie si le Buldo est en mouvement
if (this.rocherDestination != null || this.rocherPushed != null) {
this.isMovingR = true; // on indique que le Buldo est en mouvement
@@ -710,9 +717,9 @@
return;
}
if (this.isMovingR) {
if (this.rocherDestination && this.rocherDestination.sprite) {
- var xTarget = this.checkPusher(); //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
} 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
@@ -722,9 +729,10 @@
//this.isMovingR = false;
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.rocherPushed.totalForce += this.camp; // on indique le Buldo qui pousse le rocher
+ this.rocherPushed.totalBuldos += 1; // on ajoute un pousseur au rocher
this.rocherDestination.isBeingPushed = true; // on indique que le rocher est pousse par un Buldo
if (this.camp == humanCamp && this.rocherDestination.pushedByHuman == null) {
this.rocherDestination.pushedByHuman = this; // on indique le Buldo qui pousse le rocher
}
@@ -790,9 +798,9 @@
var zoneMiniy = RoadZone.y;
var zoneMaxiy = RoadZone.y + RoadZone.height;
//Calcul des ordonnees possibles pour les rochers entre zoneMiniy + 50 et zoneMaxiy - 50
var ordonneesPossibles = [];
- for (var i = zoneMiniy + 50; i < zoneMaxiy - 50; i += 100) {
+ for (var i = zoneMiniy + 50 * 1.5; i < zoneMaxiy - 50 * 1.5; i += 100 * 1.5) {
ordonneesPossibles.push(i);
}
//Securite : si le nombre de rochers demande est superieur au nombre d'ordonnees possibles, on ajuste le nombre de rochers
if (nombreRochers > ordonneesPossibles.length) {
@@ -834,9 +842,9 @@
rock.dxHotRightSpot = grosRocherDxHotRight;
rock.dyHotRightSpot = grosRocherDyHotRight;
}
//Initialisation de parametres
- rock.totalPushers = 0;
+ rock.totalForce = 0;
rochers.push(rock);
}
//On ajoute les evenements de clic sur les sprites rocher
for (var i = 0; i < rochers.length; i++) {
@@ -844,8 +852,32 @@
}
ordonneesRestantes = ordonneesPossibles; //On stocke les ordonnees restantes pour une utilisations ulterieure
return rochers;
} //fin generateRandomRock
+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.vitessePS = vitesseBuldo;
+ buldo.sprite.visible = true;
+ //On ajoute les evenements de clic sur le sprite Buldo
+ buldo.sprite.on('down', buldo.onClickBuldo.bind(buldo, buldos));
+ //On donne leurs hotspots
+ if (buldo.camp == humanCamp) {
+ buldo.dxAvHotSpot = buldoRockHotSpotX; //Hotspot avant du sprite (point de contact avec un rocher) décalage par rapport au point d'ancrage
+ buldo.dyAvHotSpot = buldoRockHotSpotY;
+ buldo.dxBkHotSpot = buldoRockBkHotSpotX; //Offset du point chaud arriere du sprite (point de contact avec un autre Buldo) décalage par rapport au point d'ancrage
+ buldo.dyBkHotSpot = buldoRockBkHotSpotY;
+ } else if (buldo.camp == ordiCamp) {
+ buldo.dxAvHotSpot = buldoZerHotSpotX; //Hotspot avant du sprite (point de contact avec un rocher) décalage par rapport au point d'ancrage
+ buldo.dyAvHotSpot = buldoZerHotSpotY;
+ buldo.dxBkHotSpot = buldoZerBkHotSpotX; //Offset du point chaud arriere du sprite (point de contact avec un autre Buldo) décalage par rapport au point d'ancrage
+ buldo.dyBkHotSpot = buldoZerBkHotSpotY;
+ }
+ return buldo;
+} //fin createSingleBuldo
function createBuldos() {
//CREATION D'OBJETS A PARTIR DES SPRITES //constructor(x, y, camp)
var buldoRock1 = new Buldo(HumanZone.x + HumanZone.width / 2, HumanZone.y + HumanZone.height / 3, humanCamp);
var buldoRock2 = new Buldo(HumanZone.x + HumanZone.width / 2, HumanZone.y + 2 * HumanZone.height / 3, humanCamp);
@@ -942,12 +974,12 @@
}
//Animation des rochers
for (var i = 0; i < rochers.length; i++) {
if (rochers[i] == null || rochers[i].sprite.visible == false) {
- //si le rocher n'existe pas, on passe au suivant
+ //si le rocher n'existe pas, ou est sorti de la route on passe au suivant
continue;
}
- rochers[i].vitesse = rochers[i].totalPushers * vitesseBuldo / rochers[i].tailleRocher; //vitesse de déplacement du 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
}
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.