User prompt
Onları yap ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'alpha' in undefined' in or related to this line: 'tween(menuCoins[i], {' Line Number: 585
User prompt
Menüyü daha güzel yap ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Para ekle
User prompt
Sekizinci de para yok
User prompt
Büyütülmüş cam barı
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var localPos = gameOverScreen.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 990
User prompt
Oyun bitince hem yeniden başlat hemde devam et butonu olsun devam etmek tek bir kere olsun ve devam edince 2 can olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Ölünce yeniden başlama butonu olsun
User prompt
Boruları uzat
User prompt
Boruların arasını aç ve uzat
User prompt
Her bir on geçince 10 puan gelsin
User prompt
Üstte kaç gün puan olduğu yazsın ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyunun ismi mutili bird olsun
User prompt
Oyunun kalitesini arttir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Müzik sesi gelmiyor
User prompt
Şarkı eklenmedi
User prompt
Müzik ekle
User prompt
Oyun başlamadan kuş yere düşüyor
User prompt
Oyun başlangıç menüsü olsun
User prompt
Yukarıya gidince cennete gidip 1 son olarak olsun
User prompt
Yürüme mekaniği yanlış
/****
* 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 = -12;
self.maxFallSpeed = 15;
self.rotation = 0;
self.flap = function () {
self.velocity = self.flapStrength;
LK.getSound('flap').play();
// Animate bird flap
tween(birdGraphics, {
rotation: -0.3
}, {
duration: 150
});
tween(birdGraphics, {
rotation: 0
}, {
duration: 150,
onFinish: function onFinish() {
if (self.velocity > 0) {
tween(birdGraphics, {
rotation: 0.3
}, {
duration: 200
});
}
}
});
};
self.update = function () {
// Don't update bird physics if game hasn't started
if (!gameStarted) {
return;
}
// Apply gravity
self.velocity += self.gravity;
if (self.velocity > self.maxFallSpeed) {
self.velocity = self.maxFallSpeed;
}
// Update position
self.y += self.velocity;
// Update rotation based on velocity with falling effect
var targetRotation = Math.min(Math.max(self.velocity * 0.05, -0.5), 0.8);
// Add dramatic falling effect when bird is falling fast
if (self.velocity > 8) {
// Create falling spin effect
tween(birdGraphics, {
rotation: targetRotation + Math.PI * 2
}, {
duration: 800,
easing: tween.easeIn
});
// Add slight scale effect during fall
tween(birdGraphics, {
scaleX: 0.9,
scaleY: 1.1
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(birdGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
} else {
// Normal rotation for regular movement
birdGraphics.rotation = targetRotation;
}
};
return self;
});
var Chicken = Container.expand(function () {
var self = Container.call(this);
var chickenGraphics = self.attachAsset('chicken', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -4;
self.baseY = 0;
self.pecking = false;
self.update = function () {
self.x += self.speed;
// Chicken walking animation - quick and jerky movements
var walkCycle = LK.ticks * 0.25; // Fast walking
// Quick head bobbing motion
self.y = self.baseY + Math.sin(walkCycle) * 1;
// Head jerking motion characteristic of chickens
chickenGraphics.x = Math.sin(walkCycle * 0.8) * 0.5;
// Periodic pecking animation
if (LK.ticks % 120 === 0) {
self.pecking = !self.pecking;
}
// Quick stepping animation every 10 frames for rapid chicken steps
if (LK.ticks % 10 === 0) {
var stepDirection = Math.floor(LK.ticks / 10) % 2 * 2 - 1;
tween(chickenGraphics, {
scaleY: 0.95,
scaleX: 1.05,
y: stepDirection * 0.3,
rotation: stepDirection * 0.05
}, {
duration: 50,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(chickenGraphics, {
scaleY: 1,
scaleX: 1,
y: 0,
rotation: 0
}, {
duration: 50,
easing: tween.easeIn
});
}
});
}
// Enhanced pecking motion when pecking
if (self.pecking) {
chickenGraphics.y = Math.sin(LK.ticks * 0.3) * 2;
}
};
return self;
});
// Cloud class removed
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -4;
self.collected = false;
self.rotationSpeed = 0.1;
self.update = function () {
self.x += self.speed;
// Rotate coin for visual appeal
coinGraphics.rotation += self.rotationSpeed;
// Gentle floating animation
coinGraphics.y = Math.sin(LK.ticks * 0.05) * 3;
};
return self;
});
var Cow = Container.expand(function () {
var self = Container.call(this);
var cowGraphics = self.attachAsset('cow', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -4;
// Add some black spots for cow appearance
self.baseY = 0;
self.update = function () {
self.x += self.speed;
// Proper walking animation with realistic bobbing
var walkCycle = LK.ticks * 0.15; // Walking speed
// Vertical bobbing motion - more pronounced and realistic
self.y = self.baseY + Math.sin(walkCycle) * 2;
// Subtle horizontal body sway
cowGraphics.x = Math.sin(walkCycle * 0.5) * 1;
// Body tilt during walking
cowGraphics.rotation = Math.sin(walkCycle) * 0.05;
// Step-based animation every 20 frames for more frequent steps
if (LK.ticks % 20 === 0) {
// Alternating leg movement effect
var stepDirection = Math.floor(LK.ticks / 20) % 2 * 2 - 1; // -1 or 1
// Step effect with body compression and extension
tween(cowGraphics, {
scaleY: 0.95,
scaleX: 1.05,
y: stepDirection * 1
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(cowGraphics, {
scaleY: 1,
scaleX: 1,
y: 0
}, {
duration: 100,
easing: tween.easeIn
});
}
});
}
};
return self;
});
var Farm = Container.expand(function () {
var self = Container.call(this);
var farmGraphics = self.attachAsset('farmGround', {
anchorX: 0,
anchorY: 0
});
self.speed = -4;
self.update = function () {
self.x += self.speed;
};
return self;
});
var Pig = Container.expand(function () {
var self = Container.call(this);
var pigGraphics = self.attachAsset('pig', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -4;
self.baseY = 0;
self.update = function () {
self.x += self.speed;
// Pig walking animation - heavier and slower
var walkCycle = LK.ticks * 0.12; // Slower walking
// Heavy bobbing motion
self.y = self.baseY + Math.sin(walkCycle) * 1.2;
// Wide body sway for heavier appearance
pigGraphics.x = Math.sin(walkCycle * 0.3) * 1.5;
// Heavy stepping animation every 25 frames
if (LK.ticks % 25 === 0) {
var stepDirection = Math.floor(LK.ticks / 25) % 2 * 2 - 1;
tween(pigGraphics, {
scaleY: 0.92,
scaleX: 1.08,
y: stepDirection * 0.8
}, {
duration: 125,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(pigGraphics, {
scaleY: 1,
scaleX: 1,
y: 0
}, {
duration: 125,
easing: tween.easeIn
});
}
});
}
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
self.passed = false;
self.gapSize = 300;
// Create top pipe
self.topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
// Create top pipe segment (Mario-style cap)
self.topPipeSegment = self.attachAsset('pipeSegment', {
anchorX: 0.5,
anchorY: 1
});
// Create bottom pipe
self.bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
// Create bottom pipe segment (Mario-style cap)
self.bottomPipeSegment = self.attachAsset('pipeSegment', {
anchorX: 0.5,
anchorY: 0
});
self.setGapPosition = function (gapY) {
self.topPipe.y = gapY - self.gapSize / 2;
self.bottomPipe.y = gapY + self.gapSize / 2;
// Position the Mario-style pipe segments
self.topPipeSegment.y = gapY - self.gapSize / 2;
self.bottomPipeSegment.y = gapY + self.gapSize / 2;
};
self.update = function () {
self.x += self.speed;
};
return self;
});
var Sheep = Container.expand(function () {
var self = Container.call(this);
var sheepGraphics = self.attachAsset('sheep', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -4;
self.baseY = 0;
self.update = function () {
self.x += self.speed;
// Sheep walking animation - lighter and bouncier than cows
var walkCycle = LK.ticks * 0.18; // Slightly faster walking
// Bouncy vertical movement
self.y = self.baseY + Math.sin(walkCycle) * 1.5;
// Gentle body sway
sheepGraphics.x = Math.sin(walkCycle * 0.4) * 0.8;
// Light stepping animation every 15 frames for quicker steps
if (LK.ticks % 15 === 0) {
var stepDirection = Math.floor(LK.ticks / 15) % 2 * 2 - 1;
tween(sheepGraphics, {
scaleY: 0.98,
scaleX: 1.02,
y: stepDirection * 0.5
}, {
duration: 75,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(sheepGraphics, {
scaleY: 1,
scaleX: 1,
y: 0
}, {
duration: 75,
easing: tween.easeIn
});
}
});
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x4a90e2
});
/****
* Game Code
****/
// Game variables
// Cloud asset removed
// Sky gradient assets removed
var bird;
var pipes = [];
var ground;
var gameStarted = false;
var gameSpeed = 4;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 180; // frames between pipe spawns
var lastPipeScore = 0;
var coins = [];
var coinSpawnTimer = 0;
var coinSpawnInterval = 200; // frames between coin spawns - slightly after pipes
// Cloud spawning removed
var farms = [];
var farmSpawnTimer = 0;
var farmSpawnInterval = 400; // frames between farm spawns
var animals = [];
var animalSpawnTimer = 0;
var animalSpawnInterval = 150; // frames between animal spawns
// Sky gradient layers removed
// Health system variables
var maxHealth = 3;
var currentHealth = 3;
var healthBar;
var healthBarBg;
// UI elements
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var instructionTxt = new Text2('Tap to Flap!', {
size: 60,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionTxt);
// Start menu UI elements
var showStartMenu = true;
var titleTxt = new Text2('Flappy Bird', {
size: 120,
fill: 0xFFD700
});
titleTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(titleTxt);
var startButtonTxt = new Text2('TAP TO START', {
size: 80,
fill: 0x00FF00
});
startButtonTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(startButtonTxt);
// Position menu elements
titleTxt.y = -200;
startButtonTxt.y = 100;
// Add pulsing animation to start button
tween(startButtonTxt, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(startButtonTxt, {
scaleX: 1,
scaleY: 1
}, {
duration: 800,
easing: tween.easeInOut
});
}
});
// Set interval for continuous button pulsing
var buttonPulseTimer = LK.setInterval(function () {
if (showStartMenu) {
tween(startButtonTxt, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(startButtonTxt, {
scaleX: 1,
scaleY: 1
}, {
duration: 800,
easing: tween.easeInOut
});
}
});
}
}, 1600);
// Create health bar
healthBarBg = LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
});
healthBarBg.x = 150;
healthBarBg.y = 20;
LK.gui.topLeft.addChild(healthBarBg);
healthBar = LK.getAsset('healthBarFill', {
anchorX: 0,
anchorY: 0
});
healthBar.x = 150;
healthBar.y = 20;
LK.gui.topLeft.addChild(healthBar);
// Create bird
bird = game.addChild(new Bird());
bird.x = 400;
bird.y = 1366; // Center of screen height
// Initialize health system
currentHealth = maxHealth;
updateHealthBar();
// Hide game UI initially
scoreTxt.alpha = 0;
instructionTxt.alpha = 0;
healthBarBg.alpha = 0;
healthBar.alpha = 0;
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0
}));
ground.x = 0;
ground.y = 2732 - 100; // Bottom of screen
// Game state tracking
var lastBirdY = bird.y;
var lastGroundCollision = false;
var lastCeilingCollision = false;
function spawnPipe() {
var pipe = new Pipe();
pipe.x = 2048 + 60; // Start off-screen right
// Random gap position (avoiding too high or too low)
var minGapY = 300;
var maxGapY = ground.y - 300;
var gapY = minGapY + Math.random() * (maxGapY - minGapY);
pipe.setGapPosition(gapY);
pipe.speed = -gameSpeed;
// Add entrance animation - pipes grow from small to normal size
pipe.scaleX = 0.3;
pipe.scaleY = 0.3;
tween(pipe, {
scaleX: 1,
scaleY: 1
}, {
duration: 400,
easing: tween.easeOut
});
pipes.push(pipe);
game.addChild(pipe);
}
function spawnCoin() {
// Only spawn coin if there's a recent pipe to place it with
if (pipes.length > 0) {
var latestPipe = pipes[pipes.length - 1];
var coin = new Coin();
// Place coin slightly ahead of the pipe gap
coin.x = latestPipe.x + 150; // Position coin in the gap area
// Place coin in the center of the pipe gap
var gapCenterY = (latestPipe.topPipe.y + latestPipe.bottomPipe.y) / 2;
coin.y = gapCenterY;
coin.speed = -gameSpeed;
// Add sparkle entrance effect - coin appears with bounce
coin.scaleX = 0;
coin.scaleY = 0;
tween(coin, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(coin, {
scaleX: 1,
scaleY: 1
}, {
duration: 150,
easing: tween.easeIn
});
}
});
coins.push(coin);
game.addChild(coin);
}
}
// Cloud spawning function removed
function spawnFarm() {
var farm = new Farm();
farm.x = 2048;
farm.y = ground.y - 200; // Position above ground
farm.speed = -gameSpeed;
farms.push(farm);
game.addChild(farm);
}
function spawnAnimal() {
if (farms.length > 0) {
var randomFarm = farms[Math.floor(Math.random() * farms.length)];
var animalTypes = [Cow, Sheep, Pig, Chicken];
var AnimalClass = animalTypes[Math.floor(Math.random() * animalTypes.length)];
var animal = new AnimalClass();
animal.x = randomFarm.x + Math.random() * 1500; // Random position on farm
animal.baseY = randomFarm.y;
animal.y = animal.baseY;
animal.speed = -gameSpeed;
animals.push(animal);
game.addChild(animal);
}
}
function updateHealthBar() {
var healthPercent = currentHealth / maxHealth;
healthBar.width = 200 * healthPercent;
// Change color based on health
if (healthPercent > 0.6) {
healthBar.tint = 0x00ff00; // Green
} else if (healthPercent > 0.3) {
healthBar.tint = 0xffff00; // Yellow
} else {
healthBar.tint = 0xff0000; // Red
}
// Flash effect when damaged
tween(healthBar, {
alpha: 0.5
}, {
duration: 100,
onFinish: function onFinish() {
tween(healthBar, {
alpha: 1
}, {
duration: 100
});
}
});
}
function takeDamage() {
currentHealth--;
updateHealthBar();
if (currentHealth <= 0) {
LK.getSound('hit').play();
// Add dramatic screen shake before game over
var originalX = game.x;
var originalY = game.y;
tween(game, {
x: originalX + 20,
y: originalY + 10
}, {
duration: 50,
onFinish: function onFinish() {
tween(game, {
x: originalX - 15,
y: originalY - 8
}, {
duration: 50,
onFinish: function onFinish() {
tween(game, {
x: originalX,
y: originalY
}, {
duration: 100,
onFinish: function onFinish() {
LK.showGameOver();
}
});
}
});
}
});
return true; // Game over
}
LK.getSound('hit').play();
// Add screen shake effect for damage feedback
var originalX = game.x;
var originalY = game.y;
tween(game, {
x: originalX + 10,
y: originalY + 5
}, {
duration: 60,
onFinish: function onFinish() {
tween(game, {
x: originalX - 8,
y: originalY - 4
}, {
duration: 60,
onFinish: function onFinish() {
tween(game, {
x: originalX,
y: originalY
}, {
duration: 80
});
}
});
}
});
// Flash bird red when damaged
tween(bird, {
tint: 0xff0000
}, {
duration: 200,
onFinish: function onFinish() {
tween(bird, {
tint: 0xffffff
}, {
duration: 200
});
}
});
return false; // Continue game
}
function checkCollisions() {
// Check ground collision
var currentGroundCollision = bird.y + 22 >= ground.y; // bird half-height
if (!lastGroundCollision && currentGroundCollision) {
LK.getSound('hit').play();
LK.showGameOver();
return;
}
lastGroundCollision = currentGroundCollision;
// Check heaven win condition - when bird reaches very top
var heavenThreshold = -50; // Above the screen
if (bird.y <= heavenThreshold) {
// Flash screen with heavenly light effect
tween(game, {
tint: 0xffffff
}, {
duration: 500,
onFinish: function onFinish() {
tween(game, {
tint: 0xffffff
}, {
duration: 500,
onFinish: function onFinish() {
LK.showYouWin(); // Show win screen
}
});
}
});
return;
}
// Check ceiling collision (but not heaven)
var currentCeilingCollision = bird.y - 22 <= 0 && bird.y > heavenThreshold;
if (!lastCeilingCollision && currentCeilingCollision) {
LK.getSound('hit').play();
LK.showGameOver();
return;
}
lastCeilingCollision = currentCeilingCollision;
// Check pipe collisions and scoring
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
// Check if bird passed through pipe (scoring)
if (!pipe.passed && bird.x > pipe.x + 60) {
pipe.passed = true;
// No score change when passing through pipes
LK.getSound('score').play();
// Increase difficulty every 5 pipes
if (LK.getScore() % 5 === 0) {
gameSpeed += 0.5;
}
}
// Check collision with pipes
var birdLeft = bird.x - 30;
var birdRight = bird.x + 30;
var birdTop = bird.y - 22;
var birdBottom = bird.y + 22;
var pipeLeft = pipe.x - 60;
var pipeRight = pipe.x + 60;
if (birdRight > pipeLeft && birdLeft < pipeRight) {
// Bird is horizontally aligned with pipe
var topPipeBottom = pipe.topPipe.y;
var bottomPipeTop = pipe.bottomPipe.y;
if (birdTop < topPipeBottom || birdBottom > bottomPipeTop) {
// Check if this pipe already caused damage
if (!pipe.damageCaused) {
pipe.damageCaused = true;
if (takeDamage()) {
return; // Game over
}
}
}
}
}
// Check coin collection
for (var j = coins.length - 1; j >= 0; j--) {
var coin = coins[j];
if (!coin.collected && bird.intersects(coin)) {
coin.collected = true;
LK.setScore(LK.getScore() + 1); // Coins worth 1 point
scoreTxt.setText(LK.getScore());
LK.getSound('coin').play();
// Add score text animation for feedback
tween(scoreTxt, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(scoreTxt, {
scaleX: 1,
scaleY: 1
}, {
duration: 150,
easing: tween.easeIn
});
}
});
// Visual effect - make coin disappear with scaling
tween(coin, {
scaleX: 0,
scaleY: 0,
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
coin.destroy();
}
});
coins.splice(j, 1);
}
}
}
// Touch controls
game.down = function (x, y, obj) {
if (showStartMenu) {
// Start the game from menu
showStartMenu = false;
gameStarted = true;
// Smooth fade out menu elements
tween(titleTxt, {
alpha: 0,
y: titleTxt.y - 100
}, {
duration: 500,
easing: tween.easeIn
});
tween(startButtonTxt, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 300,
easing: tween.easeIn
});
// Smooth fade in game UI
tween(scoreTxt, {
alpha: 1
}, {
duration: 800,
easing: tween.easeOut
});
tween(instructionTxt, {
alpha: 1
}, {
duration: 1000,
easing: tween.easeOut
});
tween(healthBarBg, {
alpha: 1
}, {
duration: 600,
easing: tween.easeOut
});
tween(healthBar, {
alpha: 1
}, {
duration: 600,
easing: tween.easeOut
});
// Start background music
try {
LK.playMusic('bgmusic', {
loop: true,
volume: 0.5
});
} catch (e) {
console.log('Music playback failed:', e);
}
// Hide instruction after a delay with smooth fade
tween(instructionTxt, {
alpha: 0
}, {
duration: 2000,
easing: tween.easeInOut
});
bird.flap();
} else if (!gameStarted) {
gameStarted = true;
tween(instructionTxt, {
alpha: 0
}, {
duration: 500,
easing: tween.easeOut
});
bird.flap();
} else {
bird.flap();
}
};
// Main game loop
game.update = function () {
if (!gameStarted) {
return;
}
// Update bird
lastBirdY = bird.y;
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Spawn coins - spawn a coin shortly after each pipe
coinSpawnTimer++;
if (coinSpawnTimer >= coinSpawnInterval) {
spawnCoin();
coinSpawnTimer = 0;
}
// Cloud spawning logic removed
// Spawn farms
farmSpawnTimer++;
if (farmSpawnTimer >= farmSpawnInterval) {
spawnFarm();
farmSpawnTimer = 0;
}
// Spawn animals on existing farms
animalSpawnTimer++;
if (animalSpawnTimer >= animalSpawnInterval) {
spawnAnimal();
animalSpawnTimer = 0;
}
// Update pipes and remove off-screen ones
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
pipe.speed = -gameSpeed;
if (pipe.x < -120) {
pipe.destroy();
pipes.splice(i, 1);
}
}
// Update coins and remove off-screen ones
for (var j = coins.length - 1; j >= 0; j--) {
var coin = coins[j];
coin.speed = -gameSpeed;
if (coin.x < -40) {
coin.destroy();
coins.splice(j, 1);
}
}
// Cloud update logic removed
// Update farms and remove off-screen ones
for (var l = farms.length - 1; l >= 0; l--) {
var farm = farms[l];
farm.speed = -gameSpeed;
if (farm.x < -2048) {
farm.destroy();
farms.splice(l, 1);
}
}
// Update animals and remove off-screen ones
for (var m = animals.length - 1; m >= 0; m--) {
var animal = animals[m];
animal.speed = -gameSpeed;
if (animal.x < -100) {
animal.destroy();
animals.splice(m, 1);
}
}
// Check all collisions
checkCollisions();
}; ===================================================================
--- original.js
+++ change.js
@@ -487,8 +487,18 @@
var maxGapY = ground.y - 300;
var gapY = minGapY + Math.random() * (maxGapY - minGapY);
pipe.setGapPosition(gapY);
pipe.speed = -gameSpeed;
+ // Add entrance animation - pipes grow from small to normal size
+ pipe.scaleX = 0.3;
+ pipe.scaleY = 0.3;
+ tween(pipe, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
pipes.push(pipe);
game.addChild(pipe);
}
function spawnCoin() {
@@ -501,8 +511,27 @@
// Place coin in the center of the pipe gap
var gapCenterY = (latestPipe.topPipe.y + latestPipe.bottomPipe.y) / 2;
coin.y = gapCenterY;
coin.speed = -gameSpeed;
+ // Add sparkle entrance effect - coin appears with bounce
+ coin.scaleX = 0;
+ coin.scaleY = 0;
+ tween(coin, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(coin, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 150,
+ easing: tween.easeIn
+ });
+ }
+ });
coins.push(coin);
game.addChild(coin);
}
}
@@ -558,12 +587,64 @@
currentHealth--;
updateHealthBar();
if (currentHealth <= 0) {
LK.getSound('hit').play();
- LK.showGameOver();
+ // Add dramatic screen shake before game over
+ var originalX = game.x;
+ var originalY = game.y;
+ tween(game, {
+ x: originalX + 20,
+ y: originalY + 10
+ }, {
+ duration: 50,
+ onFinish: function onFinish() {
+ tween(game, {
+ x: originalX - 15,
+ y: originalY - 8
+ }, {
+ duration: 50,
+ onFinish: function onFinish() {
+ tween(game, {
+ x: originalX,
+ y: originalY
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ LK.showGameOver();
+ }
+ });
+ }
+ });
+ }
+ });
return true; // Game over
}
LK.getSound('hit').play();
+ // Add screen shake effect for damage feedback
+ var originalX = game.x;
+ var originalY = game.y;
+ tween(game, {
+ x: originalX + 10,
+ y: originalY + 5
+ }, {
+ duration: 60,
+ onFinish: function onFinish() {
+ tween(game, {
+ x: originalX - 8,
+ y: originalY - 4
+ }, {
+ duration: 60,
+ onFinish: function onFinish() {
+ tween(game, {
+ x: originalX,
+ y: originalY
+ }, {
+ duration: 80
+ });
+ }
+ });
+ }
+ });
// Flash bird red when damaged
tween(bird, {
tint: 0xff0000
}, {
@@ -658,8 +739,25 @@
coin.collected = true;
LK.setScore(LK.getScore() + 1); // Coins worth 1 point
scoreTxt.setText(LK.getScore());
LK.getSound('coin').play();
+ // Add score text animation for feedback
+ tween(scoreTxt, {
+ scaleX: 1.3,
+ scaleY: 1.3
+ }, {
+ duration: 150,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(scoreTxt, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 150,
+ easing: tween.easeIn
+ });
+ }
+ });
// Visual effect - make coin disappear with scaling
tween(coin, {
scaleX: 0,
scaleY: 0,
@@ -679,16 +777,49 @@
if (showStartMenu) {
// Start the game from menu
showStartMenu = false;
gameStarted = true;
- // Hide menu elements
- titleTxt.alpha = 0;
- startButtonTxt.alpha = 0;
- // Show game UI
- scoreTxt.alpha = 1;
- instructionTxt.alpha = 1;
- healthBarBg.alpha = 1;
- healthBar.alpha = 1;
+ // Smooth fade out menu elements
+ tween(titleTxt, {
+ alpha: 0,
+ y: titleTxt.y - 100
+ }, {
+ duration: 500,
+ easing: tween.easeIn
+ });
+ tween(startButtonTxt, {
+ alpha: 0,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 300,
+ easing: tween.easeIn
+ });
+ // Smooth fade in game UI
+ tween(scoreTxt, {
+ alpha: 1
+ }, {
+ duration: 800,
+ easing: tween.easeOut
+ });
+ tween(instructionTxt, {
+ alpha: 1
+ }, {
+ duration: 1000,
+ easing: tween.easeOut
+ });
+ tween(healthBarBg, {
+ alpha: 1
+ }, {
+ duration: 600,
+ easing: tween.easeOut
+ });
+ tween(healthBar, {
+ alpha: 1
+ }, {
+ duration: 600,
+ easing: tween.easeOut
+ });
// Start background music
try {
LK.playMusic('bgmusic', {
loop: true,
@@ -696,18 +827,24 @@
});
} catch (e) {
console.log('Music playback failed:', e);
}
- // Hide instruction after a delay
+ // Hide instruction after a delay with smooth fade
tween(instructionTxt, {
alpha: 0
}, {
- duration: 2000
+ duration: 2000,
+ easing: tween.easeInOut
});
bird.flap();
} else if (!gameStarted) {
gameStarted = true;
- instructionTxt.alpha = 0;
+ tween(instructionTxt, {
+ alpha: 0
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
bird.flap();
} else {
bird.flap();
}