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
User prompt
Please fix the bug: 'Uncaught ReferenceError: buldorock_sprite is not defined' in or related to this line: 'this.sprite = buldorock_sprite;' Line Number: 505
User prompt
Please fix the bug: 'Uncaught ReferenceError: buldorock_sprite is not defined' in or related to this line: 'this.sprite = buldorock_sprite;' Line Number: 505
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: 'Uncaught ReferenceError: coupeVictoire is not defined' in or related to this line: 'LK.gui.top.addChild(coupeVictoire);' Line Number: 1001
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: 'Uncaught TypeError: Graphics is not a constructor' in or related to this line: 'var routeZone = new Graphics();' Line Number: 292
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Manque t'il route_sprite.x *= -1;
Code edit (1 edits merged)
Please save this source code
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: 'TypeError: rochers[i] is undefined' in or related to this line: 'if (rochers[i].isClicked) {' Line Number: 1029
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -189,9 +189,12 @@
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
+var nbManches = 2; //nombre de manches
+var nbManchesRestantes = nbManches; //nombre de manches restantes
var nbRochers = 10; //nombre de rochers
+var nbRochersRestants = nbRochers; //nombre de rochers restants
var nbBuldoRocks = 0; //nombre de buldoRocks
var nbBuldoZers = 0; //nombre de buldoZers
var delta = 1; //Heritage des tests en PixiJS
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
@@ -220,12 +223,8 @@
var grosRocherDxHotRight = 45 * 2; //hotspot X du sprite grosRocher, offset du sprite par rapport à l'ancrage
var grosRocherDyHotRight = 0; //hotspot Y du sprite grosRocher
var timeBeforeSplit = 200; //temps en ticks avant division du rocher bloque
var nbTicksBeforeStopFlashing = 10; //nombre de ticks avant d'arreter de clignoter
-var rocher_split_sprite = game.addChild(LK.getAsset('pouf', {
- anchorX: 0.5,
- anchorY: 0.5
-}));
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
@@ -292,8 +291,12 @@
self.vitesse = 0.0;
self.pushers = []; //Liste des buldos qui vont pousser ou qui poussent le rocher
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
+ self.rocher_split_sprite = LK.getAsset('pouf', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
self.rocher_petit_sprite = LK.getAsset('small_rock', {
anchorX: 0.5,
anchorY: 0.5
});
@@ -412,9 +415,9 @@
var index = rochers.indexOf(this);
if (index > -1) {
rochers.splice(index, 1);
}
- nbRochers = nbRochers - 1; //Decrement du nombre de rochers
+ nbRochersRestants = nbRochersRestants - 1; //Decrement du nombre de rochers
//Invisibilite du sprite rocher
this.sprite.visible = false;
}; //fin destroy
this.onOutRocher = function () {
@@ -758,9 +761,9 @@
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
- if (AH <= AD) {
+ 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) {
//Securite au cas ou le buldo depasse le point chaud du rocher
@@ -817,17 +820,24 @@
} //fin updateScoreOrdi
function updateScoreTest(nouveauScore) {
scoreFictifText.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,
+ anchorY: 0,
+ scaleX: 4,
+ scaleY: 4,
+ x: victoireX,
+ y: victoireY
+});
// Fonction pour afficher la victoire d'une equipe en fonction de sa couleur
function afficheVictoire(camp) {
- var victoireText = game.addChild(new Text2('WINNER!', {
- size: 90,
- fill: camp == humanCamp ? 'blue' : 'red'
- }));
- LK.gui.topLeft.addChild(victoireText);
- victoireText.x = camp == humanCamp ? HumanZone.width : game.width / 2;
- victoireText.y = ScoreZone.height;
+ var victoireX = camp == humanCamp ? game.width / 5 : game.width - game.width / 3;
+ var victoireY = ScoreZone.height;
+ game.addChild(coupeVictoire);
} //fin afficheVictoire
function createSingleRandomRock(size) {
//Creation d'un rocher de taille donnee a ajouter a la liste des rochers
//L'ordonnee est choisie aleatoirement dans la zone de route disponible (ordonneesRestantes)
@@ -843,8 +853,9 @@
var x = Math.random() * (zoneMaxix - zoneMinix) + zoneMinix;
var rock = new Rocher(size, x, y);
rock.sprite.visible = true;
rock.sprite.anchor.set(0.5, 0.5);
+ var rock_sprite = rock.rocher_petit_sprite;
if (size == petitRocher) {
rock.dxHotLeftSpot = petitRocherDxHotLeft;
rock.dyHotLeftSpot = petitRocherDyHotLeft;
rock.dxHotRightSpot = petitRocherDxHotRight;
@@ -854,18 +865,19 @@
rock.dxHotLeftSpot = moyenRocherDxHotLeft;
rock.dyHotLeftSpot = moyenRocherDyHotLeft;
rock.dxHotRightSpot = moyenRocherDxHotRight;
rock.dyHotRightSpot = moyenRocherDyHotRight;
+ rock_sprite = rock.rocher_moyen_sprite;
}
if (size == grosRocher) {
rock.dxHotLeftSpot = grosRocherDxHotLeft;
rock.dyHotLeftSpot = grosRocherDyHotLeft;
rock.dxHotRightSpot = grosRocherDxHotRight;
rock.dyHotRightSpot = grosRocherDyHotRight;
+ rock_sprite = rock.rocher_gros_sprite;
}
rock.totalForce = 0;
rock.sprite.on('down', rock.onClickRocherBuldo.bind(rock, buldos));
- var rock_sprite = rock.rocher_gros_sprite;
game.addChild(rock_sprite);
return rock;
} //fin createSingleRandomRock
function generateRandomRock(nombreRochers) {
@@ -983,23 +995,9 @@
anchorX: 0.5,
anchorY: 0
});
//LK.gui.top.addChild(scoreFictifText);
-//Creation de l'objet coupe de la victoire a partir de l'image coupeVictoire entre les deux scores
-var coupeVictoire = LK.getAsset('coupeVictoire', {
- anchorX: 0,
- anchorY: 0,
- scaleX: 2,
- scaleY: 2,
- x: game.width / 2,
- y: ScoreZone.height / 2
-});
-game.addChild(coupeVictoire);
-// Fonction de rappel pour le tick
-function onGameTick() {
- // Autres mises à jour du jeu ici en cours de test..
-}
-// Instead of directly calling checkMovesStack, iterate over buldos and call checkMovesStack for each
+// Instead of directly calling checkMovesStack, iterate over buldos and call checkMovesStack for each --> already doing this
LK.on('tick', function () {
//Lancement du jeu : choix des rochers a pousser pour l'ordinateur
//Si le camp actif est selectionne (-1, 1), mais que la partie n'a pas encore commence (gameHasStarted = false):
//Pour chaque Buldo du camp non actif, on copie la liste des rochers (rochers) et on la trie par ordre de temps de poussee croissant (timeToReach)
@@ -1104,29 +1102,29 @@
rocher1 = createSingleRandomRock(moyenRocher);
if (rocher1) {
rocher1.sprite.visible = true;
rochers.push(rocher1);
- nbRochers += 1;
+ nbRochersRestants += 1;
}
rocher2 = createSingleRandomRock(petitRocher);
if (rocher2) {
rocher2.sprite.visible = true;
rochers.push(rocher2);
- nbRochers += 1;
+ nbRochersRestants += 1;
}
}
if (taille == moyenRocher) {
rocher1 = createSingleRandomRock(petitRocher);
if (rocher1) {
rocher1.sprite.visible = true;
rochers.push(rocher1);
- nbRochers += 1;
+ nbRochersRestants += 1;
}
rocher2 = createSingleRandomRock(petitRocher);
if (rocher2) {
rocher2.sprite.visible = true;
rochers.push(rocher2);
- nbRochers += 1;
+ nbRochersRestants += 1;
}
}
//On supprime le rocher detruit de la liste des rochers
rocher.destroy();
@@ -1140,9 +1138,10 @@
updateScoreHumain(scoreHumain);
updateScoreOrdi(scoreOrdi);
//updateScoreTest(scoreTest);
//Fin de partie
- if (nbRochers <= 0) {
+ if (nbRochersRestants <= 0) {
+ nbManchesRestantes -= 1;
if (scoreHumain >= scoreOrdi) {
afficheVictoire(humanCamp);
} else {
afficheVictoire(ordiCamp);
@@ -1156,8 +1155,17 @@
}
});
}
if (allBack) {
- LK.showGameOver();
+ if (nbManchesRestantes > 0) {
+ rochers = generateRandomRock(nbRochers);
+ nbRochersRestants = nbRochers;
+ activeCamp = 0;
+ gameHasStarted = false;
+ scoreHumain = 0;
+ scoreOrdi = 0;
+ } else {
+ LK.showGameOver();
+ }
}
}
});
\ 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.