User prompt
Make clothes buton left Side of screan
User prompt
Remove added skin collor
User prompt
When player selecting skin game dont start since he touch back
User prompt
Remove skin
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'asset')' in or related to this line: 'var initialBirdGraphics = bird.attachAsset(skins[currentSkin].asset, {' Line Number: 818
User prompt
Remove last skin code
User prompt
Replace my crafted skin to game skin
User prompt
Craft starting button shape
User prompt
Creat a starting button
User prompt
İmprove everything beter.
User prompt
Make wether changieable
User prompt
Dont make monkey zoom
User prompt
Make only one monkey
User prompt
Make monkey move only right
User prompt
Make pipe GAP place bıg
User prompt
Make all pipe same cordinate
User prompt
Make clothes title bıg
User prompt
Make skin my crafted skin
User prompt
When chosing skin game font start
User prompt
Add some sakin in game
User prompt
At maın screan creat a clothes buton
User prompt
When player font touch screan bird start flying atomatickly
User prompt
Add a monkey
User prompt
Make a starting screan ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.velocity = 0; self.gravity = 0.6; self.flapStrength = -10; self.maxFallSpeed = 12; self.rotation = 0; self.animationTimer = 0; self.invincible = false; self.flap = function () { self.velocity = self.flapStrength; LK.getSound('flap').play(); // Wing flapping animation tween(birdGraphics, { scaleY: 1.2 }, { duration: 100, easing: tween.easeOut }); tween(birdGraphics, { scaleY: 1.0 }, { duration: 100, easing: tween.easeIn }); // Slight upward rotation on flap tween(birdGraphics, { rotation: -0.4 }, { duration: 150, easing: tween.easeOut }); }; self.update = function () { // Apply gravity self.velocity += self.gravity; // Limit fall speed if (self.velocity > self.maxFallSpeed) { self.velocity = self.maxFallSpeed; } // Update position self.y += self.velocity; // Smooth rotation based on velocity var targetRotation = Math.min(self.velocity * 0.08, 1.2); if (self.velocity < 0) { targetRotation = Math.max(self.velocity * 0.08, -0.4); } // Smooth rotation transition tween.stop(birdGraphics, { rotation: true }); tween(birdGraphics, { rotation: targetRotation }, { duration: 200, easing: tween.easeOut }); // Subtle bob animation when idle if (Math.abs(self.velocity) < 2) { self.animationTimer += 0.1; var bob = Math.sin(self.animationTimer) * 2; birdGraphics.y = bob; } // Invincibility flashing if (self.invincible) { birdGraphics.alpha = 0.5 + 0.5 * Math.sin(LK.ticks * 0.3); } else { birdGraphics.alpha = 1; } }; return self; }); var Building = Container.expand(function () { var self = Container.call(this); var buildingGraphics = self.attachAsset('building', { anchorX: 0.5, anchorY: 1 }); self.speed = -2; self.update = function () { self.x += self.speed; // Reset position when off screen if (self.x < -200) { self.x = 2048 + 200; self.y = 2732 - 100; // Ground level } }; return self; }); var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -1; self.update = function () { self.x += self.speed; // Reset position when off screen if (self.x < -200) { self.x = 2048 + 200; self.y = 100 + Math.random() * 300; } }; return self; }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -4; self.collected = false; self.update = function () { self.x += self.speed; // Simple rotation animation coinGraphics.rotation += 0.1; }; self.checkCollection = function (bird) { var distance = Math.sqrt(Math.pow(bird.x - self.x, 2) + Math.pow(bird.y - self.y, 2)); return distance < 35; // Collection radius }; return self; }); var Pipe = Container.expand(function () { var self = Container.call(this); self.gapHeight = 220; self.speed = -3; self.scored = false; // Create top pipe self.topPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 1 }); // Create bottom pipe self.bottomPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0 }); // Add pipe caps for authentic look self.topCap = LK.getAsset('pipe', { anchorX: 0.5, anchorY: 1, scaleX: 1.2, scaleY: 0.1 }); self.bottomCap = LK.getAsset('pipe', { anchorX: 0.5, anchorY: 0, scaleX: 1.2, scaleY: 0.1 }); self.addChild(self.topCap); self.addChild(self.bottomCap); self.setupPipes = function (gapCenterY) { self.topPipe.y = gapCenterY - self.gapHeight / 2; self.bottomPipe.y = gapCenterY + self.gapHeight / 2; self.topCap.y = self.topPipe.y; self.bottomCap.y = self.bottomPipe.y; }; self.update = function () { self.x += self.speed; }; self.checkCollision = function (bird) { var birdRadius = 25; var pipeWidth = 62; var birdBounds = { left: bird.x - birdRadius, right: bird.x + birdRadius, top: bird.y - birdRadius, bottom: bird.y + birdRadius }; var pipeBounds = { left: self.x - pipeWidth, right: self.x + pipeWidth, topBottom: self.topPipe.y, bottomTop: self.bottomPipe.y }; // Check if bird is within pipe horizontal bounds if (birdBounds.right > pipeBounds.left && birdBounds.left < pipeBounds.right) { // Check collision with top or bottom pipe if (birdBounds.top < pipeBounds.topBottom || birdBounds.bottom > pipeBounds.bottomTop) { return true; } } return false; }; return self; }); var SpawnPoint = Container.expand(function () { var self = Container.call(this); self.isActive = true; self.spawnType = 'pipe'; // 'pipe' or 'coin' self.cooldownTimer = 0; self.cooldownDuration = 60; // 1 second at 60fps // Create visual marker for spawn point var marker = LK.getAsset('coin', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); self.addChild(marker); self.marker = marker; self.update = function () { if (self.cooldownTimer > 0) { self.cooldownTimer--; self.marker.alpha = 0.3; // Dim when on cooldown } else { self.marker.alpha = 1.0; // Bright when ready } // Pulse animation self.marker.rotation += 0.05; var pulse = Math.sin(LK.ticks * 0.1) * 0.1 + 1; self.marker.scaleX = 0.5 * pulse; self.marker.scaleY = 0.5 * pulse; }; self.canSpawn = function () { return self.isActive && self.cooldownTimer <= 0; }; self.triggerSpawn = function () { if (self.canSpawn()) { self.cooldownTimer = self.cooldownDuration; return true; } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var bird; var pipes = []; var coins = []; var spawnPoints = []; var clouds = []; var buildings = []; var ground; var gameStarted = false; var gameActive = true; var pipeSpawnTimer = 0; var pipeSpawnInterval = 180; // 3 seconds at 60fps var playerHealth = 3; var bestScore = 0; var dayTime = true; var lastColorChangeScore = 0; // Create score display var scoreTxt = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create health display var healthTxt = new Text2('♥ ♥ ♥', { size: 60, fill: 0xFF0000 }); healthTxt.anchor.set(1, 0); healthTxt.x = -20; // Position from right edge healthTxt.y = 20; LK.gui.topRight.addChild(healthTxt); // Create game title var titleTxt = new Text2('FLAPPY BIRD', { size: 120, fill: 0xFFD700 }); titleTxt.anchor.set(0.5, 0.5); titleTxt.x = 2048 / 2; titleTxt.y = 2732 / 2 - 400; titleTxt.alpha = 0; game.addChild(titleTxt); // Create subtitle var subtitleTxt = new Text2('Guide the bird through pipes!', { size: 50, fill: 0xFFFFFF }); subtitleTxt.anchor.set(0.5, 0.5); subtitleTxt.x = 2048 / 2; subtitleTxt.y = 2732 / 2 - 300; subtitleTxt.alpha = 0; game.addChild(subtitleTxt); // Create start instruction var startTxt = new Text2('TAP TO START', { size: 60, fill: 0xFFFFFF }); startTxt.anchor.set(0.5, 0.5); startTxt.x = 2048 / 2; startTxt.y = 2732 / 2 - 200; startTxt.alpha = 0; game.addChild(startTxt); // Create best score display var bestScoreTxt = new Text2('BEST: 0', { size: 45, fill: 0xFFD700 }); bestScoreTxt.anchor.set(0.5, 0.5); bestScoreTxt.x = 2048 / 2; bestScoreTxt.y = 2732 / 2 - 100; bestScoreTxt.alpha = 0; game.addChild(bestScoreTxt); // Cascade entrance animations for starting screen tween(titleTxt, { alpha: 1, scaleX: 1.2, scaleY: 1.2 }, { duration: 1000, easing: tween.bounceOut }); LK.setTimeout(function () { tween(subtitleTxt, { alpha: 1 }, { duration: 800, easing: tween.easeOut }); }, 300); LK.setTimeout(function () { tween(startTxt, { alpha: 1 }, { duration: 1000, easing: tween.easeInOut }); }, 600); LK.setTimeout(function () { tween(bestScoreTxt, { alpha: 1 }, { duration: 800, easing: tween.easeOut }); }, 900); // Pulsing animation for start text function pulseStartText() { tween(startTxt, { scaleX: 1.2, scaleY: 1.2 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(startTxt, { scaleX: 1.0, scaleY: 1.0 }, { duration: 800, easing: tween.easeInOut, onFinish: pulseStartText }); } }); } pulseStartText(); // Add floating animation for title function floatTitle() { tween(titleTxt, { y: titleTxt.y - 20 }, { duration: 2000, easing: tween.easeInOut, onFinish: function onFinish() { tween(titleTxt, { y: titleTxt.y + 20 }, { duration: 2000, easing: tween.easeInOut, onFinish: floatTitle }); } }); } LK.setTimeout(floatTitle, 1500); // Update best score display with stored value var storedBestScore = LK.getScore() || 0; bestScoreTxt.setText('BEST: ' + storedBestScore); // Create decorative sparkles for starting screen var sparkles = []; for (var i = 0; i < 8; i++) { var sparkle = LK.getAsset('coin', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3, alpha: 0 }); sparkle.x = 2048 / 2 + (Math.random() - 0.5) * 600; sparkle.y = 2732 / 2 - 350 + (Math.random() - 0.5) * 200; sparkles.push(sparkle); game.addChild(sparkle); } // Animate sparkles function animateSparkles() { for (var i = 0; i < sparkles.length; i++) { var sparkle = sparkles[i]; var delay = i * 200; LK.setTimeout(function (s) { return function () { tween(s, { alpha: 1, rotation: Math.PI * 2, scaleX: 0.5, scaleY: 0.5 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(s, { alpha: 0, scaleX: 0.3, scaleY: 0.3 }, { duration: 500, easing: tween.easeIn }); } }); }; }(sparkle), delay); } } LK.setTimeout(animateSparkles, 2000); // Initialize bird bird = new Bird(); bird.x = -100; // Start off screen bird.y = 2732 / 2; bird.invincible = false; game.addChild(bird); // Smooth entrance animation tween(bird, { x: 2048 / 4 }, { duration: 1000, easing: tween.easeOut }); // Initialize health display updateHealthDisplay(); // Initialize clouds for (var i = 0; i < 4; i++) { var cloud = new Cloud(); cloud.x = i * 500 + 200; cloud.y = 100 + Math.random() * 300; clouds.push(cloud); game.addChild(cloud); } // Initialize buildings for (var i = 0; i < 6; i++) { var building = new Building(); building.x = i * 350 + 100; building.y = 2732 - 100; var randomHeight = 200 + Math.random() * 400; building.scaleY = randomHeight / 300; buildings.push(building); game.addChild(building); } // Initialize spawn points for (var i = 0; i < 3; i++) { var spawnPoint = new SpawnPoint(); spawnPoint.x = 2048 + 200 + i * 400; spawnPoint.y = 300 + i * 200; spawnPoints.push(spawnPoint); game.addChild(spawnPoint); } // Create ground ground = game.attachAsset('ground', { anchorX: 0, anchorY: 0, x: 0, y: 2732 - 100 }); // Add ground scrolling animation tween(ground, { x: -200 }, { duration: 4000, easing: tween.linear, onFinish: function onFinish() { ground.x = 0; tween(ground, { x: -200 }, { duration: 4000, easing: tween.linear, onFinish: arguments.callee }); } }); function spawnPipe() { var pipe = new Pipe(); pipe.x = 2048 + 200; // Start further right pipe.alpha = 0; // Start invisible // Random gap center position var minGapCenter = 200; var maxGapCenter = 2732 - 200 - 100; // Account for ground var gapCenterY = minGapCenter + Math.random() * (maxGapCenter - minGapCenter); pipe.setupPipes(gapCenterY); pipes.push(pipe); game.addChild(pipe); // Smooth pipe entrance animation tween(pipe, { x: 2048 + 60, alpha: 1 }, { duration: 500, easing: tween.easeOut }); // Spawn coin in the gap center var coin = new Coin(); coin.x = pipe.x; coin.y = gapCenterY; coin.alpha = 0; coins.push(coin); game.addChild(coin); // Coin entrance animation with slight delay tween(coin, { alpha: 1, scaleX: 1.2, scaleY: 1.2 }, { duration: 300, easing: tween.bounceOut, onFinish: function onFinish() { tween(coin, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200, easing: tween.easeOut }); } }); } function checkScore() { for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; if (!pipe.scored && pipe.x < bird.x) { pipe.scored = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore().toString()); LK.getSound('score').play(); // Score animation tween(scoreTxt, { scaleX: 1.3, scaleY: 1.3 }, { duration: 150, easing: tween.easeOut, onFinish: function onFinish() { tween(scoreTxt, { scaleX: 1.0, scaleY: 1.0 }, { duration: 150, easing: tween.easeOut }); } }); } } } function updateHealthDisplay() { var hearts = ''; for (var i = 0; i < playerHealth; i++) { hearts += '♥ '; } for (var i = playerHealth; i < 3; i++) { hearts += '♡ '; } healthTxt.setText(hearts.trim()); } function checkCoinCollection() { for (var i = coins.length - 1; i >= 0; i--) { var coin = coins[i]; if (!coin.collected && coin.checkCollection(bird)) { coin.collected = true; LK.setScore(LK.getScore() + 5); // Coins worth 5 points scoreTxt.setText(LK.getScore().toString()); LK.getSound('score').play(); coin.destroy(); coins.splice(i, 1); } } } function checkCollisions() { // Check pipe collisions for (var i = 0; i < pipes.length; i++) { if (pipes[i].checkCollision(bird)) { return true; } } // Check ground collision if (bird.y + 30 > ground.y) { return true; } // Check ceiling collision if (bird.y - 30 < 0) { return true; } return false; } function takeDamage() { if (playerHealth > 1) { playerHealth--; updateHealthDisplay(); LK.getSound('hit').play(); // Flash screen red briefly LK.effects.flashScreen(0xff0000, 500); // Reset bird position and velocity bird.y = 2732 / 2; bird.velocity = 0; // Health display shake animation tween(healthTxt, { x: healthTxt.x + 20 }, { duration: 50, easing: tween.easeOut, onFinish: function onFinish() { tween(healthTxt, { x: healthTxt.x - 40 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(healthTxt, { x: healthTxt.x + 20 }, { duration: 50, easing: tween.easeOut }); } }); } }); // Brief invincibility period bird.invincible = true; LK.setTimeout(function () { bird.invincible = false; }, 1000); } else { gameOver(); } } function gameOver() { gameActive = false; LK.getSound('hit').play(); // Stop bird movement bird.velocity = 0; // Flash screen red LK.effects.flashScreen(0xff0000, 1000); // Show game over after a brief delay LK.setTimeout(function () { LK.showGameOver(); }, 500); } // Touch/tap handler game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; gameActive = true; // Hide all starting screen elements with staggered animations tween(titleTxt, { alpha: 0, scaleX: 0.8, scaleY: 0.8 }, { duration: 400, easing: tween.easeIn, onFinish: function onFinish() { titleTxt.visible = false; } }); tween(subtitleTxt, { alpha: 0, y: subtitleTxt.y - 50 }, { duration: 350, easing: tween.easeIn, onFinish: function onFinish() { subtitleTxt.visible = false; } }); // Smooth fade out start text tween(startTxt, { alpha: 0, scaleX: 0.8, scaleY: 0.8 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { startTxt.visible = false; } }); tween(bestScoreTxt, { alpha: 0, y: bestScoreTxt.y + 50 }, { duration: 250, easing: tween.easeIn, onFinish: function onFinish() { bestScoreTxt.visible = false; } }); // Hide sparkles when game starts for (var i = 0; i < sparkles.length; i++) { tween(sparkles[i], { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 400, easing: tween.easeIn, onFinish: function (sparkle) { return function () { sparkle.visible = false; }; }(sparkles[i]) }); } // Spawn first pipe with delay LK.setTimeout(function () { spawnPipe(); }, 800); } if (gameActive) { bird.flap(); } }; // Main game loop game.update = function () { // Dynamic background color based on score var score = LK.getScore(); if (score > 0 && score % 10 === 0 && score !== lastColorChangeScore) { var transitionColor = function transitionColor() { if (stepCount < steps) { var t = stepCount / steps; // Simple linear interpolation between colors var r1 = currentColor >> 16 & 0xFF; var g1 = currentColor >> 8 & 0xFF; var b1 = currentColor & 0xFF; var r2 = newColor >> 16 & 0xFF; var g2 = newColor >> 8 & 0xFF; var b2 = newColor & 0xFF; var r = Math.floor(r1 + (r2 - r1) * t); var g = Math.floor(g1 + (g2 - g1) * t); var b = Math.floor(b1 + (b2 - b1) * t); game.setBackgroundColor(r << 16 | g << 8 | b); stepCount++; } }; lastColorChangeScore = score; var colors = [0x87CEEB, 0xFF6B35, 0x4ECDC4, 0x45B7D1, 0x96CEB4, 0xFFA726]; var newColor = colors[Math.floor(score / 10) % colors.length]; // Smooth background color transition var currentColor = game.backgroundColor; var steps = 60; // 1 second transition var stepCount = 0; var colorTransitionInterval = LK.setInterval(transitionColor, 16); LK.setTimeout(function () { LK.clearInterval(colorTransitionInterval); }, 1000); } // Always update background elements for ambiance for (var i = 0; i < clouds.length; i++) { clouds[i].update(); } for (var i = 0; i < buildings.length; i++) { buildings[i].update(); } if (!gameStarted || !gameActive) { return; } // Update bird bird.update(); // Update pipes for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].update(); // Remove pipes that have moved off screen if (pipes[i].x < -120) { pipes[i].destroy(); pipes.splice(i, 1); } } // Update coins for (var i = coins.length - 1; i >= 0; i--) { coins[i].update(); // Remove coins that have moved off screen if (coins[i].x < -120) { coins[i].destroy(); coins.splice(i, 1); } } // Update spawn points for (var i = 0; i < spawnPoints.length; i++) { spawnPoints[i].update(); // Move spawn points left spawnPoints[i].x -= 2; // Reset spawn point position when it goes off screen if (spawnPoints[i].x < -100) { spawnPoints[i].x = 2048 + 200; spawnPoints[i].y = 300 + Math.random() * 400; } } // Spawn new pipes with dynamic difficulty pipeSpawnTimer++; var adjustedInterval = Math.max(60, pipeSpawnInterval - Math.floor(LK.getScore() / 10) * 5); if (pipeSpawnTimer >= adjustedInterval) { spawnPipe(); pipeSpawnTimer = 0; } // Check for score checkScore(); // Check for coin collection checkCoinCollection(); // Check for collisions if (checkCollisions() && !bird.invincible) { takeDamage(); } // Screen shake effect when bird is close to pipes for (var i = 0; i < pipes.length; i++) { var distance = Math.abs(bird.x - pipes[i].x); if (distance < 100) { var intensity = (100 - distance) / 100 * 3; game.x = (Math.random() - 0.5) * intensity; game.y = (Math.random() - 0.5) * intensity; break; } else { game.x = 0; game.y = 0; } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocity = 0;
self.gravity = 0.6;
self.flapStrength = -10;
self.maxFallSpeed = 12;
self.rotation = 0;
self.animationTimer = 0;
self.invincible = false;
self.flap = function () {
self.velocity = self.flapStrength;
LK.getSound('flap').play();
// Wing flapping animation
tween(birdGraphics, {
scaleY: 1.2
}, {
duration: 100,
easing: tween.easeOut
});
tween(birdGraphics, {
scaleY: 1.0
}, {
duration: 100,
easing: tween.easeIn
});
// Slight upward rotation on flap
tween(birdGraphics, {
rotation: -0.4
}, {
duration: 150,
easing: tween.easeOut
});
};
self.update = function () {
// Apply gravity
self.velocity += self.gravity;
// Limit fall speed
if (self.velocity > self.maxFallSpeed) {
self.velocity = self.maxFallSpeed;
}
// Update position
self.y += self.velocity;
// Smooth rotation based on velocity
var targetRotation = Math.min(self.velocity * 0.08, 1.2);
if (self.velocity < 0) {
targetRotation = Math.max(self.velocity * 0.08, -0.4);
}
// Smooth rotation transition
tween.stop(birdGraphics, {
rotation: true
});
tween(birdGraphics, {
rotation: targetRotation
}, {
duration: 200,
easing: tween.easeOut
});
// Subtle bob animation when idle
if (Math.abs(self.velocity) < 2) {
self.animationTimer += 0.1;
var bob = Math.sin(self.animationTimer) * 2;
birdGraphics.y = bob;
}
// Invincibility flashing
if (self.invincible) {
birdGraphics.alpha = 0.5 + 0.5 * Math.sin(LK.ticks * 0.3);
} else {
birdGraphics.alpha = 1;
}
};
return self;
});
var Building = Container.expand(function () {
var self = Container.call(this);
var buildingGraphics = self.attachAsset('building', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -2;
self.update = function () {
self.x += self.speed;
// Reset position when off screen
if (self.x < -200) {
self.x = 2048 + 200;
self.y = 2732 - 100; // Ground level
}
};
return self;
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -1;
self.update = function () {
self.x += self.speed;
// Reset position when off screen
if (self.x < -200) {
self.x = 2048 + 200;
self.y = 100 + Math.random() * 300;
}
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -4;
self.collected = false;
self.update = function () {
self.x += self.speed;
// Simple rotation animation
coinGraphics.rotation += 0.1;
};
self.checkCollection = function (bird) {
var distance = Math.sqrt(Math.pow(bird.x - self.x, 2) + Math.pow(bird.y - self.y, 2));
return distance < 35; // Collection radius
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.gapHeight = 220;
self.speed = -3;
self.scored = false;
// Create top pipe
self.topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
// Create bottom pipe
self.bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
// Add pipe caps for authentic look
self.topCap = LK.getAsset('pipe', {
anchorX: 0.5,
anchorY: 1,
scaleX: 1.2,
scaleY: 0.1
});
self.bottomCap = LK.getAsset('pipe', {
anchorX: 0.5,
anchorY: 0,
scaleX: 1.2,
scaleY: 0.1
});
self.addChild(self.topCap);
self.addChild(self.bottomCap);
self.setupPipes = function (gapCenterY) {
self.topPipe.y = gapCenterY - self.gapHeight / 2;
self.bottomPipe.y = gapCenterY + self.gapHeight / 2;
self.topCap.y = self.topPipe.y;
self.bottomCap.y = self.bottomPipe.y;
};
self.update = function () {
self.x += self.speed;
};
self.checkCollision = function (bird) {
var birdRadius = 25;
var pipeWidth = 62;
var birdBounds = {
left: bird.x - birdRadius,
right: bird.x + birdRadius,
top: bird.y - birdRadius,
bottom: bird.y + birdRadius
};
var pipeBounds = {
left: self.x - pipeWidth,
right: self.x + pipeWidth,
topBottom: self.topPipe.y,
bottomTop: self.bottomPipe.y
};
// Check if bird is within pipe horizontal bounds
if (birdBounds.right > pipeBounds.left && birdBounds.left < pipeBounds.right) {
// Check collision with top or bottom pipe
if (birdBounds.top < pipeBounds.topBottom || birdBounds.bottom > pipeBounds.bottomTop) {
return true;
}
}
return false;
};
return self;
});
var SpawnPoint = Container.expand(function () {
var self = Container.call(this);
self.isActive = true;
self.spawnType = 'pipe'; // 'pipe' or 'coin'
self.cooldownTimer = 0;
self.cooldownDuration = 60; // 1 second at 60fps
// Create visual marker for spawn point
var marker = LK.getAsset('coin', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
});
self.addChild(marker);
self.marker = marker;
self.update = function () {
if (self.cooldownTimer > 0) {
self.cooldownTimer--;
self.marker.alpha = 0.3; // Dim when on cooldown
} else {
self.marker.alpha = 1.0; // Bright when ready
}
// Pulse animation
self.marker.rotation += 0.05;
var pulse = Math.sin(LK.ticks * 0.1) * 0.1 + 1;
self.marker.scaleX = 0.5 * pulse;
self.marker.scaleY = 0.5 * pulse;
};
self.canSpawn = function () {
return self.isActive && self.cooldownTimer <= 0;
};
self.triggerSpawn = function () {
if (self.canSpawn()) {
self.cooldownTimer = self.cooldownDuration;
return true;
}
return false;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var bird;
var pipes = [];
var coins = [];
var spawnPoints = [];
var clouds = [];
var buildings = [];
var ground;
var gameStarted = false;
var gameActive = true;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 180; // 3 seconds at 60fps
var playerHealth = 3;
var bestScore = 0;
var dayTime = true;
var lastColorChangeScore = 0;
// Create score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create health display
var healthTxt = new Text2('♥ ♥ ♥', {
size: 60,
fill: 0xFF0000
});
healthTxt.anchor.set(1, 0);
healthTxt.x = -20; // Position from right edge
healthTxt.y = 20;
LK.gui.topRight.addChild(healthTxt);
// Create game title
var titleTxt = new Text2('FLAPPY BIRD', {
size: 120,
fill: 0xFFD700
});
titleTxt.anchor.set(0.5, 0.5);
titleTxt.x = 2048 / 2;
titleTxt.y = 2732 / 2 - 400;
titleTxt.alpha = 0;
game.addChild(titleTxt);
// Create subtitle
var subtitleTxt = new Text2('Guide the bird through pipes!', {
size: 50,
fill: 0xFFFFFF
});
subtitleTxt.anchor.set(0.5, 0.5);
subtitleTxt.x = 2048 / 2;
subtitleTxt.y = 2732 / 2 - 300;
subtitleTxt.alpha = 0;
game.addChild(subtitleTxt);
// Create start instruction
var startTxt = new Text2('TAP TO START', {
size: 60,
fill: 0xFFFFFF
});
startTxt.anchor.set(0.5, 0.5);
startTxt.x = 2048 / 2;
startTxt.y = 2732 / 2 - 200;
startTxt.alpha = 0;
game.addChild(startTxt);
// Create best score display
var bestScoreTxt = new Text2('BEST: 0', {
size: 45,
fill: 0xFFD700
});
bestScoreTxt.anchor.set(0.5, 0.5);
bestScoreTxt.x = 2048 / 2;
bestScoreTxt.y = 2732 / 2 - 100;
bestScoreTxt.alpha = 0;
game.addChild(bestScoreTxt);
// Cascade entrance animations for starting screen
tween(titleTxt, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 1000,
easing: tween.bounceOut
});
LK.setTimeout(function () {
tween(subtitleTxt, {
alpha: 1
}, {
duration: 800,
easing: tween.easeOut
});
}, 300);
LK.setTimeout(function () {
tween(startTxt, {
alpha: 1
}, {
duration: 1000,
easing: tween.easeInOut
});
}, 600);
LK.setTimeout(function () {
tween(bestScoreTxt, {
alpha: 1
}, {
duration: 800,
easing: tween.easeOut
});
}, 900);
// Pulsing animation for start text
function pulseStartText() {
tween(startTxt, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(startTxt, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: pulseStartText
});
}
});
}
pulseStartText();
// Add floating animation for title
function floatTitle() {
tween(titleTxt, {
y: titleTxt.y - 20
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(titleTxt, {
y: titleTxt.y + 20
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: floatTitle
});
}
});
}
LK.setTimeout(floatTitle, 1500);
// Update best score display with stored value
var storedBestScore = LK.getScore() || 0;
bestScoreTxt.setText('BEST: ' + storedBestScore);
// Create decorative sparkles for starting screen
var sparkles = [];
for (var i = 0; i < 8; i++) {
var sparkle = LK.getAsset('coin', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3,
alpha: 0
});
sparkle.x = 2048 / 2 + (Math.random() - 0.5) * 600;
sparkle.y = 2732 / 2 - 350 + (Math.random() - 0.5) * 200;
sparkles.push(sparkle);
game.addChild(sparkle);
}
// Animate sparkles
function animateSparkles() {
for (var i = 0; i < sparkles.length; i++) {
var sparkle = sparkles[i];
var delay = i * 200;
LK.setTimeout(function (s) {
return function () {
tween(s, {
alpha: 1,
rotation: Math.PI * 2,
scaleX: 0.5,
scaleY: 0.5
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(s, {
alpha: 0,
scaleX: 0.3,
scaleY: 0.3
}, {
duration: 500,
easing: tween.easeIn
});
}
});
};
}(sparkle), delay);
}
}
LK.setTimeout(animateSparkles, 2000);
// Initialize bird
bird = new Bird();
bird.x = -100; // Start off screen
bird.y = 2732 / 2;
bird.invincible = false;
game.addChild(bird);
// Smooth entrance animation
tween(bird, {
x: 2048 / 4
}, {
duration: 1000,
easing: tween.easeOut
});
// Initialize health display
updateHealthDisplay();
// Initialize clouds
for (var i = 0; i < 4; i++) {
var cloud = new Cloud();
cloud.x = i * 500 + 200;
cloud.y = 100 + Math.random() * 300;
clouds.push(cloud);
game.addChild(cloud);
}
// Initialize buildings
for (var i = 0; i < 6; i++) {
var building = new Building();
building.x = i * 350 + 100;
building.y = 2732 - 100;
var randomHeight = 200 + Math.random() * 400;
building.scaleY = randomHeight / 300;
buildings.push(building);
game.addChild(building);
}
// Initialize spawn points
for (var i = 0; i < 3; i++) {
var spawnPoint = new SpawnPoint();
spawnPoint.x = 2048 + 200 + i * 400;
spawnPoint.y = 300 + i * 200;
spawnPoints.push(spawnPoint);
game.addChild(spawnPoint);
}
// Create ground
ground = game.attachAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2732 - 100
});
// Add ground scrolling animation
tween(ground, {
x: -200
}, {
duration: 4000,
easing: tween.linear,
onFinish: function onFinish() {
ground.x = 0;
tween(ground, {
x: -200
}, {
duration: 4000,
easing: tween.linear,
onFinish: arguments.callee
});
}
});
function spawnPipe() {
var pipe = new Pipe();
pipe.x = 2048 + 200; // Start further right
pipe.alpha = 0; // Start invisible
// Random gap center position
var minGapCenter = 200;
var maxGapCenter = 2732 - 200 - 100; // Account for ground
var gapCenterY = minGapCenter + Math.random() * (maxGapCenter - minGapCenter);
pipe.setupPipes(gapCenterY);
pipes.push(pipe);
game.addChild(pipe);
// Smooth pipe entrance animation
tween(pipe, {
x: 2048 + 60,
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
// Spawn coin in the gap center
var coin = new Coin();
coin.x = pipe.x;
coin.y = gapCenterY;
coin.alpha = 0;
coins.push(coin);
game.addChild(coin);
// Coin entrance animation with slight delay
tween(coin, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(coin, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200,
easing: tween.easeOut
});
}
});
}
function checkScore() {
for (var i = 0; i < pipes.length; i++) {
var pipe = pipes[i];
if (!pipe.scored && pipe.x < bird.x) {
pipe.scored = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore().toString());
LK.getSound('score').play();
// Score animation
tween(scoreTxt, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(scoreTxt, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 150,
easing: tween.easeOut
});
}
});
}
}
}
function updateHealthDisplay() {
var hearts = '';
for (var i = 0; i < playerHealth; i++) {
hearts += '♥ ';
}
for (var i = playerHealth; i < 3; i++) {
hearts += '♡ ';
}
healthTxt.setText(hearts.trim());
}
function checkCoinCollection() {
for (var i = coins.length - 1; i >= 0; i--) {
var coin = coins[i];
if (!coin.collected && coin.checkCollection(bird)) {
coin.collected = true;
LK.setScore(LK.getScore() + 5); // Coins worth 5 points
scoreTxt.setText(LK.getScore().toString());
LK.getSound('score').play();
coin.destroy();
coins.splice(i, 1);
}
}
}
function checkCollisions() {
// Check pipe collisions
for (var i = 0; i < pipes.length; i++) {
if (pipes[i].checkCollision(bird)) {
return true;
}
}
// Check ground collision
if (bird.y + 30 > ground.y) {
return true;
}
// Check ceiling collision
if (bird.y - 30 < 0) {
return true;
}
return false;
}
function takeDamage() {
if (playerHealth > 1) {
playerHealth--;
updateHealthDisplay();
LK.getSound('hit').play();
// Flash screen red briefly
LK.effects.flashScreen(0xff0000, 500);
// Reset bird position and velocity
bird.y = 2732 / 2;
bird.velocity = 0;
// Health display shake animation
tween(healthTxt, {
x: healthTxt.x + 20
}, {
duration: 50,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(healthTxt, {
x: healthTxt.x - 40
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(healthTxt, {
x: healthTxt.x + 20
}, {
duration: 50,
easing: tween.easeOut
});
}
});
}
});
// Brief invincibility period
bird.invincible = true;
LK.setTimeout(function () {
bird.invincible = false;
}, 1000);
} else {
gameOver();
}
}
function gameOver() {
gameActive = false;
LK.getSound('hit').play();
// Stop bird movement
bird.velocity = 0;
// Flash screen red
LK.effects.flashScreen(0xff0000, 1000);
// Show game over after a brief delay
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
}
// Touch/tap handler
game.down = function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
gameActive = true;
// Hide all starting screen elements with staggered animations
tween(titleTxt, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
titleTxt.visible = false;
}
});
tween(subtitleTxt, {
alpha: 0,
y: subtitleTxt.y - 50
}, {
duration: 350,
easing: tween.easeIn,
onFinish: function onFinish() {
subtitleTxt.visible = false;
}
});
// Smooth fade out start text
tween(startTxt, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
startTxt.visible = false;
}
});
tween(bestScoreTxt, {
alpha: 0,
y: bestScoreTxt.y + 50
}, {
duration: 250,
easing: tween.easeIn,
onFinish: function onFinish() {
bestScoreTxt.visible = false;
}
});
// Hide sparkles when game starts
for (var i = 0; i < sparkles.length; i++) {
tween(sparkles[i], {
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function (sparkle) {
return function () {
sparkle.visible = false;
};
}(sparkles[i])
});
}
// Spawn first pipe with delay
LK.setTimeout(function () {
spawnPipe();
}, 800);
}
if (gameActive) {
bird.flap();
}
};
// Main game loop
game.update = function () {
// Dynamic background color based on score
var score = LK.getScore();
if (score > 0 && score % 10 === 0 && score !== lastColorChangeScore) {
var transitionColor = function transitionColor() {
if (stepCount < steps) {
var t = stepCount / steps;
// Simple linear interpolation between colors
var r1 = currentColor >> 16 & 0xFF;
var g1 = currentColor >> 8 & 0xFF;
var b1 = currentColor & 0xFF;
var r2 = newColor >> 16 & 0xFF;
var g2 = newColor >> 8 & 0xFF;
var b2 = newColor & 0xFF;
var r = Math.floor(r1 + (r2 - r1) * t);
var g = Math.floor(g1 + (g2 - g1) * t);
var b = Math.floor(b1 + (b2 - b1) * t);
game.setBackgroundColor(r << 16 | g << 8 | b);
stepCount++;
}
};
lastColorChangeScore = score;
var colors = [0x87CEEB, 0xFF6B35, 0x4ECDC4, 0x45B7D1, 0x96CEB4, 0xFFA726];
var newColor = colors[Math.floor(score / 10) % colors.length];
// Smooth background color transition
var currentColor = game.backgroundColor;
var steps = 60; // 1 second transition
var stepCount = 0;
var colorTransitionInterval = LK.setInterval(transitionColor, 16);
LK.setTimeout(function () {
LK.clearInterval(colorTransitionInterval);
}, 1000);
}
// Always update background elements for ambiance
for (var i = 0; i < clouds.length; i++) {
clouds[i].update();
}
for (var i = 0; i < buildings.length; i++) {
buildings[i].update();
}
if (!gameStarted || !gameActive) {
return;
}
// Update bird
bird.update();
// Update pipes
for (var i = pipes.length - 1; i >= 0; i--) {
pipes[i].update();
// Remove pipes that have moved off screen
if (pipes[i].x < -120) {
pipes[i].destroy();
pipes.splice(i, 1);
}
}
// Update coins
for (var i = coins.length - 1; i >= 0; i--) {
coins[i].update();
// Remove coins that have moved off screen
if (coins[i].x < -120) {
coins[i].destroy();
coins.splice(i, 1);
}
}
// Update spawn points
for (var i = 0; i < spawnPoints.length; i++) {
spawnPoints[i].update();
// Move spawn points left
spawnPoints[i].x -= 2;
// Reset spawn point position when it goes off screen
if (spawnPoints[i].x < -100) {
spawnPoints[i].x = 2048 + 200;
spawnPoints[i].y = 300 + Math.random() * 400;
}
}
// Spawn new pipes with dynamic difficulty
pipeSpawnTimer++;
var adjustedInterval = Math.max(60, pipeSpawnInterval - Math.floor(LK.getScore() / 10) * 5);
if (pipeSpawnTimer >= adjustedInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Check for score
checkScore();
// Check for coin collection
checkCoinCollection();
// Check for collisions
if (checkCollisions() && !bird.invincible) {
takeDamage();
}
// Screen shake effect when bird is close to pipes
for (var i = 0; i < pipes.length; i++) {
var distance = Math.abs(bird.x - pipes[i].x);
if (distance < 100) {
var intensity = (100 - distance) / 100 * 3;
game.x = (Math.random() - 0.5) * intensity;
game.y = (Math.random() - 0.5) * intensity;
break;
} else {
game.x = 0;
game.y = 0;
}
}
};
Make bird same like flappy bird. In-Game asset. 2d. No shadows
Make background forest. In-Game asset. 2d. No shadows
Flapy bird coin. In-Game asset. 2d. No shadows
Make it flapy bird cloud. In-Game asset. 2d. High contrast. No shadows
Add a monkey flying with plane. In-Game asset. 2d. No shadows
Make a zombi flapy bird. In-Game asset. 2d. High contrast. No shadows
Make a sigma flapy bird. In-Game asset. 2d. No shadows
Make a star War flapy bird. In-Game asset. 2d. No shadows
Make a gost flapy bird. In-Game asset. 2d. High contrast. No shadows
Make a starting buton. In-Game asset. 2d. High contrast. No shadows
Make a skin buton. In-Game asset. 2d. No shadows
Make it flapy bird building. 2d. No shadows
Make it flapy bird shape. 2d. High contrast. No shadows
Make it flapy bird building. In-Game asset. 2d. No shadows