/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1", {
diamonds: 0,
ownedBirds: ["classic"],
selectedBird: "classic",
lastDailyReward: 0,
ownedThemes: ["morning"],
selectedTheme: "morning"
});
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
self.velocity = 0;
self.gravity = 0.8;
self.flapPower = -15;
self.updateBirdSkin = function () {
if (self.birdGraphics) {
self.removeChild(self.birdGraphics);
}
var skinAsset = 'bird';
if (storage.selectedBird === 'diamondSword') {
skinAsset = 'diamondSwordBird';
} else if (storage.selectedBird === 'golden') {
skinAsset = 'goldenBird';
} else if (storage.selectedBird === 'fire') {
skinAsset = 'fireBird';
}
self.birdGraphics = self.attachAsset(skinAsset, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
};
self.updateBirdSkin();
self.flap = function () {
self.velocity = self.flapPower;
LK.getSound('flap').play();
};
self.update = function () {
if (gameState !== 'playing') {
return;
}
self.velocity += self.gravity;
self.y += self.velocity;
// Rotate bird based on velocity
self.birdGraphics.rotation = Math.min(Math.max(self.velocity * 0.05, -0.5), 0.5);
// Ground collision
if (self.y > 2732 - 100 - 30) {
// Update high score if current score is higher
if (obstacleCount > highScore) {
highScore = obstacleCount;
storage.highScore = highScore;
}
LK.showGameOver();
}
// Screen boundary collision
if (self.y < 0) {
// Update high score if current score is higher
if (obstacleCount > highScore) {
highScore = obstacleCount;
storage.highScore = highScore;
}
LK.showGameOver();
}
};
return self;
});
var Diamond = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
self.collected = false;
var diamondGraphics = self.attachAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
rotation: Math.PI / 4,
scaleX: 2,
scaleY: 2
});
self.update = function () {
self.x += self.speed;
diamondGraphics.rotation += 0.1;
};
return self;
});
var GiftPanel = Container.expand(function () {
var self = Container.call(this);
// Create magical gradient background with treasure chest vibes
var magicalBg1 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x4A148C,
alpha: 0.95
});
var magicalBg2 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700,
alpha: 0.3,
scaleX: 0.95,
scaleY: 0.95
});
var magicalBg3 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFF6B35,
alpha: 0.4,
scaleX: 0.9,
scaleY: 0.9
});
// Create glowing treasure chest base using multiple diamonds
var treasureBase = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -200,
scaleX: 0.3,
scaleY: 0.2,
tint: 0x8B4513,
alpha: 0.9
}));
var treasureGlow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -200,
scaleX: 0.35,
scaleY: 0.25,
tint: 0xFFD700,
alpha: 0.6
}));
// Create treasure chest gems using multiple diamonds
var chestGem1 = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: -30,
y: -220,
scaleX: 3,
scaleY: 3,
tint: 0x00FFFF
}));
var chestGem2 = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: 30,
y: -220,
scaleX: 3,
scaleY: 3,
tint: 0xFF69B4
}));
var chestGem3 = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -180,
scaleX: 4,
scaleY: 4,
tint: 0xFFD700
}));
// Create sparkle particles floating around
var sparkleParticles = [];
for (var sp = 0; sp < 25; sp++) {
var sparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1600,
y: (Math.random() - 0.5) * 2000,
scaleX: 0.8 + Math.random() * 1.5,
scaleY: 0.8 + Math.random() * 1.5,
alpha: 0.7 + Math.random() * 0.3,
tint: 0xFFD700
}));
sparkle.floatSpeed = 0.02 + Math.random() * 0.04;
sparkle.originalY = sparkle.y;
sparkle.rotationSpeed = 0.06 + Math.random() * 0.1;
sparkleParticles.push(sparkle);
}
// Create confetti particles
var confettiParticles = [];
var confettiColors = [0xFF69B4, 0x00FFFF, 0x32CD32, 0xFFD700, 0xFF4500];
for (var cp = 0; cp < 15; cp++) {
var confetti = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1400,
y: (Math.random() - 0.5) * 1800,
scaleX: 0.5 + Math.random() * 1,
scaleY: 0.5 + Math.random() * 1,
alpha: 0.8,
tint: confettiColors[Math.floor(Math.random() * confettiColors.length)]
}));
confetti.fallSpeed = 0.02 + Math.random() * 0.03;
confetti.sideSpeed = (Math.random() - 0.5) * 0.04;
confetti.rotationSpeed = 0.08 + Math.random() * 0.12;
confettiParticles.push(confetti);
}
// Animate treasure chest with gentle glow pulsing
tween(treasureGlow, {
alpha: 0.9,
scaleX: 0.4,
scaleY: 0.3
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(treasureGlow, {
alpha: 0.6,
scaleX: 0.35,
scaleY: 0.25
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
// Animate chest gems with magical sparkle
tween(chestGem1, {
scaleX: 3.5,
scaleY: 3.5,
alpha: 0.9
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(chestGem1, {
scaleX: 3,
scaleY: 3,
alpha: 1
}, {
duration: 1500,
easing: tween.easeInOut
});
}
});
tween(chestGem2, {
scaleX: 3.5,
scaleY: 3.5,
alpha: 0.9
}, {
duration: 1800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(chestGem2, {
scaleX: 3,
scaleY: 3,
alpha: 1
}, {
duration: 1800,
easing: tween.easeInOut
});
}
});
// Update function for animated effects
self.update = function () {
// Animate sparkle particles
for (var sp = 0; sp < sparkleParticles.length; sp++) {
var sparkle = sparkleParticles[sp];
sparkle.y = sparkle.originalY + Math.sin(LK.ticks * sparkle.floatSpeed) * 30;
sparkle.rotation += sparkle.rotationSpeed;
sparkle.alpha = 0.7 + Math.sin(LK.ticks * sparkle.floatSpeed * 2) * 0.3;
}
// Animate confetti particles
for (var cp = 0; cp < confettiParticles.length; cp++) {
var confetti = confettiParticles[cp];
confetti.y += Math.sin(LK.ticks * confetti.fallSpeed) * 0.8;
confetti.x += Math.sin(LK.ticks * confetti.sideSpeed) * 0.5;
confetti.rotation += confetti.rotationSpeed;
}
};
var titleText = new Text2('DAILY TREASURE', {
size: 80,
fill: '#FFD700'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -800;
self.addChild(titleText);
// Check if daily reward is available (24 hours = 86400000 milliseconds)
var currentTime = Date.now();
var timeSinceLastReward = currentTime - (storage.lastDailyReward || 0);
var canClaimReward = timeSinceLastReward >= 86400000;
// Calculate time remaining for next gift
var timeRemaining = 86400000 - timeSinceLastReward;
var hoursRemaining = Math.floor(timeRemaining / 3600000);
var minutesRemaining = Math.floor(timeRemaining % 3600000 / 60000);
var rewardText = new Text2('đ CLAIM 5 GEMS đ', {
size: 60,
fill: '#FFD700'
});
rewardText.anchor.set(0.5, 0.5);
rewardText.x = 0;
rewardText.y = 50;
self.addChild(rewardText);
var statusText;
if (canClaimReward) {
statusText = new Text2('⨠AVAILABLE NOW! â¨', {
size: 45,
fill: '#00FF00'
});
} else {
statusText = new Text2('Come back in ' + hoursRemaining + 'h ' + minutesRemaining + 'm', {
size: 40,
fill: '#FF6B35'
});
}
statusText.anchor.set(0.5, 0.5);
statusText.x = 0;
statusText.y = 150;
self.addChild(statusText);
// Create glowing claim button
var claimButtonShadow = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 3,
y: 303,
tint: 0x000000,
alpha: 0.5
}));
var claimButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 300,
tint: canClaimReward ? 0x32CD32 : 0x696969
}));
var claimButtonGlow = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 300,
tint: 0xFFD700,
alpha: canClaimReward ? 0.6 : 0.2,
scaleX: 1.1,
scaleY: 1.1
}));
var claimButtonText = new Text2(canClaimReward ? 'CLAIM 5 GEMS' : 'CLAIMED', {
size: 30,
fill: '#FFFFFF'
});
claimButtonText.anchor.set(0.5, 0.5);
claimButton.addChild(claimButtonText);
// Add glowing animation to available button
if (canClaimReward) {
tween(claimButtonGlow, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(claimButtonGlow, {
alpha: 0.6,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1500,
easing: tween.easeInOut
});
}
});
}
claimButton.down = function () {
if (canClaimReward) {
storage.diamonds += 5;
storage.lastDailyReward = currentTime;
diamondCountText.setText('Diamonds: ' + storage.diamonds);
claimButtonText.setText('CLAIMED');
statusText.setText('Come back tomorrow!');
statusText.fill = '#FF6B35';
claimButtonGlow.alpha = 0.2;
claimButton.tint = 0x696969;
// Create celebration sparkles
for (var cs = 0; cs < 20; cs++) {
var celebrationSparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 400,
y: 300 + (Math.random() - 0.5) * 200,
scaleX: 1 + Math.random() * 2,
scaleY: 1 + Math.random() * 2,
alpha: 1,
tint: 0xFFD700
}));
tween(celebrationSparkle, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2,
y: celebrationSparkle.y - 200
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
celebrationSparkle.destroy();
}
});
}
}
};
var creatorText = new Text2('Creator:ironx_creator0', {
size: 25,
fill: '#888888'
});
creatorText.anchor.set(0.5, 0.5);
creatorText.x = 0;
creatorText.y = 700;
self.addChild(creatorText);
var closeButton = self.addChild(LK.getAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 800
}));
var closeText = new Text2('CLOSE', {
size: 30,
fill: '#FFFFFF'
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
self.destroy();
if (wasPlaying) {
startCountdown();
} else {
gameState = 'waiting';
tapToStartText.visible = true;
instructionText.visible = true;
}
};
return self;
});
var InventoryPanel = Container.expand(function () {
var self = Container.call(this);
// Create multiple layered backgrounds for frosted glass effect
var glassLayer1 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x2C3E50,
alpha: 0.85
});
var glassLayer2 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x34495E,
alpha: 0.6,
scaleX: 0.98,
scaleY: 0.98
});
var glassLayer3 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x5D6D7E,
alpha: 0.4,
scaleX: 0.96,
scaleY: 0.96
});
// Create glowing edge effects
var glowEdge1 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xF1C40F,
alpha: 0.3,
scaleX: 1.02,
scaleY: 1.02
});
var glowEdge2 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xE67E22,
alpha: 0.2,
scaleX: 1.04,
scaleY: 1.04
});
// Create subtle shadow depth
var shadowLayer = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x000000,
alpha: 0.3,
scaleX: 1.01,
scaleY: 1.01,
x: 8,
y: 8
});
// Add animated sparkle particles for premium feel
var inventorySparkles = [];
for (var sp = 0; sp < 12; sp++) {
var sparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1600,
y: (Math.random() - 0.5) * 1900,
scaleX: 0.3 + Math.random() * 0.8,
scaleY: 0.3 + Math.random() * 0.8,
alpha: 0.4 + Math.random() * 0.4,
tint: 0xF39C12
}));
sparkle.originalX = sparkle.x;
sparkle.originalY = sparkle.y;
sparkle.floatSpeed = 0.015 + Math.random() * 0.025;
sparkle.rotationSpeed = 0.03 + Math.random() * 0.06;
inventorySparkles.push(sparkle);
}
// Animate glow edges with gentle pulsing
tween(glowEdge1, {
alpha: 0.5,
scaleX: 1.03,
scaleY: 1.03
}, {
duration: 2500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(glowEdge1, {
alpha: 0.3,
scaleX: 1.02,
scaleY: 1.02
}, {
duration: 2500,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(glowEdge1, {
alpha: 0.5,
scaleX: 1.03,
scaleY: 1.03
}, {
duration: 2500,
easing: tween.easeInOut
});
}
});
}
});
tween(glowEdge2, {
alpha: 0.35,
scaleX: 1.05,
scaleY: 1.05
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(glowEdge2, {
alpha: 0.2,
scaleX: 1.04,
scaleY: 1.04
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(glowEdge2, {
alpha: 0.35,
scaleX: 1.05,
scaleY: 1.05
}, {
duration: 3000,
easing: tween.easeInOut
});
}
});
}
});
self.update = function () {
// Animate sparkle particles
for (var sp = 0; sp < inventorySparkles.length; sp++) {
var sparkle = inventorySparkles[sp];
sparkle.y += Math.sin(LK.ticks * sparkle.floatSpeed) * 0.3;
sparkle.rotation += sparkle.rotationSpeed;
sparkle.alpha = 0.4 + Math.sin(LK.ticks * sparkle.floatSpeed * 1.5) * 0.2;
}
};
var titleText = new Text2('INVENTORY', {
size: 80,
fill: '#FFFFFF'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -800;
self.addChild(titleText);
var highScoreText = new Text2('High Score: ' + highScore + ' obstacles', {
size: 50,
fill: '#FFD700'
});
highScoreText.anchor.set(0.5, 0.5);
highScoreText.x = 0;
highScoreText.y = 700;
self.addChild(highScoreText);
var birdTypes = [{
id: 'classic',
name: 'Classic Bird',
asset: 'bird'
}, {
id: 'diamondSword',
name: 'Diamond Sword Bird',
asset: 'diamondSwordBird'
}, {
id: 'golden',
name: 'Golden Bird',
asset: 'goldenBird'
}, {
id: 'fire',
name: 'Fire Bird',
asset: 'fireBird'
}];
var ownedIndex = 0;
for (var i = 0; i < birdTypes.length; i++) {
var birdType = birdTypes[i];
if (storage.ownedBirds.indexOf(birdType.id) >= 0) {
// Calculate position in 2x2 grid
var col = ownedIndex % 2; // 0 for left, 1 for right
var row = Math.floor(ownedIndex / 2); // 0 for top, 1 for bottom
var x = col === 0 ? -300 : 300; // Left or right position
var y = -400 + row * 400; // Top or bottom position with spacing
// Move golden bird and fire bird down by adjusting their y position
if (birdType.id === 'golden' || birdType.id === 'fire') {
y += 100; // Move these birds down by 100 pixels
}
// Create elegant pedestal for each bird slot
var pedestalShadow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: x + 3,
y: y + 3,
scaleX: 0.25,
scaleY: 0.25,
tint: 0x000000,
alpha: 0.4
}));
var pedestalBase = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y,
scaleX: 0.25,
scaleY: 0.25,
tint: 0x2C3E50,
alpha: 0.8
}));
var pedestalGlow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y,
scaleX: 0.27,
scaleY: 0.27,
tint: 0xF1C40F,
alpha: 0.3
}));
// Golden rim for premium feel
var goldenRim = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y,
scaleX: 0.26,
scaleY: 0.26,
tint: 0xD4AF37,
alpha: 0.6
}));
var birdPreview = self.addChild(LK.getAsset(birdType.asset, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: x,
y: y
}));
// Add gentle floating animation to bird
var birdFloatSpeed = 0.02 + Math.random() * 0.01;
(function (bird, speed, baseY) {
var originalUpdate = bird.update || function () {};
bird.update = function () {
originalUpdate.call(bird);
bird.y = baseY + Math.sin(LK.ticks * speed) * 8;
};
})(birdPreview, birdFloatSpeed, y);
// Animate pedestal glow
tween(pedestalGlow, {
alpha: 0.5,
scaleX: 0.28,
scaleY: 0.28
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(pedestalGlow, {
alpha: 0.3,
scaleX: 0.27,
scaleY: 0.27
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
var birdNameText = new Text2(birdType.name, {
size: 40,
fill: '#F1C40F'
});
birdNameText.anchor.set(0.5, 0.5);
birdNameText.x = x;
birdNameText.y = y + 80;
self.addChild(birdNameText);
// Create elegant button background
var buttonShadow = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: x + 2,
y: y + 152,
tint: 0x000000,
alpha: 0.4
}));
var buttonBase = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y + 150,
tint: 0x2C3E50,
alpha: 0.9
}));
var buttonGlow = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y + 150,
tint: 0xE67E22,
alpha: 0.4,
scaleX: 1.1,
scaleY: 1.1
}));
var selectButton = buttonBase;
var selectText = new Text2(storage.selectedBird === birdType.id ? 'SELECTED' : 'SELECT', {
size: 30,
fill: storage.selectedBird === birdType.id ? '#F1C40F' : '#FFFFFF'
});
selectText.anchor.set(0.5, 0.5);
selectButton.addChild(selectText);
// Add hover effect animation
var isSelected = storage.selectedBird === birdType.id;
if (isSelected) {
tween(buttonGlow, {
alpha: 0.7,
scaleX: 1.15,
scaleY: 1.15
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(buttonGlow, {
alpha: 0.4,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1500,
easing: tween.easeInOut
});
}
});
}
(function (birdId, button, text) {
button.down = function () {
storage.selectedBird = birdId;
text.setText('SELECTED');
LK.getSound('select').play();
// Update other buttons
for (var j = 0; j < self.children.length; j++) {
var child = self.children[j];
if (child.children && child.children[0] && child.children[0].text && child.children[0].text.indexOf('SELECT') >= 0) {
if (child !== button) {
child.children[0].setText('SELECT');
}
}
}
};
})(birdType.id, selectButton, selectText);
ownedIndex++;
}
}
var closeButton = self.addChild(LK.getAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 800
}));
var closeText = new Text2('CLOSE', {
size: 30,
fill: '#FFFFFF'
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
if (bird) {
bird.updateBirdSkin();
}
self.destroy();
if (wasPlaying) {
startCountdown();
} else {
gameState = 'waiting';
// Show tap to start UI when returning to waiting state
tapToStartText.visible = true;
instructionText.visible = true;
}
};
return self;
});
var MyThemesPanel = Container.expand(function () {
var self = Container.call(this);
// Create dynamic animated background with color shifting
var bgLayer1 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x4A148C,
alpha: 0.9
});
var bgLayer2 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x7B1FA2,
alpha: 0.7,
scaleX: 0.95,
scaleY: 0.95
});
var bgLayer3 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x8E24AA,
alpha: 0.5,
scaleX: 0.9,
scaleY: 0.9
});
// Create magical particle effects drifting around
var magicParticles = [];
for (var mp = 0; mp < 15; mp++) {
var particle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1700,
y: (Math.random() - 0.5) * 2100,
scaleX: 0.4 + Math.random() * 0.8,
scaleY: 0.4 + Math.random() * 0.8,
alpha: 0.5 + Math.random() * 0.4,
tint: 0xE1BEE7
}));
particle.driftSpeedX = (Math.random() - 0.5) * 0.02;
particle.driftSpeedY = (Math.random() - 0.5) * 0.015;
particle.twinkleSpeed = 0.03 + Math.random() * 0.04;
particle.originalAlpha = particle.alpha;
magicParticles.push(particle);
}
// Animate background layers with magical color shifting
tween(bgLayer1, {
tint: 0x6A1B9A,
alpha: 0.95
}, {
duration: 4000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bgLayer1, {
tint: 0x4A148C,
alpha: 0.9
}, {
duration: 4000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart color cycle
tween(bgLayer1, {
tint: 0x6A1B9A,
alpha: 0.95
}, {
duration: 4000,
easing: tween.easeInOut
});
}
});
}
});
tween(bgLayer2, {
tint: 0x9C27B0,
scaleX: 1.0,
scaleY: 1.0,
alpha: 0.8
}, {
duration: 5000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bgLayer2, {
tint: 0x7B1FA2,
scaleX: 0.95,
scaleY: 0.95,
alpha: 0.7
}, {
duration: 5000,
easing: tween.easeInOut
});
}
});
self.update = function () {
// Animate magical particles
for (var mp = 0; mp < magicParticles.length; mp++) {
var particle = magicParticles[mp];
particle.x += particle.driftSpeedX;
particle.y += particle.driftSpeedY;
particle.alpha = particle.originalAlpha + Math.sin(LK.ticks * particle.twinkleSpeed) * 0.3;
particle.rotation += 0.02;
// Wrap particles around screen
if (particle.x > 900) particle.x = -900;
if (particle.x < -900) particle.x = 900;
if (particle.y > 1100) particle.y = -1100;
if (particle.y < -1100) particle.y = 1100;
}
};
var titleText = new Text2('MY THEMES', {
size: 80,
fill: '#FFFFFF'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -800;
self.addChild(titleText);
var allThemes = [{
id: 'morning',
name: 'Morning Theme',
icon: 'sun'
}, {
id: 'night',
name: 'Night Theme',
icon: 'nightIcon'
}, {
id: 'mars',
name: 'Mars Theme',
icon: 'marsIcon'
}];
// Create elegant theme cards
var themeCards = [];
var cardPositions = [{
x: -300,
y: -200
},
// Morning left
{
x: 300,
y: -200
},
// Night right
{
x: 0,
y: 200
} // Mars bottom center
];
for (var t = 0; t < allThemes.length; t++) {
var theme = allThemes[t];
if (storage.ownedThemes && storage.ownedThemes.indexOf(theme.id) >= 0) {
var pos = cardPositions[t];
// Create elegant card background with glowing border
var cardShadow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x + 4,
y: pos.y + 4,
scaleX: 0.22,
scaleY: 0.25,
tint: 0x000000,
alpha: 0.4
}));
var cardBase = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y,
scaleX: 0.22,
scaleY: 0.25,
tint: 0x1A237E,
alpha: 0.85
}));
var cardGlow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y,
scaleX: 0.24,
scaleY: 0.27,
tint: 0x3F51B5,
alpha: 0.6
}));
// Add sparkle border effect
var cardSparkle = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y,
scaleX: 0.26,
scaleY: 0.29,
tint: 0xE8EAF6,
alpha: 0.3
}));
// Theme icon with illustration
var themeIcon = self.addChild(LK.getAsset(theme.icon, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: theme.id === 'mars' ? 0.8 : 1.3,
scaleY: theme.id === 'mars' ? 0.8 : 1.3,
x: pos.x,
y: pos.y - 30
}));
// Add magical floating animation to icon
(function (icon, speed, baseY) {
var originalUpdate = icon.update || function () {};
icon.update = function () {
originalUpdate.call(icon);
icon.y = baseY + Math.sin(LK.ticks * speed) * 8;
};
})(themeIcon, 0.02 + Math.random() * 0.01, pos.y - 40);
var themeNameText = new Text2(theme.name, {
size: 28,
fill: '#E8EAF6'
});
themeNameText.anchor.set(0.5, 0.5);
themeNameText.x = pos.x;
themeNameText.y = pos.y + 45;
self.addChild(themeNameText);
// Create elegant select button with hover sparkle effect
var selectButtonShadow = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x + 2,
y: pos.y + 92,
scaleX: 0.8,
scaleY: 0.8,
tint: 0x000000,
alpha: 0.4
}));
var selectButton = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y + 90,
scaleX: 0.8,
scaleY: 0.8,
tint: 0x283593,
alpha: 0.9
}));
var selectButtonGlow = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y + 90,
tint: 0x7986CB,
alpha: 0.5,
scaleX: 0.88,
scaleY: 0.88
}));
var selectText = new Text2(storage.selectedTheme === theme.id ? 'SELECTED' : 'SELECT', {
size: 22,
fill: storage.selectedTheme === theme.id ? '#FFD700' : '#FFFFFF'
});
selectText.anchor.set(0.5, 0.5);
selectButton.addChild(selectText);
// Add gentle pulsing glow animation to cards
tween(cardGlow, {
alpha: 0.8,
scaleX: 0.25,
scaleY: 0.28
}, {
duration: 2500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(cardGlow, {
alpha: 0.6,
scaleX: 0.24,
scaleY: 0.27
}, {
duration: 2500,
easing: tween.easeInOut
});
}
});
// Add sparkle animation
tween(cardSparkle, {
alpha: 0.6,
scaleX: 0.28,
scaleY: 0.31
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(cardSparkle, {
alpha: 0.3,
scaleX: 0.26,
scaleY: 0.29
}, {
duration: 3000,
easing: tween.easeInOut
});
}
});
// Add hover effect with gentle enlargement and sparkle
var isSelected = storage.selectedTheme === theme.id;
if (isSelected) {
tween(selectButtonGlow, {
alpha: 0.8,
scaleX: 0.96,
scaleY: 0.96
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(selectButtonGlow, {
alpha: 0.5,
scaleX: 0.88,
scaleY: 0.88
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
}
// Store references for updating button states
var cardData = {
themeId: theme.id,
selectText: selectText,
cardBase: cardBase,
selectButton: selectButton,
selectButtonGlow: selectButtonGlow
};
themeCards.push(cardData);
// Button interaction with sparkle effect
(function (themeId, button, text, cards) {
button.down = function () {
storage.selectedTheme = themeId;
text.setText('SELECTED');
text.fill = '#FFD700';
LK.getSound('select').play();
// Create sparkle effect on selection
for (var sp = 0; sp < 8; sp++) {
var sparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x + (Math.random() - 0.5) * 200,
y: pos.y + (Math.random() - 0.5) * 200,
scaleX: 0.8 + Math.random() * 1.2,
scaleY: 0.8 + Math.random() * 1.2,
alpha: 1,
tint: 0xFFD700
}));
tween(sparkle, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2,
y: sparkle.y - 100
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
sparkle.destroy();
}
});
}
// Update other buttons
for (var c = 0; c < cards.length; c++) {
var card = cards[c];
if (card.themeId !== themeId) {
card.selectText.setText('SELECT');
card.selectText.fill = '#FFFFFF';
}
}
// Apply theme immediately
applyTheme(themeId);
};
})(theme.id, selectButton, selectText, themeCards);
}
}
var closeButton = self.addChild(LK.getAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 800
}));
var closeText = new Text2('CLOSE', {
size: 30,
fill: '#FFFFFF'
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
self.destroy();
if (wasPlaying) {
startCountdown();
} else {
gameState = 'waiting';
tapToStartText.visible = true;
instructionText.visible = true;
}
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x += self.speed;
};
return self;
});
var ShopPanel = Container.expand(function () {
var self = Container.call(this);
var panel = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5
});
// Create vibrant gradient background layers
var gradientLayer1 = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x6A0DAD,
alpha: 0.8
});
var gradientLayer2 = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFF1493,
alpha: 0.4,
scaleX: 0.9,
scaleY: 0.9
});
var gradientLayer3 = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x00CED1,
alpha: 0.3,
scaleX: 0.8,
scaleY: 0.8
});
// Create animated sparkle particles
var sparkleParticles = [];
for (var sp = 0; sp < 20; sp++) {
var sparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1600,
y: (Math.random() - 0.5) * 2000,
scaleX: 0.5 + Math.random() * 1.5,
scaleY: 0.5 + Math.random() * 1.5,
alpha: 0.6 + Math.random() * 0.4,
tint: 0xFFD700
}));
sparkle.originalX = sparkle.x;
sparkle.originalY = sparkle.y;
sparkle.floatSpeed = 0.02 + Math.random() * 0.03;
sparkle.rotationSpeed = 0.05 + Math.random() * 0.1;
sparkleParticles.push(sparkle);
}
// Create flowing light streaks
var lightStreaks = [];
for (var ls = 0; ls < 8; ls++) {
var streak = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1800,
y: (Math.random() - 0.5) * 2200,
scaleX: 3 + Math.random() * 2,
scaleY: 0.3,
alpha: 0.3 + Math.random() * 0.3,
tint: 0x00FFFF,
rotation: Math.random() * Math.PI * 2
}));
streak.originalX = streak.x;
streak.flowSpeed = 0.01 + Math.random() * 0.02;
lightStreaks.push(streak);
}
// Animate gradient layers with pulsing effect
tween(gradientLayer2, {
scaleX: 1.1,
scaleY: 1.1,
alpha: 0.6
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(gradientLayer2, {
scaleX: 0.9,
scaleY: 0.9,
alpha: 0.4
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(gradientLayer2, {
scaleX: 1.1,
scaleY: 1.1,
alpha: 0.6
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
}
});
tween(gradientLayer3, {
scaleX: 1.0,
scaleY: 1.0,
alpha: 0.5
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(gradientLayer3, {
scaleX: 0.8,
scaleY: 0.8,
alpha: 0.3
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(gradientLayer3, {
scaleX: 1.0,
scaleY: 1.0,
alpha: 0.5
}, {
duration: 3000,
easing: tween.easeInOut
});
}
});
}
});
self.update = function () {
// Animate sparkle particles
for (var sp = 0; sp < sparkleParticles.length; sp++) {
var sparkle = sparkleParticles[sp];
sparkle.y += Math.sin(LK.ticks * sparkle.floatSpeed) * 0.5;
sparkle.rotation += sparkle.rotationSpeed;
sparkle.alpha = 0.6 + Math.sin(LK.ticks * sparkle.floatSpeed * 2) * 0.3;
}
// Animate light streaks
for (var ls = 0; ls < lightStreaks.length; ls++) {
var streak = lightStreaks[ls];
streak.x += Math.cos(LK.ticks * streak.flowSpeed) * 2;
streak.alpha = 0.3 + Math.sin(LK.ticks * streak.flowSpeed * 3) * 0.2;
streak.rotation += 0.01;
}
};
var titleText = new Text2('BIRD SHOP', {
size: 80,
fill: '#FFFFFF'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -800;
self.addChild(titleText);
var diamondText = new Text2('Diamonds: ' + storage.diamonds, {
size: 50,
fill: '#00FFFF'
});
diamondText.anchor.set(0.5, 0.5);
diamondText.x = 0;
diamondText.y = -700;
self.addChild(diamondText);
// BIRDS category title
var birdsTitle = new Text2('BIRDS', {
size: 60,
fill: '#FFD700'
});
birdsTitle.anchor.set(0.5, 0.5);
birdsTitle.x = 0;
birdsTitle.y = -500;
self.addChild(birdsTitle);
// Diamond Sword Bird (left side)
var diamondSwordBirdPreview = self.addChild(LK.getAsset('diamondSwordBird', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: -300,
y: -200
}));
var diamondSwordText = new Text2('Diamond Sword Bird\n100 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
diamondSwordText.anchor.set(0.5, 0.5);
diamondSwordText.x = -300;
diamondSwordText.y = -100;
self.addChild(diamondSwordText);
var diamondSwordButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -300,
y: 0
}));
var diamondSwordButtonText = new Text2(storage.ownedBirds.indexOf('diamondSword') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
diamondSwordButtonText.anchor.set(0.5, 0.5);
diamondSwordButton.addChild(diamondSwordButtonText);
diamondSwordButton.down = function () {
if (storage.ownedBirds.indexOf('diamondSword') < 0 && storage.diamonds >= 100) {
storage.diamonds -= 100;
storage.ownedBirds.push('diamondSword');
diamondSwordButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
// Golden Bird (center position)
var goldenBirdPreview = self.addChild(LK.getAsset('goldenBird', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: 0,
y: -200
}));
var goldenText = new Text2('Golden Bird\n200 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
goldenText.anchor.set(0.5, 0.5);
goldenText.x = 0;
goldenText.y = -100;
self.addChild(goldenText);
var goldenButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
}));
var goldenButtonText = new Text2(storage.ownedBirds.indexOf('golden') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
goldenButtonText.anchor.set(0.5, 0.5);
goldenButton.addChild(goldenButtonText);
goldenButton.down = function () {
if (storage.ownedBirds.indexOf('golden') < 0 && storage.diamonds >= 200) {
storage.diamonds -= 200;
storage.ownedBirds.push('golden');
goldenButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
// Fire Bird (right side)
var fireBirdPreview = self.addChild(LK.getAsset('fireBird', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: 300,
y: -200
}));
var fireText = new Text2('Fire Bird\n400 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
fireText.anchor.set(0.5, 0.5);
fireText.x = 300;
fireText.y = -100;
self.addChild(fireText);
var fireButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: 0
}));
var fireButtonText = new Text2(storage.ownedBirds.indexOf('fire') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
fireButtonText.anchor.set(0.5, 0.5);
fireButton.addChild(fireButtonText);
fireButton.down = function () {
if (storage.ownedBirds.indexOf('fire') < 0 && storage.diamonds >= 400) {
storage.diamonds -= 400;
storage.ownedBirds.push('fire');
fireButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
// THEMES category title
var themesTitle = new Text2('THEMES', {
size: 60,
fill: '#FFD700'
});
themesTitle.anchor.set(0.5, 0.5);
themesTitle.x = 0;
themesTitle.y = 200;
self.addChild(themesTitle);
// Morning Theme (left side)
var morningThemeIcon = self.addChild(LK.getAsset('sun', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: -400,
y: 400
}));
var morningText = new Text2('Morning Theme\nFREE', {
size: 30,
fill: '#FFFFFF'
});
morningText.anchor.set(0.5, 0.5);
morningText.x = -400;
morningText.y = 500;
self.addChild(morningText);
var morningButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -400,
y: 600
}));
var morningButtonText = new Text2('OWNED', {
size: 25,
fill: '#FFFFFF'
});
morningButtonText.anchor.set(0.5, 0.5);
morningButton.addChild(morningButtonText);
morningButton.down = function () {
// Morning theme is always free and owned
};
// Night Theme (center position) - Create a night icon with dark colors
var nightThemeIcon = self.addChild(LK.getAsset('nightIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 400
}));
// Add stars to the night icon
var star1 = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: -20,
y: 380
}));
var star2 = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: 15,
y: 370
}));
var star3 = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: -10,
y: 420
}));
// Add a moon to complete the night theme
var moon = self.addChild(LK.getAsset('moon', {
anchorX: 0.5,
anchorY: 0.5,
x: 25,
y: 385
}));
var nightText = new Text2('Night Theme\n800 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
nightText.anchor.set(0.5, 0.5);
nightText.x = 0;
nightText.y = 500;
self.addChild(nightText);
var nightButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 600
}));
var nightButtonText = new Text2(storage.ownedThemes && storage.ownedThemes.indexOf('night') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
nightButtonText.anchor.set(0.5, 0.5);
nightButton.addChild(nightButtonText);
nightButton.down = function () {
if (!storage.ownedThemes) storage.ownedThemes = [];
if (storage.ownedThemes.indexOf('night') < 0 && storage.diamonds >= 800) {
storage.diamonds -= 800;
storage.ownedThemes.push('night');
nightButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
// Mars Theme (right side) - Create Mars theme with red planet appearance
var marsThemeIcon = self.addChild(LK.getAsset('marsIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 400,
y: 400,
scaleX: 1.5,
scaleY: 1.5
}));
var marsText = new Text2('Mars Theme\n1500 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
marsText.anchor.set(0.5, 0.5);
marsText.x = 400;
marsText.y = 500;
self.addChild(marsText);
var marsButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 400,
y: 600
}));
var marsButtonText = new Text2(storage.ownedThemes && storage.ownedThemes.indexOf('mars') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
marsButtonText.anchor.set(0.5, 0.5);
marsButton.addChild(marsButtonText);
marsButton.down = function () {
if (!storage.ownedThemes) storage.ownedThemes = [];
if (storage.ownedThemes.indexOf('mars') < 0 && storage.diamonds >= 1500) {
storage.diamonds -= 1500;
storage.ownedThemes.push('mars');
marsButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
var closeButton = self.addChild(LK.getAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 800
}));
var closeText = new Text2('CLOSE', {
size: 30,
fill: '#FFFFFF'
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
self.destroy();
if (wasPlaying) {
startCountdown();
} else {
gameState = 'waiting';
// Show tap to start UI when returning to waiting state
tapToStartText.visible = true;
instructionText.visible = true;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Ensure Morning theme is always owned (for existing players)
if (!storage.ownedThemes) {
storage.ownedThemes = ["morning"];
}
if (storage.ownedThemes.indexOf("morning") < 0) {
storage.ownedThemes.push("morning");
}
var bird;
var obstacles = [];
var diamonds = [];
var ground;
var gameState = 'waiting'; // Start with waiting state
var obstacleTimer = 0;
var diamondTimer = 0;
var obstacleCount = 0;
var isCountingDown = false;
var countdownValue = 3;
var wasPlaying = false; // Track if game was playing before opening panels
var highScore = storage.highScore || 0; // Track highest obstacle count reached
// Theme elements
var backgroundSun;
var backgroundMoon;
var backgroundStars = [];
var marsDustClouds = [];
var marsSparkleStars = [];
function applyTheme(themeId) {
if (themeId === 'morning') {
// Morning theme - light blue sky with sun
game.setBackgroundColor(0x87CEEB);
// Show sun, hide moon and stars
if (backgroundSun) backgroundSun.visible = true;
if (backgroundMoon) backgroundMoon.visible = false;
for (var s = 0; s < backgroundStars.length; s++) {
backgroundStars[s].visible = false;
}
// Show clouds in morning theme
for (var c = 0; c < clouds.length; c++) {
clouds[c].visible = true;
}
// Hide mars dust clouds in morning theme
for (var d = 0; d < marsDustClouds.length; d++) {
marsDustClouds[d].visible = false;
}
} else if (themeId === 'night') {
// Night theme - dark sky with moon and stars
game.setBackgroundColor(0x191970);
// Hide sun, show moon and stars
if (backgroundSun) backgroundSun.visible = false;
if (backgroundMoon) backgroundMoon.visible = true;
for (var s = 0; s < backgroundStars.length; s++) {
backgroundStars[s].visible = true;
}
// Hide clouds in night theme
for (var c = 0; c < clouds.length; c++) {
clouds[c].visible = false;
}
} else if (themeId === 'mars') {
// Mars theme - reddish orange sky
game.setBackgroundColor(0xCD853F);
// Hide sun and moon, show specific mars elements
if (backgroundSun) backgroundSun.visible = false;
if (backgroundMoon) backgroundMoon.visible = false;
for (var s = 0; s < backgroundStars.length; s++) {
backgroundStars[s].visible = false;
}
// Hide regular clouds, show mars dust clouds
for (var c = 0; c < clouds.length; c++) {
clouds[c].visible = false;
}
for (var d = 0; d < marsDustClouds.length; d++) {
marsDustClouds[d].visible = true;
}
// Show mars sparkle stars
for (var ms = 0; ms < marsSparkleStars.length; ms++) {
marsSparkleStars[ms].visible = true;
}
}
}
// UI Elements
var diamondCountText = new Text2('Diamonds: ' + storage.diamonds, {
size: 40,
fill: '#00FFFF'
});
diamondCountText.anchor.set(1, 1);
LK.gui.bottomRight.addChild(diamondCountText);
var obstacleCountText = new Text2('Obstacle: 0', {
size: 50,
fill: '#FFFFFF'
});
obstacleCountText.anchor.set(0.5, 0);
obstacleCountText.y = 100; // Position below the top to avoid platform menu
LK.gui.top.addChild(obstacleCountText);
var shopButton = LK.getAsset('shopButton', {
anchorX: 0,
anchorY: 1,
x: 0,
y: 0
});
var shopButtonText = new Text2('SHOP', {
size: 25,
fill: '#FFFFFF'
});
shopButtonText.anchor.set(0.5, 0.5);
shopButton.addChild(shopButtonText);
LK.gui.bottomLeft.addChild(shopButton);
var myThemesButton = LK.getAsset('themesButton', {
anchorX: 0,
anchorY: 1,
x: 170,
y: 0
});
var myThemesButtonText = new Text2('MY THEMES', {
size: 20,
fill: '#FFFFFF'
});
myThemesButtonText.anchor.set(0.5, 0.5);
myThemesButton.addChild(myThemesButtonText);
LK.gui.bottomLeft.addChild(myThemesButton);
var inventoryButton = LK.getAsset('inventoryButton', {
anchorX: 1,
anchorY: 0
});
var inventoryButtonText = new Text2('INVENTORY', {
size: 20,
fill: '#FFFFFF'
});
inventoryButtonText.anchor.set(0.5, 0.5);
inventoryButton.addChild(inventoryButtonText);
LK.gui.topRight.addChild(inventoryButton);
// Position inventory button below diamond counter
inventoryButton.y = 60;
var giftButton = LK.getAsset('giftButton', {
anchorX: 1,
anchorY: 0
});
var giftButtonText = new Text2('GIFT', {
size: 20,
fill: '#FFFFFF'
});
giftButtonText.anchor.set(0.5, 0.5);
giftButton.addChild(giftButtonText);
LK.gui.topRight.addChild(giftButton);
// Position gift button below inventory button
giftButton.y = 160;
// Tap to start UI
var tapToStartText = new Text2('TAP TO START', {
size: 80,
fill: '#FFFFFF'
});
tapToStartText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(tapToStartText);
var instructionText = new Text2('Tap screen to flap\nAvoid obstacles\nCollect diamonds', {
size: 40,
fill: '#FFFFFF'
});
instructionText.anchor.set(0.5, 0.5);
instructionText.y = 100;
LK.gui.center.addChild(instructionText);
// Countdown text for resume
var countdownText = new Text2('3', {
size: 200,
fill: '#FFFF00'
});
countdownText.anchor.set(0.5, 0.5);
countdownText.visible = false;
LK.gui.center.addChild(countdownText);
shopButton.down = function () {
if (gameState === 'playing' || gameState === 'waiting') {
wasPlaying = gameState === 'playing';
gameState = 'shop';
// Hide tap to start UI when opening shop
tapToStartText.visible = false;
instructionText.visible = false;
var shopPanel = new ShopPanel();
shopPanel.x = 1024;
shopPanel.y = 1366;
game.addChild(shopPanel);
}
// Update clouds - move them slowly across screen
for (var k = clouds.length - 1; k >= 0; k--) {
var cloud = clouds[k];
cloud.x += cloud.speed;
// Respawn cloud on the right when it goes off-screen
if (cloud.x < -120) {
cloud.x = 2048 + 120;
cloud.y = Math.random() * 1500 + 200;
cloud.scaleX = 0.8 + Math.random() * 0.6;
cloud.scaleY = 0.8 + Math.random() * 0.6;
cloud.speed = -0.5 - Math.random() * 1;
}
}
// Update Mars dust clouds
for (var md = 0; md < marsDustClouds.length; md++) {
var dustCloud = marsDustClouds[md];
if (dustCloud.visible) {
dustCloud.x += dustCloud.speed;
if (dustCloud.x < -120) {
dustCloud.x = 2048 + 120;
dustCloud.y = Math.random() * 1800 + 400;
dustCloud.scaleX = 0.6 + Math.random() * 0.8;
dustCloud.scaleY = 0.6 + Math.random() * 0.8;
dustCloud.speed = -0.3 - Math.random() * 0.7;
}
}
}
// Update Mars sparkle stars
for (var mst = 0; mst < marsSparkleStars.length; mst++) {
var sparkle = marsSparkleStars[mst];
if (sparkle.visible) {
sparkle.alpha = sparkle.originalAlpha + Math.sin(LK.ticks * sparkle.twinkleSpeed) * 0.3;
}
}
};
inventoryButton.down = function () {
if (gameState === 'playing' || gameState === 'waiting') {
wasPlaying = gameState === 'playing';
gameState = 'inventory';
// Hide tap to start UI when opening inventory
tapToStartText.visible = false;
instructionText.visible = false;
var inventoryPanel = new InventoryPanel();
inventoryPanel.x = 1024;
inventoryPanel.y = 1366;
game.addChild(inventoryPanel);
}
};
giftButton.down = function () {
if (gameState === 'playing' || gameState === 'waiting') {
wasPlaying = gameState === 'playing';
gameState = 'gift';
// Hide tap to start UI when opening gift panel
tapToStartText.visible = false;
instructionText.visible = false;
var giftPanel = new GiftPanel();
giftPanel.x = 1024;
giftPanel.y = 1366;
game.addChild(giftPanel);
}
};
myThemesButton.down = function () {
if (gameState === 'playing' || gameState === 'waiting') {
wasPlaying = gameState === 'playing';
gameState = 'mythemes';
// Hide tap to start UI when opening my themes panel
tapToStartText.visible = false;
instructionText.visible = false;
var myThemesPanel = new MyThemesPanel();
myThemesPanel.x = 1024;
myThemesPanel.y = 1366;
game.addChild(myThemesPanel);
}
};
// Initialize bird
bird = new Bird();
bird.x = 300;
bird.y = 1366;
game.addChild(bird);
// Initialize ground
ground = LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2732 - 100
});
game.addChild(ground);
// Initialize background clouds
var clouds = [];
for (var c = 0; c < 6; c++) {
var cloud = LK.getAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 1500 + 200,
scaleX: 0.8 + Math.random() * 0.6,
scaleY: 0.8 + Math.random() * 0.6,
alpha: 0.7
});
cloud.speed = -0.5 - Math.random() * 1;
clouds.push(cloud);
game.addChild(cloud);
}
// Initialize theme background elements
backgroundSun = LK.getAsset('sun', {
anchorX: 0.5,
anchorY: 0.5,
x: 1800,
y: 300,
scaleX: 1.5,
scaleY: 1.5,
alpha: 0.8
});
game.addChild(backgroundSun);
backgroundMoon = LK.getAsset('moon', {
anchorX: 0.5,
anchorY: 0.5,
x: 1800,
y: 300,
scaleX: 3,
scaleY: 3,
alpha: 0.9,
visible: false
});
game.addChild(backgroundMoon);
// Create background stars
for (var st = 0; st < 15; st++) {
var star = LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 1000 + 100,
scaleX: 1 + Math.random() * 2,
scaleY: 1 + Math.random() * 2,
alpha: 0.7 + Math.random() * 0.3,
visible: false
});
backgroundStars.push(star);
game.addChild(star);
}
// Create Mars dust clouds
for (var md = 0; md < 8; md++) {
var dustCloud = LK.getAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 1800 + 400,
scaleX: 0.6 + Math.random() * 0.8,
scaleY: 0.6 + Math.random() * 0.8,
alpha: 0.3 + Math.random() * 0.3,
tint: 0xD2691E,
visible: false
});
dustCloud.speed = -0.3 - Math.random() * 0.7;
marsDustClouds.push(dustCloud);
game.addChild(dustCloud);
}
// Create Mars sparkle stars
for (var mst = 0; mst < 10; mst++) {
var sparkleVar = LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 800 + 100,
scaleX: 0.8 + Math.random() * 1.5,
scaleY: 0.8 + Math.random() * 1.5,
alpha: 0.8 + Math.random() * 0.2,
tint: 0xFFD700,
visible: false
});
sparkleVar.twinkleSpeed = 0.02 + Math.random() * 0.03;
sparkleVar.originalAlpha = sparkleVar.alpha;
marsSparkleStars.push(sparkleVar);
game.addChild(sparkleVar);
}
// Apply initial theme
applyTheme(storage.selectedTheme || 'morning');
function startCountdown() {
isCountingDown = true;
countdownValue = 3;
countdownText.setText(countdownValue.toString());
countdownText.visible = true;
countdownText.alpha = 1;
countdownText.scaleX = 1;
countdownText.scaleY = 1;
function showNumber() {
countdownText.setText(countdownValue.toString());
countdownText.alpha = 1;
countdownText.scaleX = 2;
countdownText.scaleY = 2;
tween(countdownText, {
alpha: 0.3,
scaleX: 1,
scaleY: 1
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
countdownValue--;
if (countdownValue > 0) {
showNumber();
} else {
countdownText.visible = false;
isCountingDown = false;
gameState = 'playing';
}
}
});
}
showNumber();
}
game.down = function (x, y, obj) {
if (gameState === 'waiting') {
// Start the game
gameState = 'playing';
// Reset obstacle counter
obstacleCount = 0;
obstacleCountText.setText('Obstacle: 0');
// Hide tap to start UI
tapToStartText.visible = false;
instructionText.visible = false;
// Start background music
LK.playMusic('bgmusic');
} else if (gameState === 'playing') {
bird.flap();
}
};
game.update = function () {
if (gameState === 'waiting') {
// Animate tap to start text
tapToStartText.y = Math.sin(LK.ticks * 0.1) * 20;
// Don't update game mechanics while waiting
return;
}
if (gameState !== 'playing' || isCountingDown || gameState === 'shop' || gameState === 'inventory' || gameState === 'gift' || gameState === 'mythemes') {
return;
}
// Spawn obstacles
obstacleTimer++;
if (obstacleTimer >= 90) {
// Every 1.5 seconds at 60fps - faster spawn rate
obstacleTimer = 0;
// Create gap in middle
var gapSize = 320; // Further increased gap size for easier gameplay
var gapCenter = Math.random() * (2732 - 200 - gapSize) + 100 + gapSize / 2;
// Top obstacle
var topObstacle = new Obstacle();
topObstacle.x = 2048 + 40;
topObstacle.y = gapCenter - gapSize / 2 - 200;
obstacles.push(topObstacle);
game.addChild(topObstacle);
// Bottom obstacle
var bottomObstacle = new Obstacle();
bottomObstacle.x = 2048 + 40;
bottomObstacle.y = gapCenter + gapSize / 2 + 200;
obstacles.push(bottomObstacle);
game.addChild(bottomObstacle);
}
// Spawn diamonds
diamondTimer++;
if (diamondTimer >= 90) {
// Every 1.5 seconds
diamondTimer = 0;
var diamond = new Diamond();
diamond.x = 2048 + 15;
diamond.y = Math.random() * (2732 - 300) + 150;
diamonds.push(diamond);
game.addChild(diamond);
}
// Update and check obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
// Check if bird passed this obstacle (from right to left)
if (obstacle.lastX === undefined) obstacle.lastX = obstacle.x;
if (obstacle.lastX > bird.x && obstacle.x <= bird.x && !obstacle.passed) {
obstacle.passed = true;
// Only count every second obstacle (since we create pairs)
if (i % 2 === 0) {
obstacleCount++;
obstacleCountText.setText('Obstacle: ' + obstacleCount);
}
}
obstacle.lastX = obstacle.x;
if (obstacle.x < -100) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Collision with bird - check with scaled bird size
var birdBounds = {
left: bird.x - 60 * 1.5 / 2,
right: bird.x + 60 * 1.5 / 2,
top: bird.y - 60 * 1.5 / 2,
bottom: bird.y + 60 * 1.5 / 2
};
var obstacleBounds = {
left: obstacle.x - 40,
right: obstacle.x + 40,
top: obstacle.y - 200,
bottom: obstacle.y + 200
};
if (birdBounds.right > obstacleBounds.left && birdBounds.left < obstacleBounds.right && birdBounds.bottom > obstacleBounds.top && birdBounds.top < obstacleBounds.bottom) {
// Update high score if current score is higher
if (obstacleCount > highScore) {
highScore = obstacleCount;
storage.highScore = highScore;
}
LK.showGameOver();
return;
}
}
// Update and check diamonds
for (var j = diamonds.length - 1; j >= 0; j--) {
var diamond = diamonds[j];
if (diamond.x < -50) {
diamond.destroy();
diamonds.splice(j, 1);
continue;
}
// Collection by bird
if (!diamond.collected && bird.intersects(diamond)) {
diamond.collected = true;
storage.diamonds++;
diamondCountText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('collect').play();
diamond.destroy();
diamonds.splice(j, 1);
}
}
}; /****
* Plugins
****/
var storage = LK.import("@upit/storage.v1", {
diamonds: 0,
ownedBirds: ["classic"],
selectedBird: "classic",
lastDailyReward: 0,
ownedThemes: ["morning"],
selectedTheme: "morning"
});
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
self.velocity = 0;
self.gravity = 0.8;
self.flapPower = -15;
self.updateBirdSkin = function () {
if (self.birdGraphics) {
self.removeChild(self.birdGraphics);
}
var skinAsset = 'bird';
if (storage.selectedBird === 'diamondSword') {
skinAsset = 'diamondSwordBird';
} else if (storage.selectedBird === 'golden') {
skinAsset = 'goldenBird';
} else if (storage.selectedBird === 'fire') {
skinAsset = 'fireBird';
}
self.birdGraphics = self.attachAsset(skinAsset, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
};
self.updateBirdSkin();
self.flap = function () {
self.velocity = self.flapPower;
LK.getSound('flap').play();
};
self.update = function () {
if (gameState !== 'playing') {
return;
}
self.velocity += self.gravity;
self.y += self.velocity;
// Rotate bird based on velocity
self.birdGraphics.rotation = Math.min(Math.max(self.velocity * 0.05, -0.5), 0.5);
// Ground collision
if (self.y > 2732 - 100 - 30) {
// Update high score if current score is higher
if (obstacleCount > highScore) {
highScore = obstacleCount;
storage.highScore = highScore;
}
LK.showGameOver();
}
// Screen boundary collision
if (self.y < 0) {
// Update high score if current score is higher
if (obstacleCount > highScore) {
highScore = obstacleCount;
storage.highScore = highScore;
}
LK.showGameOver();
}
};
return self;
});
var Diamond = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
self.collected = false;
var diamondGraphics = self.attachAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
rotation: Math.PI / 4,
scaleX: 2,
scaleY: 2
});
self.update = function () {
self.x += self.speed;
diamondGraphics.rotation += 0.1;
};
return self;
});
var GiftPanel = Container.expand(function () {
var self = Container.call(this);
// Create magical gradient background with treasure chest vibes
var magicalBg1 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x4A148C,
alpha: 0.95
});
var magicalBg2 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700,
alpha: 0.3,
scaleX: 0.95,
scaleY: 0.95
});
var magicalBg3 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFF6B35,
alpha: 0.4,
scaleX: 0.9,
scaleY: 0.9
});
// Create glowing treasure chest base using multiple diamonds
var treasureBase = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -200,
scaleX: 0.3,
scaleY: 0.2,
tint: 0x8B4513,
alpha: 0.9
}));
var treasureGlow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -200,
scaleX: 0.35,
scaleY: 0.25,
tint: 0xFFD700,
alpha: 0.6
}));
// Create treasure chest gems using multiple diamonds
var chestGem1 = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: -30,
y: -220,
scaleX: 3,
scaleY: 3,
tint: 0x00FFFF
}));
var chestGem2 = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: 30,
y: -220,
scaleX: 3,
scaleY: 3,
tint: 0xFF69B4
}));
var chestGem3 = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -180,
scaleX: 4,
scaleY: 4,
tint: 0xFFD700
}));
// Create sparkle particles floating around
var sparkleParticles = [];
for (var sp = 0; sp < 25; sp++) {
var sparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1600,
y: (Math.random() - 0.5) * 2000,
scaleX: 0.8 + Math.random() * 1.5,
scaleY: 0.8 + Math.random() * 1.5,
alpha: 0.7 + Math.random() * 0.3,
tint: 0xFFD700
}));
sparkle.floatSpeed = 0.02 + Math.random() * 0.04;
sparkle.originalY = sparkle.y;
sparkle.rotationSpeed = 0.06 + Math.random() * 0.1;
sparkleParticles.push(sparkle);
}
// Create confetti particles
var confettiParticles = [];
var confettiColors = [0xFF69B4, 0x00FFFF, 0x32CD32, 0xFFD700, 0xFF4500];
for (var cp = 0; cp < 15; cp++) {
var confetti = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1400,
y: (Math.random() - 0.5) * 1800,
scaleX: 0.5 + Math.random() * 1,
scaleY: 0.5 + Math.random() * 1,
alpha: 0.8,
tint: confettiColors[Math.floor(Math.random() * confettiColors.length)]
}));
confetti.fallSpeed = 0.02 + Math.random() * 0.03;
confetti.sideSpeed = (Math.random() - 0.5) * 0.04;
confetti.rotationSpeed = 0.08 + Math.random() * 0.12;
confettiParticles.push(confetti);
}
// Animate treasure chest with gentle glow pulsing
tween(treasureGlow, {
alpha: 0.9,
scaleX: 0.4,
scaleY: 0.3
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(treasureGlow, {
alpha: 0.6,
scaleX: 0.35,
scaleY: 0.25
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
// Animate chest gems with magical sparkle
tween(chestGem1, {
scaleX: 3.5,
scaleY: 3.5,
alpha: 0.9
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(chestGem1, {
scaleX: 3,
scaleY: 3,
alpha: 1
}, {
duration: 1500,
easing: tween.easeInOut
});
}
});
tween(chestGem2, {
scaleX: 3.5,
scaleY: 3.5,
alpha: 0.9
}, {
duration: 1800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(chestGem2, {
scaleX: 3,
scaleY: 3,
alpha: 1
}, {
duration: 1800,
easing: tween.easeInOut
});
}
});
// Update function for animated effects
self.update = function () {
// Animate sparkle particles
for (var sp = 0; sp < sparkleParticles.length; sp++) {
var sparkle = sparkleParticles[sp];
sparkle.y = sparkle.originalY + Math.sin(LK.ticks * sparkle.floatSpeed) * 30;
sparkle.rotation += sparkle.rotationSpeed;
sparkle.alpha = 0.7 + Math.sin(LK.ticks * sparkle.floatSpeed * 2) * 0.3;
}
// Animate confetti particles
for (var cp = 0; cp < confettiParticles.length; cp++) {
var confetti = confettiParticles[cp];
confetti.y += Math.sin(LK.ticks * confetti.fallSpeed) * 0.8;
confetti.x += Math.sin(LK.ticks * confetti.sideSpeed) * 0.5;
confetti.rotation += confetti.rotationSpeed;
}
};
var titleText = new Text2('DAILY TREASURE', {
size: 80,
fill: '#FFD700'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -800;
self.addChild(titleText);
// Check if daily reward is available (24 hours = 86400000 milliseconds)
var currentTime = Date.now();
var timeSinceLastReward = currentTime - (storage.lastDailyReward || 0);
var canClaimReward = timeSinceLastReward >= 86400000;
// Calculate time remaining for next gift
var timeRemaining = 86400000 - timeSinceLastReward;
var hoursRemaining = Math.floor(timeRemaining / 3600000);
var minutesRemaining = Math.floor(timeRemaining % 3600000 / 60000);
var rewardText = new Text2('đ CLAIM 5 GEMS đ', {
size: 60,
fill: '#FFD700'
});
rewardText.anchor.set(0.5, 0.5);
rewardText.x = 0;
rewardText.y = 50;
self.addChild(rewardText);
var statusText;
if (canClaimReward) {
statusText = new Text2('⨠AVAILABLE NOW! â¨', {
size: 45,
fill: '#00FF00'
});
} else {
statusText = new Text2('Come back in ' + hoursRemaining + 'h ' + minutesRemaining + 'm', {
size: 40,
fill: '#FF6B35'
});
}
statusText.anchor.set(0.5, 0.5);
statusText.x = 0;
statusText.y = 150;
self.addChild(statusText);
// Create glowing claim button
var claimButtonShadow = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 3,
y: 303,
tint: 0x000000,
alpha: 0.5
}));
var claimButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 300,
tint: canClaimReward ? 0x32CD32 : 0x696969
}));
var claimButtonGlow = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 300,
tint: 0xFFD700,
alpha: canClaimReward ? 0.6 : 0.2,
scaleX: 1.1,
scaleY: 1.1
}));
var claimButtonText = new Text2(canClaimReward ? 'CLAIM 5 GEMS' : 'CLAIMED', {
size: 30,
fill: '#FFFFFF'
});
claimButtonText.anchor.set(0.5, 0.5);
claimButton.addChild(claimButtonText);
// Add glowing animation to available button
if (canClaimReward) {
tween(claimButtonGlow, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(claimButtonGlow, {
alpha: 0.6,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1500,
easing: tween.easeInOut
});
}
});
}
claimButton.down = function () {
if (canClaimReward) {
storage.diamonds += 5;
storage.lastDailyReward = currentTime;
diamondCountText.setText('Diamonds: ' + storage.diamonds);
claimButtonText.setText('CLAIMED');
statusText.setText('Come back tomorrow!');
statusText.fill = '#FF6B35';
claimButtonGlow.alpha = 0.2;
claimButton.tint = 0x696969;
// Create celebration sparkles
for (var cs = 0; cs < 20; cs++) {
var celebrationSparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 400,
y: 300 + (Math.random() - 0.5) * 200,
scaleX: 1 + Math.random() * 2,
scaleY: 1 + Math.random() * 2,
alpha: 1,
tint: 0xFFD700
}));
tween(celebrationSparkle, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2,
y: celebrationSparkle.y - 200
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
celebrationSparkle.destroy();
}
});
}
}
};
var creatorText = new Text2('Creator:ironx_creator0', {
size: 25,
fill: '#888888'
});
creatorText.anchor.set(0.5, 0.5);
creatorText.x = 0;
creatorText.y = 700;
self.addChild(creatorText);
var closeButton = self.addChild(LK.getAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 800
}));
var closeText = new Text2('CLOSE', {
size: 30,
fill: '#FFFFFF'
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
self.destroy();
if (wasPlaying) {
startCountdown();
} else {
gameState = 'waiting';
tapToStartText.visible = true;
instructionText.visible = true;
}
};
return self;
});
var InventoryPanel = Container.expand(function () {
var self = Container.call(this);
// Create multiple layered backgrounds for frosted glass effect
var glassLayer1 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x2C3E50,
alpha: 0.85
});
var glassLayer2 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x34495E,
alpha: 0.6,
scaleX: 0.98,
scaleY: 0.98
});
var glassLayer3 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x5D6D7E,
alpha: 0.4,
scaleX: 0.96,
scaleY: 0.96
});
// Create glowing edge effects
var glowEdge1 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xF1C40F,
alpha: 0.3,
scaleX: 1.02,
scaleY: 1.02
});
var glowEdge2 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xE67E22,
alpha: 0.2,
scaleX: 1.04,
scaleY: 1.04
});
// Create subtle shadow depth
var shadowLayer = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x000000,
alpha: 0.3,
scaleX: 1.01,
scaleY: 1.01,
x: 8,
y: 8
});
// Add animated sparkle particles for premium feel
var inventorySparkles = [];
for (var sp = 0; sp < 12; sp++) {
var sparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1600,
y: (Math.random() - 0.5) * 1900,
scaleX: 0.3 + Math.random() * 0.8,
scaleY: 0.3 + Math.random() * 0.8,
alpha: 0.4 + Math.random() * 0.4,
tint: 0xF39C12
}));
sparkle.originalX = sparkle.x;
sparkle.originalY = sparkle.y;
sparkle.floatSpeed = 0.015 + Math.random() * 0.025;
sparkle.rotationSpeed = 0.03 + Math.random() * 0.06;
inventorySparkles.push(sparkle);
}
// Animate glow edges with gentle pulsing
tween(glowEdge1, {
alpha: 0.5,
scaleX: 1.03,
scaleY: 1.03
}, {
duration: 2500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(glowEdge1, {
alpha: 0.3,
scaleX: 1.02,
scaleY: 1.02
}, {
duration: 2500,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(glowEdge1, {
alpha: 0.5,
scaleX: 1.03,
scaleY: 1.03
}, {
duration: 2500,
easing: tween.easeInOut
});
}
});
}
});
tween(glowEdge2, {
alpha: 0.35,
scaleX: 1.05,
scaleY: 1.05
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(glowEdge2, {
alpha: 0.2,
scaleX: 1.04,
scaleY: 1.04
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(glowEdge2, {
alpha: 0.35,
scaleX: 1.05,
scaleY: 1.05
}, {
duration: 3000,
easing: tween.easeInOut
});
}
});
}
});
self.update = function () {
// Animate sparkle particles
for (var sp = 0; sp < inventorySparkles.length; sp++) {
var sparkle = inventorySparkles[sp];
sparkle.y += Math.sin(LK.ticks * sparkle.floatSpeed) * 0.3;
sparkle.rotation += sparkle.rotationSpeed;
sparkle.alpha = 0.4 + Math.sin(LK.ticks * sparkle.floatSpeed * 1.5) * 0.2;
}
};
var titleText = new Text2('INVENTORY', {
size: 80,
fill: '#FFFFFF'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -800;
self.addChild(titleText);
var highScoreText = new Text2('High Score: ' + highScore + ' obstacles', {
size: 50,
fill: '#FFD700'
});
highScoreText.anchor.set(0.5, 0.5);
highScoreText.x = 0;
highScoreText.y = 700;
self.addChild(highScoreText);
var birdTypes = [{
id: 'classic',
name: 'Classic Bird',
asset: 'bird'
}, {
id: 'diamondSword',
name: 'Diamond Sword Bird',
asset: 'diamondSwordBird'
}, {
id: 'golden',
name: 'Golden Bird',
asset: 'goldenBird'
}, {
id: 'fire',
name: 'Fire Bird',
asset: 'fireBird'
}];
var ownedIndex = 0;
for (var i = 0; i < birdTypes.length; i++) {
var birdType = birdTypes[i];
if (storage.ownedBirds.indexOf(birdType.id) >= 0) {
// Calculate position in 2x2 grid
var col = ownedIndex % 2; // 0 for left, 1 for right
var row = Math.floor(ownedIndex / 2); // 0 for top, 1 for bottom
var x = col === 0 ? -300 : 300; // Left or right position
var y = -400 + row * 400; // Top or bottom position with spacing
// Move golden bird and fire bird down by adjusting their y position
if (birdType.id === 'golden' || birdType.id === 'fire') {
y += 100; // Move these birds down by 100 pixels
}
// Create elegant pedestal for each bird slot
var pedestalShadow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: x + 3,
y: y + 3,
scaleX: 0.25,
scaleY: 0.25,
tint: 0x000000,
alpha: 0.4
}));
var pedestalBase = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y,
scaleX: 0.25,
scaleY: 0.25,
tint: 0x2C3E50,
alpha: 0.8
}));
var pedestalGlow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y,
scaleX: 0.27,
scaleY: 0.27,
tint: 0xF1C40F,
alpha: 0.3
}));
// Golden rim for premium feel
var goldenRim = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y,
scaleX: 0.26,
scaleY: 0.26,
tint: 0xD4AF37,
alpha: 0.6
}));
var birdPreview = self.addChild(LK.getAsset(birdType.asset, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: x,
y: y
}));
// Add gentle floating animation to bird
var birdFloatSpeed = 0.02 + Math.random() * 0.01;
(function (bird, speed, baseY) {
var originalUpdate = bird.update || function () {};
bird.update = function () {
originalUpdate.call(bird);
bird.y = baseY + Math.sin(LK.ticks * speed) * 8;
};
})(birdPreview, birdFloatSpeed, y);
// Animate pedestal glow
tween(pedestalGlow, {
alpha: 0.5,
scaleX: 0.28,
scaleY: 0.28
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(pedestalGlow, {
alpha: 0.3,
scaleX: 0.27,
scaleY: 0.27
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
var birdNameText = new Text2(birdType.name, {
size: 40,
fill: '#F1C40F'
});
birdNameText.anchor.set(0.5, 0.5);
birdNameText.x = x;
birdNameText.y = y + 80;
self.addChild(birdNameText);
// Create elegant button background
var buttonShadow = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: x + 2,
y: y + 152,
tint: 0x000000,
alpha: 0.4
}));
var buttonBase = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y + 150,
tint: 0x2C3E50,
alpha: 0.9
}));
var buttonGlow = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y + 150,
tint: 0xE67E22,
alpha: 0.4,
scaleX: 1.1,
scaleY: 1.1
}));
var selectButton = buttonBase;
var selectText = new Text2(storage.selectedBird === birdType.id ? 'SELECTED' : 'SELECT', {
size: 30,
fill: storage.selectedBird === birdType.id ? '#F1C40F' : '#FFFFFF'
});
selectText.anchor.set(0.5, 0.5);
selectButton.addChild(selectText);
// Add hover effect animation
var isSelected = storage.selectedBird === birdType.id;
if (isSelected) {
tween(buttonGlow, {
alpha: 0.7,
scaleX: 1.15,
scaleY: 1.15
}, {
duration: 1500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(buttonGlow, {
alpha: 0.4,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1500,
easing: tween.easeInOut
});
}
});
}
(function (birdId, button, text) {
button.down = function () {
storage.selectedBird = birdId;
text.setText('SELECTED');
LK.getSound('select').play();
// Update other buttons
for (var j = 0; j < self.children.length; j++) {
var child = self.children[j];
if (child.children && child.children[0] && child.children[0].text && child.children[0].text.indexOf('SELECT') >= 0) {
if (child !== button) {
child.children[0].setText('SELECT');
}
}
}
};
})(birdType.id, selectButton, selectText);
ownedIndex++;
}
}
var closeButton = self.addChild(LK.getAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 800
}));
var closeText = new Text2('CLOSE', {
size: 30,
fill: '#FFFFFF'
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
if (bird) {
bird.updateBirdSkin();
}
self.destroy();
if (wasPlaying) {
startCountdown();
} else {
gameState = 'waiting';
// Show tap to start UI when returning to waiting state
tapToStartText.visible = true;
instructionText.visible = true;
}
};
return self;
});
var MyThemesPanel = Container.expand(function () {
var self = Container.call(this);
// Create dynamic animated background with color shifting
var bgLayer1 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x4A148C,
alpha: 0.9
});
var bgLayer2 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x7B1FA2,
alpha: 0.7,
scaleX: 0.95,
scaleY: 0.95
});
var bgLayer3 = self.attachAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x8E24AA,
alpha: 0.5,
scaleX: 0.9,
scaleY: 0.9
});
// Create magical particle effects drifting around
var magicParticles = [];
for (var mp = 0; mp < 15; mp++) {
var particle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1700,
y: (Math.random() - 0.5) * 2100,
scaleX: 0.4 + Math.random() * 0.8,
scaleY: 0.4 + Math.random() * 0.8,
alpha: 0.5 + Math.random() * 0.4,
tint: 0xE1BEE7
}));
particle.driftSpeedX = (Math.random() - 0.5) * 0.02;
particle.driftSpeedY = (Math.random() - 0.5) * 0.015;
particle.twinkleSpeed = 0.03 + Math.random() * 0.04;
particle.originalAlpha = particle.alpha;
magicParticles.push(particle);
}
// Animate background layers with magical color shifting
tween(bgLayer1, {
tint: 0x6A1B9A,
alpha: 0.95
}, {
duration: 4000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bgLayer1, {
tint: 0x4A148C,
alpha: 0.9
}, {
duration: 4000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart color cycle
tween(bgLayer1, {
tint: 0x6A1B9A,
alpha: 0.95
}, {
duration: 4000,
easing: tween.easeInOut
});
}
});
}
});
tween(bgLayer2, {
tint: 0x9C27B0,
scaleX: 1.0,
scaleY: 1.0,
alpha: 0.8
}, {
duration: 5000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bgLayer2, {
tint: 0x7B1FA2,
scaleX: 0.95,
scaleY: 0.95,
alpha: 0.7
}, {
duration: 5000,
easing: tween.easeInOut
});
}
});
self.update = function () {
// Animate magical particles
for (var mp = 0; mp < magicParticles.length; mp++) {
var particle = magicParticles[mp];
particle.x += particle.driftSpeedX;
particle.y += particle.driftSpeedY;
particle.alpha = particle.originalAlpha + Math.sin(LK.ticks * particle.twinkleSpeed) * 0.3;
particle.rotation += 0.02;
// Wrap particles around screen
if (particle.x > 900) particle.x = -900;
if (particle.x < -900) particle.x = 900;
if (particle.y > 1100) particle.y = -1100;
if (particle.y < -1100) particle.y = 1100;
}
};
var titleText = new Text2('MY THEMES', {
size: 80,
fill: '#FFFFFF'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -800;
self.addChild(titleText);
var allThemes = [{
id: 'morning',
name: 'Morning Theme',
icon: 'sun'
}, {
id: 'night',
name: 'Night Theme',
icon: 'nightIcon'
}, {
id: 'mars',
name: 'Mars Theme',
icon: 'marsIcon'
}];
// Create elegant theme cards
var themeCards = [];
var cardPositions = [{
x: -300,
y: -200
},
// Morning left
{
x: 300,
y: -200
},
// Night right
{
x: 0,
y: 200
} // Mars bottom center
];
for (var t = 0; t < allThemes.length; t++) {
var theme = allThemes[t];
if (storage.ownedThemes && storage.ownedThemes.indexOf(theme.id) >= 0) {
var pos = cardPositions[t];
// Create elegant card background with glowing border
var cardShadow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x + 4,
y: pos.y + 4,
scaleX: 0.22,
scaleY: 0.25,
tint: 0x000000,
alpha: 0.4
}));
var cardBase = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y,
scaleX: 0.22,
scaleY: 0.25,
tint: 0x1A237E,
alpha: 0.85
}));
var cardGlow = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y,
scaleX: 0.24,
scaleY: 0.27,
tint: 0x3F51B5,
alpha: 0.6
}));
// Add sparkle border effect
var cardSparkle = self.addChild(LK.getAsset('inventoryPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y,
scaleX: 0.26,
scaleY: 0.29,
tint: 0xE8EAF6,
alpha: 0.3
}));
// Theme icon with illustration
var themeIcon = self.addChild(LK.getAsset(theme.icon, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: theme.id === 'mars' ? 0.8 : 1.3,
scaleY: theme.id === 'mars' ? 0.8 : 1.3,
x: pos.x,
y: pos.y - 30
}));
// Add magical floating animation to icon
(function (icon, speed, baseY) {
var originalUpdate = icon.update || function () {};
icon.update = function () {
originalUpdate.call(icon);
icon.y = baseY + Math.sin(LK.ticks * speed) * 8;
};
})(themeIcon, 0.02 + Math.random() * 0.01, pos.y - 40);
var themeNameText = new Text2(theme.name, {
size: 28,
fill: '#E8EAF6'
});
themeNameText.anchor.set(0.5, 0.5);
themeNameText.x = pos.x;
themeNameText.y = pos.y + 45;
self.addChild(themeNameText);
// Create elegant select button with hover sparkle effect
var selectButtonShadow = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x + 2,
y: pos.y + 92,
scaleX: 0.8,
scaleY: 0.8,
tint: 0x000000,
alpha: 0.4
}));
var selectButton = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y + 90,
scaleX: 0.8,
scaleY: 0.8,
tint: 0x283593,
alpha: 0.9
}));
var selectButtonGlow = self.addChild(LK.getAsset('selectButton', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x,
y: pos.y + 90,
tint: 0x7986CB,
alpha: 0.5,
scaleX: 0.88,
scaleY: 0.88
}));
var selectText = new Text2(storage.selectedTheme === theme.id ? 'SELECTED' : 'SELECT', {
size: 22,
fill: storage.selectedTheme === theme.id ? '#FFD700' : '#FFFFFF'
});
selectText.anchor.set(0.5, 0.5);
selectButton.addChild(selectText);
// Add gentle pulsing glow animation to cards
tween(cardGlow, {
alpha: 0.8,
scaleX: 0.25,
scaleY: 0.28
}, {
duration: 2500,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(cardGlow, {
alpha: 0.6,
scaleX: 0.24,
scaleY: 0.27
}, {
duration: 2500,
easing: tween.easeInOut
});
}
});
// Add sparkle animation
tween(cardSparkle, {
alpha: 0.6,
scaleX: 0.28,
scaleY: 0.31
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(cardSparkle, {
alpha: 0.3,
scaleX: 0.26,
scaleY: 0.29
}, {
duration: 3000,
easing: tween.easeInOut
});
}
});
// Add hover effect with gentle enlargement and sparkle
var isSelected = storage.selectedTheme === theme.id;
if (isSelected) {
tween(selectButtonGlow, {
alpha: 0.8,
scaleX: 0.96,
scaleY: 0.96
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(selectButtonGlow, {
alpha: 0.5,
scaleX: 0.88,
scaleY: 0.88
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
}
// Store references for updating button states
var cardData = {
themeId: theme.id,
selectText: selectText,
cardBase: cardBase,
selectButton: selectButton,
selectButtonGlow: selectButtonGlow
};
themeCards.push(cardData);
// Button interaction with sparkle effect
(function (themeId, button, text, cards) {
button.down = function () {
storage.selectedTheme = themeId;
text.setText('SELECTED');
text.fill = '#FFD700';
LK.getSound('select').play();
// Create sparkle effect on selection
for (var sp = 0; sp < 8; sp++) {
var sparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: pos.x + (Math.random() - 0.5) * 200,
y: pos.y + (Math.random() - 0.5) * 200,
scaleX: 0.8 + Math.random() * 1.2,
scaleY: 0.8 + Math.random() * 1.2,
alpha: 1,
tint: 0xFFD700
}));
tween(sparkle, {
alpha: 0,
scaleX: 0.2,
scaleY: 0.2,
y: sparkle.y - 100
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
sparkle.destroy();
}
});
}
// Update other buttons
for (var c = 0; c < cards.length; c++) {
var card = cards[c];
if (card.themeId !== themeId) {
card.selectText.setText('SELECT');
card.selectText.fill = '#FFFFFF';
}
}
// Apply theme immediately
applyTheme(themeId);
};
})(theme.id, selectButton, selectText, themeCards);
}
}
var closeButton = self.addChild(LK.getAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 800
}));
var closeText = new Text2('CLOSE', {
size: 30,
fill: '#FFFFFF'
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
self.destroy();
if (wasPlaying) {
startCountdown();
} else {
gameState = 'waiting';
tapToStartText.visible = true;
instructionText.visible = true;
}
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x += self.speed;
};
return self;
});
var ShopPanel = Container.expand(function () {
var self = Container.call(this);
var panel = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5
});
// Create vibrant gradient background layers
var gradientLayer1 = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x6A0DAD,
alpha: 0.8
});
var gradientLayer2 = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFF1493,
alpha: 0.4,
scaleX: 0.9,
scaleY: 0.9
});
var gradientLayer3 = self.attachAsset('shopPanel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x00CED1,
alpha: 0.3,
scaleX: 0.8,
scaleY: 0.8
});
// Create animated sparkle particles
var sparkleParticles = [];
for (var sp = 0; sp < 20; sp++) {
var sparkle = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1600,
y: (Math.random() - 0.5) * 2000,
scaleX: 0.5 + Math.random() * 1.5,
scaleY: 0.5 + Math.random() * 1.5,
alpha: 0.6 + Math.random() * 0.4,
tint: 0xFFD700
}));
sparkle.originalX = sparkle.x;
sparkle.originalY = sparkle.y;
sparkle.floatSpeed = 0.02 + Math.random() * 0.03;
sparkle.rotationSpeed = 0.05 + Math.random() * 0.1;
sparkleParticles.push(sparkle);
}
// Create flowing light streaks
var lightStreaks = [];
for (var ls = 0; ls < 8; ls++) {
var streak = self.addChild(LK.getAsset('diamond', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 1800,
y: (Math.random() - 0.5) * 2200,
scaleX: 3 + Math.random() * 2,
scaleY: 0.3,
alpha: 0.3 + Math.random() * 0.3,
tint: 0x00FFFF,
rotation: Math.random() * Math.PI * 2
}));
streak.originalX = streak.x;
streak.flowSpeed = 0.01 + Math.random() * 0.02;
lightStreaks.push(streak);
}
// Animate gradient layers with pulsing effect
tween(gradientLayer2, {
scaleX: 1.1,
scaleY: 1.1,
alpha: 0.6
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(gradientLayer2, {
scaleX: 0.9,
scaleY: 0.9,
alpha: 0.4
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(gradientLayer2, {
scaleX: 1.1,
scaleY: 1.1,
alpha: 0.6
}, {
duration: 2000,
easing: tween.easeInOut
});
}
});
}
});
tween(gradientLayer3, {
scaleX: 1.0,
scaleY: 1.0,
alpha: 0.5
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(gradientLayer3, {
scaleX: 0.8,
scaleY: 0.8,
alpha: 0.3
}, {
duration: 3000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(gradientLayer3, {
scaleX: 1.0,
scaleY: 1.0,
alpha: 0.5
}, {
duration: 3000,
easing: tween.easeInOut
});
}
});
}
});
self.update = function () {
// Animate sparkle particles
for (var sp = 0; sp < sparkleParticles.length; sp++) {
var sparkle = sparkleParticles[sp];
sparkle.y += Math.sin(LK.ticks * sparkle.floatSpeed) * 0.5;
sparkle.rotation += sparkle.rotationSpeed;
sparkle.alpha = 0.6 + Math.sin(LK.ticks * sparkle.floatSpeed * 2) * 0.3;
}
// Animate light streaks
for (var ls = 0; ls < lightStreaks.length; ls++) {
var streak = lightStreaks[ls];
streak.x += Math.cos(LK.ticks * streak.flowSpeed) * 2;
streak.alpha = 0.3 + Math.sin(LK.ticks * streak.flowSpeed * 3) * 0.2;
streak.rotation += 0.01;
}
};
var titleText = new Text2('BIRD SHOP', {
size: 80,
fill: '#FFFFFF'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -800;
self.addChild(titleText);
var diamondText = new Text2('Diamonds: ' + storage.diamonds, {
size: 50,
fill: '#00FFFF'
});
diamondText.anchor.set(0.5, 0.5);
diamondText.x = 0;
diamondText.y = -700;
self.addChild(diamondText);
// BIRDS category title
var birdsTitle = new Text2('BIRDS', {
size: 60,
fill: '#FFD700'
});
birdsTitle.anchor.set(0.5, 0.5);
birdsTitle.x = 0;
birdsTitle.y = -500;
self.addChild(birdsTitle);
// Diamond Sword Bird (left side)
var diamondSwordBirdPreview = self.addChild(LK.getAsset('diamondSwordBird', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: -300,
y: -200
}));
var diamondSwordText = new Text2('Diamond Sword Bird\n100 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
diamondSwordText.anchor.set(0.5, 0.5);
diamondSwordText.x = -300;
diamondSwordText.y = -100;
self.addChild(diamondSwordText);
var diamondSwordButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -300,
y: 0
}));
var diamondSwordButtonText = new Text2(storage.ownedBirds.indexOf('diamondSword') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
diamondSwordButtonText.anchor.set(0.5, 0.5);
diamondSwordButton.addChild(diamondSwordButtonText);
diamondSwordButton.down = function () {
if (storage.ownedBirds.indexOf('diamondSword') < 0 && storage.diamonds >= 100) {
storage.diamonds -= 100;
storage.ownedBirds.push('diamondSword');
diamondSwordButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
// Golden Bird (center position)
var goldenBirdPreview = self.addChild(LK.getAsset('goldenBird', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: 0,
y: -200
}));
var goldenText = new Text2('Golden Bird\n200 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
goldenText.anchor.set(0.5, 0.5);
goldenText.x = 0;
goldenText.y = -100;
self.addChild(goldenText);
var goldenButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
}));
var goldenButtonText = new Text2(storage.ownedBirds.indexOf('golden') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
goldenButtonText.anchor.set(0.5, 0.5);
goldenButton.addChild(goldenButtonText);
goldenButton.down = function () {
if (storage.ownedBirds.indexOf('golden') < 0 && storage.diamonds >= 200) {
storage.diamonds -= 200;
storage.ownedBirds.push('golden');
goldenButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
// Fire Bird (right side)
var fireBirdPreview = self.addChild(LK.getAsset('fireBird', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: 300,
y: -200
}));
var fireText = new Text2('Fire Bird\n400 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
fireText.anchor.set(0.5, 0.5);
fireText.x = 300;
fireText.y = -100;
self.addChild(fireText);
var fireButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: 0
}));
var fireButtonText = new Text2(storage.ownedBirds.indexOf('fire') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
fireButtonText.anchor.set(0.5, 0.5);
fireButton.addChild(fireButtonText);
fireButton.down = function () {
if (storage.ownedBirds.indexOf('fire') < 0 && storage.diamonds >= 400) {
storage.diamonds -= 400;
storage.ownedBirds.push('fire');
fireButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
// THEMES category title
var themesTitle = new Text2('THEMES', {
size: 60,
fill: '#FFD700'
});
themesTitle.anchor.set(0.5, 0.5);
themesTitle.x = 0;
themesTitle.y = 200;
self.addChild(themesTitle);
// Morning Theme (left side)
var morningThemeIcon = self.addChild(LK.getAsset('sun', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: -400,
y: 400
}));
var morningText = new Text2('Morning Theme\nFREE', {
size: 30,
fill: '#FFFFFF'
});
morningText.anchor.set(0.5, 0.5);
morningText.x = -400;
morningText.y = 500;
self.addChild(morningText);
var morningButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -400,
y: 600
}));
var morningButtonText = new Text2('OWNED', {
size: 25,
fill: '#FFFFFF'
});
morningButtonText.anchor.set(0.5, 0.5);
morningButton.addChild(morningButtonText);
morningButton.down = function () {
// Morning theme is always free and owned
};
// Night Theme (center position) - Create a night icon with dark colors
var nightThemeIcon = self.addChild(LK.getAsset('nightIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 400
}));
// Add stars to the night icon
var star1 = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: -20,
y: 380
}));
var star2 = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: 15,
y: 370
}));
var star3 = self.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: -10,
y: 420
}));
// Add a moon to complete the night theme
var moon = self.addChild(LK.getAsset('moon', {
anchorX: 0.5,
anchorY: 0.5,
x: 25,
y: 385
}));
var nightText = new Text2('Night Theme\n800 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
nightText.anchor.set(0.5, 0.5);
nightText.x = 0;
nightText.y = 500;
self.addChild(nightText);
var nightButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 600
}));
var nightButtonText = new Text2(storage.ownedThemes && storage.ownedThemes.indexOf('night') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
nightButtonText.anchor.set(0.5, 0.5);
nightButton.addChild(nightButtonText);
nightButton.down = function () {
if (!storage.ownedThemes) storage.ownedThemes = [];
if (storage.ownedThemes.indexOf('night') < 0 && storage.diamonds >= 800) {
storage.diamonds -= 800;
storage.ownedThemes.push('night');
nightButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
// Mars Theme (right side) - Create Mars theme with red planet appearance
var marsThemeIcon = self.addChild(LK.getAsset('marsIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 400,
y: 400,
scaleX: 1.5,
scaleY: 1.5
}));
var marsText = new Text2('Mars Theme\n1500 Diamonds', {
size: 30,
fill: '#FFFFFF'
});
marsText.anchor.set(0.5, 0.5);
marsText.x = 400;
marsText.y = 500;
self.addChild(marsText);
var marsButton = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 400,
y: 600
}));
var marsButtonText = new Text2(storage.ownedThemes && storage.ownedThemes.indexOf('mars') >= 0 ? 'OWNED' : 'BUY', {
size: 25,
fill: '#FFFFFF'
});
marsButtonText.anchor.set(0.5, 0.5);
marsButton.addChild(marsButtonText);
marsButton.down = function () {
if (!storage.ownedThemes) storage.ownedThemes = [];
if (storage.ownedThemes.indexOf('mars') < 0 && storage.diamonds >= 1500) {
storage.diamonds -= 1500;
storage.ownedThemes.push('mars');
marsButtonText.setText('OWNED');
diamondText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('purchase').play();
}
};
var closeButton = self.addChild(LK.getAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 800
}));
var closeText = new Text2('CLOSE', {
size: 30,
fill: '#FFFFFF'
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
self.destroy();
if (wasPlaying) {
startCountdown();
} else {
gameState = 'waiting';
// Show tap to start UI when returning to waiting state
tapToStartText.visible = true;
instructionText.visible = true;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Ensure Morning theme is always owned (for existing players)
if (!storage.ownedThemes) {
storage.ownedThemes = ["morning"];
}
if (storage.ownedThemes.indexOf("morning") < 0) {
storage.ownedThemes.push("morning");
}
var bird;
var obstacles = [];
var diamonds = [];
var ground;
var gameState = 'waiting'; // Start with waiting state
var obstacleTimer = 0;
var diamondTimer = 0;
var obstacleCount = 0;
var isCountingDown = false;
var countdownValue = 3;
var wasPlaying = false; // Track if game was playing before opening panels
var highScore = storage.highScore || 0; // Track highest obstacle count reached
// Theme elements
var backgroundSun;
var backgroundMoon;
var backgroundStars = [];
var marsDustClouds = [];
var marsSparkleStars = [];
function applyTheme(themeId) {
if (themeId === 'morning') {
// Morning theme - light blue sky with sun
game.setBackgroundColor(0x87CEEB);
// Show sun, hide moon and stars
if (backgroundSun) backgroundSun.visible = true;
if (backgroundMoon) backgroundMoon.visible = false;
for (var s = 0; s < backgroundStars.length; s++) {
backgroundStars[s].visible = false;
}
// Show clouds in morning theme
for (var c = 0; c < clouds.length; c++) {
clouds[c].visible = true;
}
// Hide mars dust clouds in morning theme
for (var d = 0; d < marsDustClouds.length; d++) {
marsDustClouds[d].visible = false;
}
} else if (themeId === 'night') {
// Night theme - dark sky with moon and stars
game.setBackgroundColor(0x191970);
// Hide sun, show moon and stars
if (backgroundSun) backgroundSun.visible = false;
if (backgroundMoon) backgroundMoon.visible = true;
for (var s = 0; s < backgroundStars.length; s++) {
backgroundStars[s].visible = true;
}
// Hide clouds in night theme
for (var c = 0; c < clouds.length; c++) {
clouds[c].visible = false;
}
} else if (themeId === 'mars') {
// Mars theme - reddish orange sky
game.setBackgroundColor(0xCD853F);
// Hide sun and moon, show specific mars elements
if (backgroundSun) backgroundSun.visible = false;
if (backgroundMoon) backgroundMoon.visible = false;
for (var s = 0; s < backgroundStars.length; s++) {
backgroundStars[s].visible = false;
}
// Hide regular clouds, show mars dust clouds
for (var c = 0; c < clouds.length; c++) {
clouds[c].visible = false;
}
for (var d = 0; d < marsDustClouds.length; d++) {
marsDustClouds[d].visible = true;
}
// Show mars sparkle stars
for (var ms = 0; ms < marsSparkleStars.length; ms++) {
marsSparkleStars[ms].visible = true;
}
}
}
// UI Elements
var diamondCountText = new Text2('Diamonds: ' + storage.diamonds, {
size: 40,
fill: '#00FFFF'
});
diamondCountText.anchor.set(1, 1);
LK.gui.bottomRight.addChild(diamondCountText);
var obstacleCountText = new Text2('Obstacle: 0', {
size: 50,
fill: '#FFFFFF'
});
obstacleCountText.anchor.set(0.5, 0);
obstacleCountText.y = 100; // Position below the top to avoid platform menu
LK.gui.top.addChild(obstacleCountText);
var shopButton = LK.getAsset('shopButton', {
anchorX: 0,
anchorY: 1,
x: 0,
y: 0
});
var shopButtonText = new Text2('SHOP', {
size: 25,
fill: '#FFFFFF'
});
shopButtonText.anchor.set(0.5, 0.5);
shopButton.addChild(shopButtonText);
LK.gui.bottomLeft.addChild(shopButton);
var myThemesButton = LK.getAsset('themesButton', {
anchorX: 0,
anchorY: 1,
x: 170,
y: 0
});
var myThemesButtonText = new Text2('MY THEMES', {
size: 20,
fill: '#FFFFFF'
});
myThemesButtonText.anchor.set(0.5, 0.5);
myThemesButton.addChild(myThemesButtonText);
LK.gui.bottomLeft.addChild(myThemesButton);
var inventoryButton = LK.getAsset('inventoryButton', {
anchorX: 1,
anchorY: 0
});
var inventoryButtonText = new Text2('INVENTORY', {
size: 20,
fill: '#FFFFFF'
});
inventoryButtonText.anchor.set(0.5, 0.5);
inventoryButton.addChild(inventoryButtonText);
LK.gui.topRight.addChild(inventoryButton);
// Position inventory button below diamond counter
inventoryButton.y = 60;
var giftButton = LK.getAsset('giftButton', {
anchorX: 1,
anchorY: 0
});
var giftButtonText = new Text2('GIFT', {
size: 20,
fill: '#FFFFFF'
});
giftButtonText.anchor.set(0.5, 0.5);
giftButton.addChild(giftButtonText);
LK.gui.topRight.addChild(giftButton);
// Position gift button below inventory button
giftButton.y = 160;
// Tap to start UI
var tapToStartText = new Text2('TAP TO START', {
size: 80,
fill: '#FFFFFF'
});
tapToStartText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(tapToStartText);
var instructionText = new Text2('Tap screen to flap\nAvoid obstacles\nCollect diamonds', {
size: 40,
fill: '#FFFFFF'
});
instructionText.anchor.set(0.5, 0.5);
instructionText.y = 100;
LK.gui.center.addChild(instructionText);
// Countdown text for resume
var countdownText = new Text2('3', {
size: 200,
fill: '#FFFF00'
});
countdownText.anchor.set(0.5, 0.5);
countdownText.visible = false;
LK.gui.center.addChild(countdownText);
shopButton.down = function () {
if (gameState === 'playing' || gameState === 'waiting') {
wasPlaying = gameState === 'playing';
gameState = 'shop';
// Hide tap to start UI when opening shop
tapToStartText.visible = false;
instructionText.visible = false;
var shopPanel = new ShopPanel();
shopPanel.x = 1024;
shopPanel.y = 1366;
game.addChild(shopPanel);
}
// Update clouds - move them slowly across screen
for (var k = clouds.length - 1; k >= 0; k--) {
var cloud = clouds[k];
cloud.x += cloud.speed;
// Respawn cloud on the right when it goes off-screen
if (cloud.x < -120) {
cloud.x = 2048 + 120;
cloud.y = Math.random() * 1500 + 200;
cloud.scaleX = 0.8 + Math.random() * 0.6;
cloud.scaleY = 0.8 + Math.random() * 0.6;
cloud.speed = -0.5 - Math.random() * 1;
}
}
// Update Mars dust clouds
for (var md = 0; md < marsDustClouds.length; md++) {
var dustCloud = marsDustClouds[md];
if (dustCloud.visible) {
dustCloud.x += dustCloud.speed;
if (dustCloud.x < -120) {
dustCloud.x = 2048 + 120;
dustCloud.y = Math.random() * 1800 + 400;
dustCloud.scaleX = 0.6 + Math.random() * 0.8;
dustCloud.scaleY = 0.6 + Math.random() * 0.8;
dustCloud.speed = -0.3 - Math.random() * 0.7;
}
}
}
// Update Mars sparkle stars
for (var mst = 0; mst < marsSparkleStars.length; mst++) {
var sparkle = marsSparkleStars[mst];
if (sparkle.visible) {
sparkle.alpha = sparkle.originalAlpha + Math.sin(LK.ticks * sparkle.twinkleSpeed) * 0.3;
}
}
};
inventoryButton.down = function () {
if (gameState === 'playing' || gameState === 'waiting') {
wasPlaying = gameState === 'playing';
gameState = 'inventory';
// Hide tap to start UI when opening inventory
tapToStartText.visible = false;
instructionText.visible = false;
var inventoryPanel = new InventoryPanel();
inventoryPanel.x = 1024;
inventoryPanel.y = 1366;
game.addChild(inventoryPanel);
}
};
giftButton.down = function () {
if (gameState === 'playing' || gameState === 'waiting') {
wasPlaying = gameState === 'playing';
gameState = 'gift';
// Hide tap to start UI when opening gift panel
tapToStartText.visible = false;
instructionText.visible = false;
var giftPanel = new GiftPanel();
giftPanel.x = 1024;
giftPanel.y = 1366;
game.addChild(giftPanel);
}
};
myThemesButton.down = function () {
if (gameState === 'playing' || gameState === 'waiting') {
wasPlaying = gameState === 'playing';
gameState = 'mythemes';
// Hide tap to start UI when opening my themes panel
tapToStartText.visible = false;
instructionText.visible = false;
var myThemesPanel = new MyThemesPanel();
myThemesPanel.x = 1024;
myThemesPanel.y = 1366;
game.addChild(myThemesPanel);
}
};
// Initialize bird
bird = new Bird();
bird.x = 300;
bird.y = 1366;
game.addChild(bird);
// Initialize ground
ground = LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2732 - 100
});
game.addChild(ground);
// Initialize background clouds
var clouds = [];
for (var c = 0; c < 6; c++) {
var cloud = LK.getAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 1500 + 200,
scaleX: 0.8 + Math.random() * 0.6,
scaleY: 0.8 + Math.random() * 0.6,
alpha: 0.7
});
cloud.speed = -0.5 - Math.random() * 1;
clouds.push(cloud);
game.addChild(cloud);
}
// Initialize theme background elements
backgroundSun = LK.getAsset('sun', {
anchorX: 0.5,
anchorY: 0.5,
x: 1800,
y: 300,
scaleX: 1.5,
scaleY: 1.5,
alpha: 0.8
});
game.addChild(backgroundSun);
backgroundMoon = LK.getAsset('moon', {
anchorX: 0.5,
anchorY: 0.5,
x: 1800,
y: 300,
scaleX: 3,
scaleY: 3,
alpha: 0.9,
visible: false
});
game.addChild(backgroundMoon);
// Create background stars
for (var st = 0; st < 15; st++) {
var star = LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 1000 + 100,
scaleX: 1 + Math.random() * 2,
scaleY: 1 + Math.random() * 2,
alpha: 0.7 + Math.random() * 0.3,
visible: false
});
backgroundStars.push(star);
game.addChild(star);
}
// Create Mars dust clouds
for (var md = 0; md < 8; md++) {
var dustCloud = LK.getAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 1800 + 400,
scaleX: 0.6 + Math.random() * 0.8,
scaleY: 0.6 + Math.random() * 0.8,
alpha: 0.3 + Math.random() * 0.3,
tint: 0xD2691E,
visible: false
});
dustCloud.speed = -0.3 - Math.random() * 0.7;
marsDustClouds.push(dustCloud);
game.addChild(dustCloud);
}
// Create Mars sparkle stars
for (var mst = 0; mst < 10; mst++) {
var sparkleVar = LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 800 + 100,
scaleX: 0.8 + Math.random() * 1.5,
scaleY: 0.8 + Math.random() * 1.5,
alpha: 0.8 + Math.random() * 0.2,
tint: 0xFFD700,
visible: false
});
sparkleVar.twinkleSpeed = 0.02 + Math.random() * 0.03;
sparkleVar.originalAlpha = sparkleVar.alpha;
marsSparkleStars.push(sparkleVar);
game.addChild(sparkleVar);
}
// Apply initial theme
applyTheme(storage.selectedTheme || 'morning');
function startCountdown() {
isCountingDown = true;
countdownValue = 3;
countdownText.setText(countdownValue.toString());
countdownText.visible = true;
countdownText.alpha = 1;
countdownText.scaleX = 1;
countdownText.scaleY = 1;
function showNumber() {
countdownText.setText(countdownValue.toString());
countdownText.alpha = 1;
countdownText.scaleX = 2;
countdownText.scaleY = 2;
tween(countdownText, {
alpha: 0.3,
scaleX: 1,
scaleY: 1
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
countdownValue--;
if (countdownValue > 0) {
showNumber();
} else {
countdownText.visible = false;
isCountingDown = false;
gameState = 'playing';
}
}
});
}
showNumber();
}
game.down = function (x, y, obj) {
if (gameState === 'waiting') {
// Start the game
gameState = 'playing';
// Reset obstacle counter
obstacleCount = 0;
obstacleCountText.setText('Obstacle: 0');
// Hide tap to start UI
tapToStartText.visible = false;
instructionText.visible = false;
// Start background music
LK.playMusic('bgmusic');
} else if (gameState === 'playing') {
bird.flap();
}
};
game.update = function () {
if (gameState === 'waiting') {
// Animate tap to start text
tapToStartText.y = Math.sin(LK.ticks * 0.1) * 20;
// Don't update game mechanics while waiting
return;
}
if (gameState !== 'playing' || isCountingDown || gameState === 'shop' || gameState === 'inventory' || gameState === 'gift' || gameState === 'mythemes') {
return;
}
// Spawn obstacles
obstacleTimer++;
if (obstacleTimer >= 90) {
// Every 1.5 seconds at 60fps - faster spawn rate
obstacleTimer = 0;
// Create gap in middle
var gapSize = 320; // Further increased gap size for easier gameplay
var gapCenter = Math.random() * (2732 - 200 - gapSize) + 100 + gapSize / 2;
// Top obstacle
var topObstacle = new Obstacle();
topObstacle.x = 2048 + 40;
topObstacle.y = gapCenter - gapSize / 2 - 200;
obstacles.push(topObstacle);
game.addChild(topObstacle);
// Bottom obstacle
var bottomObstacle = new Obstacle();
bottomObstacle.x = 2048 + 40;
bottomObstacle.y = gapCenter + gapSize / 2 + 200;
obstacles.push(bottomObstacle);
game.addChild(bottomObstacle);
}
// Spawn diamonds
diamondTimer++;
if (diamondTimer >= 90) {
// Every 1.5 seconds
diamondTimer = 0;
var diamond = new Diamond();
diamond.x = 2048 + 15;
diamond.y = Math.random() * (2732 - 300) + 150;
diamonds.push(diamond);
game.addChild(diamond);
}
// Update and check obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
// Check if bird passed this obstacle (from right to left)
if (obstacle.lastX === undefined) obstacle.lastX = obstacle.x;
if (obstacle.lastX > bird.x && obstacle.x <= bird.x && !obstacle.passed) {
obstacle.passed = true;
// Only count every second obstacle (since we create pairs)
if (i % 2 === 0) {
obstacleCount++;
obstacleCountText.setText('Obstacle: ' + obstacleCount);
}
}
obstacle.lastX = obstacle.x;
if (obstacle.x < -100) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Collision with bird - check with scaled bird size
var birdBounds = {
left: bird.x - 60 * 1.5 / 2,
right: bird.x + 60 * 1.5 / 2,
top: bird.y - 60 * 1.5 / 2,
bottom: bird.y + 60 * 1.5 / 2
};
var obstacleBounds = {
left: obstacle.x - 40,
right: obstacle.x + 40,
top: obstacle.y - 200,
bottom: obstacle.y + 200
};
if (birdBounds.right > obstacleBounds.left && birdBounds.left < obstacleBounds.right && birdBounds.bottom > obstacleBounds.top && birdBounds.top < obstacleBounds.bottom) {
// Update high score if current score is higher
if (obstacleCount > highScore) {
highScore = obstacleCount;
storage.highScore = highScore;
}
LK.showGameOver();
return;
}
}
// Update and check diamonds
for (var j = diamonds.length - 1; j >= 0; j--) {
var diamond = diamonds[j];
if (diamond.x < -50) {
diamond.destroy();
diamonds.splice(j, 1);
continue;
}
// Collection by bird
if (!diamond.collected && bird.intersects(diamond)) {
diamond.collected = true;
storage.diamonds++;
diamondCountText.setText('Diamonds: ' + storage.diamonds);
LK.getSound('collect').play();
diamond.destroy();
diamonds.splice(j, 1);
}
}
};
oyunlardaki kuş. In-Game asset. 2d. High contrast. No shadows
oyunlardaki satÄąn alma butonu. In-Game asset. 2d. High contrast. No shadows
oyunlardaki çarpĹ butonu. In-Game asset. 2d. High contrast. No shadows
oyunlardaki mavi elmas. In-Game asset. 2d. High contrast. No shadows
oyunlardaki elmas kĹlĹç taşĹyan elmas kuş. In-Game asset. 2d. High contrast. No shadows
oyunlardaki altĹn kuş. In-Game asset. 2d. High contrast. No shadows
oyunlardaki envanter butonu. In-Game asset. 2d. High contrast. No shadows
oyunlardaki market ikonu. In-Game asset. 2d. High contrast. No shadows
oyunlarda hediye veren aryuĚzuĚn simgesi. In-Game asset. 2d. High contrast. No shadows
oyunlardaki bulut. In-Game asset. 2d. High contrast. No shadows
OĚyle bir şey istiyorumki oyunlardaki gibi boĚyle oraya tÄąklarsÄąn temalar açĹlÄąr ya temalarÄą andÄąran birşey. In-Game asset. 2d. High contrast. No shadows
oyunlardaki guĚneş. In-Game asset. 2d. High contrast. No shadows
oyunlardaki beyaz ay. In-Game asset. 2d. High contrast. No shadows
oyunlardaki gece oldugu zaman yÄąldÄąz. In-Game asset. 2d. High contrast. No shadows
oyunlardaki Use yazÄąsÄą. In-Game asset. 2d. High contrast. No shadows
mars gezegeni. In-Game asset. 2d. High contrast. No shadows
oyunlardaki ateş kuş. In-Game asset. 2d. High contrast. No shadows