User prompt
İnekler yürüsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Borulara deyince canımız azalsın ve can bari olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Boruların reginde olmasın arka plan
User prompt
Altalara çiftlik koyun ve daha fazla hayvan ekle
User prompt
Arka plan ekle ve oyunu gerçekçi yap
User prompt
Boruların arasından geçerken 0 puan olsun
User prompt
Para toplayınca bir puan artsın borulardan geçerken 1 puan azalsın
User prompt
Altınları geçiş yerlerine yerleştir
User prompt
Borular yapışık olmasın
User prompt
Boruların aralarını aç
User prompt
Kuş düşerken kuş düşme efekti olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Altın ekle
User prompt
Mariodaki borulardan yap
User prompt
Çok uzunn olsun yani çok fazla
User prompt
Boruları uzat
Code edit (1 edits merged)
Please save this source code
User prompt
Flippy Bird
Initial prompt
Bana flippy bird oyununu yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocity = 0;
self.gravity = 0.8;
self.flapStrength = -12;
self.maxFallSpeed = 15;
self.rotation = 0;
self.flap = function () {
self.velocity = self.flapStrength;
LK.getSound('flap').play();
// Animate bird flap
tween(birdGraphics, {
rotation: -0.3
}, {
duration: 150
});
tween(birdGraphics, {
rotation: 0
}, {
duration: 150,
onFinish: function onFinish() {
if (self.velocity > 0) {
tween(birdGraphics, {
rotation: 0.3
}, {
duration: 200
});
}
}
});
};
self.update = function () {
// Apply gravity
self.velocity += self.gravity;
if (self.velocity > self.maxFallSpeed) {
self.velocity = self.maxFallSpeed;
}
// Update position
self.y += self.velocity;
// Update rotation based on velocity with falling effect
var targetRotation = Math.min(Math.max(self.velocity * 0.05, -0.5), 0.8);
// Add dramatic falling effect when bird is falling fast
if (self.velocity > 8) {
// Create falling spin effect
tween(birdGraphics, {
rotation: targetRotation + Math.PI * 2
}, {
duration: 800,
easing: tween.easeIn
});
// Add slight scale effect during fall
tween(birdGraphics, {
scaleX: 0.9,
scaleY: 1.1
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(birdGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
} else {
// Normal rotation for regular movement
birdGraphics.rotation = targetRotation;
}
};
return self;
});
var Chicken = Container.expand(function () {
var self = Container.call(this);
var chickenGraphics = self.attachAsset('chicken', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -4;
self.baseY = 0;
self.pecking = false;
self.update = function () {
self.x += self.speed;
// Chicken pecking animation
if (LK.ticks % 120 === 0) {
self.pecking = !self.pecking;
}
if (self.pecking) {
self.y = self.baseY + Math.sin(LK.ticks * 0.2) * 3;
} else {
self.y = self.baseY + Math.sin(LK.ticks * 0.05) * 1;
}
};
return self;
});
// Cloud class removed
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -4;
self.collected = false;
self.rotationSpeed = 0.1;
self.update = function () {
self.x += self.speed;
// Rotate coin for visual appeal
coinGraphics.rotation += self.rotationSpeed;
// Gentle floating animation
coinGraphics.y = Math.sin(LK.ticks * 0.05) * 3;
};
return self;
});
var Cow = Container.expand(function () {
var self = Container.call(this);
var cowGraphics = self.attachAsset('cow', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -4;
// Add some black spots for cow appearance
self.baseY = 0;
self.update = function () {
self.x += self.speed;
// Gentle bobbing motion
self.y = self.baseY + Math.sin(LK.ticks * 0.03) * 2;
};
return self;
});
var Farm = Container.expand(function () {
var self = Container.call(this);
var farmGraphics = self.attachAsset('farmGround', {
anchorX: 0,
anchorY: 0
});
self.speed = -4;
self.update = function () {
self.x += self.speed;
};
return self;
});
var Pig = Container.expand(function () {
var self = Container.call(this);
var pigGraphics = self.attachAsset('pig', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -4;
self.baseY = 0;
self.update = function () {
self.x += self.speed;
// Gentle bobbing motion
self.y = self.baseY + Math.sin(LK.ticks * 0.035) * 1;
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
self.passed = false;
self.gapSize = 300;
// Create top pipe
self.topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
// Create top pipe segment (Mario-style cap)
self.topPipeSegment = self.attachAsset('pipeSegment', {
anchorX: 0.5,
anchorY: 1
});
// Create bottom pipe
self.bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
// Create bottom pipe segment (Mario-style cap)
self.bottomPipeSegment = self.attachAsset('pipeSegment', {
anchorX: 0.5,
anchorY: 0
});
self.setGapPosition = function (gapY) {
self.topPipe.y = gapY - self.gapSize / 2;
self.bottomPipe.y = gapY + self.gapSize / 2;
// Position the Mario-style pipe segments
self.topPipeSegment.y = gapY - self.gapSize / 2;
self.bottomPipeSegment.y = gapY + self.gapSize / 2;
};
self.update = function () {
self.x += self.speed;
};
return self;
});
var Sheep = Container.expand(function () {
var self = Container.call(this);
var sheepGraphics = self.attachAsset('sheep', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -4;
self.baseY = 0;
self.update = function () {
self.x += self.speed;
// Gentle bobbing motion
self.y = self.baseY + Math.sin(LK.ticks * 0.04) * 1.5;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x4a90e2
});
/****
* Game Code
****/
// Sky gradient assets removed
// Cloud asset removed
// Game variables
var bird;
var pipes = [];
var ground;
var gameStarted = false;
var gameSpeed = 4;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 180; // frames between pipe spawns
var lastPipeScore = 0;
var coins = [];
var coinSpawnTimer = 0;
var coinSpawnInterval = 200; // frames between coin spawns - slightly after pipes
// Cloud spawning removed
var farms = [];
var farmSpawnTimer = 0;
var farmSpawnInterval = 400; // frames between farm spawns
var animals = [];
var animalSpawnTimer = 0;
var animalSpawnInterval = 150; // frames between animal spawns
// Sky gradient layers removed
// UI elements
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var instructionTxt = new Text2('Tap to Flap!', {
size: 60,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionTxt);
// Create bird
bird = game.addChild(new Bird());
bird.x = 400;
bird.y = 1366; // Center of screen height
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0
}));
ground.x = 0;
ground.y = 2732 - 100; // Bottom of screen
// Game state tracking
var lastBirdY = bird.y;
var lastGroundCollision = false;
var lastCeilingCollision = false;
function spawnPipe() {
var pipe = new Pipe();
pipe.x = 2048 + 60; // Start off-screen right
// Random gap position (avoiding too high or too low)
var minGapY = 300;
var maxGapY = ground.y - 300;
var gapY = minGapY + Math.random() * (maxGapY - minGapY);
pipe.setGapPosition(gapY);
pipe.speed = -gameSpeed;
pipes.push(pipe);
game.addChild(pipe);
}
function spawnCoin() {
// Only spawn coin if there's a recent pipe to place it with
if (pipes.length > 0) {
var latestPipe = pipes[pipes.length - 1];
var coin = new Coin();
// Place coin slightly ahead of the pipe gap
coin.x = latestPipe.x + 150; // Position coin in the gap area
// Place coin in the center of the pipe gap
var gapCenterY = (latestPipe.topPipe.y + latestPipe.bottomPipe.y) / 2;
coin.y = gapCenterY;
coin.speed = -gameSpeed;
coins.push(coin);
game.addChild(coin);
}
}
// Cloud spawning function removed
function spawnFarm() {
var farm = new Farm();
farm.x = 2048;
farm.y = ground.y - 200; // Position above ground
farm.speed = -gameSpeed;
farms.push(farm);
game.addChild(farm);
}
function spawnAnimal() {
if (farms.length > 0) {
var randomFarm = farms[Math.floor(Math.random() * farms.length)];
var animalTypes = [Cow, Sheep, Pig, Chicken];
var AnimalClass = animalTypes[Math.floor(Math.random() * animalTypes.length)];
var animal = new AnimalClass();
animal.x = randomFarm.x + Math.random() * 1500; // Random position on farm
animal.baseY = randomFarm.y;
animal.y = animal.baseY;
animal.speed = -gameSpeed;
animals.push(animal);
game.addChild(animal);
}
}
function checkCollisions() {
// Check ground collision
var currentGroundCollision = bird.y + 22 >= ground.y; // bird half-height
if (!lastGroundCollision && currentGroundCollision) {
LK.getSound('hit').play();
LK.showGameOver();
return;
}
lastGroundCollision = currentGroundCollision;
// Check ceiling collision
var currentCeilingCollision = bird.y - 22 <= 0;
if (!lastCeilingCollision && currentCeilingCollision) {
LK.getSound('hit').play();
LK.showGameOver();
return;
}
lastCeilingCollision = currentCeilingCollision;
// Check pipe collisions and scoring
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
// Check if bird passed through pipe (scoring)
if (!pipe.passed && bird.x > pipe.x + 60) {
pipe.passed = true;
// No score change when passing through pipes
LK.getSound('score').play();
// Increase difficulty every 5 pipes
if (LK.getScore() % 5 === 0) {
gameSpeed += 0.5;
}
}
// Check collision with pipes
var birdLeft = bird.x - 30;
var birdRight = bird.x + 30;
var birdTop = bird.y - 22;
var birdBottom = bird.y + 22;
var pipeLeft = pipe.x - 60;
var pipeRight = pipe.x + 60;
if (birdRight > pipeLeft && birdLeft < pipeRight) {
// Bird is horizontally aligned with pipe
var topPipeBottom = pipe.topPipe.y;
var bottomPipeTop = pipe.bottomPipe.y;
if (birdTop < topPipeBottom || birdBottom > bottomPipeTop) {
// Collision with pipe
LK.getSound('hit').play();
LK.showGameOver();
return;
}
}
}
// Check coin collection
for (var j = coins.length - 1; j >= 0; j--) {
var coin = coins[j];
if (!coin.collected && bird.intersects(coin)) {
coin.collected = true;
LK.setScore(LK.getScore() + 1); // Coins worth 1 point
scoreTxt.setText(LK.getScore());
LK.getSound('coin').play();
// Visual effect - make coin disappear with scaling
tween(coin, {
scaleX: 0,
scaleY: 0,
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
coin.destroy();
}
});
coins.splice(j, 1);
}
}
}
// Touch controls
game.down = function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
instructionTxt.alpha = 0;
}
bird.flap();
};
// Main game loop
game.update = function () {
if (!gameStarted) {
return;
}
// Update bird
lastBirdY = bird.y;
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Spawn coins - spawn a coin shortly after each pipe
coinSpawnTimer++;
if (coinSpawnTimer >= coinSpawnInterval) {
spawnCoin();
coinSpawnTimer = 0;
}
// Cloud spawning logic removed
// Spawn farms
farmSpawnTimer++;
if (farmSpawnTimer >= farmSpawnInterval) {
spawnFarm();
farmSpawnTimer = 0;
}
// Spawn animals on existing farms
animalSpawnTimer++;
if (animalSpawnTimer >= animalSpawnInterval) {
spawnAnimal();
animalSpawnTimer = 0;
}
// Update pipes and remove off-screen ones
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
pipe.speed = -gameSpeed;
if (pipe.x < -120) {
pipe.destroy();
pipes.splice(i, 1);
}
}
// Update coins and remove off-screen ones
for (var j = coins.length - 1; j >= 0; j--) {
var coin = coins[j];
coin.speed = -gameSpeed;
if (coin.x < -40) {
coin.destroy();
coins.splice(j, 1);
}
}
// Cloud update logic removed
// Update farms and remove off-screen ones
for (var l = farms.length - 1; l >= 0; l--) {
var farm = farms[l];
farm.speed = -gameSpeed;
if (farm.x < -2048) {
farm.destroy();
farms.splice(l, 1);
}
}
// Update animals and remove off-screen ones
for (var m = animals.length - 1; m >= 0; m--) {
var animal = animals[m];
animal.speed = -gameSpeed;
if (animal.x < -100) {
animal.destroy();
animals.splice(m, 1);
}
}
// Check all collisions
checkCollisions();
}; ===================================================================
--- original.js
+++ change.js
@@ -105,30 +105,9 @@
}
};
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 - Math.random() * 2; // Random speed between -1 and -3
- self.baseY = 0;
- self.floatSpeed = 0.02 + Math.random() * 0.02;
- // Random scale for variety
- var scale = 0.8 + Math.random() * 0.6;
- cloudGraphics.scaleX = scale;
- cloudGraphics.scaleY = scale;
- // Random opacity for depth
- cloudGraphics.alpha = 0.6 + Math.random() * 0.4;
- self.update = function () {
- self.x += self.speed;
- // Gentle floating motion
- self.y = self.baseY + Math.sin(LK.ticks * self.floatSpeed) * 20;
- };
- return self;
-});
+// Cloud class removed
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
@@ -251,8 +230,10 @@
/****
* Game Code
****/
+// Sky gradient assets removed
+// Cloud asset removed
// Game variables
var bird;
var pipes = [];
var ground;
@@ -263,39 +244,16 @@
var lastPipeScore = 0;
var coins = [];
var coinSpawnTimer = 0;
var coinSpawnInterval = 200; // frames between coin spawns - slightly after pipes
-var clouds = [];
-var cloudSpawnTimer = 0;
-var cloudSpawnInterval = 300; // frames between cloud spawns
+// Cloud spawning removed
var farms = [];
var farmSpawnTimer = 0;
var farmSpawnInterval = 400; // frames between farm spawns
var animals = [];
var animalSpawnTimer = 0;
var animalSpawnInterval = 150; // frames between animal spawns
-// Create sky gradient layers for depth
-var skyTop = game.addChild(LK.getAsset('skyGradient', {
- anchorX: 0,
- anchorY: 0
-}));
-skyTop.x = 0;
-skyTop.y = 0;
-skyTop.alpha = 0.8;
-var skyMiddle = game.addChild(LK.getAsset('skyGradientMiddle', {
- anchorX: 0,
- anchorY: 0
-}));
-skyMiddle.x = 0;
-skyMiddle.y = 400;
-skyMiddle.alpha = 0.7;
-var skyBottom = game.addChild(LK.getAsset('skyGradientBottom', {
- anchorX: 0,
- anchorY: 0
-}));
-skyBottom.x = 0;
-skyBottom.y = 800;
-skyBottom.alpha = 0.6;
+// Sky gradient layers removed
// UI elements
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
@@ -349,16 +307,9 @@
coins.push(coin);
game.addChild(coin);
}
}
-function spawnCloud() {
- var cloud = new Cloud();
- cloud.x = 2048 + 100; // Start off-screen right
- cloud.baseY = 200 + Math.random() * 800; // Random height in upper portion
- cloud.y = cloud.baseY;
- clouds.push(cloud);
- game.addChild(cloud);
-}
+// Cloud spawning function removed
function spawnFarm() {
var farm = new Farm();
farm.x = 2048;
farm.y = ground.y - 200; // Position above ground
@@ -478,14 +429,9 @@
if (coinSpawnTimer >= coinSpawnInterval) {
spawnCoin();
coinSpawnTimer = 0;
}
- // Spawn clouds for background atmosphere
- cloudSpawnTimer++;
- if (cloudSpawnTimer >= cloudSpawnInterval) {
- spawnCloud();
- cloudSpawnTimer = 0;
- }
+ // Cloud spawning logic removed
// Spawn farms
farmSpawnTimer++;
if (farmSpawnTimer >= farmSpawnInterval) {
spawnFarm();
@@ -514,16 +460,9 @@
coin.destroy();
coins.splice(j, 1);
}
}
- // Update clouds and remove off-screen ones
- for (var k = clouds.length - 1; k >= 0; k--) {
- var cloud = clouds[k];
- if (cloud.x < -250) {
- cloud.destroy();
- clouds.splice(k, 1);
- }
- }
+ // Cloud update logic removed
// Update farms and remove off-screen ones
for (var l = farms.length - 1; l >= 0; l--) {
var farm = farms[l];
farm.speed = -gameSpeed;