User prompt
üstteki bariyerin yani duvarın çizgileri arasından geçtiğimiz yerde duruyor düzelt
User prompt
Duvarların arasında oluşan bu şeyleri kaldır olmaması gerekiyor.
User prompt
arasından geçtiğimiz duvarların kalitesi için baya bir uğraş ekstradan bloklar ve üzerinde uğraş ve daha düzgün daha gerçekçi hale getir oyundaki gibi olsun
User prompt
ayarlar kısmında menüler arası bariyer koy birbirlerini algılamasınlar birbirlerini hata vermesinler diye
User prompt
ayarlar kısmında dil seçeneği ve hız seçenekleri evet görünüm olarak birbirlerinde gözükmeseler bile tıklanırken birbirlerini algılıyorlar yani bir menüde diğeri algılanıyor böyle hataları düzelt
User prompt
oyun bitti tekrar dene ana menü gibi seçenekler ingilizce menü olsa bile türkçe kalıyor böyle hataları düzelt
User prompt
Diller Arası Karışım Oldu Türkçe Ve İngilizce Birbirine Girdi İngilizce Seçtiğimizde Tamamen İngilizce Menü Türkçe Seçtiğimizde Tamamen Türkçe Şey Olsun Hiç Birbirine Girmesin
User prompt
En Yüksek Skor Gibi Ve Başka Dillere Çevirdiğimizde Yazıların Tabelalardan Açtığını Görüyoruz. Her Dile Özgü Açmaması İçin Dikkat Et.
User prompt
en yüksek yaptığımız skoru gösteren tabela her zaman en yüksek yaptığımız skoru göstersin oyundan çık gir yapsak bile silinmesin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
düğmeleri daha çok sade hale getir ve düğmeler daha düzgün daha şık dursun
User prompt
Arka planda yaşanan ama bizim görmediğimiz hataları düzeltin.
User prompt
Aslında hız seçenekleri yeşil duvarın arkasında kalmış olabilir. Öne getir ve bu ayarları diğer seçeneklerine göre düzgün hale getir. Diğer seçenekleri bozuyor olabilir.
User prompt
hız ayarları düğmeleri gözükmüyor baştan yap eskilerini sil
User prompt
düğmeleri aslında duvarın arkasına koymuş olabilirsin. gözükmüyor çünkü
User prompt
ayarlar kısmında hız seçenekleri gözükmüyor
User prompt
Ayarlar kısmında düğmeler birbirine girmiş öyle hataları düzelt ve düğmeleri daha düzgün hale getir.
User prompt
ayarlar kısmında geri tuşu kayboldu
User prompt
Hız kısmında ve dil kısmında hatalar oluştu.
User prompt
Ayarlar kısmında dil veya hızı seçince arkası gözükmesin.
User prompt
Kız veya dil seçeneğini seçince arkası gözüktüğü için kötü oluyor.
User prompt
dil ve ayarlar kısmında hız ve dil birbirine girdi ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Dilleri seçince menüler arası şeyler değişmiyor, Türkçe kalıyor. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyunu ilk açtığımızda Türkçe değil İngilizce başlasın. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Ayarlar kısmının arka planın rengini arkası gözükmeyecek şekilde ayarla
User prompt
ayarlar kısmına dil seçeneği ekle ↪💡 Consider importing and using the following plugins: @upit/storage.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; // Don't set gravity and jumpStrength here as gameSpeed may not be initialized yet // They will be set dynamically in update method self.flap = function () { self.velocity = baseJumpStrength * gameSpeed; 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; } // Update dynamic values based on current game speed var gravity = baseGravity * gameSpeed; var jumpStrength = baseJumpStrength * gameSpeed; self.velocity += 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 = basePipeSpeed * gameSpeed; 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; } // Update dynamic speed based on current game speed self.speed = basePipeSpeed * gameSpeed; 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 = { highScore: 0 }; } var bird; var pipes = []; var ground; var topBarrier; var bottomBarrier; var gameStarted = false; var gameOver = false; var showMainMenu = true; 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 var gameSpeed = 1; // Current game speed multiplier (1 = normal, 2 = 2x, 3 = 3x) var baseGravity = 0.8; // Base gravity for bird var baseJumpStrength = -12; // Base jump strength for bird var basePipeSpeed = -3; // Base pipe movement speed // Initialize game speed properly gameSpeed = 1; // 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 settings button for top right corner var settingsButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 120, height: 120, alpha: 0.9 }); settingsButton.tint = 0x4169E1; try { if (LK.gui && LK.gui.topRight) { LK.gui.topRight.addChild(settingsButton); settingsButton.x = -80; settingsButton.y = 80; } } catch (e) { console.log("Settings button error:", e); } // Create settings icon text (gear symbol) var settingsIcon = new Text2('⚙', { size: 60, fill: 0xFFFFFF }); settingsIcon.anchor.set(0.5, 0.5); try { if (LK.gui && LK.gui.topRight) { LK.gui.topRight.addChild(settingsIcon); settingsIcon.x = -80; settingsIcon.y = 80; } } catch (e) { console.log("Settings icon error:", e); } // Create settings menu overlay (initially hidden) var settingsOverlay = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 2048, height: 2732, alpha: 1.0 }); settingsOverlay.tint = 0x2F4F4F; settingsOverlay.visible = false; LK.gui.center.addChild(settingsOverlay); var settingsTitle = new Text2('AYARLAR', { size: 100, fill: 0xFFFFFF }); settingsTitle.anchor.set(0.5, 0.5); settingsTitle.stroke = 0x000000; settingsTitle.strokeThickness = 5; settingsTitle.visible = false; LK.gui.center.addChild(settingsTitle); settingsTitle.y = -300; // Create close settings button var closeSettingsButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 100, alpha: 0.9 }); closeSettingsButton.tint = 0xFF4500; closeSettingsButton.visible = false; LK.gui.center.addChild(closeSettingsButton); closeSettingsButton.y = 150; var closeSettingsText = new Text2('KAPAT', { size: 50, fill: 0xFFFFFF }); closeSettingsText.anchor.set(0.5, 0.5); closeSettingsText.stroke = 0x000000; closeSettingsText.strokeThickness = 3; closeSettingsText.visible = false; LK.gui.center.addChild(closeSettingsText); closeSettingsText.y = 150; // Create speed menu button var speedMenuButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 100, alpha: 0.9 }); speedMenuButton.tint = 0x4169E1; speedMenuButton.visible = false; LK.gui.center.addChild(speedMenuButton); speedMenuButton.y = -150; var speedMenuText = new Text2('HIZ', { size: 60, fill: 0xFFFFFF }); speedMenuText.anchor.set(0.5, 0.5); speedMenuText.stroke = 0x000000; speedMenuText.strokeThickness = 3; speedMenuText.visible = false; LK.gui.center.addChild(speedMenuText); speedMenuText.y = -150; // Create language menu button var languageMenuButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 100, alpha: 0.9 }); languageMenuButton.tint = 0x9932CC; languageMenuButton.visible = false; LK.gui.center.addChild(languageMenuButton); languageMenuButton.y = -20; var languageMenuText = new Text2('DİL', { size: 60, fill: 0xFFFFFF }); languageMenuText.anchor.set(0.5, 0.5); languageMenuText.stroke = 0x000000; languageMenuText.strokeThickness = 3; languageMenuText.visible = false; LK.gui.center.addChild(languageMenuText); languageMenuText.y = -20; // Create speed control title var speedTitle = new Text2('HIZ AYARI', { size: 80, fill: 0xFFFFFF }); speedTitle.anchor.set(0.5, 0.5); speedTitle.stroke = 0x000000; speedTitle.strokeThickness = 4; speedTitle.visible = false; LK.gui.center.addChild(speedTitle); speedTitle.y = -200; // Ensure speed title is rendered above speed overlay LK.gui.center.removeChild(speedTitle); LK.gui.center.addChild(speedTitle); // Create speed option buttons var normalSpeedButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 80, alpha: 0.9 }); normalSpeedButton.tint = 0x32CD32; normalSpeedButton.visible = false; LK.gui.center.addChild(normalSpeedButton); normalSpeedButton.y = -80; normalSpeedButton.x = -280; // Ensure normal speed button is rendered above speed overlay LK.gui.center.removeChild(normalSpeedButton); LK.gui.center.addChild(normalSpeedButton); var normalSpeedText = new Text2('NORMAL', { size: 40, fill: 0xFFFFFF }); normalSpeedText.anchor.set(0.5, 0.5); normalSpeedText.stroke = 0x000000; normalSpeedText.strokeThickness = 2; normalSpeedText.visible = false; LK.gui.center.addChild(normalSpeedText); normalSpeedText.y = -80; normalSpeedText.x = -280; // Ensure normal speed text is rendered above speed overlay LK.gui.center.removeChild(normalSpeedText); LK.gui.center.addChild(normalSpeedText); var speed15xButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 80, alpha: 0.9 }); speed15xButton.tint = 0xFF4500; speed15xButton.visible = false; LK.gui.center.addChild(speed15xButton); speed15xButton.y = -80; speed15xButton.x = 0; // Ensure 1.5X speed button is rendered above speed overlay LK.gui.center.removeChild(speed15xButton); LK.gui.center.addChild(speed15xButton); var speed15xText = new Text2('1.5X', { size: 40, fill: 0xFFFFFF }); speed15xText.anchor.set(0.5, 0.5); speed15xText.stroke = 0x000000; speed15xText.strokeThickness = 2; speed15xText.visible = false; LK.gui.center.addChild(speed15xText); speed15xText.y = -80; speed15xText.x = 0; // Ensure 1.5X speed text is rendered above speed overlay LK.gui.center.removeChild(speed15xText); LK.gui.center.addChild(speed15xText); var speed2xButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 80, alpha: 0.9 }); speed2xButton.tint = 0xFF8C00; speed2xButton.visible = false; LK.gui.center.addChild(speed2xButton); speed2xButton.y = -80; speed2xButton.x = 280; // Ensure 2X speed button is rendered above speed overlay LK.gui.center.removeChild(speed2xButton); LK.gui.center.addChild(speed2xButton); var speed2xText = new Text2('2X', { size: 40, fill: 0xFFFFFF }); speed2xText.anchor.set(0.5, 0.5); speed2xText.stroke = 0x000000; speed2xText.strokeThickness = 2; speed2xText.visible = false; LK.gui.center.addChild(speed2xText); speed2xText.y = -80; speed2xText.x = 280; // Ensure 2X speed text is rendered above speed overlay LK.gui.center.removeChild(speed2xText); LK.gui.center.addChild(speed2xText); // Current speed indicator var currentSpeedText = new Text2('MEVCUT: NORMAL', { size: 50, fill: 0xFFD700 }); currentSpeedText.anchor.set(0.5, 0.5); currentSpeedText.stroke = 0x000000; currentSpeedText.strokeThickness = 3; currentSpeedText.visible = false; LK.gui.center.addChild(currentSpeedText); currentSpeedText.y = 30; // Ensure current speed text is rendered above speed overlay LK.gui.center.removeChild(currentSpeedText); LK.gui.center.addChild(currentSpeedText); // Create back button for speed controls var speedBackButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 100, alpha: 0.9 }); speedBackButton.tint = 0xFF4500; speedBackButton.visible = false; LK.gui.center.addChild(speedBackButton); speedBackButton.y = 150; // Ensure speed back button is rendered above speed overlay LK.gui.center.removeChild(speedBackButton); LK.gui.center.addChild(speedBackButton); var speedBackText = new Text2('GERİ', { size: 50, fill: 0xFFFFFF }); speedBackText.anchor.set(0.5, 0.5); speedBackText.stroke = 0x000000; speedBackText.strokeThickness = 3; speedBackText.visible = false; LK.gui.center.addChild(speedBackText); speedBackText.y = 150; // Ensure speed back text is rendered above speed overlay LK.gui.center.removeChild(speedBackText); LK.gui.center.addChild(speedBackText); // 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; // Initialize bird properly bird.velocity = 0; // 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; 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; // Show settings button and icon settingsButton.visible = true; settingsIcon.visible = true; // Show cup shape (high score indicator) if (cupShape) cupShape.visible = true; // Hide instruction instructionTxt.visible = false; instructionBg.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; // Hide settings button and icon settingsButton.visible = false; settingsIcon.visible = false; // Hide cup shape (high score indicator) if (cupShape) cupShape.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; // 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(getText('score') + ': ' + finalScore); // Always show the current high score from storage var currentHighScore = _storage.highScore || 0; bestScoreText.setText(getText('bestScore') + ': ' + currentHighScore); } // 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; } // Create speed overlay background var speedOverlay = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 2048, height: 2732, alpha: 1.0 }); speedOverlay.tint = 0x2F4F4F; speedOverlay.visible = false; LK.gui.center.addChild(speedOverlay); // Move speed overlay to front to ensure it's above other elements LK.gui.center.removeChild(speedOverlay); LK.gui.center.addChild(speedOverlay); // Create language overlay background var languageOverlay = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 2048, height: 2732, alpha: 1.0 }); languageOverlay.tint = 0x2F4F4F; languageOverlay.visible = false; LK.gui.center.addChild(languageOverlay); // Create language control title var languageTitle = new Text2('DİL SEÇENEKLERİ', { size: 80, fill: 0xFFFFFF }); languageTitle.anchor.set(0.5, 0.5); languageTitle.stroke = 0x000000; languageTitle.strokeThickness = 4; languageTitle.visible = false; LK.gui.center.addChild(languageTitle); languageTitle.y = -200; // Create language option buttons var turkishButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80, alpha: 0.9 }); turkishButton.tint = 0x32CD32; turkishButton.visible = false; LK.gui.center.addChild(turkishButton); turkishButton.y = -80; turkishButton.x = -220; var turkishText = new Text2('TÜRKÇE', { size: 40, fill: 0xFFFFFF }); turkishText.anchor.set(0.5, 0.5); turkishText.stroke = 0x000000; turkishText.strokeThickness = 2; turkishText.visible = false; LK.gui.center.addChild(turkishText); turkishText.y = -80; turkishText.x = -220; var englishButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80, alpha: 0.9 }); englishButton.tint = 0xFF4500; englishButton.visible = false; LK.gui.center.addChild(englishButton); englishButton.y = -80; englishButton.x = 220; var englishText = new Text2('ENGLISH', { size: 40, fill: 0xFFFFFF }); englishText.anchor.set(0.5, 0.5); englishText.stroke = 0x000000; englishText.strokeThickness = 2; englishText.visible = false; LK.gui.center.addChild(englishText); englishText.y = -80; englishText.x = 220; // Current language indicator var currentLanguageText = new Text2('MEVCUT: TÜRKÇE', { size: 50, fill: 0xFFD700 }); currentLanguageText.anchor.set(0.5, 0.5); currentLanguageText.stroke = 0x000000; currentLanguageText.strokeThickness = 3; currentLanguageText.visible = false; LK.gui.center.addChild(currentLanguageText); currentLanguageText.y = 30; // Create back button for language controls var languageBackButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 100, alpha: 0.9 }); languageBackButton.tint = 0xFF4500; languageBackButton.visible = false; LK.gui.center.addChild(languageBackButton); languageBackButton.y = 150; var languageBackText = new Text2('GERİ', { size: 50, fill: 0xFFFFFF }); languageBackText.anchor.set(0.5, 0.5); languageBackText.stroke = 0x000000; languageBackText.strokeThickness = 3; languageBackText.visible = false; LK.gui.center.addChild(languageBackText); languageBackText.y = 150; // Function to show settings menu function showSettingsMenu() { settingsOverlay.visible = true; settingsTitle.visible = true; closeSettingsButton.visible = true; closeSettingsText.visible = true; speedMenuButton.visible = true; speedMenuText.visible = true; languageMenuButton.visible = true; languageMenuText.visible = true; } // Function to hide settings menu function hideSettingsMenu() { settingsOverlay.visible = false; settingsTitle.visible = false; closeSettingsButton.visible = false; closeSettingsText.visible = false; speedMenuButton.visible = false; speedMenuText.visible = false; languageMenuButton.visible = false; languageMenuText.visible = false; hideSpeedControls(); hideLanguageControls(); } // Function to show language controls function showLanguageControls() { // Hide speed controls first hideSpeedControls(); // Hide language menu button languageMenuButton.visible = false; languageMenuText.visible = false; // Show language overlay and controls languageOverlay.visible = true; languageTitle.visible = true; turkishButton.visible = true; turkishText.visible = true; englishButton.visible = true; englishText.visible = true; currentLanguageText.visible = true; languageBackButton.visible = true; languageBackText.visible = true; updateLanguageDisplay(); } // Function to hide language controls function hideLanguageControls() { languageOverlay.visible = false; languageTitle.visible = false; turkishButton.visible = false; turkishText.visible = false; englishButton.visible = false; englishText.visible = false; currentLanguageText.visible = false; languageBackButton.visible = false; languageBackText.visible = false; // Show language menu button again if settings overlay is visible if (settingsOverlay.visible) { languageMenuButton.visible = true; languageMenuText.visible = true; } } // Language text objects var languageTexts = { tr: { mainTitle: 'FLAPPY BIRD', playButton: 'OYNA', instruction: 'TIKLA VE OYNA!', gameOver: 'OYUN BİTTİ', score: 'SKOR', bestScore: 'EN İYİ', retry: 'TEKRAR DENE', mainMenu: 'ANA MENÜ', settings: 'AYARLAR', close: 'KAPAT', speed: 'HIZ', language: 'DİL', speedTitle: 'HIZ AYARI', languageTitle: 'DİL SEÇENEKLERİ', normal: 'NORMAL', current: 'MEVCUT', highestScore: 'EN YÜKSEK', back: 'GERİ' }, en: { mainTitle: 'FLAPPY BIRD', playButton: 'PLAY', instruction: 'CLICK TO PLAY!', gameOver: 'GAME OVER', score: 'SCORE', bestScore: 'BEST', retry: 'RETRY', mainMenu: 'MAIN MENU', settings: 'SETTINGS', close: 'CLOSE', speed: 'SPEED', language: 'LANGUAGE', speedTitle: 'SPEED SETTINGS', languageTitle: 'LANGUAGE OPTIONS', normal: 'NORMAL', current: 'CURRENT', highestScore: 'HIGHEST SCORE', back: 'BACK' } }; // Function to get text for current language function getText(key) { return languageTexts[currentLanguage][key] || languageTexts['en'][key]; } // Function to update all text elements to current language function updateAllTexts() { // Main menu texts playButtonText.setText(getText('playButton')); instructionTxt.setText(getText('instruction')); // Game over texts gameOverTitle.setText(getText('gameOver')); retryButtonText.setText(getText('retry')); menuButtonText.setText(getText('mainMenu')); // Settings texts settingsTitle.setText(getText('settings')); closeSettingsText.setText(getText('close')); speedMenuText.setText(getText('speed')); languageMenuText.setText(getText('language')); speedTitle.setText(getText('speedTitle')); languageTitle.setText(getText('languageTitle')); normalSpeedText.setText(getText('normal')); speedBackText.setText(getText('back')); languageBackText.setText(getText('back')); // Update current speed text var speedText = getText('normal'); if (gameSpeed === 2) speedText = '2X';else if (gameSpeed === 1.5) speedText = '1.5X'; currentSpeedText.setText(getText('current') + ': ' + speedText); } // Function to update language display function updateLanguageDisplay() { var langText = currentLanguage === 'tr' ? 'TÜRKÇE' : 'ENGLISH'; currentLanguageText.setText(getText('current') + ': ' + langText); // Update button colors to show selected language turkishButton.tint = currentLanguage === 'tr' ? 0x00FF00 : 0x32CD32; englishButton.tint = currentLanguage === 'en' ? 0x00FF00 : 0xFF4500; } // Function to set language function setLanguage(lang) { currentLanguage = lang; _storage.language = lang; updateLanguageDisplay(); updateAllTexts(); // Update all text elements } // Function to show speed controls function showSpeedControls() { // Hide language controls first hideLanguageControls(); // Hide speed menu button speedMenuButton.visible = false; speedMenuText.visible = false; // Show speed overlay and controls speedOverlay.visible = true; speedTitle.visible = true; normalSpeedButton.visible = true; normalSpeedText.visible = true; speed15xButton.visible = true; speed15xText.visible = true; speed2xButton.visible = true; speed2xText.visible = true; currentSpeedText.visible = true; speedBackButton.visible = true; speedBackText.visible = true; updateSpeedDisplay(); } // Function to hide speed controls function hideSpeedControls() { speedOverlay.visible = false; speedTitle.visible = false; normalSpeedButton.visible = false; normalSpeedText.visible = false; speed2xButton.visible = false; speed2xText.visible = false; speed15xButton.visible = false; speed15xText.visible = false; currentSpeedText.visible = false; speedBackButton.visible = false; speedBackText.visible = false; // Show speed menu button again if settings overlay is visible if (settingsOverlay.visible) { speedMenuButton.visible = true; speedMenuText.visible = true; } } // Function to update speed display function updateSpeedDisplay() { var speedText = getText('normal'); if (gameSpeed === 2) speedText = '2X';else if (gameSpeed === 1.5) speedText = '1.5X'; currentSpeedText.setText(getText('current') + ': ' + speedText); // Update button colors to show selected speed normalSpeedButton.tint = gameSpeed === 1 ? 0x00FF00 : 0x32CD32; speed2xButton.tint = gameSpeed === 2 ? 0x00FF00 : 0xFF8C00; speed15xButton.tint = gameSpeed === 1.5 ? 0x00FF00 : 0xFF4500; } // Function to set game speed function setGameSpeed(newSpeed) { gameSpeed = newSpeed; updateSpeedDisplay(); // Update existing pipes if they exist for (var i = 0; i < pipes.length; i++) { if (pipes[i]) { pipes[i].speed = basePipeSpeed * gameSpeed; } } } // Current language variable var currentLanguage = 'en'; // Default to English // 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.language) _storage.language = 'en'; currentLanguage = _storage.language; // Load high score from persistent storage try { var savedHighScore = storage.highScore || 0; _storage.highScore = savedHighScore; } catch (e) { console.log("Storage load error:", e); } } catch (e) { console.log("Storage initialization error:", e); _storage = { globalLeaderboardNames: [], globalLeaderboardScores: [], highScore: 0, lastScore: 0 }; } // Initialize username if not exists if (!_storage.username) { var playerNumber = 1; while (_storage.globalLeaderboardNames.indexOf('Oyuncu ' + playerNumber) !== -1) { playerNumber++; } _storage.username = 'Oyuncu ' + playerNumber; } // Initialize game resetGame(); // Use resetGame to properly initialize all states // Update all texts to current language updateAllTexts(); // Touch/click handler game.down = function (x, y, obj) { // Check settings button click - settings button is positioned at topRight with offset var settingsX = 2048 - 80; // topRight.x + settingsButton.x offset var settingsY = 80; // topRight.y + settingsButton.y offset var settingsSize = 120; // Settings button size if (x >= settingsX - settingsSize / 2 && x <= settingsX + settingsSize / 2 && y >= settingsY - settingsSize / 2 && y <= settingsY + settingsSize / 2) { // 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; // Add visual feedback with tween tween(settingsButton, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, onFinish: function onFinish() { tween(settingsButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); showSettingsMenu(); return; } // Check close settings button if settings menu is open if (settingsOverlay.visible) { // Check speed menu button (HIZ) - centered at 1024x1216, button is 400x100 if (speedMenuButton.visible && x >= 824 && x <= 1224 && y >= 1166 && y <= 1266) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(speedMenuButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(speedMenuButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); showSpeedControls(); return; } // Check language menu button (DIL) - centered at 1024x1346, button is 400x100 if (languageMenuButton.visible && x >= 824 && x <= 1224 && y >= 1296 && y <= 1396) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(languageMenuButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(languageMenuButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); showLanguageControls(); return; } // Check Turkish language button at x = 1024-220 = 804, y = 1366-80 = 1286, size 300x80 if (turkishButton.visible && x >= 654 && x <= 954 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(turkishButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(turkishButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); setLanguage('tr'); return; } // Check English language button at x = 1024+220 = 1244, y = 1286, size 300x80 if (englishButton.visible && x >= 1094 && x <= 1394 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(englishButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(englishButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); setLanguage('en'); return; } // Check speed buttons - Normal button at x = 1024-280 = 744, y = 1366-80 = 1286, size 200x80 if (x >= 644 && x <= 844 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(normalSpeedButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(normalSpeedButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); setGameSpeed(1); return; } // Check 1.5X speed button at x = 1024, y = 1286, size 200x80 if (x >= 924 && x <= 1124 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(speed15xButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(speed15xButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); setGameSpeed(1.5); return; } // Check 2X speed button at x = 1024+280 = 1304, y = 1286, size 200x80 if (x >= 1204 && x <= 1404 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(speed2xButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(speed2xButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); setGameSpeed(2); return; } // Check speed back button at x = 1024, y = 1516, size 300x100 if (speedBackButton.visible && x >= 874 && x <= 1174 && y >= 1466 && y <= 1566) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(speedBackButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(speedBackButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); hideSpeedControls(); return; } // Check language back button at x = 1024, y = 1516, size 300x100 if (languageBackButton.visible && x >= 874 && x <= 1174 && y >= 1466 && y <= 1566) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; tween(languageBackButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(languageBackButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); hideLanguageControls(); return; } // Check close settings button (KAPAT) - centered at 1024x1516, button is 300x100 if (x >= 874 && x <= 1174 && y >= 1466 && y <= 1566) { // 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(closeSettingsButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(closeSettingsButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); hideSettingsMenu(); return; } return; // Don't process other clicks when settings menu is open } // 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(getText('highestScore') + ': ' + 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 || 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; // Save high score to persistent storage try { storage.highScore = currentScore; } catch (e) { console.log("Storage save error:", e); } } // 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; // Save high score to persistent storage try { storage.highScore = currentScore; } catch (e) { console.log("Storage save error:", e); } } // 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
@@ -533,8 +533,11 @@
speedTitle.strokeThickness = 4;
speedTitle.visible = false;
LK.gui.center.addChild(speedTitle);
speedTitle.y = -200;
+// Ensure speed title is rendered above speed overlay
+LK.gui.center.removeChild(speedTitle);
+LK.gui.center.addChild(speedTitle);
// Create speed option buttons
var normalSpeedButton = LK.getAsset('playButtonOval', {
anchorX: 0.5,
anchorY: 0.5,
@@ -546,8 +549,11 @@
normalSpeedButton.visible = false;
LK.gui.center.addChild(normalSpeedButton);
normalSpeedButton.y = -80;
normalSpeedButton.x = -280;
+// Ensure normal speed button is rendered above speed overlay
+LK.gui.center.removeChild(normalSpeedButton);
+LK.gui.center.addChild(normalSpeedButton);
var normalSpeedText = new Text2('NORMAL', {
size: 40,
fill: 0xFFFFFF
});
@@ -557,8 +563,11 @@
normalSpeedText.visible = false;
LK.gui.center.addChild(normalSpeedText);
normalSpeedText.y = -80;
normalSpeedText.x = -280;
+// Ensure normal speed text is rendered above speed overlay
+LK.gui.center.removeChild(normalSpeedText);
+LK.gui.center.addChild(normalSpeedText);
var speed15xButton = LK.getAsset('playButtonOval', {
anchorX: 0.5,
anchorY: 0.5,
width: 200,
@@ -569,8 +578,11 @@
speed15xButton.visible = false;
LK.gui.center.addChild(speed15xButton);
speed15xButton.y = -80;
speed15xButton.x = 0;
+// Ensure 1.5X speed button is rendered above speed overlay
+LK.gui.center.removeChild(speed15xButton);
+LK.gui.center.addChild(speed15xButton);
var speed15xText = new Text2('1.5X', {
size: 40,
fill: 0xFFFFFF
});
@@ -580,8 +592,11 @@
speed15xText.visible = false;
LK.gui.center.addChild(speed15xText);
speed15xText.y = -80;
speed15xText.x = 0;
+// Ensure 1.5X speed text is rendered above speed overlay
+LK.gui.center.removeChild(speed15xText);
+LK.gui.center.addChild(speed15xText);
var speed2xButton = LK.getAsset('playButtonOval', {
anchorX: 0.5,
anchorY: 0.5,
width: 200,
@@ -592,8 +607,11 @@
speed2xButton.visible = false;
LK.gui.center.addChild(speed2xButton);
speed2xButton.y = -80;
speed2xButton.x = 280;
+// Ensure 2X speed button is rendered above speed overlay
+LK.gui.center.removeChild(speed2xButton);
+LK.gui.center.addChild(speed2xButton);
var speed2xText = new Text2('2X', {
size: 40,
fill: 0xFFFFFF
});
@@ -603,8 +621,11 @@
speed2xText.visible = false;
LK.gui.center.addChild(speed2xText);
speed2xText.y = -80;
speed2xText.x = 280;
+// Ensure 2X speed text is rendered above speed overlay
+LK.gui.center.removeChild(speed2xText);
+LK.gui.center.addChild(speed2xText);
// Current speed indicator
var currentSpeedText = new Text2('MEVCUT: NORMAL', {
size: 50,
fill: 0xFFD700
@@ -614,8 +635,11 @@
currentSpeedText.strokeThickness = 3;
currentSpeedText.visible = false;
LK.gui.center.addChild(currentSpeedText);
currentSpeedText.y = 30;
+// Ensure current speed text is rendered above speed overlay
+LK.gui.center.removeChild(currentSpeedText);
+LK.gui.center.addChild(currentSpeedText);
// Create back button for speed controls
var speedBackButton = LK.getAsset('playButtonOval', {
anchorX: 0.5,
anchorY: 0.5,
@@ -626,8 +650,11 @@
speedBackButton.tint = 0xFF4500;
speedBackButton.visible = false;
LK.gui.center.addChild(speedBackButton);
speedBackButton.y = 150;
+// Ensure speed back button is rendered above speed overlay
+LK.gui.center.removeChild(speedBackButton);
+LK.gui.center.addChild(speedBackButton);
var speedBackText = new Text2('GERİ', {
size: 50,
fill: 0xFFFFFF
});
@@ -636,8 +663,11 @@
speedBackText.strokeThickness = 3;
speedBackText.visible = false;
LK.gui.center.addChild(speedBackText);
speedBackText.y = 150;
+// Ensure speed back text is rendered above speed overlay
+LK.gui.center.removeChild(speedBackText);
+LK.gui.center.addChild(speedBackText);
// Create invisible barrier blocks to constrain bird before game starts
var topBarrier = game.addChild(LK.getAsset('barrier', {
anchorX: 0.5,
anchorY: 1
@@ -815,8 +845,11 @@
});
speedOverlay.tint = 0x2F4F4F;
speedOverlay.visible = false;
LK.gui.center.addChild(speedOverlay);
+// Move speed overlay to front to ensure it's above other elements
+LK.gui.center.removeChild(speedOverlay);
+LK.gui.center.addChild(speedOverlay);
// Create language overlay background
var languageOverlay = LK.getAsset('barrier', {
anchorX: 0.5,
anchorY: 0.5,