User prompt
If flappy touch the ground he will out
User prompt
Make score on the upper side and the score will shows number and the number will increasing by time of gameplay
User prompt
Remove stones
User prompt
Spawn stones in random position
User prompt
Decrease the size of flappy 1.5×
User prompt
Increase the size of flappy 3×
User prompt
Remove trees
User prompt
On the upper side make sky
User prompt
Increase size of trees 2×
User prompt
Trees wikl apear on only base
User prompt
Increase size of trees
User prompt
Increase the number of trees increase the size of trees and trees
User prompt
Make trees everywhere
User prompt
Add some trees in background
User prompt
Make some trees
User prompt
The background of game make grass
Initial prompt
Flappy bird
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Flappy class representing the player character var Flappy = Container.expand(function () { var self = Container.call(this); var flappyGraphics = self.attachAsset('flappy', { anchorX: 0.5, anchorY: 0.5 }); self.gravity = 0.5; self.lift = -10; self.velocity = 0; self.jump = function () { self.velocity = self.lift; }; self.update = function () { self.velocity += self.gravity; self.y += self.velocity; if (self.y > 2732 - flappyGraphics.height / 2) { self.y = 2732 - flappyGraphics.height / 2; self.velocity = 0; } if (self.y < flappyGraphics.height / 2) { self.y = flappyGraphics.height / 2; self.velocity = 0; } }; }); // Pipe class representing the obstacles var Pipe = Container.expand(function () { var self = Container.call(this); var pipeGraphics = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -5; self.update = function () { self.x += self.speed; if (self.x < -pipeGraphics.width / 2) { self.destroy(); } }; }); // Tree class representing the trees var Tree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.attachAsset('tree', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -2; // Set tree speed to move left self.update = function () { self.x += self.speed; if (self.x < -treeGraphics.width / 2) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 // Init game with grass green background }); /**** * Game Code ****/ var flappy = game.addChild(new Flappy()); flappy.x = 2048 / 4; flappy.y = 2732 / 2; var pipes = []; var trees = []; var treeInterval = 300; var pipeInterval = 90; var frameCount = 0; game.down = function (x, y, obj) { flappy.jump(); }; game.update = function () { frameCount++; if (frameCount % pipeInterval === 0) { var pipeTop = new Pipe(); var pipeBottom = new Pipe(); var pipeGap = 400; var pipeHeight = Math.random() * (2732 - pipeGap - 200) + 100; pipeTop.x = 2048; pipeTop.y = pipeHeight / 2; pipeBottom.x = 2048; pipeBottom.y = pipeHeight + pipeGap + pipeHeight / 2; pipes.push(pipeTop); pipes.push(pipeBottom); game.addChild(pipeTop); game.addChild(pipeBottom); } if (frameCount % treeInterval === 0) { var tree = new Tree(); tree.x = Math.random() * 2048; // Random x position tree.y = Math.random() * 2732; // Random y position trees.push(tree); game.addChild(tree); } for (var i = trees.length - 1; i >= 0; i--) { trees[i].update(); } for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].update(); if (pipes[i].intersects(flappy)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } for (var i = trees.length - 1; i >= 0; i--) { trees[i].update(); } flappy.update(); };
===================================================================
--- original.js
+++ change.js
@@ -49,8 +49,9 @@
var treeGraphics = self.attachAsset('tree', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.speed = -2; // Set tree speed to move left
self.update = function () {
self.x += self.speed;
if (self.x < -treeGraphics.width / 2) {
self.destroy();
@@ -74,9 +75,8 @@
var pipes = [];
var trees = [];
var treeInterval = 300;
var pipeInterval = 90;
-var treeInterval = 300;
var frameCount = 0;
game.down = function (x, y, obj) {
flappy.jump();
};
@@ -97,10 +97,10 @@
game.addChild(pipeBottom);
}
if (frameCount % treeInterval === 0) {
var tree = new Tree();
- tree.x = 2048;
- tree.y = 2732 - 200; // Position tree at the bottom of the screen
+ tree.x = Math.random() * 2048; // Random x position
+ tree.y = Math.random() * 2732; // Random y position
trees.push(tree);
game.addChild(tree);
}
for (var i = trees.length - 1; i >= 0; i--) {