===================================================================
--- original.js
+++ change.js
@@ -27,8 +27,20 @@
self.velocity = 0;
}
};
});
+// Cloud class
+var Cloud = Container.expand(function () {
+ var self = Container.call(this);
+ var cloudGraphics = self.attachAsset('cloud', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -2;
+ self.move = function () {
+ self.x += self.speed;
+ };
+});
// Pipe class
var Pipe = Container.expand(function (isTop, height) {
var self = Container.call(this);
var pipeGraphics = self.attachAsset(isTop ? 'pipeTop' : 'pipeBottom', {
@@ -60,8 +72,17 @@
bird.x = 2048 / 4;
bird.y = 2732 / 2;
game.addChild(bird);
}
+// Initialize clouds
+var clouds = [];
+for (var i = 0; i < 5; i++) {
+ var cloud = new Cloud();
+ cloud.x = Math.random() * 2048;
+ cloud.y = Math.random() * 2732;
+ clouds.push(cloud);
+ game.addChild(cloud);
+}
// Function to add pipes
function addPipe() {
var topPipeHeight = Math.floor(Math.random() * (2732 - gap)) + 100; // Random height for top pipe
var bottomPipeHeight = 2732 - topPipeHeight - gap;
@@ -116,5 +137,13 @@
}
bird.update();
updatePipes();
checkCollision();
+ // Update clouds
+ for (var i = clouds.length - 1; i >= 0; i--) {
+ clouds[i].move();
+ if (clouds[i].x < -200) {
+ clouds[i].x = 2048;
+ clouds[i].y = Math.random() * 2732;
+ }
+ }
});
\ No newline at end of file
A yellow bird. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A green pipe facing upwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Clouds. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.