User prompt
Boruları birbirinden uzaklaştır böyle oyun çok zor oluyor
User prompt
borular birbirine çok yakın, uzaklaştır bir de boruları biraz daha kalınlaştır
User prompt
Boruları kalınlaştır ve oyunu da biraz kolaylaştır
User prompt
boruları kuşun geçebileceği şekilde hizalar mısın
User prompt
boruları yukarıdan aşağıya doğru uzatır mısın, yani flappy bird oyunundaki gibi boruların sonu olmayacak
User prompt
boruları daha düzgün bir şekilde hizalar mısın
Code edit (1 edits merged)
Please save this source code
User prompt
Flappy Wings
Initial prompt
Bana flappy bird oyunu 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.velocityY = 0; self.gravity = 0.8; self.flapPower = -15; self.maxFallSpeed = 12; self.flap = function () { self.velocityY = self.flapPower; LK.getSound('flap').play(); // Rotate bird upward when flapping tween(birdGraphics, { rotation: -0.3 }, { duration: 150 }); }; self.update = function () { // Apply gravity self.velocityY += self.gravity; if (self.velocityY > self.maxFallSpeed) { self.velocityY = self.maxFallSpeed; } // Move bird self.y += self.velocityY; // Rotate bird based on velocity if (self.velocityY > 0) { var targetRotation = Math.min(self.velocityY * 0.08, 1.5); tween(birdGraphics, { rotation: targetRotation }, { duration: 200 }); } }; return self; }); var Pipe = Container.expand(function () { var self = Container.call(this); self.topPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 1 }); self.bottomPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0 }); self.gapSize = 300; self.speed = -4; self.scored = false; self.setup = function (gapY) { // Ensure gap is properly centered and pipes are aligned var halfGap = self.gapSize / 2; self.topPipe.y = gapY - halfGap; self.bottomPipe.y = gapY + halfGap; // Ensure pipes are properly aligned horizontally self.topPipe.x = 0; self.bottomPipe.x = 0; }; 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 ground; var gameStarted = false; var gameOver = false; var pipeSpawnTimer = 0; var pipeSpawnInterval = 90; // frames between pipe spawns // Create score display var scoreTxt = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create tap to start instruction var instructionTxt = new Text2('TAP TO START', { size: 80, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2 - 200; game.addChild(instructionTxt); // Initialize bird bird = game.addChild(new Bird()); bird.x = 2048 / 4; bird.y = 2732 / 2; // Create ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1 })); ground.x = 0; ground.y = 2732; function startGame() { gameStarted = true; if (instructionTxt.parent) { instructionTxt.parent.removeChild(instructionTxt); } bird.flap(); } function spawnPipe() { var pipe = new Pipe(); // Calculate safe boundaries for gap placement var safeTop = 200; // Distance from top var safeBottom = ground.y - 200; // Distance from ground var availableHeight = safeBottom - safeTop; // Create more centered and evenly distributed gaps var gapY = safeTop + availableHeight * 0.3 + Math.random() * (availableHeight * 0.4); // Ensure gap doesn't go too high or too low gapY = Math.max(safeTop + pipe.gapSize / 2, Math.min(safeBottom - pipe.gapSize / 2, gapY)); pipe.setup(gapY); pipe.x = 2048 + 60; // Start slightly closer for better alignment pipes.push(pipe); game.addChild(pipe); } function checkCollisions() { // Check ground collision if (bird.y + 30 >= ground.y) { return true; } // Check ceiling collision if (bird.y - 30 <= 0) { return true; } // Check pipe collisions for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; var birdLeft = bird.x - 40; var birdRight = bird.x + 40; var birdTop = bird.y - 30; var birdBottom = bird.y + 30; var pipeLeft = pipe.x - 60; var pipeRight = pipe.x + 60; // Check if bird is in pipe's x range if (birdRight > pipeLeft && birdLeft < pipeRight) { // Check collision with top pipe (more precise alignment) if (birdTop <= pipe.topPipe.y) { return true; } // Check collision with bottom pipe (more precise alignment) if (birdBottom >= 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 + 60) { pipe.scored = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); LK.getSound('score').play(); // Increase difficulty slightly if (LK.getScore() % 5 === 0 && pipeSpawnInterval > 60) { pipeSpawnInterval -= 2; } break; } } } 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 (gameOver) { return; } if (!gameStarted) { startGame(); } else { bird.flap(); } }; game.update = function () { if (gameOver) { return; } if (gameStarted) { // Check for collisions if (checkCollisions()) { gameOver = true; LK.showGameOver(); return; } // Spawn pipes pipeSpawnTimer++; if (pipeSpawnTimer >= pipeSpawnInterval) { spawnPipe(); pipeSpawnTimer = 0; } // Update score updateScore(); // Cleanup off-screen pipes cleanupPipes(); } else { // Gentle floating animation when waiting to start bird.y += Math.sin(LK.ticks * 0.1) * 0.5; } };
===================================================================
--- original.js
+++ change.js
@@ -59,10 +59,15 @@
self.gapSize = 300;
self.speed = -4;
self.scored = false;
self.setup = function (gapY) {
- self.topPipe.y = gapY - self.gapSize / 2;
- self.bottomPipe.y = gapY + self.gapSize / 2;
+ // Ensure gap is properly centered and pipes are aligned
+ var halfGap = self.gapSize / 2;
+ self.topPipe.y = gapY - halfGap;
+ self.bottomPipe.y = gapY + halfGap;
+ // Ensure pipes are properly aligned horizontally
+ self.topPipe.x = 0;
+ self.bottomPipe.x = 0;
};
self.update = function () {
self.x += self.speed;
};
@@ -121,13 +126,18 @@
bird.flap();
}
function spawnPipe() {
var pipe = new Pipe();
- var minY = 400;
- var maxY = 2732 - 400;
- var gapY = minY + Math.random() * (maxY - minY);
+ // Calculate safe boundaries for gap placement
+ var safeTop = 200; // Distance from top
+ var safeBottom = ground.y - 200; // Distance from ground
+ var availableHeight = safeBottom - safeTop;
+ // Create more centered and evenly distributed gaps
+ var gapY = safeTop + availableHeight * 0.3 + Math.random() * (availableHeight * 0.4);
+ // Ensure gap doesn't go too high or too low
+ gapY = Math.max(safeTop + pipe.gapSize / 2, Math.min(safeBottom - pipe.gapSize / 2, gapY));
pipe.setup(gapY);
- pipe.x = 2048 + 100;
+ pipe.x = 2048 + 60; // Start slightly closer for better alignment
pipes.push(pipe);
game.addChild(pipe);
}
function checkCollisions() {
@@ -149,14 +159,14 @@
var pipeLeft = pipe.x - 60;
var pipeRight = pipe.x + 60;
// Check if bird is in pipe's x range
if (birdRight > pipeLeft && birdLeft < pipeRight) {
- // Check collision with top pipe
- if (birdTop < pipe.topPipe.y) {
+ // Check collision with top pipe (more precise alignment)
+ if (birdTop <= pipe.topPipe.y) {
return true;
}
- // Check collision with bottom pipe
- if (birdBottom > pipe.bottomPipe.y) {
+ // Check collision with bottom pipe (more precise alignment)
+ if (birdBottom >= pipe.bottomPipe.y) {
return true;
}
}
}