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 Monkey = Container.expand(function () {
var self = Container.call(this);
var monkeyGraphics = self.attachAsset('monkey', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -1.5;
self.verticalSpeed = 0;
self.bounceHeight = 50;
self.animationTimer = 0;
self.direction = 1; // 1 for right, -1 for left
self.baseY = 0;
self.update = function () {
// Horizontal movement - only right
self.x += Math.abs(self.speed);
// Bouncing animation
self.animationTimer += 0.08;
self.y = self.baseY + Math.sin(self.animationTimer) * self.bounceHeight;
// Swinging animation
monkeyGraphics.rotation = Math.sin(self.animationTimer * 1.5) * 0.3;
// Always face right - no scaling animation
monkeyGraphics.scaleX = 1;
monkeyGraphics.scaleY = 1;
// Reset position when off screen
if (self.x > 2048 + 100) {
self.x = -100;
self.baseY = 200 + Math.random() * 400;
}
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.gapHeight = 320;
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 monkeys = [];
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;
var currentSkin = 5;
var skinShowMode = false;
var currentWeather = 0;
var weatherChangeTimer = 0;
var weatherChangeInterval = 1800; // 30 seconds at 60fps
var weatherTypes = [{
name: 'Sunny',
bgColor: 0x87CEEB,
cloudAlpha: 0.8,
cloudSpeed: 1
}, {
name: 'Cloudy',
bgColor: 0x708090,
cloudAlpha: 1.0,
cloudSpeed: 1.5
}, {
name: 'Stormy',
bgColor: 0x2F4F4F,
cloudAlpha: 1.2,
cloudSpeed: 2.0
}, {
name: 'Sunset',
bgColor: 0xFF6B35,
cloudAlpha: 0.9,
cloudSpeed: 0.8
}, {
name: 'Night',
bgColor: 0x191970,
cloudAlpha: 0.6,
cloudSpeed: 0.5
}];
var skins = [{
name: 'Classic',
asset: 'bird',
color: 0xFFFFFF
}, {
name: 'Red Fire',
asset: 'bird_red',
color: 0xFF4444
}, {
name: 'Blue Ice',
asset: 'bird_blue',
color: 0x4488FF
}, {
name: 'Green Forest',
asset: 'bird_green',
color: 0x44FF44
}, {
name: 'Golden King',
asset: 'bird_golden',
color: 0xFFD700
}, {
name: 'My Crafted',
asset: 'bird',
color: 0xFF00FF
}];
// 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 weather display
var weatherTxt = new Text2('Weather: Sunny', {
size: 40,
fill: 0xFFFFFF
});
weatherTxt.anchor.set(0, 0);
weatherTxt.x = 20;
weatherTxt.y = 20;
LK.gui.topLeft.addChild(weatherTxt);
// 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);
// Create clothes button
var clothesBtn = new Text2('SKINS', {
size: 80,
fill: 0x00FF00
});
clothesBtn.anchor.set(0.5, 0.5);
clothesBtn.x = 2048 / 2;
clothesBtn.y = 2732 / 2 + 50;
clothesBtn.alpha = 0;
game.addChild(clothesBtn);
// Create skin selection UI
var skinTitleTxt = new Text2('SELECT SKIN', {
size: 80,
fill: 0xFFD700
});
skinTitleTxt.anchor.set(0.5, 0.5);
skinTitleTxt.x = 2048 / 2;
skinTitleTxt.y = 400;
skinTitleTxt.alpha = 0;
skinTitleTxt.visible = false;
game.addChild(skinTitleTxt);
var skinNameTxt = new Text2('Classic', {
size: 60,
fill: 0xFFFFFF
});
skinNameTxt.anchor.set(0.5, 0.5);
skinNameTxt.x = 2048 / 2;
skinNameTxt.y = 2732 / 2 - 100;
skinNameTxt.alpha = 0;
skinNameTxt.visible = false;
game.addChild(skinNameTxt);
var prevBtn = new Text2('< PREV', {
size: 50,
fill: 0xFFFFFF
});
prevBtn.anchor.set(0.5, 0.5);
prevBtn.x = 2048 / 2 - 200;
prevBtn.y = 2732 / 2 + 100;
prevBtn.alpha = 0;
prevBtn.visible = false;
game.addChild(prevBtn);
var nextBtn = new Text2('NEXT >', {
size: 50,
fill: 0xFFFFFF
});
nextBtn.anchor.set(0.5, 0.5);
nextBtn.x = 2048 / 2 + 200;
nextBtn.y = 2732 / 2 + 100;
nextBtn.alpha = 0;
nextBtn.visible = false;
game.addChild(nextBtn);
var backBtn = new Text2('BACK', {
size: 50,
fill: 0xFF4444
});
backBtn.anchor.set(0.5, 0.5);
backBtn.x = 2048 / 2;
backBtn.y = 2732 / 2 + 200;
backBtn.alpha = 0;
backBtn.visible = false;
game.addChild(backBtn);
var skinPreviewBird = new Bird();
skinPreviewBird.x = 2048 / 2;
skinPreviewBird.y = 2732 / 2;
skinPreviewBird.alpha = 0;
skinPreviewBird.visible = false;
game.addChild(skinPreviewBird);
// 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);
LK.setTimeout(function () {
tween(clothesBtn, {
alpha: 1,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 600,
easing: tween.bounceOut
});
}, 1200);
// 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);
// Apply current skin
bird.removeChildren();
var initialBirdGraphics = bird.attachAsset(skins[currentSkin].asset, {
anchorX: 0.5,
anchorY: 0.5
});
initialBirdGraphics.tint = skins[currentSkin].color;
// 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 monkeys
var monkey = new Monkey();
monkey.x = 2048 + 300;
monkey.baseY = 200 + Math.random() * 400;
monkey.y = monkey.baseY;
monkeys.push(monkey);
game.addChild(monkey);
// 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
// Fixed gap center position - all pipes at same Y coordinate
var gapCenterY = 2732 / 2; // Center of screen vertically
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);
}
function showSkinSelection() {
skinShowMode = true;
// Hide main menu elements
titleTxt.visible = false;
subtitleTxt.visible = false;
startTxt.visible = false;
bestScoreTxt.visible = false;
clothesBtn.visible = false;
for (var i = 0; i < sparkles.length; i++) {
sparkles[i].visible = false;
}
// Show skin selection elements
skinTitleTxt.visible = true;
skinNameTxt.visible = true;
prevBtn.visible = true;
nextBtn.visible = true;
backBtn.visible = true;
skinPreviewBird.visible = true;
// Animate skin UI entrance
tween(skinTitleTxt, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(skinNameTxt, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(prevBtn, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(nextBtn, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(backBtn, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(skinPreviewBird, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
updateSkinPreview();
}
function hideSkinSelection() {
skinShowMode = false;
// Hide skin selection elements
tween(skinTitleTxt, {
alpha: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
skinTitleTxt.visible = false;
}
});
tween(skinNameTxt, {
alpha: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
skinNameTxt.visible = false;
}
});
tween(prevBtn, {
alpha: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
prevBtn.visible = false;
}
});
tween(nextBtn, {
alpha: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
nextBtn.visible = false;
}
});
tween(backBtn, {
alpha: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
backBtn.visible = false;
}
});
tween(skinPreviewBird, {
alpha: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
skinPreviewBird.visible = false;
}
});
// Show main menu elements
LK.setTimeout(function () {
titleTxt.visible = true;
subtitleTxt.visible = true;
startTxt.visible = true;
bestScoreTxt.visible = true;
clothesBtn.visible = true;
for (var i = 0; i < sparkles.length; i++) {
sparkles[i].visible = true;
}
tween(titleTxt, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(subtitleTxt, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(startTxt, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(bestScoreTxt, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
tween(clothesBtn, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
}, 300);
}
function updateSkinPreview() {
var skin = skins[currentSkin];
skinNameTxt.setText(skin.name);
skinNameTxt.fill = skin.color;
// Update preview bird skin
skinPreviewBird.removeChildren();
var newBirdGraphics = skinPreviewBird.attachAsset(skin.asset, {
anchorX: 0.5,
anchorY: 0.5
});
newBirdGraphics.tint = skin.color;
// Add floating animation to preview bird
tween(skinPreviewBird, {
y: skinPreviewBird.y - 10
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(skinPreviewBird, {
y: skinPreviewBird.y + 10
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: updateSkinPreview
});
}
});
}
function changeSkin(direction) {
currentSkin += direction;
if (currentSkin < 0) {
currentSkin = skins.length - 1;
} else if (currentSkin >= skins.length) {
currentSkin = 0;
}
updateSkinPreview();
// Update actual bird skin
bird.removeChildren();
var newBirdGraphics = bird.attachAsset(skins[currentSkin].asset, {
anchorX: 0.5,
anchorY: 0.5
});
newBirdGraphics.tint = skins[currentSkin].color;
}
function changeWeather() {
currentWeather = (currentWeather + 1) % weatherTypes.length;
var weather = weatherTypes[currentWeather];
// Smooth background color transition
var currentColor = game.backgroundColor;
var newColor = weather.bgColor;
var steps = 120; // 2 second transition
var stepCount = 0;
var transitionColor = function transitionColor() {
if (stepCount < steps) {
var t = stepCount / steps;
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++;
}
};
var colorTransitionInterval = LK.setInterval(transitionColor, 16);
LK.setTimeout(function () {
LK.clearInterval(colorTransitionInterval);
}, 2000);
// Update cloud properties for weather effect
for (var i = 0; i < clouds.length; i++) {
var cloud = clouds[i];
cloud.speed = -weather.cloudSpeed;
tween(cloud, {
alpha: weather.cloudAlpha
}, {
duration: 2000,
easing: tween.easeInOut
});
}
// Update weather display
weatherTxt.setText('Weather: ' + weather.name);
// Add weather-specific visual effects
if (weather.name === 'Stormy') {
// Screen flash effect for lightning
LK.setTimeout(function () {
LK.effects.flashScreen(0xFFFFFF, 200);
}, 1000);
}
}
// Touch/tap handler
game.down = function (x, y, obj) {
if (!gameStarted) {
if (skinShowMode) {
// Check skin selection UI clicks
var prevBounds = {
left: prevBtn.x - 75,
right: prevBtn.x + 75,
top: prevBtn.y - 30,
bottom: prevBtn.y + 30
};
var nextBounds = {
left: nextBtn.x - 75,
right: nextBtn.x + 75,
top: nextBtn.y - 30,
bottom: nextBtn.y + 30
};
var backBounds = {
left: backBtn.x - 50,
right: backBtn.x + 50,
top: backBtn.y - 30,
bottom: backBtn.y + 30
};
if (x >= prevBounds.left && x <= prevBounds.right && y >= prevBounds.top && y <= prevBounds.bottom) {
// Previous skin button
tween(prevBtn, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(prevBtn, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100,
easing: tween.easeOut
});
}
});
changeSkin(-1);
return;
} else if (x >= nextBounds.left && x <= nextBounds.right && y >= nextBounds.top && y <= nextBounds.bottom) {
// Next skin button
tween(nextBtn, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(nextBtn, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100,
easing: tween.easeOut
});
}
});
changeSkin(1);
return;
} else if (x >= backBounds.left && x <= backBounds.right && y >= backBounds.top && y <= backBounds.bottom) {
// Back button - start game directly
tween(backBtn, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(backBtn, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100,
easing: tween.easeOut
});
}
});
// Hide skin selection and start game
hideSkinSelection();
// Start the game immediately
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 clothes button when game starts
tween(clothesBtn, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
clothesBtn.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);
return;
}
} else {
// Check if skins button was clicked
var clothesBounds = {
left: clothesBtn.x - 100,
right: clothesBtn.x + 100,
top: clothesBtn.y - 30,
bottom: clothesBtn.y + 30
};
if (x >= clothesBounds.left && x <= clothesBounds.right && y >= clothesBounds.top && y <= clothesBounds.bottom) {
// Skins button clicked - add button press animation
tween(clothesBtn, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(clothesBtn, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
easing: tween.easeOut
});
}
});
showSkinSelection();
return; // Don't start game
}
}
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 clothes button when game starts
tween(clothesBtn, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
clothesBtn.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);
// Bird will start flying when user first touches screen
}
if (gameActive) {
bird.flap();
}
};
// Main game loop
game.update = function () {
// Weather change system
if (gameStarted && gameActive) {
weatherChangeTimer++;
if (weatherChangeTimer >= weatherChangeInterval) {
changeWeather();
weatherChangeTimer = 0;
}
}
// 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();
}
for (var i = 0; i < monkeys.length; i++) {
monkeys[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;
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -299,8 +299,37 @@
var dayTime = true;
var lastColorChangeScore = 0;
var currentSkin = 5;
var skinShowMode = false;
+var currentWeather = 0;
+var weatherChangeTimer = 0;
+var weatherChangeInterval = 1800; // 30 seconds at 60fps
+var weatherTypes = [{
+ name: 'Sunny',
+ bgColor: 0x87CEEB,
+ cloudAlpha: 0.8,
+ cloudSpeed: 1
+}, {
+ name: 'Cloudy',
+ bgColor: 0x708090,
+ cloudAlpha: 1.0,
+ cloudSpeed: 1.5
+}, {
+ name: 'Stormy',
+ bgColor: 0x2F4F4F,
+ cloudAlpha: 1.2,
+ cloudSpeed: 2.0
+}, {
+ name: 'Sunset',
+ bgColor: 0xFF6B35,
+ cloudAlpha: 0.9,
+ cloudSpeed: 0.8
+}, {
+ name: 'Night',
+ bgColor: 0x191970,
+ cloudAlpha: 0.6,
+ cloudSpeed: 0.5
+}];
var skins = [{
name: 'Classic',
asset: 'bird',
color: 0xFFFFFF
@@ -340,8 +369,17 @@
healthTxt.anchor.set(1, 0);
healthTxt.x = -20; // Position from right edge
healthTxt.y = 20;
LK.gui.topRight.addChild(healthTxt);
+// Create weather display
+var weatherTxt = new Text2('Weather: Sunny', {
+ size: 40,
+ fill: 0xFFFFFF
+});
+weatherTxt.anchor.set(0, 0);
+weatherTxt.x = 20;
+weatherTxt.y = 20;
+LK.gui.topLeft.addChild(weatherTxt);
// Create game title
var titleTxt = new Text2('FLAPPY BIRD', {
size: 120,
fill: 0xFFD700
@@ -1023,8 +1061,57 @@
anchorY: 0.5
});
newBirdGraphics.tint = skins[currentSkin].color;
}
+function changeWeather() {
+ currentWeather = (currentWeather + 1) % weatherTypes.length;
+ var weather = weatherTypes[currentWeather];
+ // Smooth background color transition
+ var currentColor = game.backgroundColor;
+ var newColor = weather.bgColor;
+ var steps = 120; // 2 second transition
+ var stepCount = 0;
+ var transitionColor = function transitionColor() {
+ if (stepCount < steps) {
+ var t = stepCount / steps;
+ 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++;
+ }
+ };
+ var colorTransitionInterval = LK.setInterval(transitionColor, 16);
+ LK.setTimeout(function () {
+ LK.clearInterval(colorTransitionInterval);
+ }, 2000);
+ // Update cloud properties for weather effect
+ for (var i = 0; i < clouds.length; i++) {
+ var cloud = clouds[i];
+ cloud.speed = -weather.cloudSpeed;
+ tween(cloud, {
+ alpha: weather.cloudAlpha
+ }, {
+ duration: 2000,
+ easing: tween.easeInOut
+ });
+ }
+ // Update weather display
+ weatherTxt.setText('Weather: ' + weather.name);
+ // Add weather-specific visual effects
+ if (weather.name === 'Stormy') {
+ // Screen flash effect for lightning
+ LK.setTimeout(function () {
+ LK.effects.flashScreen(0xFFFFFF, 200);
+ }, 1000);
+ }
+}
// Touch/tap handler
game.down = function (x, y, obj) {
if (!gameStarted) {
if (skinShowMode) {
@@ -1303,39 +1390,15 @@
}
};
// 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);
+ // Weather change system
+ if (gameStarted && gameActive) {
+ weatherChangeTimer++;
+ if (weatherChangeTimer >= weatherChangeInterval) {
+ changeWeather();
+ weatherChangeTimer = 0;
+ }
}
// Always update background elements for ambiance
for (var i = 0; i < clouds.length; i++) {
clouds[i].update();
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