User prompt
pipe ı düzelt karekter iki borunun arasından geçemiyor
User prompt
fix the game bug
User prompt
fix the bird and pipe size
User prompt
fix game
User prompt
fix pipe
User prompt
ground iyi fkat sonsuz gözükmüyor
User prompt
oyundaki pipe ve ground du düzelt
User prompt
oyunu düzenle ve hataları kapat
User prompt
Flappy bird game
Code edit (1 edits merged)
Please save this source code
User prompt
Flappy Wings
Initial prompt
Flappy bird
/****
* 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.flapPower = -12;
self.maxVelocity = 15;
self.flap = function () {
self.velocity = self.flapPower;
LK.getSound('flap').play();
// Add flap animation
tween.stop(birdGraphics, {
rotation: true
});
birdGraphics.rotation = -0.3;
tween(birdGraphics, {
rotation: 0.3
}, {
duration: 300,
easing: tween.easeOut
});
};
self.update = function () {
self.velocity += self.gravity;
if (self.velocity > self.maxVelocity) {
self.velocity = self.maxVelocity;
}
self.y += self.velocity;
// Rotate bird based on velocity
var targetRotation = Math.max(-0.5, Math.min(0.8, self.velocity * 0.08));
birdGraphics.rotation = targetRotation;
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.gapSize = 300;
self.speed = -4;
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
});
self.setGapPosition = function (gapY) {
self.topPipe.y = gapY - self.gapSize / 2;
self.bottomPipe.y = gapY + self.gapSize / 2;
};
self.update = function () {
self.x += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var bird;
var pipes = [];
var gameStarted = false;
var gameOver = false;
var pipeTimer = 0;
var pipeSpacing = 300;
// 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 START', {
size: 60,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionTxt);
// Initialize bird
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = 1366;
function startGame() {
gameStarted = true;
gameOver = false;
instructionTxt.visible = false;
bird.flap();
}
function spawnPipe() {
var pipe = new Pipe();
pipe.x = 2200;
// Random gap position (avoiding top and bottom edges)
var minGapY = 400;
var maxGapY = 2332;
var gapY = minGapY + Math.random() * (maxGapY - minGapY);
pipe.setGapPosition(gapY);
pipes.push(pipe);
game.addChild(pipe);
}
function checkCollisions() {
// Check ground and ceiling collision
if (bird.y > 2732 - 30 || bird.y < 30) {
return true;
}
// Check pipe collisions
for (var i = 0; i < pipes.length; i++) {
var pipe = pipes[i];
// Simple collision detection with pipes
if (bird.x + 30 > pipe.x - 60 && bird.x - 30 < pipe.x + 60) {
if (bird.y - 30 < pipe.topPipe.y || bird.y + 30 > pipe.bottomPipe.y) {
return true;
}
}
}
return false;
}
function updateScore() {
for (var i = 0; i < pipes.length; i++) {
var pipe = pipes[i];
if (!pipe.scored && bird.x > pipe.x) {
pipe.scored = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('score').play();
}
}
}
function cleanupPipes() {
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
if (pipe.x < -200) {
pipe.destroy();
pipes.splice(i, 1);
}
}
}
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
} else if (!gameOver) {
bird.flap();
}
};
game.update = function () {
if (!gameStarted || gameOver) {
return;
}
// Update pipes
for (var i = 0; i < pipes.length; i++) {
pipes[i].update();
}
// Spawn new pipes
pipeTimer++;
if (pipeTimer >= pipeSpacing / 4) {
spawnPipe();
pipeTimer = 0;
}
// Update bird
bird.update();
// Check collisions
if (checkCollisions()) {
if (!gameOver) {
gameOver = true;
LK.getSound('hit').play();
LK.showGameOver();
}
}
// Update score
updateScore();
// Cleanup old pipes
cleanupPipes();
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,193 @@
-/****
+/****
+* 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.flapPower = -12;
+ self.maxVelocity = 15;
+ self.flap = function () {
+ self.velocity = self.flapPower;
+ LK.getSound('flap').play();
+ // Add flap animation
+ tween.stop(birdGraphics, {
+ rotation: true
+ });
+ birdGraphics.rotation = -0.3;
+ tween(birdGraphics, {
+ rotation: 0.3
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ };
+ self.update = function () {
+ self.velocity += self.gravity;
+ if (self.velocity > self.maxVelocity) {
+ self.velocity = self.maxVelocity;
+ }
+ self.y += self.velocity;
+ // Rotate bird based on velocity
+ var targetRotation = Math.max(-0.5, Math.min(0.8, self.velocity * 0.08));
+ birdGraphics.rotation = targetRotation;
+ };
+ return self;
+});
+var Pipe = Container.expand(function () {
+ var self = Container.call(this);
+ self.gapSize = 300;
+ self.speed = -4;
+ 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
+ });
+ self.setGapPosition = function (gapY) {
+ self.topPipe.y = gapY - self.gapSize / 2;
+ self.bottomPipe.y = gapY + self.gapSize / 2;
+ };
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+var bird;
+var pipes = [];
+var gameStarted = false;
+var gameOver = false;
+var pipeTimer = 0;
+var pipeSpacing = 300;
+// 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 START', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+instructionTxt.anchor.set(0.5, 0.5);
+LK.gui.center.addChild(instructionTxt);
+// Initialize bird
+bird = game.addChild(new Bird());
+bird.x = 300;
+bird.y = 1366;
+function startGame() {
+ gameStarted = true;
+ gameOver = false;
+ instructionTxt.visible = false;
+ bird.flap();
+}
+function spawnPipe() {
+ var pipe = new Pipe();
+ pipe.x = 2200;
+ // Random gap position (avoiding top and bottom edges)
+ var minGapY = 400;
+ var maxGapY = 2332;
+ var gapY = minGapY + Math.random() * (maxGapY - minGapY);
+ pipe.setGapPosition(gapY);
+ pipes.push(pipe);
+ game.addChild(pipe);
+}
+function checkCollisions() {
+ // Check ground and ceiling collision
+ if (bird.y > 2732 - 30 || bird.y < 30) {
+ return true;
+ }
+ // Check pipe collisions
+ for (var i = 0; i < pipes.length; i++) {
+ var pipe = pipes[i];
+ // Simple collision detection with pipes
+ if (bird.x + 30 > pipe.x - 60 && bird.x - 30 < pipe.x + 60) {
+ if (bird.y - 30 < pipe.topPipe.y || bird.y + 30 > pipe.bottomPipe.y) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+function updateScore() {
+ for (var i = 0; i < pipes.length; i++) {
+ var pipe = pipes[i];
+ if (!pipe.scored && bird.x > pipe.x) {
+ pipe.scored = true;
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ LK.getSound('score').play();
+ }
+ }
+}
+function cleanupPipes() {
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ var pipe = pipes[i];
+ if (pipe.x < -200) {
+ pipe.destroy();
+ pipes.splice(i, 1);
+ }
+ }
+}
+game.down = function (x, y, obj) {
+ if (!gameStarted) {
+ startGame();
+ } else if (!gameOver) {
+ bird.flap();
+ }
+};
+game.update = function () {
+ if (!gameStarted || gameOver) {
+ return;
+ }
+ // Update pipes
+ for (var i = 0; i < pipes.length; i++) {
+ pipes[i].update();
+ }
+ // Spawn new pipes
+ pipeTimer++;
+ if (pipeTimer >= pipeSpacing / 4) {
+ spawnPipe();
+ pipeTimer = 0;
+ }
+ // Update bird
+ bird.update();
+ // Check collisions
+ if (checkCollisions()) {
+ if (!gameOver) {
+ gameOver = true;
+ LK.getSound('hit').play();
+ LK.showGameOver();
+ }
+ }
+ // Update score
+ updateScore();
+ // Cleanup old pipes
+ cleanupPipes();
+};
\ No newline at end of file