User prompt
Please fix the bug: 'TypeError: LK.showLeaderboard is not a function' in or related to this line: 'LK.showLeaderboard();' Line Number: 59
User prompt
Add a menu before starting the game, with the play and leaderboards buttons
Code edit (11 edits merged)
Please save this source code
User prompt
after 40 points Create obstacle every 30 ticks
User prompt
after 15 points Create obstacle every 36 ticks
Code edit (7 edits merged)
Please save this source code
User prompt
the bird's falling speed increases every 0.5 seconds and starts again when you tap on the screen
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
every 10th obstacle moves at a speed of -10
Code edit (5 edits merged)
Please save this source code
User prompt
obstacles appear every 0.6 seconds
Code edit (1 edits merged)
Please save this source code
User prompt
after five points counter Update score every 2 seconds
User prompt
obstacles appear every 0.8 seconds
User prompt
after 5 points, obstacles begin to smoothly rise and fall attachAsset x,y = 0.3
User prompt
after 5 points, obstacles begin to smoothly rise and fall by 100 pixels
User prompt
add a new object that moves from right to left
User prompt
Add an object obstacle2, similar to obstacle 1, but the movement speed is 2 times higher
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
after clicking on the screen, the bird object is reduced vertically by 10 pixels and returns to its original size again
Code edit (19 edits merged)
Please save this source code
User prompt
after 20 points we begin to create conditions var obstaclesGraphics = self.attachAsset('obstacle', { anchorX: 0.3, anchor: 0.3, shape: ellipse
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -37,14 +37,26 @@
shape: 'ellipse'
});
self.speedX = -5;
self.move = function () {
- // Obstacle moves from right to left
self.x += self.speedX;
- // Rotate obstacle counterclockwise
self.rotation -= 0.11;
};
});
+// Obstacle2 class
+var Obstacle2 = Container.expand(function () {
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ shape: 'ellipse'
+ });
+ self.speedX = -10;
+ self.move = function () {
+ self.x += self.speedX;
+ self.rotation -= 0.11;
+ };
+});
/****
* Initialize Game
****/
@@ -74,9 +86,11 @@
bird.scale.y = 1; // Return bird to original size after 100ms
}, 100);
});
var obstacles = [];
+var obstacles2 = [];
var obstacleCreationCounter = 0;
+var obstacle2CreationCounter = 0;
LK.on('tick', function () {
bird.move();
// Create a new obstacle every 60 ticks (approximately 1 second)
obstacleCreationCounter++;
@@ -86,32 +100,54 @@
newObstacle.y = Math.random() * 2732; // Start at a random height
obstacles.push(newObstacle);
obstacleCreationCounter = 0;
}
+ if (obstacle2CreationCounter >= 60) {
+ var newObstacle2 = game.addChild(new Obstacle2());
+ newObstacle2.x = 2048; // Start at the right edge of the screen
+ newObstacle2.y = Math.random() * 2732; // Start at a random height
+ obstacles2.push(newObstacle2);
+ obstacle2CreationCounter = 0;
+ }
// Move each obstacle and check for collisions
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
obstacle.move();
- // Check if bird has collided with the obstacle
var dx = bird.x - obstacle.x;
var dy = bird.y - obstacle.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < bird.width / 2 + obstacle.width / 2) {
- // Flash screen red for 1 second (1000ms) to show game over.
LK.effects.flashScreen(0xff0000, 1000);
- // Show game over. The game will be automatically paused while game over is showing.
- // Display the final score at the center of the screen
var gameOverScoreTxt = new Text2(score.toString(), {
size: 200,
fill: "#FFFFFF"
});
- gameOverScoreTxt.anchor.set(0.5, 0.5); // Anchor to the center
- gameOverScoreTxt.x = 2048 / 2; // Position at the center of the screen horizontally
- gameOverScoreTxt.y = 2732 / 4; // Position at the center of the screen vertically
+ gameOverScoreTxt.anchor.set(0.5, 0.5);
+ gameOverScoreTxt.x = 2048 / 2;
+ gameOverScoreTxt.y = 2732 / 4;
game.addChild(gameOverScoreTxt);
LK.showGameOver();
}
}
+ for (var i = 0; i < obstacles2.length; i++) {
+ var obstacle2 = obstacles2[i];
+ obstacle2.move();
+ var dx = bird.x - obstacle2.x;
+ var dy = bird.y - obstacle2.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < bird.width / 2 + obstacle2.width / 2) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ var gameOverScoreTxt = new Text2(score.toString(), {
+ size: 200,
+ fill: "#FFFFFF"
+ });
+ gameOverScoreTxt.anchor.set(0.5, 0.5);
+ gameOverScoreTxt.x = 2048 / 2;
+ gameOverScoreTxt.y = 2732 / 4;
+ game.addChild(gameOverScoreTxt);
+ LK.showGameOver();
+ }
+ }
// Check if bird has fallen off the screen or risen above the screen
var dx = bird.x - 2048 / 2;
var dy = bird.y - 2670 / 2;
var distance = Math.sqrt(dx * dx + dy * dy);
голубое небо, горизонт и зеленое поле. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Мультяшный квадратный сюрикен. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
button leaderboards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.