User prompt
oyundaki hiç birşey değiştirme ama tüm hataları düzelt
User prompt
en iyi skoru gösteren tabelanın hatalarını düzelt en yüksek yaptığımız skoru her zaman göstersin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyunun açılmasıyla ilgili hataları düzelt
User prompt
kuşun hızıyla ilgili hataları düzelt
User prompt
oyun başladığında ayarlar kısmıyla yüksek skor kısmı gözükmesin
User prompt
en iyi skoru kaydetmesiyle ilgili bir hata var kaydetmiyor
User prompt
hız seçenekleri sırayla normal 1.5x 1.5x ve 2x
User prompt
ayarlara tıklayınca hız diye bir seçenek olsun ona tıklayınca hız ayarlama kısmı çıksın ortaya
User prompt
3x olmak yerine seçenekler normal 1x, 2x, 1.5x gibi
User prompt
ayarlara tıklayınca hız ayarlama logosu çıksın oradan istediğimiz hızı seçelim normal, 2x ve 3x gibi seçenek olsun
User prompt
AYARLAR LOGOSUNUN BOYUTUNU BÜYÜT
User prompt
sağ üst köşeye ayarlar kısmına ekle
User prompt
şu an hiç bir işe yaramayan kodları sil fazladan olanları oyunu bozma
User prompt
Bazı cihazlarda oyunun açılmaması ile ilgili hatalar var. Düzelt.
User prompt
Oyunun Daha İyi Çalışması İçin Daha Önce Kullandığın Fakat Şu An Kullanmadığın Kodları Sil İşine Yaramayan
User prompt
Oyun bittiği yazısını beyaz yap
User prompt
Oyunu bozmadan hata veren her şeyi düzelt.
User prompt
Yanlış anladın oyuncu tekrar denetüşüne basarsa oyun direk başlamıyor tıkla ve oyna menüsü var ya oraya yönlendiriliyor
User prompt
oyuncu eğer tekrar da net ucuna basarsa direkt tıkla ve oyuna kısmına yönlendirmeliyiz
User prompt
Oynayan Kişi Yenildiğinde Tekrar Oynayın Tuşu Tekrar Deneyin Tuşu Gibi Birşey Olsun
User prompt
Duvarın üstüne koyduğun daha güzel dursun diye koyduğun şeyleri daha güzel görsellerle değiştir.
User prompt
Duvarda oluşan hataları düzelt ama bozma.
User prompt
Duvarların görünümünü iyileştir. Daha iyi olsun.
User prompt
Duvar ile kuşun hatasını düzelt.
User prompt
butonlara çok hızlı tıklayınca oyundan atıyor
/**** * 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.jumpStrength = -12; self.flap = function () { self.velocity = self.jumpStrength; try { LK.getSound('flap').play(); } catch (e) { console.log("Flap sound error:", e); } }; self.update = function () { if (!gameStarted) { // Don't apply physics before game starts - keep bird completely still self.velocity = 0; self.y = 1366; // Keep bird at starting position birdGraphics.rotation = 0; // Keep bird level return; } self.velocity += self.gravity; self.y += self.velocity; // Rotate bird based on velocity birdGraphics.rotation = Math.max(-0.5, Math.min(1.5, self.velocity * 0.1)); // Limit bird movement to screen bounds with proper collision detection var birdRadius = 40; // Half of bird height for collision detection if (self.y - birdRadius < 0) { self.y = birdRadius; self.velocity = 0; } if (self.y + birdRadius > 2732 - 150) { self.y = 2732 - 150 - birdRadius; self.velocity = 0; } }; return self; }); var Pipe = Container.expand(function (gapCenterY) { var self = Container.call(this); self.gapSize = 600; self.speed = -3; self.passed = false; self.gapCenterY = gapCenterY; // Store pipe width for consistent collision detection self.pipeWidth = 120; // Create top pipe body var topPipe = self.attachAsset('topPipe', { anchorX: 0.5, anchorY: 1 }); topPipe.y = gapCenterY - self.gapSize / 2; // Set reasonable height for top pipe (minimum 200px, maximum based on gap position) var topPipeHeight = Math.max(200, gapCenterY - self.gapSize / 2); topPipe.height = topPipeHeight; topPipe.width = self.pipeWidth; // Create enhanced top pipe highlight with metallic shine var topPipeHighlight = self.attachAsset('pipeHighlight', { anchorX: 0.5, anchorY: 1 }); topPipeHighlight.y = gapCenterY - self.gapSize / 2; topPipeHighlight.height = topPipeHeight; topPipeHighlight.width = 35; topPipeHighlight.x = -30; topPipeHighlight.tint = 0xE6E6FA; // Lavender metallic shine // Add secondary highlight for depth var topPipeShine = self.attachAsset('pipeHighlight', { anchorX: 0.5, anchorY: 1 }); topPipeShine.y = gapCenterY - self.gapSize / 2; topPipeShine.height = topPipeHeight; topPipeShine.width = 15; topPipeShine.x = -35; topPipeShine.tint = 0xF5F5F5; // Bright metallic shine topPipeShine.alpha = 0.8; // Create decorative top pipe cap with metallic rim var topPipeCap = self.attachAsset('pipeTop', { anchorX: 0.5, anchorY: 1 }); topPipeCap.y = gapCenterY - self.gapSize / 2; topPipeCap.width = self.pipeWidth + 30; // More prominent cap topPipeCap.tint = 0x4169E1; // Royal blue metallic color // Add metallic rim effect on top cap var topCapRim = self.attachAsset('pipeTop', { anchorX: 0.5, anchorY: 1 }); topCapRim.y = gapCenterY - self.gapSize / 2; topCapRim.width = self.pipeWidth + 40; topCapRim.height = 25; topCapRim.tint = 0x708090; // Slate gray metallic rim // Add golden accent stripe var topCapAccent = self.attachAsset('pipeTop', { anchorX: 0.5, anchorY: 1 }); topCapAccent.y = gapCenterY - self.gapSize / 2 + 15; topCapAccent.width = self.pipeWidth + 25; topCapAccent.height = 15; topCapAccent.tint = 0xFFD700; // Gold accent // Create bottom pipe body var bottomPipe = self.attachAsset('bottomPipe', { anchorX: 0.5, anchorY: 0 }); bottomPipe.y = gapCenterY + self.gapSize / 2; // Set reasonable height for bottom pipe (minimum 200px, maximum based on available space) var bottomPipeHeight = Math.max(200, 2732 - 150 - (gapCenterY + self.gapSize / 2)); bottomPipe.height = bottomPipeHeight; bottomPipe.width = self.pipeWidth; // Create enhanced bottom pipe highlight with metallic shine var bottomPipeHighlight = self.attachAsset('pipeHighlight', { anchorX: 0.5, anchorY: 0 }); bottomPipeHighlight.y = gapCenterY + self.gapSize / 2; bottomPipeHighlight.height = bottomPipeHeight; bottomPipeHighlight.width = 35; bottomPipeHighlight.x = -30; bottomPipeHighlight.tint = 0xE6E6FA; // Lavender metallic shine // Add secondary highlight for depth var bottomPipeShine = self.attachAsset('pipeHighlight', { anchorX: 0.5, anchorY: 0 }); bottomPipeShine.y = gapCenterY + self.gapSize / 2; bottomPipeShine.height = bottomPipeHeight; bottomPipeShine.width = 15; bottomPipeShine.x = -35; bottomPipeShine.tint = 0xF5F5F5; // Bright metallic shine bottomPipeShine.alpha = 0.8; // Create decorative bottom pipe cap with metallic rim var bottomPipeCap = self.attachAsset('pipeBottom', { anchorX: 0.5, anchorY: 0 }); bottomPipeCap.y = gapCenterY + self.gapSize / 2; bottomPipeCap.width = self.pipeWidth + 30; // More prominent cap bottomPipeCap.tint = 0x4169E1; // Royal blue metallic color // Add metallic rim effect on bottom cap var bottomCapRim = self.attachAsset('pipeBottom', { anchorX: 0.5, anchorY: 0 }); bottomCapRim.y = gapCenterY + self.gapSize / 2; bottomCapRim.width = self.pipeWidth + 40; bottomCapRim.height = 25; bottomCapRim.tint = 0x708090; // Slate gray metallic rim // Add golden accent stripe var bottomCapAccent = self.attachAsset('pipeBottom', { anchorX: 0.5, anchorY: 0 }); bottomCapAccent.y = gapCenterY + self.gapSize / 2 - 15; bottomCapAccent.width = self.pipeWidth + 25; bottomCapAccent.height = 15; bottomCapAccent.tint = 0xFFD700; // Gold accent self.update = function () { if (!gameStarted) { // Don't move pipes before game starts return; } self.x += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game(); /**** * Game Code ****/ // Game variables try {} catch (e) { console.log("Asset initialization error:", e); } var tween; var storage; try { tween = LK.import("@upit/tween.v1"); storage = LK.import("@upit/storage.v1"); } catch (e) { console.log("Plugin import error:", e); // Provide fallback objects to prevent undefined errors tween = function tween() { return { duration: 0, onFinish: function onFinish() {} }; }; storage = {}; } var bird; var pipes = []; var ground; var topBarrier; var bottomBarrier; var gameStarted = false; var gameOver = false; var showMainMenu = true; var showLeaderboard = false; var showGameOver = false; var pipeSpacing = 500; // Increased spacing between pipes to make them further apart var buttonClickTimeout = null; // Prevent rapid button clicks var lastButtonClickTime = 0; // Track last button click time // Initialize storage with defaults var _storage = storage; // Create score text display var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); scoreTxt.stroke = 0x000000; scoreTxt.strokeThickness = 5; try { if (LK.gui && LK.gui.top) { LK.gui.top.addChild(scoreTxt); } } catch (e) { console.log("GUI score text error:", e); } // Create cup shape for score var cupShape; try { cupShape = LK.getAsset('cup', { anchorX: 0.5, anchorY: 0 }); cupShape.tint = 0xFFD700; if (LK.gui && LK.gui.bottomRight) { LK.gui.bottomRight.addChild(cupShape); cupShape.y = -230; cupShape.x = -100; } } catch (e) { console.log("Cup shape error:", e); } // Create main menu elements var mainMenuTitle = new Text2('FLAPPY BIRD', { size: 100, fill: 0xFFD700 }); mainMenuTitle.anchor.set(0.5, 0.5); mainMenuTitle.stroke = 0x000000; mainMenuTitle.strokeThickness = 5; try { if (LK.gui && LK.gui.center) { LK.gui.center.addChild(mainMenuTitle); mainMenuTitle.y = -200; } } catch (e) { console.log("Main menu title error:", e); } // Create play button with oval shape var playButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 100, alpha: 0.9 }); playButton.tint = 0xFF4500; LK.gui.center.addChild(playButton); playButton.y = 50; var playButtonText = new Text2('OYNA', { size: 50, fill: 0xFFFFFF }); playButtonText.anchor.set(0.5, 0.5); playButtonText.stroke = 0x000000; playButtonText.strokeThickness = 3; LK.gui.center.addChild(playButtonText); playButtonText.y = 50; // Create instruction text var instructionTxt = new Text2('TIKLA VE OYNA!', { size: 60, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.stroke = 0x000000; instructionTxt.strokeThickness = 3; instructionTxt.visible = false; // Add background shape for instruction text var instructionBg = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 100, alpha: 0.8 }); instructionBg.tint = 0x8B0000; instructionBg.visible = false; LK.gui.center.addChild(instructionBg); LK.gui.center.addChild(instructionTxt); // Create game over screen elements var gameOverBg = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 1600, height: 1200, alpha: 0.95 }); gameOverBg.tint = 0x2F4F4F; gameOverBg.visible = false; LK.gui.center.addChild(gameOverBg); var gameOverTitle = new Text2('OYUN BİTTİ', { size: 120, fill: 0xFFFFFF }); gameOverTitle.anchor.set(0.5, 0.5); gameOverTitle.stroke = 0x000000; gameOverTitle.strokeThickness = 6; gameOverTitle.visible = false; LK.gui.center.addChild(gameOverTitle); gameOverTitle.y = -300; var finalScoreText = new Text2('SKOR: 0', { size: 80, fill: 0xFFFFFF }); finalScoreText.anchor.set(0.5, 0.5); finalScoreText.stroke = 0x000000; finalScoreText.strokeThickness = 4; finalScoreText.visible = false; LK.gui.center.addChild(finalScoreText); finalScoreText.y = -150; var bestScoreText = new Text2('EN İYİ: 0', { size: 60, fill: 0xFFD700 }); bestScoreText.anchor.set(0.5, 0.5); bestScoreText.stroke = 0x000000; bestScoreText.strokeThickness = 3; bestScoreText.visible = false; LK.gui.center.addChild(bestScoreText); bestScoreText.y = -50; // Create retry button var retryButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 120, alpha: 0.9 }); retryButton.tint = 0x32CD32; retryButton.visible = false; LK.gui.center.addChild(retryButton); retryButton.y = 100; var retryButtonText = new Text2('TEKRAR DENE', { size: 50, fill: 0xFFFFFF }); retryButtonText.anchor.set(0.5, 0.5); retryButtonText.stroke = 0x000000; retryButtonText.strokeThickness = 3; retryButtonText.visible = false; LK.gui.center.addChild(retryButtonText); retryButtonText.y = 100; // Create menu button var menuButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 120, alpha: 0.9 }); menuButton.tint = 0xFF4500; menuButton.visible = false; LK.gui.center.addChild(menuButton); menuButton.y = 250; var menuButtonText = new Text2('ANA MENÜ', { size: 50, fill: 0xFFFFFF }); menuButtonText.anchor.set(0.5, 0.5); menuButtonText.stroke = 0x000000; menuButtonText.strokeThickness = 3; menuButtonText.visible = false; LK.gui.center.addChild(menuButtonText); menuButtonText.y = 250; // Create leaderboard background var leaderboardBg = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 1800, height: 2200, alpha: 0.95 }); leaderboardBg.tint = 0x2F4F4F; leaderboardBg.visible = false; LK.gui.center.addChild(leaderboardBg); // Create leaderboard elements var leaderboardTitle = new Text2('SKOR TABLOSU', { size: 80, fill: 0xFFD700 }); leaderboardTitle.anchor.set(0.5, 0.5); leaderboardTitle.stroke = 0x000000; leaderboardTitle.strokeThickness = 4; leaderboardTitle.visible = false; LK.gui.center.addChild(leaderboardTitle); leaderboardTitle.y = -350; var highScoreText = new Text2('EN YÜKSEK SKOR: 0', { size: 50, fill: 0xFFFFFF }); highScoreText.anchor.set(0.5, 0.5); highScoreText.stroke = 0x000000; highScoreText.strokeThickness = 3; highScoreText.visible = false; LK.gui.center.addChild(highScoreText); highScoreText.y = -250; var currentScoreText = new Text2('SON SKOR: 0', { size: 50, fill: 0xFFFFFF }); currentScoreText.anchor.set(0.5, 0.5); currentScoreText.stroke = 0x000000; currentScoreText.strokeThickness = 3; currentScoreText.visible = false; LK.gui.center.addChild(currentScoreText); currentScoreText.y = -180; // Create back button for leaderboard var backButton = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80, alpha: 0.9 }); backButton.tint = 0xDC143C; backButton.visible = false; LK.gui.center.addChild(backButton); backButton.y = 350; var backButtonText = new Text2('GERİ', { size: 50, fill: 0xFFFFFF }); backButtonText.anchor.set(0.5, 0.5); backButtonText.stroke = 0x000000; backButtonText.strokeThickness = 3; backButtonText.visible = false; LK.gui.center.addChild(backButtonText); backButtonText.y = 350; // Create invisible barrier blocks to constrain bird before game starts var topBarrier = game.addChild(LK.getAsset('barrier', { anchorX: 0.5, anchorY: 1 })); topBarrier.x = 400; topBarrier.y = 1316; // 50 pixels above bird topBarrier.alpha = 0; // Make invisible var bottomBarrier = game.addChild(LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0 })); bottomBarrier.x = 400; bottomBarrier.y = 1416; // 50 pixels below bird bottomBarrier.alpha = 0; // Make invisible // Create and add background image (appears behind barriers but in front of other elements) var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0 })); background.x = 0; background.y = 0; // Scale background to fill screen for better performance background.scaleX = 2; background.scaleY = 2; // Create ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1 })); ground.x = 0; ground.y = 2732; ground.tint = 0x654321; // Create bird bird = game.addChild(new Bird()); bird.x = 400; bird.y = 1366; // Create pipe function function createPipe() { // Define safe boundaries for gap center to ensure both pipes have reasonable heights var minGapY = 800; // Minimum gap center position (ensures top pipe has decent height) var maxGapY = 1800; // Maximum gap center position (ensures bottom pipe has decent height) var gapCenterY = minGapY + Math.random() * (maxGapY - minGapY); var pipe = new Pipe(gapCenterY); // Calculate position based on last pipe position + consistent spacing if (pipes.length === 0) { pipe.x = 2048 + 100; // First pipe position - brought closer } else { pipe.x = pipes[pipes.length - 1].x + pipeSpacing; // Consistent spacing from last pipe } ; pipes.push(pipe); game.addChild(pipe); } // Reset game function function resetGame() { // Reset bird bird.x = 400; bird.y = 1366; bird.velocity = 0; // Clear pipes for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].destroy(); } pipes = []; // Reset variables gameStarted = false; gameOver = false; showMainMenu = true; showLeaderboard = false; showGameOver = false; // Hide game over screen hideGameOverScreen(); LK.setScore(0); scoreTxt.setText('0'); // Show main menu mainMenuTitle.visible = true; playButton.visible = true; playButtonText.visible = true; // Hide instruction instructionTxt.visible = false; instructionBg.visible = false; // Hide leaderboard elements leaderboardBg.visible = false; leaderboardTitle.visible = false; highScoreText.visible = false; currentScoreText.visible = false; backButton.visible = false; backButtonText.visible = false; // Clear existing barriers if they exist if (topBarrier) { topBarrier.destroy(); topBarrier = null; } if (bottomBarrier) { bottomBarrier.destroy(); bottomBarrier = null; } // Recreate invisible barriers topBarrier = game.addChild(LK.getAsset('barrier', { anchorX: 0.5, anchorY: 1 })); topBarrier.x = 400; topBarrier.y = 1316; // 50 pixels above bird topBarrier.alpha = 0; // Make invisible bottomBarrier = game.addChild(LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0 })); bottomBarrier.x = 400; bottomBarrier.y = 1416; // 50 pixels below bird bottomBarrier.alpha = 0; // Make invisible // Create initial pipes createPipe(); createPipe(); } // Function to start game from main menu function startGameFromMenu() { showMainMenu = false; // Hide main menu elements mainMenuTitle.visible = false; playButton.visible = false; playButtonText.visible = false; // Show instruction instructionTxt.visible = true; instructionBg.visible = true; } // Function to show game over screen function showGameOverScreen(finalScore) { showGameOver = true; gameStarted = false; showMainMenu = false; showLeaderboard = false; // Hide instruction instructionTxt.visible = false; instructionBg.visible = false; // Show game over elements gameOverBg.visible = true; gameOverTitle.visible = true; finalScoreText.visible = true; bestScoreText.visible = true; retryButton.visible = true; retryButtonText.visible = true; menuButton.visible = true; menuButtonText.visible = true; // Update score displays finalScoreText.setText('SKOR: ' + finalScore); bestScoreText.setText('EN İYİ: ' + (_storage.highScore || 0)); } // Function to hide game over screen function hideGameOverScreen() { showGameOver = false; // Hide game over elements gameOverBg.visible = false; gameOverTitle.visible = false; finalScoreText.visible = false; bestScoreText.visible = false; retryButton.visible = false; retryButtonText.visible = false; menuButton.visible = false; menuButtonText.visible = false; } // Initialize local storage arrays if they don't exist try { if (!_storage) _storage = {}; if (!_storage.globalLeaderboardNames) _storage.globalLeaderboardNames = []; if (!_storage.globalLeaderboardScores) _storage.globalLeaderboardScores = []; if (!_storage.highScore) _storage.highScore = 0; if (!_storage.lastScore) _storage.lastScore = 0; if (!_storage.leaderboardPage) _storage.leaderboardPage = 0; } catch (e) { console.log("Storage initialization error:", e); _storage = { globalLeaderboardNames: [], globalLeaderboardScores: [], highScore: 0, lastScore: 0, leaderboardPage: 0 }; } // Initialize username if not exists if (!_storage.username) { var playerNumber = 1; while (_storage.globalLeaderboardNames.indexOf('Oyuncu ' + playerNumber) !== -1) { playerNumber++; } _storage.username = 'Oyuncu ' + playerNumber; } // Global leaderboard is now initialized in showLeaderboardScreen function // Initialize game createPipe(); createPipe(); // Touch/click handler game.down = function (x, y, obj) { // Check cup click - cup is positioned at bottomRight with offset var cupX = 2048 - 100; // bottomRight.x + cupShape.x offset var cupY = 2732 - 230; // bottomRight.y + cupShape.y offset var cupSize = 120; // Cup asset size if (x >= cupX - cupSize / 2 && x <= cupX + cupSize / 2 && y >= cupY && y <= cupY + cupSize) { // Prevent rapid clicks var currentTime; try { currentTime = Date.now ? Date.now() : new Date().getTime(); } catch (e) { currentTime = 0; } if (currentTime - lastButtonClickTime < 500) { return; // Ignore click if too recent } lastButtonClickTime = currentTime; // Clear any existing high score displays first var existingDisplays = LK.gui.center.children; for (var k = existingDisplays.length - 1; k >= 0; k--) { var child = existingDisplays[k]; if (child && child.getText && child.getText().indexOf('EN YÜKSEK:') !== -1) { try { child.destroy(); } catch (e) { console.log("Error destroying high score display:", e); } } } // Clear any existing backgrounds for (var k = existingDisplays.length - 1; k >= 0; k--) { var child = existingDisplays[k]; if (child && child.tint === 0x000000 && child.width === 700) { try { child.destroy(); } catch (e) { console.log("Error destroying background:", e); } } } // Show highest score in a temporary display using storage var highScore = _storage && _storage.highScore || 0; var highScoreDisplay = new Text2('EN YÜKSEK: ' + highScore, { size: 90, fill: 0xFFFF00 }); highScoreDisplay.anchor.set(0.5, 0.5); highScoreDisplay.stroke = 0x000000; highScoreDisplay.strokeThickness = 4; LK.gui.center.addChild(highScoreDisplay); highScoreDisplay.y = -100; // Add background for better visibility var highScoreBg = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 700, height: 160, alpha: 0.98 }); highScoreBg.tint = 0x000000; LK.gui.center.addChild(highScoreBg); highScoreBg.y = -100; // Move background behind text LK.gui.center.removeChild(highScoreBg); LK.gui.center.addChildAt(highScoreBg, LK.gui.center.getChildIndex(highScoreDisplay)); // Auto-hide after 3 seconds LK.setTimeout(function () { try { if (highScoreDisplay && highScoreDisplay.parent) { highScoreDisplay.destroy(); } if (highScoreBg && highScoreBg.parent) { highScoreBg.destroy(); } } catch (e) { console.log("Error in timeout cleanup:", e); } }, 3000); return; } if (gameOver || showGameOver) { // Check retry button (TEKRAR DENE) - centered at 1024x1466, button is 400x120 if (x >= 824 && x <= 1224 && y >= 1406 && y <= 1526) { // Prevent rapid clicks var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) { return; // Ignore click if too recent } lastButtonClickTime = currentTime; // Add visual feedback with tween tween(retryButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(retryButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); hideGameOverScreen(); resetGame(); // Show instruction screen instead of starting game directly startGameFromMenu(); return; } // Check menu button (ANA MENÜ) - centered at 1024x1616, button is 400x120 if (x >= 824 && x <= 1224 && y >= 1556 && y <= 1676) { // Prevent rapid clicks var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) { return; // Ignore click if too recent } lastButtonClickTime = currentTime; // Add visual feedback with tween tween(menuButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(menuButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); hideGameOverScreen(); resetGame(); return; } return; } if (showMainMenu) { // Check play button (OYNA) - centered at 1024x1366, button is 300x80 if (x >= 874 && x <= 1174 && y >= 1326 && y <= 1406) { // Prevent rapid clicks var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) { return; // Ignore click if too recent } lastButtonClickTime = currentTime; // Clear any existing timeout if (buttonClickTimeout) { LK.clearTimeout(buttonClickTimeout); buttonClickTimeout = null; } // Add visual feedback with tween tween(playButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(playButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); // Add small delay to prevent double clicks buttonClickTimeout = LK.setTimeout(function () { buttonClickTimeout = null; startGameFromMenu(); }, 150); return; } return; } if (!gameStarted) { gameStarted = true; instructionTxt.visible = false; instructionBg.visible = false; // Remove invisible barriers when game starts if (topBarrier) { topBarrier.destroy(); topBarrier = null; } if (bottomBarrier) { bottomBarrier.destroy(); bottomBarrier = null; } } bird.flap(); }; // Main game loop game.update = function () { if (gameOver || showMainMenu || showLeaderboard || showGameOver) return; // Only run game logic if game has started if (gameStarted) { // Check ground and ceiling collision with proper bird size (bird is 80px tall, 120px wide) var birdRadius = 40; // Half of bird height for collision detection if (bird.y + birdRadius >= 2732 - 150 || bird.y - birdRadius <= 0) { gameOver = true; var currentScore = LK.getScore(); _storage.lastScore = currentScore; if (currentScore > (_storage.highScore || 0)) { _storage.highScore = currentScore; } // Add to leaderboard if score > 0 if (currentScore > 0 && _storage) { var currentUsername = _storage.username || 'Oyuncu'; var playerExists = false; var leaderboardNames = _storage.globalLeaderboardNames || []; for (var i = 0; i < leaderboardNames.length; i++) { if (_storage.globalLeaderboardNames[i] === currentUsername) { if (currentScore > _storage.globalLeaderboardScores[i]) { _storage.globalLeaderboardScores[i] = currentScore; } playerExists = true; break; } } if (!playerExists) { _storage.globalLeaderboardNames.push(currentUsername); _storage.globalLeaderboardScores.push(currentScore); } } showGameOverScreen(currentScore); return; } // Check pipe collisions and scoring for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; if (!pipe || !bird || pipe.destroyed) continue; // Check scoring first - only for pipes that haven't been passed yet if (!pipe.passed && pipe.x + 50 < bird.x) { pipe.passed = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore().toString()); try { LK.getSound('score').play(); } catch (e) { console.log("Sound error:", e); } } // Only check collision for pipes that are close to the bird if (Math.abs(pipe.x - bird.x) < 150) { // Check if bird is within pipe horizontally using actual pipe width var pipeHalfWidth = (pipe.pipeWidth || 120) / 2; if (bird.x + 40 > pipe.x - pipeHalfWidth && bird.x - 40 < pipe.x + pipeHalfWidth) { // Check collision with top or bottom pipe - bird is 80px tall, so use 40px radius var birdTop = bird.y - 40; var birdBottom = bird.y + 40; var gapTop = pipe.gapCenterY - pipe.gapSize / 2; var gapBottom = pipe.gapCenterY + pipe.gapSize / 2; // Collision occurs if bird overlaps with pipe (outside the gap) if (birdTop < gapTop || birdBottom > gapBottom) { gameOver = true; var currentScore = LK.getScore(); _storage.lastScore = currentScore; if (currentScore > (_storage.highScore || 0)) { _storage.highScore = currentScore; } // Add to leaderboard if score > 0 if (currentScore > 0) { var currentUsername = _storage.username; var playerExists = false; for (var j = 0; j < _storage.globalLeaderboardNames.length; j++) { if (_storage.globalLeaderboardNames[j] === currentUsername) { if (currentScore > _storage.globalLeaderboardScores[j]) { _storage.globalLeaderboardScores[j] = currentScore; } playerExists = true; break; } } if (!playerExists) { _storage.globalLeaderboardNames.push(currentUsername); _storage.globalLeaderboardScores.push(currentScore); } } showGameOverScreen(currentScore); return; } } } } // Create new pipes - maintain consistent spacing if (pipes.length === 0 || pipes.length > 0 && pipes[pipes.length - 1].x <= 2048 + 100 - pipeSpacing) { createPipe(); } // Remove off-screen pipes periodically using frame counter if (!game.frameCounter) game.frameCounter = 0; game.frameCounter++; if (game.frameCounter % 30 === 0) { for (var j = pipes.length - 1; j >= 0; j--) { if (pipes[j].x < -150) { pipes[j].destroy(); pipes.splice(j, 1); } } } } };
===================================================================
--- original.js
+++ change.js
@@ -1,11 +1,5 @@
/****
-* Plugins
-****/
-var tween = LK.import("@upit/tween.v1");
-var storage = LK.import("@upit/storage.v1");
-
-/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
@@ -189,8 +183,27 @@
/****
* Game Code
****/
// Game variables
+try {} catch (e) {
+ console.log("Asset initialization error:", e);
+}
+var tween;
+var storage;
+try {
+ tween = LK.import("@upit/tween.v1");
+ storage = LK.import("@upit/storage.v1");
+} catch (e) {
+ console.log("Plugin import error:", e);
+ // Provide fallback objects to prevent undefined errors
+ tween = function tween() {
+ return {
+ duration: 0,
+ onFinish: function onFinish() {}
+ };
+ };
+ storage = {};
+}
var bird;
var pipes = [];
var ground;
var topBarrier;
@@ -212,28 +225,47 @@
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.stroke = 0x000000;
scoreTxt.strokeThickness = 5;
-LK.gui.top.addChild(scoreTxt);
+try {
+ if (LK.gui && LK.gui.top) {
+ LK.gui.top.addChild(scoreTxt);
+ }
+} catch (e) {
+ console.log("GUI score text error:", e);
+}
// Create cup shape for score
-var cupShape = LK.getAsset('cup', {
- anchorX: 0.5,
- anchorY: 0
-});
-cupShape.tint = 0xFFD700;
-LK.gui.bottomRight.addChild(cupShape);
-cupShape.y = -230;
-cupShape.x = -100;
+var cupShape;
+try {
+ cupShape = LK.getAsset('cup', {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ cupShape.tint = 0xFFD700;
+ if (LK.gui && LK.gui.bottomRight) {
+ LK.gui.bottomRight.addChild(cupShape);
+ cupShape.y = -230;
+ cupShape.x = -100;
+ }
+} catch (e) {
+ console.log("Cup shape error:", e);
+}
// Create main menu elements
var mainMenuTitle = new Text2('FLAPPY BIRD', {
size: 100,
fill: 0xFFD700
});
mainMenuTitle.anchor.set(0.5, 0.5);
mainMenuTitle.stroke = 0x000000;
mainMenuTitle.strokeThickness = 5;
-LK.gui.center.addChild(mainMenuTitle);
-mainMenuTitle.y = -200;
+try {
+ if (LK.gui && LK.gui.center) {
+ LK.gui.center.addChild(mainMenuTitle);
+ mainMenuTitle.y = -200;
+ }
+} catch (e) {
+ console.log("Main menu title error:", e);
+}
// Create play button with oval shape
var playButton = LK.getAsset('playButtonOval', {
anchorX: 0.5,
anchorY: 0.5,
@@ -586,14 +618,25 @@
menuButton.visible = false;
menuButtonText.visible = false;
}
// Initialize local storage arrays if they don't exist
-if (!_storage) _storage = {};
-if (!_storage.globalLeaderboardNames) _storage.globalLeaderboardNames = [];
-if (!_storage.globalLeaderboardScores) _storage.globalLeaderboardScores = [];
-if (!_storage.highScore) _storage.highScore = 0;
-if (!_storage.lastScore) _storage.lastScore = 0;
-if (!_storage.leaderboardPage) _storage.leaderboardPage = 0;
+try {
+ if (!_storage) _storage = {};
+ if (!_storage.globalLeaderboardNames) _storage.globalLeaderboardNames = [];
+ if (!_storage.globalLeaderboardScores) _storage.globalLeaderboardScores = [];
+ if (!_storage.highScore) _storage.highScore = 0;
+ if (!_storage.lastScore) _storage.lastScore = 0;
+ if (!_storage.leaderboardPage) _storage.leaderboardPage = 0;
+} catch (e) {
+ console.log("Storage initialization error:", e);
+ _storage = {
+ globalLeaderboardNames: [],
+ globalLeaderboardScores: [],
+ highScore: 0,
+ lastScore: 0,
+ leaderboardPage: 0
+ };
+}
// Initialize username if not exists
if (!_storage.username) {
var playerNumber = 1;
while (_storage.globalLeaderboardNames.indexOf('Oyuncu ' + playerNumber) !== -1) {
@@ -612,9 +655,14 @@
var cupY = 2732 - 230; // bottomRight.y + cupShape.y offset
var cupSize = 120; // Cup asset size
if (x >= cupX - cupSize / 2 && x <= cupX + cupSize / 2 && y >= cupY && y <= cupY + cupSize) {
// Prevent rapid clicks
- var currentTime = Date.now();
+ var currentTime;
+ try {
+ currentTime = Date.now ? Date.now() : new Date().getTime();
+ } catch (e) {
+ currentTime = 0;
+ }
if (currentTime - lastButtonClickTime < 500) {
return; // Ignore click if too recent
}
lastButtonClickTime = currentTime;