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
User prompt
Please fix the bug: 'ReferenceError: scoreText is not defined' in or related to this line: 'if (scoreText) {' Line Number: 169
Code edit (1 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: 169
Code edit (1 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: 172
Code edit (7 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: 178
User prompt
Please fix the bug: 'ReferenceError: scoreText is not defined' in or related to this line: 'scoreText.setText(nouveauScore);' Line Number: 173
User prompt
Please fix the bug: 'ReferenceError: scoreText is not defined' in or related to this line: 'scoreText.setText(nouveauScore);' Line Number: 172
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: startPoints is not defined' in or related to this line: 'var randomIndex = Math.floor(Math.random() * startPoints.length);' Line Number: 86
Code edit (1 edits merged)
Please save this source code
Initial prompt
Coco Monkey
===================================================================
--- original.js
+++ change.js
@@ -103,8 +103,40 @@
parasol.x = 2048 / 2;
parasol.y = 2500;
var coconuts = [];
var score = 0;
+var scoreTest = 0;
+var scoreTxt;
+/****
+* Game zones and backgrounds
+****/
+var ScoreZone = {
+ x: 0,
+ y: 0,
+ width: game.width,
+ height: 200 * game.height / 2732
+};
+var MainZone = {
+ x: 0,
+ y: ScoreZone.height,
+ width: game.width,
+ height: game.height - 2 * ScoreZone.height
+};
+var OptionsZone = {
+ x: 0,
+ y: game.height - ScoreZone.height,
+ width: game.width,
+ height: 200 * game.height / 2732
+};
+/****
+* Score
+****/
+var scoreTestText = new Text2('0', {
+ size: 30,
+ fill: "#000000",
+ anchorX: 0.5,
+ anchorY: 0
+});
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
@@ -119,9 +151,29 @@
parasol.y = y;
};
// Define the startPoints array
var startPoints = [2048 / 4, 2048 / 2, 2048 / 4 * 3];
+/****
+* Functions
+****/
+function updateScoreTest(nouveauScore) {
+ scoreTestText.setText(nouveauScore);
+} //fin updateScoreTest
+function updateScore(nouveauScore) {
+ if (nouveauScore < 0) {
+ nouveauScore = 0;
+ score = 0;
+ }
+ scoreText.setText(nouveauScore);
+} //fin updateScore
+/****
+* Main loop
+****/
game.update = function () {
+ //Mise à jour score
+ //updateScoreTest(scoreTest);
+ updateScore(score);
+ //Autres actions à effectuer sans urgence
if (LK.ticks % 60 == 0) {
var newCoconut = new Coconut();
// Choisir aléatoirement un point de départ
var randomIndex = Math.floor(Math.random() * startPoints.length);
@@ -132,9 +184,9 @@
}
for (var i = coconuts.length - 1; i >= 0; i--) {
if (coconuts[i].intersects(parasol)) {
score += 1;
- scoreTxt.setText(score);
+ //scoreTxt.setText(score);
coconuts[i].destroy();
coconuts.splice(i, 1);
} else if (coconuts[i].y > 2732) {
LK.effects.flashScreen(0xff0000, 1000);