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
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.getText is not a function' in or related to this line: 'var victoireText = game.addChild(LK.getText('Victoire', {' Line Number: 792
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 (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: OrdiZone is not defined' in or related to this line: 'scoreOrdiText.x = OrdiZone.x + HumanZone.width / 2;' Line Number: 933
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 TypeError: LK.Text2 is not a constructor' in or related to this line: 'var scoreHumainText = new LK.Text2('Score Humain: 0', {' Line Number: 912
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: updateScoreHumainText is not defined' in or related to this line: 'updateScoreHumainText.text = mettreAJourScore(scoreHumain);' Line Number: 960
User prompt
Please fix the bug: 'Uncaught TypeError: LK.Text2 is not a constructor' in or related to this line: 'var scoreOrdiText = new LK.Text2('Score Ordi: 0', {' Line Number: 919
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: LK.Text2 is not a constructor' in or related to this line: 'var scoreHumainText = new LK.Text2('Score Humain: 0', {' Line Number: 911
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'pushedByOrdi')' in or related to this line: 'if (this.camp == humanCamp && this.rocherDestination.pushedByHuman != this) {' Line Number: 655
===================================================================
--- original.js
+++ change.js
@@ -45,8 +45,13 @@
- 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.
- It is possible to push a rock that is being pushed by the opponent to block or slow down its movement.
- If a second Buldo is added in this situation, the rock will be pushed in the direction where there are fewer Buldos.
+- When a rock is blocked, it splits into smaller rocks depending of its size.
+- A large rock splits into a small and a medium one.
+- A medium rock splits into two small rocks.
+- A small rock is destroyed and disappears.
+- The splitted new rocks are thrown from the position of the blocked rock to a free ligne.
- 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 (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.
@@ -185,9 +190,9 @@
}
}
var nbRochers = 10; //nombre de rochers
var delta = 1;
-var vitesseBuldo = 4.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 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
var ancrageMedian = 0.5; //ancrage median des sprites
var buldoRockHotSpotX = 45; //hotspot X du sprite buldoRock, offset du sprite par rapport à l'ancrage
@@ -197,8 +202,9 @@
var buldoZerHotSpotX = 45; //hotspot X du sprite buldoZer, offset du sprite par rapport à l'ancrage
var buldoZerHotSpotY = 0; //hotspot Y du sprite buldoZer
var buldoZerBkHotSpotX = 45; //hotspot arriere du buldoZer
var buldoZerBkHotSpotY = 0;
+var ordonneesRestantes = []; //liste des ordonnees non encore utilisees pour le placement des rochers
var petitRocher = 2; //taille du rocher (2=petit, 4=moyen, 8=gros)
var petitRocherDxHotLeft = -25; //hotspot X du sprite petitRocher, offset du sprite par rapport à l'ancrage
var petitRocherDyHotLeft = 0; //hotspot Y du sprite petitRocher
var petitRocherDxHotRight = 25; //hotspot X du sprite petitRocher, offset du sprite par rapport à l'ancrage
@@ -336,20 +342,9 @@
}
});
//Si le buldo selectionne est trouve, on le deplace vers le sprite rocher
if (buldo != null && !buldo.isMoving) {
- x = buldo.camp == humanCamp ? x + this.dxHotLeftSpot : x + this.dxHotRightSpot;
- y = this.sprite.y;
- buldo.rocherDestination = this; //Le buldo a pour destination le sprite rocher cliqué
- var sens = buldo.sprite.y < y ? 1 : -1; //Test Calcul du sens de deplacement horizontale : 1=droite, -1=gauche
- 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(typeLigneHtoR, this, 0); //Test mouvement Buldo vers le rocher
- buldo.addMoveToStack(typeRotation, 180, 0); //Test rotation Buldo
- buldo.addMoveToStack(typeLigneHtoX, buldo.xBase + buldo.camp * buldo.dxAvHotSpot, 0); //Test mouvement Buldo vers la position de base
- buldo.addMoveToStack(typeRotation, -180, 0); //Test rotation Buldo
+ buldo.moveToRock(this); //On deplace le buldo vers le rocher
}
}
}; //fin onClickRocherBuldo
this.destroy = function () {
@@ -365,8 +360,10 @@
this.pushedByOrdi.rocherDestination = null;
this.pushedByOrdi.isPushing = false;
this.pushedByOrdi = null;
}
+ //On recupere l'ordonnee du rocher pour une potentielle reutilisation
+ ordonneesRestantes.push(this.sprite.y);
//Invisibilite du sprite rocher
this.sprite.visible = false;
}; //fin destroy
this.onOutRocher = function () {
@@ -738,8 +735,22 @@
}
}
return;
}; // fin deplaceHtoR
+ this.moveToRock = function (rocher) {
+ 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é
+ var sens = this.sprite.y < y ? 1 : -1; //Test 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;
+ }; //fin moveToRock
}); //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);
@@ -816,9 +827,9 @@
//On ajoute les evenements de clic sur les sprites rocher
for (var i = 0; i < rochers.length; i++) {
rochers[i].sprite.on('down', rochers[i].onClickRocherBuldo.bind(rochers[i], buldos));
}
- ;
+ ordonneesRestantes = ordonneesPossibles; //On stocke les ordonnees restantes pour une utilisations ulterieure
return rochers;
} //fin generateRandomRock
function createBuldos() {
//CREATION D'OBJETS A PARTIR DES SPRITES //constructor(x, y, camp)
@@ -881,8 +892,15 @@
return buldos;
} //fin de createBuldos
var buldos = createBuldos(); //Creation des Buldos
var rochers = generateRandomRock(nbRochers); //création des rochers
+// Création de l'objet de texte pour le score du camp humain
+var scoreHumainText = new Text2('Score Humain: 0', {
+ size: 50,
+ fill: "#ffffff",
+ anchorX: 0.5,
+ anchorY: 0
+});
// Fonction de rappel pour le tick
function onGameTick() {
// Autres mises à jour du jeu ici en cours de test..
}
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.