/**** * Classes ****/ // Assets will be automatically created and loaded by the LK engine based on their usage in the code. // Bird class to represent the player character var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.velocity = 0; self.gravity = 0.5; self.lift = -10; self.update = function () { self.velocity += self.gravity; self.y += self.velocity; if (self.y > 2732 - birdGraphics.height / 2) { self.y = 2732 - birdGraphics.height / 2; self.velocity = 0; } if (self.y < birdGraphics.height / 2) { self.y = birdGraphics.height / 2; self.velocity = 0; } }; self.flap = function () { self.velocity = self.lift; }; }); // Pipe class to represent obstacles var Pipe = Container.expand(function () { var self = Container.call(this); var pipeGraphics = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 800 }); self.speed = -5; self.update = function () { self.x += self.speed; if (self.x < -pipeGraphics.width / 2) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ var bird = game.addChild(new Bird()); bird.x = 2048 / 4; bird.y = 2732 / 2; var pipes = []; var pipeInterval = 90; // Interval for pipe generation var ticks = 0; game.down = function (x, y, obj) { bird.flap(); }; game.update = function () { bird.update(); if (ticks % pipeInterval === 0) { var pipe = new Pipe(); pipe.x = 2048 + pipe.width / 2; pipe.y = Math.random() * (2732 - 400) + 200; // Random y position pipes.push(pipe); game.addChild(pipe); } for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].update(); if (pipes[i].intersects(bird)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } if (pipes[i].x < -pipes[i].width / 2) { pipes.splice(i, 1); } } ticks++; };
===================================================================
--- original.js
+++ change.js
@@ -1,86 +1,88 @@
-/****
+/****
* Classes
-****/
+****/
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// Bird class to represent the player character
var Bird = Container.expand(function () {
- var self = Container.call(this);
- var birdGraphics = self.attachAsset('bird', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.velocity = 0;
- self.gravity = 0.5;
- self.lift = -10;
- self.update = function () {
- self.velocity += self.gravity;
- self.y += self.velocity;
- if (self.y > 2732 - birdGraphics.height / 2) {
- self.y = 2732 - birdGraphics.height / 2;
- self.velocity = 0;
- }
- if (self.y < birdGraphics.height / 2) {
- self.y = birdGraphics.height / 2;
- self.velocity = 0;
- }
- };
- self.flap = function () {
- self.velocity = self.lift;
- };
+ var self = Container.call(this);
+ var birdGraphics = self.attachAsset('bird', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocity = 0;
+ self.gravity = 0.5;
+ self.lift = -10;
+ self.update = function () {
+ self.velocity += self.gravity;
+ self.y += self.velocity;
+ if (self.y > 2732 - birdGraphics.height / 2) {
+ self.y = 2732 - birdGraphics.height / 2;
+ self.velocity = 0;
+ }
+ if (self.y < birdGraphics.height / 2) {
+ self.y = birdGraphics.height / 2;
+ self.velocity = 0;
+ }
+ };
+ self.flap = function () {
+ self.velocity = self.lift;
+ };
});
// Pipe class to represent 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();
- }
- };
+ var self = Container.call(this);
+ var pipeGraphics = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 200,
+ height: 800
+ });
+ self.speed = -5;
+ self.update = function () {
+ self.x += self.speed;
+ if (self.x < -pipeGraphics.width / 2) {
+ self.destroy();
+ }
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x87CEEB // Sky blue background
+ backgroundColor: 0x87CEEB // Sky blue background
});
-/****
+/****
* Game Code
-****/
+****/
var bird = game.addChild(new Bird());
bird.x = 2048 / 4;
bird.y = 2732 / 2;
var pipes = [];
var pipeInterval = 90; // Interval for pipe generation
var ticks = 0;
game.down = function (x, y, obj) {
- bird.flap();
+ bird.flap();
};
game.update = function () {
- bird.update();
- if (ticks % pipeInterval === 0) {
- var pipe = new Pipe();
- pipe.x = 2048 + pipe.width / 2;
- pipe.y = Math.random() * (2732 - 400) + 200; // Random y position
- pipes.push(pipe);
- game.addChild(pipe);
- }
- for (var i = pipes.length - 1; i >= 0; i--) {
- pipes[i].update();
- if (pipes[i].intersects(bird)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- if (pipes[i].x < -pipes[i].width / 2) {
- pipes.splice(i, 1);
- }
- }
- ticks++;
+ bird.update();
+ if (ticks % pipeInterval === 0) {
+ var pipe = new Pipe();
+ pipe.x = 2048 + pipe.width / 2;
+ pipe.y = Math.random() * (2732 - 400) + 200; // Random y position
+ pipes.push(pipe);
+ game.addChild(pipe);
+ }
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ pipes[i].update();
+ if (pipes[i].intersects(bird)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ if (pipes[i].x < -pipes[i].width / 2) {
+ pipes.splice(i, 1);
+ }
+ }
+ ticks++;
};
\ No newline at end of file
Flappy Bird Game Single Design Pipe. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Remove Single Text And The Option Of Top Right Side Fill With Another Background
Flappy Bird Realistic Bird. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.