/****
* Classes
****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins 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.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
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();
}
};
});
/****
* 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 score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
function spawnPipe() {
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);
}
game.down = function (x, y, obj) {
bird.flap();
};
game.update = function () {
bird.update();
if (bird.y >= 2732 - bird.height / 2) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver('Chodu Noob');
} else {
for (var i = pipes.length - 1; i >= 0; i--) {
pipes[i].update();
if (pipes[i].intersects(bird)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.getSound('gameover').play();
LK.showGameOver('Chodu Noob');
}
if (pipes[i].x < bird.x && !pipes[i].passed) {
pipes[i].passed = true;
score++;
scoreTxt.setText(score);
}
}
if (LK.ticks % 90 == 0) {
spawnPipe();
}
}
};
A Proper Bird not A Circle Or Rectangle (And The Bird Should Be In Pixelart) Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A Green Pipe Of Flappy Bird, instead Of The Squares, I Need A Single Straight Pipe (pipe should be single Single. I Need Horizontal Pipes Not Vertical.Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.