User prompt
kuşun zıplama hızını biraz artırır mısın çok abartı olmicak şekilde
User prompt
kuş her borudan geçtiğinde point.wav adlı ses bitene kadar çalsın
User prompt
çok zor borulardan geçilmiyor boruyu biraz uzat deliği falan
User prompt
oyuna skor sistemi ekle skorları kaydetsin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
olmamış
User prompt
boru kuşa doğru gelsin
User prompt
kuşun zıplama gücünü artır
Code edit (1 edits merged)
Please save this source code
User prompt
Flappy Bird
Initial prompt
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.velocity = 0;
self.gravity = 0.8;
self.flapPower = -12;
self.maxFallSpeed = 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 () {
// Apply gravity
self.velocity += self.gravity;
// Cap fall speed
if (self.velocity > self.maxFallSpeed) {
self.velocity = self.maxFallSpeed;
}
// Update position
self.y += self.velocity;
// Check boundaries
if (self.y < 0) {
self.y = 0;
self.velocity = 0;
}
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.speed = -4;
self.gapSize = 300;
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 ground;
var gameStarted = false;
var gameSpeed = 4;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 90; // frames between pipe spawns
// Create score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
// Create tap to start text
var startTxt = new Text2('TAP TO START', {
size: 60,
fill: 0xFFFFFF
});
startTxt.anchor.set(0.5, 0.5);
game.addChild(startTxt);
startTxt.x = 2048 / 2;
startTxt.y = 2732 / 2 - 200;
// Create bird
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = 2732 / 2;
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1
}));
ground.x = 0;
ground.y = 2732;
function spawnPipe() {
var pipe = new Pipe();
pipe.x = 2048 + 60; // Start off-screen right
// Random gap position (avoid too high or too low)
var minGapY = 200;
var maxGapY = 2732 - 200 - 150; // Account for ground height
var gapY = minGapY + Math.random() * (maxGapY - minGapY);
pipe.setGapPosition(gapY);
pipes.push(pipe);
game.addChild(pipe);
}
function checkCollisions() {
// Check ground collision
if (bird.y >= ground.y - ground.height / 2 - bird.height / 2) {
return true;
}
// Check ceiling collision
if (bird.y <= bird.height / 2) {
return true;
}
// Check pipe collisions
for (var i = 0; i < pipes.length; i++) {
var pipe = pipes[i];
// Check if bird is horizontally aligned with pipe
if (bird.x + bird.width / 2 > pipe.x - pipe.topPipe.width / 2 && bird.x - bird.width / 2 < pipe.x + pipe.topPipe.width / 2) {
// Check top pipe collision
if (bird.y - bird.height / 2 < pipe.topPipe.y) {
return true;
}
// Check bottom pipe collision
if (bird.y + bird.height / 2 > pipe.bottomPipe.y) {
return true;
}
}
}
return false;
}
function updateScore() {
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());
LK.getSound('score').play();
// Increase difficulty slightly
if (LK.getScore() % 5 === 0 && pipeSpawnInterval > 60) {
pipeSpawnInterval -= 2;
}
}
}
}
game.down = function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
startTxt.visible = false;
}
if (gameStarted) {
bird.flap();
}
};
game.update = function () {
if (!gameStarted) {
return;
}
// Update bird
bird.update();
// Check collisions
if (checkCollisions()) {
LK.showGameOver();
return;
}
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Update pipes
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
pipe.update();
// Remove pipes that are off-screen
if (pipe.x < -120) {
pipe.destroy();
pipes.splice(i, 1);
}
}
// Update score
updateScore();
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,211 @@
-/****
+/****
+* 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.maxFallSpeed = 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 () {
+ // Apply gravity
+ self.velocity += self.gravity;
+ // Cap fall speed
+ if (self.velocity > self.maxFallSpeed) {
+ self.velocity = self.maxFallSpeed;
+ }
+ // Update position
+ self.y += self.velocity;
+ // Check boundaries
+ if (self.y < 0) {
+ self.y = 0;
+ self.velocity = 0;
+ }
+ };
+ return self;
+});
+var Pipe = Container.expand(function () {
+ var self = Container.call(this);
+ self.speed = -4;
+ self.gapSize = 300;
+ 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 ground;
+var gameStarted = false;
+var gameSpeed = 4;
+var pipeSpawnTimer = 0;
+var pipeSpawnInterval = 90; // frames between pipe spawns
+// Create score display
+var scoreTxt = new Text2('0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+scoreTxt.y = 100;
+// Create tap to start text
+var startTxt = new Text2('TAP TO START', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+startTxt.anchor.set(0.5, 0.5);
+game.addChild(startTxt);
+startTxt.x = 2048 / 2;
+startTxt.y = 2732 / 2 - 200;
+// Create bird
+bird = game.addChild(new Bird());
+bird.x = 300;
+bird.y = 2732 / 2;
+// Create ground
+ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 1
+}));
+ground.x = 0;
+ground.y = 2732;
+function spawnPipe() {
+ var pipe = new Pipe();
+ pipe.x = 2048 + 60; // Start off-screen right
+ // Random gap position (avoid too high or too low)
+ var minGapY = 200;
+ var maxGapY = 2732 - 200 - 150; // Account for ground height
+ var gapY = minGapY + Math.random() * (maxGapY - minGapY);
+ pipe.setGapPosition(gapY);
+ pipes.push(pipe);
+ game.addChild(pipe);
+}
+function checkCollisions() {
+ // Check ground collision
+ if (bird.y >= ground.y - ground.height / 2 - bird.height / 2) {
+ return true;
+ }
+ // Check ceiling collision
+ if (bird.y <= bird.height / 2) {
+ return true;
+ }
+ // Check pipe collisions
+ for (var i = 0; i < pipes.length; i++) {
+ var pipe = pipes[i];
+ // Check if bird is horizontally aligned with pipe
+ if (bird.x + bird.width / 2 > pipe.x - pipe.topPipe.width / 2 && bird.x - bird.width / 2 < pipe.x + pipe.topPipe.width / 2) {
+ // Check top pipe collision
+ if (bird.y - bird.height / 2 < pipe.topPipe.y) {
+ return true;
+ }
+ // Check bottom pipe collision
+ if (bird.y + bird.height / 2 > pipe.bottomPipe.y) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+function updateScore() {
+ 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());
+ LK.getSound('score').play();
+ // Increase difficulty slightly
+ if (LK.getScore() % 5 === 0 && pipeSpawnInterval > 60) {
+ pipeSpawnInterval -= 2;
+ }
+ }
+ }
+}
+game.down = function (x, y, obj) {
+ if (!gameStarted) {
+ gameStarted = true;
+ startTxt.visible = false;
+ }
+ if (gameStarted) {
+ bird.flap();
+ }
+};
+game.update = function () {
+ if (!gameStarted) {
+ return;
+ }
+ // Update bird
+ bird.update();
+ // Check collisions
+ if (checkCollisions()) {
+ LK.showGameOver();
+ return;
+ }
+ // Spawn pipes
+ pipeSpawnTimer++;
+ if (pipeSpawnTimer >= pipeSpawnInterval) {
+ spawnPipe();
+ pipeSpawnTimer = 0;
+ }
+ // Update pipes
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ var pipe = pipes[i];
+ pipe.update();
+ // Remove pipes that are off-screen
+ if (pipe.x < -120) {
+ pipe.destroy();
+ pipes.splice(i, 1);
+ }
+ }
+ // Update score
+ updateScore();
+};
\ No newline at end of file