/**** 
* 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.flapPower = -12;
	self.maxFallSpeed = 12;
	self.rotation = 0;
	self.flap = function () {
		self.velocity = self.flapPower;
		LK.getSound('flap').play();
		// Animate bird rotation for flap effect
		tween(birdGraphics, {
			rotation: -0.3
		}, {
			duration: 100
		});
		tween(birdGraphics, {
			rotation: 0
		}, {
			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;
		// Rotate bird based on velocity
		if (self.velocity > 0) {
			birdGraphics.rotation = Math.min(self.velocity * 0.1, 1.2);
		} else {
			birdGraphics.rotation = Math.max(self.velocity * 0.05, -0.5);
		}
	};
	return self;
});
var Coin = Container.expand(function () {
	var self = Container.call(this);
	self.speed = -4;
	self.collected = false;
	var coinGraphics = self.attachAsset('coin', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Add rotation animation for visual appeal
	self.rotationSpeed = 0.1;
	self.update = function () {
		self.x += self.speed;
		// Rotate coin for visual effect
		coinGraphics.rotation += self.rotationSpeed;
	};
	return self;
});
var Ground = Container.expand(function () {
	var self = Container.call(this);
	var groundGraphics = self.attachAsset('ground', {
		anchorX: 0,
		anchorY: 0
	});
	return self;
});
var Particle = Container.expand(function () {
	var self = Container.call(this);
	var particleGraphics = self.attachAsset('particle', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.velocityX = (Math.random() - 0.5) * 8;
	self.velocityY = (Math.random() - 0.5) * 8;
	self.life = 60; // 1 second at 60fps
	self.maxLife = 60;
	self.update = function () {
		self.x += self.velocityX;
		self.y += self.velocityY;
		self.life--;
		// Fade out over time
		particleGraphics.alpha = self.life / self.maxLife;
	};
	return self;
});
var Pipe = Container.expand(function () {
	var self = Container.call(this);
	self.speed = -4;
	self.gapSize = 1000;
	self.scored = false;
	// Create top pipe
	self.topPipe = self.attachAsset('pipe', {
		anchorX: 0.5,
		anchorY: 1
	});
	// Create bottom pipe
	self.bottomPipe = self.attachAsset('pipe', {
		anchorX: 0.5,
		anchorY: 0
	});
	self.setGapPosition = function (centerY) {
		self.topPipe.y = centerY - self.gapSize / 2;
		self.bottomPipe.y = centerY + self.gapSize / 2;
	};
	self.update = function () {
		self.x += self.speed;
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB
});
/**** 
* Game Code
****/ 
// Game variables
var bird;
var pipes = [];
var coins = [];
var particles = [];
var ground;
var gameStarted = false;
var gameOver = false;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 90; // 90 ticks = 1.5 seconds at 60fps
// Create particle effect function
function createParticleEffect(x, y, count) {
	for (var k = 0; k < count; k++) {
		var particle = game.addChild(new Particle());
		particle.x = x;
		particle.y = y;
		particles.push(particle);
	}
}
// Score display
var scoreTxt = new Text2('0', {
	size: 100,
	fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
// Instructions text
var instructionTxt = new Text2('TAP TO FLAP', {
	size: 80,
	fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
game.addChild(instructionTxt);
instructionTxt.x = 2048 / 2;
instructionTxt.y = 2732 / 2 - 200;
// Initialize bird
bird = game.addChild(new Bird());
bird.x = 400;
bird.y = 2732 / 2;
// Initialize ground
ground = game.addChild(new Ground());
ground.x = 0;
ground.y = 2732 - 150;
// Touch/tap controls
game.down = function (x, y, obj) {
	if (!gameStarted) {
		gameStarted = true;
		instructionTxt.visible = false;
	}
	if (!gameOver) {
		bird.flap();
	}
};
// Spawn pipe function
function spawnPipe() {
	var pipe = game.addChild(new Pipe());
	pipe.x = 2048 + 90; // Start off screen
	// Random gap position (avoid too high or too low)
	var minY = 300;
	var maxY = 2732 - 450; // Account for ground height
	var gapCenterY = minY + Math.random() * (maxY - minY);
	pipe.setGapPosition(gapCenterY);
	pipes.push(pipe);
	// Spawn coin in the center of the pipe gap
	var coin = game.addChild(new Coin());
	coin.x = pipe.x;
	coin.y = gapCenterY;
	coins.push(coin);
}
// Check collision between bird and pipe
function checkPipeCollision(bird, pipe) {
	var birdBounds = {
		left: bird.x - 30,
		right: bird.x + 30,
		top: bird.y - 22,
		bottom: bird.y + 22
	};
	var pipeBounds = {
		left: pipe.x - 90,
		right: pipe.x + 90,
		topPipeBottom: pipe.topPipe.y,
		bottomPipeTop: pipe.bottomPipe.y
	};
	// Check if bird is within pipe x bounds
	if (birdBounds.right > pipeBounds.left && birdBounds.left < pipeBounds.right) {
		// Check if bird hits top or bottom pipe
		if (birdBounds.top < pipeBounds.topPipeBottom || birdBounds.bottom > pipeBounds.bottomPipeTop) {
			return true;
		}
	}
	return false;
}
// Main game update loop
game.update = function () {
	if (!gameStarted || gameOver) {
		return;
	}
	// Update bird
	bird.update();
	// Check ground collision
	if (bird.y + 22 >= ground.y || bird.y - 22 <= 0) {
		gameOver = true;
		LK.getSound('hit').play();
		// Add screen flash and particles for ground collision
		LK.effects.flashScreen(0xFF0000, 500);
		createParticleEffect(bird.x, bird.y, 10);
		LK.showGameOver();
		return;
	}
	// Spawn pipes
	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];
		pipe.update();
		// Check collision
		if (checkPipeCollision(bird, pipe)) {
			gameOver = true;
			LK.getSound('hit').play();
			// Add screen shake effect
			LK.effects.flashScreen(0xFF0000, 500);
			// Create impact particles
			createParticleEffect(bird.x, bird.y, 12);
			LK.showGameOver();
			return;
		}
		// Check scoring (bird passed through pipe)
		if (!pipe.scored && bird.x > pipe.x + 90) {
			pipe.scored = true;
			LK.setScore(LK.getScore() + 1);
			scoreTxt.setText(LK.getScore());
			LK.getSound('score').play();
		}
		// Remove pipes that are off screen
		if (pipe.x < -180) {
			pipe.destroy();
			pipes.splice(i, 1);
		}
	}
	// Update coins and check collection
	for (var j = coins.length - 1; j >= 0; j--) {
		var coin = coins[j];
		coin.update();
		// Check if bird collected the coin
		if (!coin.collected && bird.intersects(coin)) {
			coin.collected = true;
			LK.setScore(LK.getScore() + 1);
			scoreTxt.setText(LK.getScore());
			LK.getSound('coin').play();
			// Create particle effect at coin position
			createParticleEffect(coin.x, coin.y, 8);
			// Flash coin collection feedback
			LK.effects.flashObject(scoreTxt, 0xFFD700, 300);
			coin.destroy();
			coins.splice(j, 1);
			continue;
		}
		// Remove coins that are off screen
		if (coin.x < -120) {
			coin.destroy();
			coins.splice(j, 1);
		}
	}
	// Update particles
	for (var p = particles.length - 1; p >= 0; p--) {
		var particle = particles[p];
		particle.update();
		// Remove particles when their life expires
		if (particle.life <= 0) {
			particle.destroy();
			particles.splice(p, 1);
		}
	}
}; /**** 
* 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.flapPower = -12;
	self.maxFallSpeed = 12;
	self.rotation = 0;
	self.flap = function () {
		self.velocity = self.flapPower;
		LK.getSound('flap').play();
		// Animate bird rotation for flap effect
		tween(birdGraphics, {
			rotation: -0.3
		}, {
			duration: 100
		});
		tween(birdGraphics, {
			rotation: 0
		}, {
			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;
		// Rotate bird based on velocity
		if (self.velocity > 0) {
			birdGraphics.rotation = Math.min(self.velocity * 0.1, 1.2);
		} else {
			birdGraphics.rotation = Math.max(self.velocity * 0.05, -0.5);
		}
	};
	return self;
});
var Coin = Container.expand(function () {
	var self = Container.call(this);
	self.speed = -4;
	self.collected = false;
	var coinGraphics = self.attachAsset('coin', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Add rotation animation for visual appeal
	self.rotationSpeed = 0.1;
	self.update = function () {
		self.x += self.speed;
		// Rotate coin for visual effect
		coinGraphics.rotation += self.rotationSpeed;
	};
	return self;
});
var Ground = Container.expand(function () {
	var self = Container.call(this);
	var groundGraphics = self.attachAsset('ground', {
		anchorX: 0,
		anchorY: 0
	});
	return self;
});
var Particle = Container.expand(function () {
	var self = Container.call(this);
	var particleGraphics = self.attachAsset('particle', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.velocityX = (Math.random() - 0.5) * 8;
	self.velocityY = (Math.random() - 0.5) * 8;
	self.life = 60; // 1 second at 60fps
	self.maxLife = 60;
	self.update = function () {
		self.x += self.velocityX;
		self.y += self.velocityY;
		self.life--;
		// Fade out over time
		particleGraphics.alpha = self.life / self.maxLife;
	};
	return self;
});
var Pipe = Container.expand(function () {
	var self = Container.call(this);
	self.speed = -4;
	self.gapSize = 1000;
	self.scored = false;
	// Create top pipe
	self.topPipe = self.attachAsset('pipe', {
		anchorX: 0.5,
		anchorY: 1
	});
	// Create bottom pipe
	self.bottomPipe = self.attachAsset('pipe', {
		anchorX: 0.5,
		anchorY: 0
	});
	self.setGapPosition = function (centerY) {
		self.topPipe.y = centerY - self.gapSize / 2;
		self.bottomPipe.y = centerY + self.gapSize / 2;
	};
	self.update = function () {
		self.x += self.speed;
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB
});
/**** 
* Game Code
****/ 
// Game variables
var bird;
var pipes = [];
var coins = [];
var particles = [];
var ground;
var gameStarted = false;
var gameOver = false;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 90; // 90 ticks = 1.5 seconds at 60fps
// Create particle effect function
function createParticleEffect(x, y, count) {
	for (var k = 0; k < count; k++) {
		var particle = game.addChild(new Particle());
		particle.x = x;
		particle.y = y;
		particles.push(particle);
	}
}
// Score display
var scoreTxt = new Text2('0', {
	size: 100,
	fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
// Instructions text
var instructionTxt = new Text2('TAP TO FLAP', {
	size: 80,
	fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
game.addChild(instructionTxt);
instructionTxt.x = 2048 / 2;
instructionTxt.y = 2732 / 2 - 200;
// Initialize bird
bird = game.addChild(new Bird());
bird.x = 400;
bird.y = 2732 / 2;
// Initialize ground
ground = game.addChild(new Ground());
ground.x = 0;
ground.y = 2732 - 150;
// Touch/tap controls
game.down = function (x, y, obj) {
	if (!gameStarted) {
		gameStarted = true;
		instructionTxt.visible = false;
	}
	if (!gameOver) {
		bird.flap();
	}
};
// Spawn pipe function
function spawnPipe() {
	var pipe = game.addChild(new Pipe());
	pipe.x = 2048 + 90; // Start off screen
	// Random gap position (avoid too high or too low)
	var minY = 300;
	var maxY = 2732 - 450; // Account for ground height
	var gapCenterY = minY + Math.random() * (maxY - minY);
	pipe.setGapPosition(gapCenterY);
	pipes.push(pipe);
	// Spawn coin in the center of the pipe gap
	var coin = game.addChild(new Coin());
	coin.x = pipe.x;
	coin.y = gapCenterY;
	coins.push(coin);
}
// Check collision between bird and pipe
function checkPipeCollision(bird, pipe) {
	var birdBounds = {
		left: bird.x - 30,
		right: bird.x + 30,
		top: bird.y - 22,
		bottom: bird.y + 22
	};
	var pipeBounds = {
		left: pipe.x - 90,
		right: pipe.x + 90,
		topPipeBottom: pipe.topPipe.y,
		bottomPipeTop: pipe.bottomPipe.y
	};
	// Check if bird is within pipe x bounds
	if (birdBounds.right > pipeBounds.left && birdBounds.left < pipeBounds.right) {
		// Check if bird hits top or bottom pipe
		if (birdBounds.top < pipeBounds.topPipeBottom || birdBounds.bottom > pipeBounds.bottomPipeTop) {
			return true;
		}
	}
	return false;
}
// Main game update loop
game.update = function () {
	if (!gameStarted || gameOver) {
		return;
	}
	// Update bird
	bird.update();
	// Check ground collision
	if (bird.y + 22 >= ground.y || bird.y - 22 <= 0) {
		gameOver = true;
		LK.getSound('hit').play();
		// Add screen flash and particles for ground collision
		LK.effects.flashScreen(0xFF0000, 500);
		createParticleEffect(bird.x, bird.y, 10);
		LK.showGameOver();
		return;
	}
	// Spawn pipes
	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];
		pipe.update();
		// Check collision
		if (checkPipeCollision(bird, pipe)) {
			gameOver = true;
			LK.getSound('hit').play();
			// Add screen shake effect
			LK.effects.flashScreen(0xFF0000, 500);
			// Create impact particles
			createParticleEffect(bird.x, bird.y, 12);
			LK.showGameOver();
			return;
		}
		// Check scoring (bird passed through pipe)
		if (!pipe.scored && bird.x > pipe.x + 90) {
			pipe.scored = true;
			LK.setScore(LK.getScore() + 1);
			scoreTxt.setText(LK.getScore());
			LK.getSound('score').play();
		}
		// Remove pipes that are off screen
		if (pipe.x < -180) {
			pipe.destroy();
			pipes.splice(i, 1);
		}
	}
	// Update coins and check collection
	for (var j = coins.length - 1; j >= 0; j--) {
		var coin = coins[j];
		coin.update();
		// Check if bird collected the coin
		if (!coin.collected && bird.intersects(coin)) {
			coin.collected = true;
			LK.setScore(LK.getScore() + 1);
			scoreTxt.setText(LK.getScore());
			LK.getSound('coin').play();
			// Create particle effect at coin position
			createParticleEffect(coin.x, coin.y, 8);
			// Flash coin collection feedback
			LK.effects.flashObject(scoreTxt, 0xFFD700, 300);
			coin.destroy();
			coins.splice(j, 1);
			continue;
		}
		// Remove coins that are off screen
		if (coin.x < -120) {
			coin.destroy();
			coins.splice(j, 1);
		}
	}
	// Update particles
	for (var p = particles.length - 1; p >= 0; p--) {
		var particle = particles[p];
		particle.update();
		// Remove particles when their life expires
		if (particle.life <= 0) {
			particle.destroy();
			particles.splice(p, 1);
		}
	}
};
:quality(85)/https://cdn.frvr.ai/684b4fdacbf2c9e503b00e5b.png%3F3) 
 flappy birdteki borular yeşil olsun. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
:quality(85)/https://cdn.frvr.ai/684be93880775d5411161b4e.png%3F3) 
 altı toprak üstü otlu olsun . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
:quality(85)/https://cdn.frvr.ai/684beace80775d5411161b5b.png%3F3) 
 pixel art coin. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/684beb5380775d5411161b6a.png%3F3) 
 pixel art bird. In-Game asset. 2d. High contrast. No shadows