User prompt
arka planı acilen geri sil
User prompt
oyuna arka plan ekle
User prompt
boruların arasından geçtiğimizde boruların arasındaki coin kaybolsun
User prompt
bu coinlerin üstüne gittiğimizde yok olsunlar
User prompt
her bir borunun arasına coin koy
User prompt
kuş daha güzel süzülsün ve yere daha yavaş düşsün
User prompt
boruların arası daha geniş olsun
User prompt
kuşun kontrolünü daha basit yap
Code edit (1 edits merged)
Please save this source code
User prompt
Flappy Pipe Dash
Initial prompt
🎯 GÖREV: FLAPPY BIRD TARZI OYUN YAP (AÇIK VE NET KOMUTLAR) 1. OYUNCU KARAKTERİ Ekranın sol tarafına yakın bir karakter (top/kuş/şekil) yerleştir. Her tıklamada karakter bir miktar yukarı zıplasın. Zıplamazsa oyun olmaz. Zıplar, sonra yerçekimiyle düşer. 2. ENGELLER (BORULAR) Her biri üstte ve altta olacak şekilde, arada boşluk bulunan iki dikdörtgen boru yap. Bu borular ekranın sağından çıkar, sola doğru sabit hızla hareket eder. Aradaki boşluktan karakter geçmeye çalışır. Karakter boruya çarparsa anında ölür. Borular görünür olacak. Şeffaf, görünmez, içinden geçilen hiçbir şey istemiyorum. Her boru çifti (üst+alt) farklı yüksekliklerde olsun (rastgele belirlenebilir). 3. ZEMİN Ekranın en altında, karakterin üstüne düşebileceği bir zemin olacak. Zemin yeşil çizgi değil, çarpışma özelliği olan sabit bir engel olmalı. Karakter bu zemine değdiği anda da ölmeli. 4. PUAN SİSTEMİ Her geçilen boru çifti için skor +1 artsın. Skor ekranın üst kısmında yazsın. Borunun içinden geçince puan artmalı. Boruya çarpınca artmamalı. 5. GAME OVER Karakter ölürse (boruya ya da zemine çarparsa), ekrana şu yazılar gelsin: “Game Over” Skor “Yeniden Başla” butonu 6. GÖRSELLER Arka plan açık mavi. Borular yeşil. Karakter başka bir renk (örneğin kırmızı). Renkler birbirinden net şekilde ayırt edilebilir olsun. Görünmeyen veya şeffaf hiçbir nesne istemiyorum. ❌ BU HATALARI BİR DAHA YAPMA: Görünmeyen boru koyma. Karakter engelin içinden geçebiliyorsa bu hata demektir. Puan sistemi yoksa oyun eksiktir. Zıplama düzgün çalışmıyorsa oyun olmaz.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // PipePair class var PipePair = Container.expand(function () { var self = Container.call(this); // Top pipe var topPipe = self.attachAsset('pipe', { anchorX: 0, anchorY: 1 }); // Bottom pipe var bottomPipe = self.attachAsset('pipe', { anchorX: 0, anchorY: 0 }); self.topPipe = topPipe; self.bottomPipe = bottomPipe; // Set pipes' positions based on gapY self.setGap = function (gapY) { // gapY is the vertical center of the gap var gapTop = gapY - gapHeight / 2; var gapBottom = gapY + gapHeight / 2; topPipe.x = 0; topPipe.y = gapTop; topPipe.height = gapTop; bottomPipe.x = 0; bottomPipe.y = gapBottom; bottomPipe.height = 2732 - gapBottom - groundHeight; }; // For collision detection self.getTopBounds = function () { return { x: self.x, y: 0, width: topPipe.width, height: topPipe.y }; }; self.getBottomBounds = function () { return { x: self.x, y: bottomPipe.y, width: bottomPipe.width, height: bottomPipe.height }; }; // Used to check if player has passed this pipe self.passed = false; return self; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerSprite = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.radius = playerSprite.width / 2; self.vy = 0; // vertical velocity // For collision detection self.getBounds = function () { return { x: self.x - self.radius, y: self.y - self.radius, width: self.radius * 2, height: self.radius * 2 }; }; // Update position and apply gravity self.update = function () { self.vy += gravity; self.y += self.vy; // Clamp to top of screen if (self.y - self.radius < 0) { self.y = self.radius; self.vy = 0; } }; // Jump self.flap = function () { self.vy = jumpVelocity; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb // Sky blue }); /**** * Game Code ****/ // Ground // Pipe (green) // Character (bird/ball) // Constants var gravity = 2.2; var jumpVelocity = -38; var pipeSpeed = 16; var pipeInterval = 90; // frames between pipes var gapHeight = 520; var groundHeight = 120; var pipeWidth = 220; // Game state var player; var pipes = []; var ground; var score = 0; var scoreTxt; var lastPipeTick = 0; var gameStarted = false; var gameOver = false; // Create ground ground = LK.getAsset('ground', { anchorX: 0, anchorY: 0, x: 0, y: 2732 - groundHeight }); game.addChild(ground); // Create player player = new Player(); player.x = 420; player.y = 2732 / 2; game.addChild(player); // Score text scoreTxt = new Text2('0', { size: 180, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Reset function function resetGame() { // Remove pipes for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].destroy(); pipes.splice(i, 1); } // Reset player player.x = 420; player.y = 2732 / 2; player.vy = 0; // Reset score score = 0; scoreTxt.setText(score); lastPipeTick = LK.ticks; gameStarted = false; gameOver = false; } // Start game on first tap game.down = function (x, y, obj) { if (gameOver) return; if (!gameStarted) { gameStarted = true; player.flap(); } else { player.flap(); } }; // Main update loop game.update = function () { if (gameOver) return; if (gameStarted) { player.update(); // Move pipes and check for collisions for (var i = pipes.length - 1; i >= 0; i--) { var pipePair = pipes[i]; pipePair.x -= pipeSpeed; // Remove pipes that have gone off screen if (pipePair.x + pipeWidth < 0) { pipePair.destroy(); pipes.splice(i, 1); continue; } // Check for collision with player var pBounds = player.getBounds(); var tBounds = pipePair.getTopBounds(); var bBounds = pipePair.getBottomBounds(); if (rectsIntersect(pBounds, tBounds) || rectsIntersect(pBounds, bBounds)) { endGame(); return; } // Check if player passed the pipe for scoring if (!pipePair.passed && pipePair.x + pipeWidth < player.x - player.radius) { pipePair.passed = true; score += 1; scoreTxt.setText(score); } } // Add new pipes if (LK.ticks - lastPipeTick >= pipeInterval) { var gapY = getRandomGapY(); var pipePair = new PipePair(); pipePair.x = 2048; pipePair.setGap(gapY); pipes.push(pipePair); game.addChild(pipePair); lastPipeTick = LK.ticks; } // Check collision with ground if (player.y + player.radius >= 2732 - groundHeight) { player.y = 2732 - groundHeight - player.radius; endGame(); return; } } }; // End game function endGame() { gameOver = true; LK.effects.flashScreen(0xff0000, 600); LK.showGameOver(); } // Utility: Rectangle intersection function rectsIntersect(a, b) { return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y; } // Utility: Random gap Y position (avoid too close to top/bottom) function getRandomGapY() { var minY = gapHeight / 2 + 120; var maxY = 2732 - groundHeight - gapHeight / 2 - 120; return minY + Math.floor(Math.random() * (maxY - minY)); } // Reset game on game over LK.on('gameover', function () { resetGame(); }); // Initial reset resetGame();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,239 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// PipePair class
+var PipePair = Container.expand(function () {
+ var self = Container.call(this);
+ // Top pipe
+ var topPipe = self.attachAsset('pipe', {
+ anchorX: 0,
+ anchorY: 1
+ });
+ // Bottom pipe
+ var bottomPipe = self.attachAsset('pipe', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ self.topPipe = topPipe;
+ self.bottomPipe = bottomPipe;
+ // Set pipes' positions based on gapY
+ self.setGap = function (gapY) {
+ // gapY is the vertical center of the gap
+ var gapTop = gapY - gapHeight / 2;
+ var gapBottom = gapY + gapHeight / 2;
+ topPipe.x = 0;
+ topPipe.y = gapTop;
+ topPipe.height = gapTop;
+ bottomPipe.x = 0;
+ bottomPipe.y = gapBottom;
+ bottomPipe.height = 2732 - gapBottom - groundHeight;
+ };
+ // For collision detection
+ self.getTopBounds = function () {
+ return {
+ x: self.x,
+ y: 0,
+ width: topPipe.width,
+ height: topPipe.y
+ };
+ };
+ self.getBottomBounds = function () {
+ return {
+ x: self.x,
+ y: bottomPipe.y,
+ width: bottomPipe.width,
+ height: bottomPipe.height
+ };
+ };
+ // Used to check if player has passed this pipe
+ self.passed = false;
+ return self;
+});
+// Player class
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerSprite = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.radius = playerSprite.width / 2;
+ self.vy = 0; // vertical velocity
+ // For collision detection
+ self.getBounds = function () {
+ return {
+ x: self.x - self.radius,
+ y: self.y - self.radius,
+ width: self.radius * 2,
+ height: self.radius * 2
+ };
+ };
+ // Update position and apply gravity
+ self.update = function () {
+ self.vy += gravity;
+ self.y += self.vy;
+ // Clamp to top of screen
+ if (self.y - self.radius < 0) {
+ self.y = self.radius;
+ self.vy = 0;
+ }
+ };
+ // Jump
+ self.flap = function () {
+ self.vy = jumpVelocity;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb // Sky blue
+});
+
+/****
+* Game Code
+****/
+// Ground
+// Pipe (green)
+// Character (bird/ball)
+// Constants
+var gravity = 2.2;
+var jumpVelocity = -38;
+var pipeSpeed = 16;
+var pipeInterval = 90; // frames between pipes
+var gapHeight = 520;
+var groundHeight = 120;
+var pipeWidth = 220;
+// Game state
+var player;
+var pipes = [];
+var ground;
+var score = 0;
+var scoreTxt;
+var lastPipeTick = 0;
+var gameStarted = false;
+var gameOver = false;
+// Create ground
+ground = LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 2732 - groundHeight
+});
+game.addChild(ground);
+// Create player
+player = new Player();
+player.x = 420;
+player.y = 2732 / 2;
+game.addChild(player);
+// Score text
+scoreTxt = new Text2('0', {
+ size: 180,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Reset function
+function resetGame() {
+ // Remove pipes
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ pipes[i].destroy();
+ pipes.splice(i, 1);
+ }
+ // Reset player
+ player.x = 420;
+ player.y = 2732 / 2;
+ player.vy = 0;
+ // Reset score
+ score = 0;
+ scoreTxt.setText(score);
+ lastPipeTick = LK.ticks;
+ gameStarted = false;
+ gameOver = false;
+}
+// Start game on first tap
+game.down = function (x, y, obj) {
+ if (gameOver) return;
+ if (!gameStarted) {
+ gameStarted = true;
+ player.flap();
+ } else {
+ player.flap();
+ }
+};
+// Main update loop
+game.update = function () {
+ if (gameOver) return;
+ if (gameStarted) {
+ player.update();
+ // Move pipes and check for collisions
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ var pipePair = pipes[i];
+ pipePair.x -= pipeSpeed;
+ // Remove pipes that have gone off screen
+ if (pipePair.x + pipeWidth < 0) {
+ pipePair.destroy();
+ pipes.splice(i, 1);
+ continue;
+ }
+ // Check for collision with player
+ var pBounds = player.getBounds();
+ var tBounds = pipePair.getTopBounds();
+ var bBounds = pipePair.getBottomBounds();
+ if (rectsIntersect(pBounds, tBounds) || rectsIntersect(pBounds, bBounds)) {
+ endGame();
+ return;
+ }
+ // Check if player passed the pipe for scoring
+ if (!pipePair.passed && pipePair.x + pipeWidth < player.x - player.radius) {
+ pipePair.passed = true;
+ score += 1;
+ scoreTxt.setText(score);
+ }
+ }
+ // Add new pipes
+ if (LK.ticks - lastPipeTick >= pipeInterval) {
+ var gapY = getRandomGapY();
+ var pipePair = new PipePair();
+ pipePair.x = 2048;
+ pipePair.setGap(gapY);
+ pipes.push(pipePair);
+ game.addChild(pipePair);
+ lastPipeTick = LK.ticks;
+ }
+ // Check collision with ground
+ if (player.y + player.radius >= 2732 - groundHeight) {
+ player.y = 2732 - groundHeight - player.radius;
+ endGame();
+ return;
+ }
+ }
+};
+// End game
+function endGame() {
+ gameOver = true;
+ LK.effects.flashScreen(0xff0000, 600);
+ LK.showGameOver();
+}
+// Utility: Rectangle intersection
+function rectsIntersect(a, b) {
+ return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y;
+}
+// Utility: Random gap Y position (avoid too close to top/bottom)
+function getRandomGapY() {
+ var minY = gapHeight / 2 + 120;
+ var maxY = 2732 - groundHeight - gapHeight / 2 - 120;
+ return minY + Math.floor(Math.random() * (maxY - minY));
+}
+// Reset game on game over
+LK.on('gameover', function () {
+ resetGame();
+});
+// Initial reset
+resetGame();
\ No newline at end of file