User prompt
Elements after left side screen despawn itself
User prompt
Add particle effect of fire in back of the bird
User prompt
Bg size = gameplay screen
User prompt
Link background with Bg assets
User prompt
Increase spawn rate of pipes
User prompt
Background colour black
Code edit (3 edits merged)
Please save this source code
User prompt
Increase speed
Code edit (1 edits merged)
Please save this source code
Initial prompt
Flappy bird
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Bird class var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.gravity = 0.3; self.lift = -15; self.velocity = 0; self.flap = function () { self.velocity = self.lift; }; self.update = function () { self.velocity += self.gravity; self.y += self.velocity; if (self.y > 2732) { self.y = 2732; self.velocity = 0; LK.showGameOver(); } if (self.y < 0) { self.y = 0; self.velocity = 0; } // Add fire particle effect var fireParticle = new FireParticle(); fireParticle.x = self.x - 50; fireParticle.y = self.y; game.addChild(fireParticle); }; return self; }); // Coin class var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -8; self.update = function () { self.x += self.speed; if (self.x < -coinGraphics.width) { self.destroy(); } }; return self; }); // FireParticle class var FireParticle = Container.expand(function () { var self = Container.call(this); var fireGraphics = self.attachAsset('fireParticle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -5; self.update = function () { self.x += self.speed; self.alpha -= 0.02; if (self.alpha <= 0) { self.destroy(); } }; return self; }); // Pipe class var Pipe = Container.expand(function () { var self = Container.call(this); var pipeGraphics = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -8; self.update = function () { self.x += self.speed; if (self.x < -pipeGraphics.width) { self.destroy(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Black background }); /**** * Game Code ****/ var background = LK.getAsset('Bg', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, width: 2048, height: 2732 }); game.addChild(background); var bird = game.addChild(new Bird()); bird.x = 2048 / 4; bird.y = 2732 / 2; var pipes = []; var coins = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); function spawnPipe() { var gap = 400; var topPipeHeight = Math.random() * (2732 - gap); var bottomPipeHeight = 2732 - topPipeHeight - gap; var topPipe = new Pipe(); topPipe.x = 2048; topPipe.y = topPipeHeight / 2; pipes.push(topPipe); game.addChild(topPipe); var bottomPipe = new Pipe(); bottomPipe.x = 2048; bottomPipe.y = 2732 - bottomPipeHeight / 2; pipes.push(bottomPipe); game.addChild(bottomPipe); } function spawnCoin() { var coin = new Coin(); coin.x = 2048; coin.y = Math.random() * 2732; coins.push(coin); game.addChild(coin); } game.down = function (x, y, obj) { bird.flap(); }; game.update = function () { bird.update(); for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].update(); if (pipes[i].intersects(bird)) { LK.showGameOver(); for (var k = game.children.length - 1; k >= 0; k--) { if (game.children[k] instanceof FireParticle) { game.children[k].update(); } } } if (pipes[i].x < -pipes[i].width) { pipes[i].destroy(); pipes.splice(i, 1); } } for (var j = coins.length - 1; j >= 0; j--) { coins[j].update(); if (coins[j].intersects(bird)) { score += 1; scoreTxt.setText(score); coins[j].destroy(); coins.splice(j, 1); } if (coins[j].x < -coins[j].width) { coins[j].destroy(); coins.splice(j, 1); } } if (LK.ticks % 60 == 0) { spawnPipe(); } if (LK.ticks % 150 == 0) { spawnCoin(); } };
===================================================================
--- original.js
+++ change.js
@@ -146,16 +146,18 @@
for (var i = pipes.length - 1; i >= 0; i--) {
pipes[i].update();
if (pipes[i].intersects(bird)) {
LK.showGameOver();
- // Update fire particles
for (var k = game.children.length - 1; k >= 0; k--) {
if (game.children[k] instanceof FireParticle) {
game.children[k].update();
}
}
}
- ;
+ if (pipes[i].x < -pipes[i].width) {
+ pipes[i].destroy();
+ pipes.splice(i, 1);
+ }
}
for (var j = coins.length - 1; j >= 0; j--) {
coins[j].update();
if (coins[j].intersects(bird)) {
@@ -163,8 +165,12 @@
scoreTxt.setText(score);
coins[j].destroy();
coins.splice(j, 1);
}
+ if (coins[j].x < -coins[j].width) {
+ coins[j].destroy();
+ coins.splice(j, 1);
+ }
}
if (LK.ticks % 60 == 0) {
spawnPipe();
}
Spikes. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Gold coin write I on center of the coin. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A 2d war symmetrical landscape low Polly. Single Game Texture. In-Game asset. 2d. Blank background. No shadows.
Fire partical trail. Single Game Texture. In-Game asset. 2d. Blank background. No shadows.