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
Code edit (4 edits merged)
Please save this source code
User prompt
intersection of bird objects and obstacles within the radius of the image, not the object
Code edit (1 edits merged)
Please save this source code
User prompt
death when colliding with an obstacle only in the center of the obstacle object
User prompt
change obstacle object from square to circle
User prompt
reduce the distance between a bird colliding with an obstacle by 100
Code edit (1 edits merged)
Please save this source code
User prompt
radius 25 object obstacle for contact with bird
===================================================================
--- original.js
+++ change.js
@@ -36,18 +36,13 @@
anchorY: 0.5,
shape: 'ellipse'
});
self.speedX = -5;
- self.originalY = self.y; // Track the original y position
self.move = function () {
// Obstacle moves from right to left
self.x += self.speedX;
// Rotate obstacle counterclockwise
self.rotation -= 0.11;
- // After 5 points, obstacles begin to smoothly rise and fall by 100 pixels
- if (score > 5) {
- self.y = self.originalY + 100 * Math.sin(LK.ticks / 60); // 60 ticks is approximately 1 second
- }
};
});
/****
@@ -80,8 +75,9 @@
}, 100);
});
var obstacles = [];
var obstacleCreationCounter = 0;
+var score = 0; // Add a variable to track the player's score
LK.on('tick', function () {
bird.move();
// Create a new obstacle every 60 ticks (approximately 1 second)
obstacleCreationCounter++;
@@ -91,12 +87,24 @@
newObstacle.y = Math.random() * 2732; // Start at a random height
obstacles.push(newObstacle);
obstacleCreationCounter = 0;
}
+ // If the player's score is 5 or more, make the obstacles move up and down
+ if (score >= 5) {
+ for (var i = 0; i < obstacles.length; i++) {
+ var obstacle = obstacles[i];
+ obstacle.y += Math.sin(obstacle.x * 0.01) * 5; // Change the y position of the obstacle based on a sine wave
+ }
+ }
// 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 passed the obstacle
+ if (bird.x > obstacle.x + obstacle.width / 2 && !obstacle.passed) {
+ score++; // Increase the player's score
+ obstacle.passed = true; // Mark the obstacle as passed so the score is only increased once per obstacle
+ }
// 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);
@@ -153,12 +161,5 @@
// Update score every 2 seconds
LK.setInterval(function () {
score++;
scoreTxt.setText(score.toString());
- // After 5 points, obstacles begin to smoothly rise and fall by 100 pixels
- if (score > 5) {
- for (var i = 0; i < obstacles.length; i++) {
- var obstacle = obstacles[i];
- obstacle.y += 100 * Math.sin(LK.ticks / 60); // 60 ticks is approximately 1 second
- }
- }
}, 1500);
\ No newline at end of file
голубое небо, горизонт и зеленое поле. 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.