===================================================================
--- original.js
+++ change.js
@@ -94,8 +94,17 @@
font: "Digital-7, 'Courier New', Courier, monospace"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
+var highestScore = 0;
+var highestScoreTxt = new Text2('Highest: 0', {
+ size: 100,
+ fill: "#000000",
+ font: "Digital-7, 'Courier New', Courier, monospace"
+});
+highestScoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(highestScoreTxt);
+highestScoreTxt.y = scoreTxt.height; // Position below the current score
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = 2048 + obstacle.width / 2;
obstacle.y = obstacle.height / 2;
@@ -123,8 +132,12 @@
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].update();
if (bird.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
+ if (score > highestScore) {
+ highestScore = score;
+ highestScoreTxt.setText('Highest: ' + highestScore);
+ }
LK.showGameOver();
}
}
for (var j = coins.length - 1; j >= 0; j--) {
@@ -136,8 +149,14 @@
coins[j].destroy();
coins.splice(j, 1);
if (score >= 100) {
LK.effects.flashScreen(0xff0000, 1000);
+ if (score > highestScore) {
+ highestScore = score;
+ highestScoreTxt.setText('Highest: ' + highestScore);
+ }
+ score = 0;
+ scoreTxt.setText(score);
LK.showGameOver();
}
}
}