User prompt
Please fix the bug: 'TypeError: LK.showLeaderboard is not a function' in or related to this line: 'LK.showLeaderboard();' Line Number: 187
Code edit (4 edits merged)
Please save this source code
User prompt
add leaderboard in the gameover screen
User prompt
remove leaderboard button
User prompt
place the leaderboard button to the top right
User prompt
add a button to show leaderboard
User prompt
acorn give 10 points
User prompt
increase score by 1 point each seconds
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: treeTrunk is not defined' in or related to this line: 'treeTrunk.x = 2048 / 2;' Line Number: 120
Code edit (1 edits merged)
Please save this source code
User prompt
the score displayed should be updated when the score change
===================================================================
--- original.js
+++ change.js
@@ -91,8 +91,12 @@
/****
* Game Code
****/
// Create static platforms
+var scoreTimer = LK.setInterval(function () {
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+}, 1000);
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
@@ -109,9 +113,9 @@
var treeTrunks = [];
for (var i = 0; i < 3; ++i) {
var treeTrunk = game.addChild(new TreeTrunk());
treeTrunk.x = 2048 / 2;
- treeTrunk.y = i * treeTrunk.height;
+ treeTrunk.y = i * -treeTrunk.height;
treeTrunks.push(treeTrunk);
}
for (var i = 0; i < nbPlatform; i++) {
var platform = new Obstacle();
@@ -155,9 +159,9 @@
obstacles[i].y = obstacles[lastPlatformSpawned].height - gap;
obstacles[i].x = Math.random() * (2048 - obstacles[i].width);
obstacles[i].width = (Math.random() * (0.3 - 0.1) + 0.1) * 2048;
if (platformSpeed < 20) {
- platformSpeed += 1;
+ platformSpeed += 0.1;
}
lastPlatformSpawned = i;
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].speedY = platformSpeed;
@@ -165,8 +169,11 @@
}
}
for (var i = 0; i < 3; ++i) {
treeTrunks[i].update();
+ if (treeTrunks[i].y > 2732) {
+ treeTrunks[i].y = treeTrunks[(i + 2 + treeTrunks.length) % treeTrunks.length].y - treeTrunk.height;
+ }
}
// Game over when hero touches bottom of the screen
if (hero.y >= 2732 - hero.height) {
LK.showGameOver();
a little squirrel with sun glasses and earring. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d flat leaf green horizontal platform. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
acorn. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.