/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
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.8;
self.flapStrength = -15;
self.maxFallSpeed = 12;
self.flap = function () {
self.velocity = self.flapStrength;
LK.getSound('flap').play();
// Add flap animation
birdGraphics.rotation = -0.3;
tween(birdGraphics, {
rotation: 0.3
}, {
duration: 200
});
};
self.update = function () {
// Apply gravity
self.velocity += self.gravity;
// Limit fall speed
if (self.velocity > self.maxFallSpeed) {
self.velocity = self.maxFallSpeed;
}
// Update position
self.y += self.velocity;
// Check ground collision
if (self.y >= 2732 - 100 - 30) {
// Ground height minus bird radius
gameOver = true;
}
// Check ceiling collision
if (self.y <= 30) {
// Bird radius
self.y = 30;
self.velocity = 0;
}
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
self.passed = false;
// Create top pipe
var topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
// Create bottom pipe
var bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
self.setGap = function (gapY, gapSize) {
// Position top pipe to cover from top of screen down to gap start
topPipe.y = gapY - gapSize / 2;
topPipe.height = gapY - gapSize / 2;
// Position bottom pipe to cover from gap end to ground level
bottomPipe.y = gapY + gapSize / 2;
bottomPipe.height = 2732 - 100 - (gapY + gapSize / 2); // Screen height minus ground height minus gap end
// Ensure pipes fully cover their respective areas
if (topPipe.height < 0) topPipe.height = 0;
if (bottomPipe.height < 0) bottomPipe.height = 0;
};
self.checkCollision = function (bird) {
var birdBounds = {
left: bird.x - 30,
right: bird.x + 30,
top: bird.y - 22,
bottom: bird.y + 22
};
var pipeBounds = {
left: self.x - 60,
right: self.x + 60
};
// Check if bird is horizontally aligned with pipe
if (birdBounds.right > pipeBounds.left && birdBounds.left < pipeBounds.right) {
// Check collision with top pipe (covers from top to gap start)
if (birdBounds.top < topPipe.height) {
return true;
}
// Check collision with bottom pipe (covers from gap end to ground)
if (birdBounds.bottom > bottomPipe.y) {
return true;
}
}
return false;
};
self.update = function () {
self.x += self.speed;
// Check if bird passed this pipe
if (!self.passed && bird.x > self.x + 60) {
self.passed = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('score').play();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var bird;
var pipes = [];
var ground;
var scoreTxt;
var gameOver = false;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 270; // Spawn pipe every 4.5 seconds at 60fps
var gapSize = 400;
// Create background
var background = game.attachAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
scaleX: 20.48,
// Scale to cover full width (2048px)
scaleY: 27.32 // Scale to cover full height (2732px)
});
// Create bird
bird = game.addChild(new Bird());
bird.x = 400;
bird.y = 1366; // Middle of screen
// Create ground
ground = game.attachAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2732 - 100
});
// Create score display
scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Position score away from top-left menu
scoreTxt.x = 0;
scoreTxt.y = 50;
// Play Recep Tayyip Erdogan music in background
LK.playMusic('recep_tayyip_erdogan');
// Game input handler
game.down = function (x, y, obj) {
if (!gameOver) {
bird.flap();
}
};
// Spawn initial pipes
function spawnPipe() {
var pipe = new Pipe();
pipe.x = 2048 + 60; // Start off-screen right
// Random gap position (avoid too high or too low)
var gapY = 300 + Math.random() * (2732 - 400 - gapSize);
pipe.setGap(gapY, gapSize);
pipes.push(pipe);
game.addChild(pipe);
}
// Main game update
game.update = function () {
if (gameOver) {
LK.showGameOver();
return;
}
// Spawn pipes at intervals
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Update pipes and check collisions
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
// Check collision with bird
if (pipe.checkCollision(bird)) {
gameOver = true;
continue;
}
// Remove pipes that are off-screen
if (pipe.x < -120) {
pipe.destroy();
pipes.splice(i, 1);
}
}
// Gradually increase difficulty
if (LK.getScore() > 0 && LK.getScore() % 5 === 0) {
// Increase pipe speed slightly every 5 points
var speedIncrease = Math.min(LK.getScore() / 10, 2);
for (var j = 0; j < pipes.length; j++) {
pipes[j].speed = -4 - speedIncrease;
}
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
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.8;
self.flapStrength = -15;
self.maxFallSpeed = 12;
self.flap = function () {
self.velocity = self.flapStrength;
LK.getSound('flap').play();
// Add flap animation
birdGraphics.rotation = -0.3;
tween(birdGraphics, {
rotation: 0.3
}, {
duration: 200
});
};
self.update = function () {
// Apply gravity
self.velocity += self.gravity;
// Limit fall speed
if (self.velocity > self.maxFallSpeed) {
self.velocity = self.maxFallSpeed;
}
// Update position
self.y += self.velocity;
// Check ground collision
if (self.y >= 2732 - 100 - 30) {
// Ground height minus bird radius
gameOver = true;
}
// Check ceiling collision
if (self.y <= 30) {
// Bird radius
self.y = 30;
self.velocity = 0;
}
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
self.passed = false;
// Create top pipe
var topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
// Create bottom pipe
var bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
self.setGap = function (gapY, gapSize) {
// Position top pipe to cover from top of screen down to gap start
topPipe.y = gapY - gapSize / 2;
topPipe.height = gapY - gapSize / 2;
// Position bottom pipe to cover from gap end to ground level
bottomPipe.y = gapY + gapSize / 2;
bottomPipe.height = 2732 - 100 - (gapY + gapSize / 2); // Screen height minus ground height minus gap end
// Ensure pipes fully cover their respective areas
if (topPipe.height < 0) topPipe.height = 0;
if (bottomPipe.height < 0) bottomPipe.height = 0;
};
self.checkCollision = function (bird) {
var birdBounds = {
left: bird.x - 30,
right: bird.x + 30,
top: bird.y - 22,
bottom: bird.y + 22
};
var pipeBounds = {
left: self.x - 60,
right: self.x + 60
};
// Check if bird is horizontally aligned with pipe
if (birdBounds.right > pipeBounds.left && birdBounds.left < pipeBounds.right) {
// Check collision with top pipe (covers from top to gap start)
if (birdBounds.top < topPipe.height) {
return true;
}
// Check collision with bottom pipe (covers from gap end to ground)
if (birdBounds.bottom > bottomPipe.y) {
return true;
}
}
return false;
};
self.update = function () {
self.x += self.speed;
// Check if bird passed this pipe
if (!self.passed && bird.x > self.x + 60) {
self.passed = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('score').play();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var bird;
var pipes = [];
var ground;
var scoreTxt;
var gameOver = false;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 270; // Spawn pipe every 4.5 seconds at 60fps
var gapSize = 400;
// Create background
var background = game.attachAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
scaleX: 20.48,
// Scale to cover full width (2048px)
scaleY: 27.32 // Scale to cover full height (2732px)
});
// Create bird
bird = game.addChild(new Bird());
bird.x = 400;
bird.y = 1366; // Middle of screen
// Create ground
ground = game.attachAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2732 - 100
});
// Create score display
scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Position score away from top-left menu
scoreTxt.x = 0;
scoreTxt.y = 50;
// Play Recep Tayyip Erdogan music in background
LK.playMusic('recep_tayyip_erdogan');
// Game input handler
game.down = function (x, y, obj) {
if (!gameOver) {
bird.flap();
}
};
// Spawn initial pipes
function spawnPipe() {
var pipe = new Pipe();
pipe.x = 2048 + 60; // Start off-screen right
// Random gap position (avoid too high or too low)
var gapY = 300 + Math.random() * (2732 - 400 - gapSize);
pipe.setGap(gapY, gapSize);
pipes.push(pipe);
game.addChild(pipe);
}
// Main game update
game.update = function () {
if (gameOver) {
LK.showGameOver();
return;
}
// Spawn pipes at intervals
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Update pipes and check collisions
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
// Check collision with bird
if (pipe.checkCollision(bird)) {
gameOver = true;
continue;
}
// Remove pipes that are off-screen
if (pipe.x < -120) {
pipe.destroy();
pipes.splice(i, 1);
}
}
// Gradually increase difficulty
if (LK.getScore() > 0 && LK.getScore() % 5 === 0) {
// Increase pipe speed slightly every 5 points
var speedIncrease = Math.min(LK.getScore() / 10, 2);
for (var j = 0; j < pipes.length; j++) {
pipes[j].speed = -4 - speedIncrease;
}
}
};