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 (19 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: coconut is not defined' in or related to this line: 'scoreTest = "Zone contact = " + zoneIntersectParasol(coconut[i]);' Line Number: 434
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: livesLeftGraphics[i] is undefined' in or related to this line: 'livesLeftGraphics[i].destroy();' Line Number: 264
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: Sprite is not a constructor' in or related to this line: 'var newLife = new Sprite('life');' Line Number: 267
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: scor is not defined' in or related to this line: 'scor += 1;' Line Number: 120
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: OptionsZone is undefined' in or related to this line: 'parasol.y = OptionsZone.y - 400;' Line Number: 189
Code edit (1 edits merged)
Please save this source code
Code edit (23 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: abs is not defined' in or related to this line: 'var deltaX = abs(coconuts[i].x - coconuts[i].X1);' Line Number: 307
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: 'ReferenceError: scoreText is not defined' in or related to this line: 'scoreText.setText(nouveauScore);' Line Number: 214
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -110,9 +110,9 @@
//if (self.x < self.X2) {
score += 1;
self.x += self.distPerTick;
self.y = self.a * (self.x - self.X1) * (self.x - self.X2) + self.Y0;
- scoreTest = "x= " + self.x + " y= " + self.y + " a= " + self.a + " distPerTick= " + self.distPerTick;
+ //scoreTest = "x= " + self.x + " y= " + self.y + " a= " + self.a + " distPerTick= " + self.distPerTick;
}
}; //fin updateParabol
});
@@ -127,8 +127,11 @@
/****
* Game Code
****/
/****
+* Game zones and backgrounds
+****/
+/****
* GAME DESCRIPTION:
* Game Principle:
* NAME: COCO MONKEY V1.0 by Dalhem 2024
* -There is beach where people are enjoying the sun by the shadow of palm trees.
@@ -172,11 +175,8 @@
* The left zone: the coconut will bounce to the extrem left.
* The center zone: the coconut will randomly bounce to the left or to the right.
* The right zone: the coconut will bounce to the extrem right.
****/
-/****
-* Game zones and backgrounds
-****/
var ScoreZone = {
x: 0,
y: 0,
width: game.width,
@@ -247,19 +247,29 @@
scoreTxt.setText(nouveauScore);
} //fin updateScore
function setLivesLeft() {
//Affiche le nombre de vies restantes (sprite 'life' ) dans le coin supérieur gauche
+ scoreTest = "Nb de coeurs restants : " + livesLeftGraphics.length + " / Nb de vies restantes : " + livesLeft;
//Commence par effacer les vies restantes s'il y en a
- for (var i = 0; livesLeftGraphics.length; i++) {
- game.removeChild(livesLeftGraphics[i]);
+ for (var i = 0; i < livesLeftGraphics.length; i++) {
+ if (livesLeftGraphics[i]) {
+ game.removeChild(livesLeftGraphics[i]);
+ livesLeftGraphics[i].destroy();
+ livesLeftGraphics.splice(i, 1);
+ }
}
//Crée des sprites 'life' si nécessaire (si livesLeft > livesLeftGraphics.length)
if (livesLeft > livesLeftGraphics.length) {
for (var i = livesLeftGraphics.length; i < livesLeft; i++) {
- var newLife = LK.getAsset('life', {});
- newLife.x = 100 * i;
- newLife.y = 0;
- livesLeftGraphics.push(newLife);
+ var lifeGraphics = LK.getAsset('life', {
+ anchorX: 0.5,
+ anchorY: 0,
+ scaleX: 1,
+ scaleY: 1,
+ x: ScoreZone.x + 100 + 100 * i,
+ y: ScoreZone.y + 100
+ });
+ livesLeftGraphics.push(lifeGraphics);
}
}
//Affiche les sprites 'life' dans le coin supérieur gauche
for (var i = 0; i < livesLeft; i++) {
@@ -287,15 +297,15 @@
* Main loop
****/
game.update = function () {
//Mise à jour score
- scoreTest = livesLeft;
+ //scoreTest = livesLeft;
updateScoreTest(scoreTest);
updateScore(score);
//Autres actions à effectuer sans urgence
if (LK.ticks % 60 == 0) {
//Afficher les coeurs
- //setLivesLeft();
+ setLivesLeft();
// Créer un nouveau coco
if (coconuts.length < nombreCoconuts) {
var newCoconut = chooseNextStartPoint();
game.addChild(newCoconut);
@@ -306,9 +316,9 @@
if (coconuts[i].intersects(parasol) && (coconuts[i].isFalling || coconuts[i].isBouncing)) {
score += 1;
coconuts[i].isFalling = false;
var deltaX = Math.abs(coconuts[i].x - XL);
- coconuts[i].trajectory.setParameters(1, coconuts[i].x, XC - deltaX, coconuts[i].y, ScoreZone.height + 200, 500);
+ coconuts[i].trajectory.setParameters(1, coconuts[i].x, XC - deltaX, coconuts[i].y, ScoreZone.height + 200, 1000);
coconuts[i].isBouncing = true;
}
}
//Mise à jour des coconuts bouncing