User prompt
hız menüsündeki tuşların algılanması için düğmeleri büyüt
User prompt
hız göstergesi olan menüde tuşlar algılamıyor
User prompt
Hız göstergesi yani hız seçenekleri sadece görüntü olarak değil işlevsel olarak da çalışsın ve seçtiğimiz hız alttaki yazıyı değiştirsin ve kuşun hızını da.
User prompt
hız 4 yazısı seçtiğimizde o 1x yazısı değişsin böylece seçtiğimizi anlayalım hangisini seçtiğimizi anlayalım ki ona göre ayarlayalım
User prompt
Seçtiğimiz hıza göre alttaki normal yazısı seçtiğimiz hıza dönüşsün yani yazı tipi olarak normal yazmasın hep.
User prompt
Seçtiğimiz hıza göre kuşun hızı dengeli fakat önemli böyle oyunu bozmadan bir hız artışı yaşasın.
User prompt
Evet bu sefer görünüyorlar fakat etkileşime geçemiyoruz yani hız ayarı ve geri tuşları çalışmıyor
User prompt
Belki de hız menüsündeki tuşlar yeşil duvarın arkasında kalmıştır. Öne al.
User prompt
oyundaki görüntü hatalarını düzeltelim
User prompt
oyundaki tehnik hataları düzelt
User prompt
Ama düğmeler ne gözüküyor ne tıklanıyor.
User prompt
1x, 1.5x, 2x, 2.5x hız seçenekleri ekle
User prompt
Eklediğin hız seçenekleri gözükmüyor.
User prompt
hız menüsünde ayarlar kısmındaki hız menüsüne tıklayınca 1x, 1.5x, 2x, 2.5x seçenekleri ekle ve bunları daha iyi daha dengeli yap hatasız
User prompt
menüleri düzelt gereksiz kodları düzelt ve hız menüsü gözükmüyor onu da düzelt
User prompt
ayarlar kısmına girsek bile menüdeki oyna tuşu ve diğer tuşlar ortaya çıkıyor bu da görünümü bozuyor menüler arası hataları düzelt
User prompt
ciddi ciddi tüm kodu kontrol et
User prompt
Kasma ve donma için herşeyi kontrol et.
User prompt
Kasma ve donma hataları var.
User prompt
Kasma, donma istemiyorum.
User prompt
Kasma ve donma hiç istemiyorum.
User prompt
gereksiz tüm kodları sil ama gereksiz tüm kodları sil
User prompt
Bine kadar şu şekilde oyun kasmaması için şöyle yapacağız sen her 10 önümüzde olan duvarı yenileyeceksin arkamızda olan 10 duvarı sileceksin yani arkamızda 10 duvar olunca hepsini sileceksin
User prompt
Kasma ve donmaları düzelt
User prompt
Herşey düzgün fakat duvarlar otomatik oluşması veya süreli bir şekilde oluşmasın. Direkt oluşmuş şekilde dünya başlasın ve bine kadar sürsün binden sonra duvar oluşmasın.
/**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); // Create bird graphics with proper anchoring var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); // Initialize bird properties self.velocity = 0; self.flapCooldown = 0; // Optimized flap function self.flap = function () { // Prevent rapid flapping if (self.flapCooldown > 0) return; self.flapCooldown = 8; // Frames to wait before next flap // Set velocity with simple scaling self.velocity = baseJumpStrength * gameSpeed; // Play flap sound with minimal error handling try { LK.getSound('flap').play(); } catch (e) { // Silent fail } }; // Remove idle animation function self.startIdleAnimation = function () { // No animation needed }; // Optimized update method self.update = function () { // Update cooldowns if (self.flapCooldown > 0) self.flapCooldown--; if (!gameStarted) { // Pre-game idle state self.velocity = 0; self.y = 1366; return; } // Simple physics self.velocity += baseGravity * gameSpeed; self.y += self.velocity; // Simple rotation - reduce calculation frequency if (LK.ticks % 3 === 0) { birdGraphics.rotation = Math.max(-0.6, Math.min(1.2, self.velocity * 0.08)); } // Screen bounds collision if (self.y < 40) { self.y = 40; self.velocity = 0; } if (self.y > 2582) { self.y = 2582; self.velocity = 0; } }; return self; }); var Pipe = Container.expand(function (gapCenterY) { var self = Container.call(this); self.gapSize = 750 + (gameSpeed - 1) * 50; self.speed = basePipeSpeed * gameSpeed; self.passed = false; self.gapCenterY = gapCenterY; self.pipeWidth = 120; // Calculate pipe heights var topPipeHeight = Math.max(200, gapCenterY - self.gapSize / 2); var bottomPipeHeight = Math.max(200, 2732 - 150 - (gapCenterY + self.gapSize / 2)); // Simple top pipe - single element var topPipe = self.attachAsset('topPipe', { anchorX: 0.5, anchorY: 1 }); topPipe.y = gapCenterY - self.gapSize / 2; topPipe.height = topPipeHeight; topPipe.width = self.pipeWidth; topPipe.tint = 0x228b22; // Simple bottom pipe - single element var bottomPipe = self.attachAsset('bottomPipe', { anchorX: 0.5, anchorY: 0 }); bottomPipe.y = gapCenterY + self.gapSize / 2; bottomPipe.height = bottomPipeHeight; bottomPipe.width = self.pipeWidth; bottomPipe.tint = 0x228b22; // Simple pipe caps var topPipeCap = self.attachAsset('pipeTop', { anchorX: 0.5, anchorY: 1 }); topPipeCap.y = gapCenterY - self.gapSize / 2; topPipeCap.width = self.pipeWidth + 20; topPipeCap.height = 25; topPipeCap.tint = 0x32cd32; var bottomPipeCap = self.attachAsset('pipeBottom', { anchorX: 0.5, anchorY: 0 }); bottomPipeCap.y = gapCenterY + self.gapSize / 2; bottomPipeCap.width = self.pipeWidth + 20; bottomPipeCap.height = 25; bottomPipeCap.tint = 0x32cd32; self.update = function () { if (!gameStarted) { return; } // Use pre-calculated speed instead of calculating every frame self.x += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game(); /**** * Game Code ****/ // Initialize plugins with proper error handling var tween; var storage; try { tween = LK.import("@upit/tween.v1"); storage = LK.import("@upit/storage.v1", { highScore: 0, language: 'en', username: 'Player1', globalLeaderboardNames: [], globalLeaderboardScores: [], lastScore: 0 }); } catch (e) { console.log("Plugin import error:", e); // Provide comprehensive fallback objects to prevent undefined errors tween = function tween(target, props, options) { return { duration: options ? options.duration || 0 : 0, onFinish: options && options.onFinish ? options.onFinish : function () {} }; }; // Add stop method to fallback tween object tween.stop = function (target, properties) { // Fallback stop method - does nothing but prevents errors }; // Add easing methods to fallback tween object tween.easeOut = function (t) { return t; }; tween.easeIn = function (t) { return t; }; tween.easeInOut = function (t) { return t; }; tween.linear = function (t) { return t; }; storage = { highScore: 0, language: 'en', username: 'Player1', globalLeaderboardNames: [], globalLeaderboardScores: [], lastScore: 0 }; } var bird; var pipes = []; var ground; var gameStarted = false; var gameOver = false; var showMainMenu = true; var showGameOver = false; var lastButtonClickTime = 0; // Track last button click time var gameSpeed = 1; // Current game speed multiplier (1 = normal, 2 = 2x, 3 = 3x) var baseGravity = 0.55; // Base gravity for bird - fine-tuned for better control var baseJumpStrength = -9.5; // Base jump strength for bird - fine-tuned for better balance 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: 90, 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 = -280; } } catch (e) { console.log("Main menu title error:", e); } // Create instruction text var instructionTxt = new Text2('TIKLA VE OYNA!', { size: 50, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.stroke = 0x000000; instructionTxt.strokeThickness = 3; instructionTxt.visible = false; instructionTxt.y = -50; // Remove background shape for instruction text - no longer needed LK.gui.center.addChild(instructionTxt); // Create game over screen elements var gameOverBg = LK.getAsset('topPipe', { 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 with enhanced styling var retryButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 380, height: 110, alpha: 1.0 }); retryButton.tint = 0xFF9800; // Orange like original Flappy Bird retryButton.visible = false; LK.gui.center.addChild(retryButton); retryButton.y = 100; // Add retry button shadow for depth var retryButtonShadow = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 380, height: 110, alpha: 0.3 }); retryButtonShadow.tint = 0xE65100; // Darker orange shadow retryButtonShadow.visible = false; LK.gui.center.addChild(retryButtonShadow); retryButtonShadow.y = 108; // Offset shadow slightly down retryButtonShadow.x = 4; // Offset shadow slightly right // Add retry button highlight var retryButtonHighlight = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 350, height: 85, alpha: 0.4 }); retryButtonHighlight.tint = 0xFFB74D; // Lighter orange highlight retryButtonHighlight.visible = false; LK.gui.center.addChild(retryButtonHighlight); retryButtonHighlight.y = 92; // Offset highlight slightly up var retryButtonText = new Text2('TEKRAR DENE', { size: 44, fill: 0xFFFFFF }); retryButtonText.anchor.set(0.5, 0.5); retryButtonText.stroke = 0xE65100; retryButtonText.strokeThickness = 3; retryButtonText.visible = false; LK.gui.center.addChild(retryButtonText); retryButtonText.y = 100; // Create menu button with enhanced styling var menuButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 380, height: 110, alpha: 1.0 }); menuButton.tint = 0xF44336; // Red like original Flappy Bird menuButton.visible = false; LK.gui.center.addChild(menuButton); menuButton.y = 250; // Add menu button shadow for depth var menuButtonShadow = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 380, height: 110, alpha: 0.3 }); menuButtonShadow.tint = 0xD32F2F; // Darker red shadow menuButtonShadow.visible = false; LK.gui.center.addChild(menuButtonShadow); menuButtonShadow.y = 258; // Offset shadow slightly down menuButtonShadow.x = 4; // Offset shadow slightly right // Add menu button highlight var menuButtonHighlight = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 350, height: 85, alpha: 0.4 }); menuButtonHighlight.tint = 0xEF5350; // Lighter red highlight menuButtonHighlight.visible = false; LK.gui.center.addChild(menuButtonHighlight); menuButtonHighlight.y = 242; // Offset highlight slightly up var menuButtonText = new Text2('ANA MENÜ', { size: 44, fill: 0xFFFFFF }); menuButtonText.anchor.set(0.5, 0.5); menuButtonText.stroke = 0xD32F2F; menuButtonText.strokeThickness = 3; menuButtonText.visible = false; LK.gui.center.addChild(menuButtonText); menuButtonText.y = 250; // Create separate settings button element var settingsButton = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 100, height: 100, alpha: 1.0 }); settingsButton.tint = 0x8E44AD; 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 separate settings button shadow element var settingsButtonShadow = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 100, height: 100, alpha: 0.3 }); settingsButtonShadow.tint = 0x6B2C91; // Darker purple shadow try { if (LK.gui && LK.gui.topRight) { LK.gui.topRight.addChild(settingsButtonShadow); settingsButtonShadow.x = -77; settingsButtonShadow.y = 83; } } catch (e) { console.log("Settings button shadow error:", e); } // Create separate settings button highlight element var settingsButtonHighlight = LK.getAsset('playButtonOval', { anchorX: 0.5, anchorY: 0.5, width: 85, height: 85, alpha: 0.4 }); settingsButtonHighlight.tint = 0xBB8FCE; // Lighter purple highlight try { if (LK.gui && LK.gui.topRight) { LK.gui.topRight.addChild(settingsButtonHighlight); settingsButtonHighlight.x = -80; settingsButtonHighlight.y = 77; } } catch (e) { console.log("Settings button highlight error:", e); } // Create separate settings icon text element var settingsIcon = new Text2('⚙', { size: 60, fill: 0xFFFFFF }); settingsIcon.anchor.set(0.5, 0.5); settingsIcon.stroke = 0x6B2C91; settingsIcon.strokeThickness = 2; 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('topPipe', { 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 with modern rectangular design var closeSettingsButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 260, height: 70, alpha: 1.0 }); closeSettingsButton.tint = 0x95A5A6; closeSettingsButton.visible = false; LK.gui.center.addChild(closeSettingsButton); closeSettingsButton.y = 150; // Add close button shadow for depth var closeSettingsButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 260, height: 70, alpha: 0.3 }); closeSettingsButtonShadow.tint = 0x7F8C8D; closeSettingsButtonShadow.visible = false; LK.gui.center.addChild(closeSettingsButtonShadow); closeSettingsButtonShadow.y = 155; closeSettingsButtonShadow.x = 3; // Add close button highlight var closeSettingsButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 240, height: 55, alpha: 0.4 }); closeSettingsButtonHighlight.tint = 0xBDC3C7; closeSettingsButtonHighlight.visible = false; LK.gui.center.addChild(closeSettingsButtonHighlight); closeSettingsButtonHighlight.y = 145; var closeSettingsText = new Text2('KAPAT', { size: 36, fill: 0xFFFFFF }); closeSettingsText.anchor.set(0.5, 0.5); closeSettingsText.stroke = 0x7F8C8D; closeSettingsText.strokeThickness = 2; closeSettingsText.visible = false; LK.gui.center.addChild(closeSettingsText); closeSettingsText.y = 150; // Create speed menu button with modern rectangular design var speedMenuButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 340, height: 75, alpha: 1.0 }); speedMenuButton.tint = 0x3498DB; speedMenuButton.visible = false; LK.gui.center.addChild(speedMenuButton); speedMenuButton.y = -150; // Add speed button shadow for depth var speedMenuButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 340, height: 75, alpha: 0.3 }); speedMenuButtonShadow.tint = 0x2980B9; speedMenuButtonShadow.visible = false; LK.gui.center.addChild(speedMenuButtonShadow); speedMenuButtonShadow.y = -145; speedMenuButtonShadow.x = 3; // Add speed button highlight var speedMenuButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 320, height: 60, alpha: 0.4 }); speedMenuButtonHighlight.tint = 0x5DADE2; speedMenuButtonHighlight.visible = false; LK.gui.center.addChild(speedMenuButtonHighlight); speedMenuButtonHighlight.y = -155; var speedMenuText = new Text2('HIZ', { size: 42, fill: 0xFFFFFF }); speedMenuText.anchor.set(0.5, 0.5); speedMenuText.stroke = 0x2980B9; speedMenuText.strokeThickness = 2; speedMenuText.visible = false; LK.gui.center.addChild(speedMenuText); speedMenuText.y = -150; // Create language menu button with modern rectangular design var languageMenuButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 340, height: 75, alpha: 1.0 }); languageMenuButton.tint = 0x9B59B6; languageMenuButton.visible = false; LK.gui.center.addChild(languageMenuButton); languageMenuButton.y = -20; // Add language button shadow for depth var languageMenuButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 340, height: 75, alpha: 0.3 }); languageMenuButtonShadow.tint = 0x8E44AD; languageMenuButtonShadow.visible = false; LK.gui.center.addChild(languageMenuButtonShadow); languageMenuButtonShadow.y = -15; languageMenuButtonShadow.x = 3; // Add language button highlight var languageMenuButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 320, height: 60, alpha: 0.4 }); languageMenuButtonHighlight.tint = 0xBB8FCE; languageMenuButtonHighlight.visible = false; LK.gui.center.addChild(languageMenuButtonHighlight); languageMenuButtonHighlight.y = -25; var languageMenuText = new Text2('DİL', { size: 42, fill: 0xFFFFFF }); languageMenuText.anchor.set(0.5, 0.5); languageMenuText.stroke = 0x8E44AD; languageMenuText.strokeThickness = 2; languageMenuText.visible = false; LK.gui.center.addChild(languageMenuText); languageMenuText.y = -20; // Create new speed control elements 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; // Create speed option buttons with modern rectangular design var normalSpeedButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 65, alpha: 1.0 }); normalSpeedButton.tint = 0x27AE60; normalSpeedButton.visible = false; LK.gui.center.addChild(normalSpeedButton); normalSpeedButton.y = -80; normalSpeedButton.x = -280; // Add normal speed button shadow var normalSpeedButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 65, alpha: 0.3 }); normalSpeedButtonShadow.tint = 0x1E8449; normalSpeedButtonShadow.visible = false; LK.gui.center.addChild(normalSpeedButtonShadow); normalSpeedButtonShadow.y = -75; normalSpeedButtonShadow.x = -277; // Add normal speed button highlight var normalSpeedButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 160, height: 50, alpha: 0.4 }); normalSpeedButtonHighlight.tint = 0x58D68D; normalSpeedButtonHighlight.visible = false; LK.gui.center.addChild(normalSpeedButtonHighlight); normalSpeedButtonHighlight.y = -85; normalSpeedButtonHighlight.x = -280; var normalSpeedText = new Text2('NORMAL', { size: 32, fill: 0xFFFFFF }); normalSpeedText.anchor.set(0.5, 0.5); normalSpeedText.stroke = 0x1E8449; normalSpeedText.strokeThickness = 2; normalSpeedText.visible = false; LK.gui.center.addChild(normalSpeedText); normalSpeedText.y = -80; normalSpeedText.x = -280; var speed15xButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 65, alpha: 1.0 }); speed15xButton.tint = 0xF39C12; speed15xButton.visible = false; LK.gui.center.addChild(speed15xButton); speed15xButton.y = -80; speed15xButton.x = 0; // Add 1.5x speed button shadow var speed15xButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 65, alpha: 0.3 }); speed15xButtonShadow.tint = 0xD68910; speed15xButtonShadow.visible = false; LK.gui.center.addChild(speed15xButtonShadow); speed15xButtonShadow.y = -75; speed15xButtonShadow.x = 3; // Add 1.5x speed button highlight var speed15xButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 160, height: 50, alpha: 0.4 }); speed15xButtonHighlight.tint = 0xF7DC6F; speed15xButtonHighlight.visible = false; LK.gui.center.addChild(speed15xButtonHighlight); speed15xButtonHighlight.y = -85; speed15xButtonHighlight.x = 0; var speed15xText = new Text2('1.5X', { size: 32, fill: 0xFFFFFF }); speed15xText.anchor.set(0.5, 0.5); speed15xText.stroke = 0xD68910; speed15xText.strokeThickness = 2; speed15xText.visible = false; LK.gui.center.addChild(speed15xText); speed15xText.y = -80; speed15xText.x = 0; var speed2xButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 65, alpha: 1.0 }); speed2xButton.tint = 0xE74C3C; speed2xButton.visible = false; LK.gui.center.addChild(speed2xButton); speed2xButton.y = -80; speed2xButton.x = 180; // Add 2x speed button shadow var speed2xButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 65, alpha: 0.3 }); speed2xButtonShadow.tint = 0xC0392B; speed2xButtonShadow.visible = false; LK.gui.center.addChild(speed2xButtonShadow); speed2xButtonShadow.y = -75; speed2xButtonShadow.x = 183; // Add 2x speed button highlight var speed2xButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 160, height: 50, alpha: 0.4 }); speed2xButtonHighlight.tint = 0xF1948A; speed2xButtonHighlight.visible = false; LK.gui.center.addChild(speed2xButtonHighlight); speed2xButtonHighlight.y = -85; speed2xButtonHighlight.x = 180; var speed2xText = new Text2('2X', { size: 32, fill: 0xFFFFFF }); speed2xText.anchor.set(0.5, 0.5); speed2xText.stroke = 0xC0392B; speed2xText.strokeThickness = 2; speed2xText.visible = false; LK.gui.center.addChild(speed2xText); speed2xText.y = -80; speed2xText.x = 180; // Create 2.5x speed button var speed25xButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 65, alpha: 1.0 }); speed25xButton.tint = 0x9C27B0; speed25xButton.visible = false; LK.gui.center.addChild(speed25xButton); speed25xButton.y = -80; speed25xButton.x = 360; // Add 2.5x speed button shadow var speed25xButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 65, alpha: 0.3 }); speed25xButtonShadow.tint = 0x7B1FA2; speed25xButtonShadow.visible = false; LK.gui.center.addChild(speed25xButtonShadow); speed25xButtonShadow.y = -75; speed25xButtonShadow.x = 363; // Add 2.5x speed button highlight var speed25xButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 160, height: 50, alpha: 0.4 }); speed25xButtonHighlight.tint = 0xBA68C8; speed25xButtonHighlight.visible = false; LK.gui.center.addChild(speed25xButtonHighlight); speed25xButtonHighlight.y = -85; speed25xButtonHighlight.x = 360; var speed25xText = new Text2('2.5X', { size: 32, fill: 0xFFFFFF }); speed25xText.anchor.set(0.5, 0.5); speed25xText.stroke = 0x7B1FA2; speed25xText.strokeThickness = 2; speed25xText.visible = false; LK.gui.center.addChild(speed25xText); speed25xText.y = -80; speed25xText.x = 360; // 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; // Create back button for speed controls with modern rectangular design var speedBackButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 65, alpha: 1.0 }); speedBackButton.tint = 0x7F8C8D; speedBackButton.visible = false; LK.gui.center.addChild(speedBackButton); speedBackButton.y = 150; // Add speed back button shadow var speedBackButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 65, alpha: 0.3 }); speedBackButtonShadow.tint = 0x566573; speedBackButtonShadow.visible = false; LK.gui.center.addChild(speedBackButtonShadow); speedBackButtonShadow.y = 155; speedBackButtonShadow.x = 3; // Add speed back button highlight var speedBackButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 50, alpha: 0.4 }); speedBackButtonHighlight.tint = 0xABB2B9; speedBackButtonHighlight.visible = false; LK.gui.center.addChild(speedBackButtonHighlight); speedBackButtonHighlight.y = 145; var speedBackText = new Text2('GERİ', { size: 36, fill: 0xFFFFFF }); speedBackText.anchor.set(0.5, 0.5); speedBackText.stroke = 0x566573; speedBackText.strokeThickness = 2; speedBackText.visible = false; LK.gui.center.addChild(speedBackText); speedBackText.y = 150; // Simple background setup var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0 })); background.x = 0; background.y = 0; 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 - position in open area away from any walls bird = game.addChild(new Bird()); bird.x = 300; // Position bird further back in open area bird.y = 1366; // Initialize bird properly bird.velocity = 0; // Pre-generate all pipes function function generateAllPipes() { // Define safe boundaries for gap center to ensure both pipes have reasonable heights var minGapY = 700; // Increased minimum gap center position for better clearance var maxGapY = 1900; // Adjusted maximum gap center position for better clearance // Calculate how many pipes we need for 1000 points var totalPipesNeeded = 1000; // One pipe per point var currentX = 1200; // Starting position ahead of bird var pipeSpacing = 450; // Fixed spacing between pipes for (var pipeIndex = 0; pipeIndex < totalPipesNeeded; pipeIndex++) { var gapCenterY; // Create more varied random patterns with better distribution var randomPattern = Math.random(); if (randomPattern < 0.4) { // 40% chance for high gaps (easier to navigate) gapCenterY = minGapY + Math.random() * 300; } else if (randomPattern < 0.7) { // 30% chance for middle gaps (moderate difficulty) gapCenterY = 1000 + Math.random() * 500; } else { // 30% chance for low gaps (more challenging but still passable) gapCenterY = maxGapY - Math.random() * 300; } // Add some variation based on pipe index for progressive difficulty if (pipeIndex > 10) { // After pipe 10, make gaps slightly more challenging var difficultyFactor = Math.min(0.8, pipeIndex / 50); // Max 80% difficulty increase var centerPull = 1300; // Pull towards center-high area gapCenterY = gapCenterY + (centerPull - gapCenterY) * difficultyFactor * 0.3; } // Ensure the gap stays within safe boundaries gapCenterY = Math.max(minGapY, Math.min(maxGapY, gapCenterY)); var pipe = new Pipe(gapCenterY); pipe.x = currentX; pipe.passed = false; pipes.push(pipe); game.addChild(pipe); // Move to next pipe position currentX += pipeSpacing; } } // Reset game function function resetGame() { // Reset bird - position it in open area with no walls bird.x = 300; // Position bird in open area 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; // Show play button elements if (playButton) playButton.visible = true; if (playButtonShadow) playButtonShadow.visible = true; if (playButtonHighlight) playButtonHighlight.visible = true; if (playButtonText) playButtonText.visible = true; // Show all settings button elements settingsButton.visible = true; settingsButtonShadow.visible = true; settingsButtonHighlight.visible = true; settingsIcon.visible = true; // Show cup shape (high score indicator) if (cupShape) cupShape.visible = true; // Hide instruction instructionTxt.visible = false; generateAllPipes(); } // Function to start game from main menu function startGameFromMenu() { showMainMenu = false; // Hide main menu elements mainMenuTitle.visible = false; // Hide play button elements if (playButton) playButton.visible = false; if (playButtonShadow) playButtonShadow.visible = false; if (playButtonHighlight) playButtonHighlight.visible = false; if (playButtonText) playButtonText.visible = false; // Hide all settings button elements settingsButton.visible = false; settingsButtonShadow.visible = false; settingsButtonHighlight.visible = false; settingsIcon.visible = false; // Hide cup shape (high score indicator) if (cupShape) cupShape.visible = false; // Show instruction instructionTxt.visible = true; } // Function to show game over screen function showGameOverScreen(finalScore) { showGameOver = true; gameStarted = false; showMainMenu = false; // Hide instruction instructionTxt.visible = false; // Show game over elements gameOverBg.visible = true; gameOverTitle.visible = true; finalScoreText.visible = true; bestScoreText.visible = true; retryButton.visible = true; retryButtonText.visible = true; retryButtonShadow.visible = true; retryButtonHighlight.visible = true; menuButton.visible = true; menuButtonText.visible = true; menuButtonShadow.visible = true; menuButtonHighlight.visible = true; // Update score displays finalScoreText.setText(getText('score') + ': ' + finalScore); // Use proper text sizing if (finalScoreText.width > 600) { var newSize = Math.max(50, Math.floor(80 * 600 / finalScoreText.width)); finalScoreText.style = { size: newSize, fill: finalScoreText.style.fill }; } // Always show the current high score from storage var currentHighScore = _storage && _storage.highScore ? _storage.highScore : 0; bestScoreText.setText(getText('bestScore') + ': ' + currentHighScore); // Use proper text sizing if (bestScoreText.width > 600) { var newSize = Math.max(40, Math.floor(60 * 600 / bestScoreText.width)); bestScoreText.style = { size: newSize, fill: bestScoreText.style.fill }; } // Simple game over screen display - no animations } // 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; retryButtonShadow.visible = false; retryButtonHighlight.visible = false; menuButton.visible = false; menuButtonText.visible = false; menuButtonShadow.visible = false; menuButtonHighlight.visible = false; } // Create speed overlay background - moved to end to ensure it's on top var speedOverlay = LK.getAsset('topPipe', { anchorX: 0.5, anchorY: 0.5, width: 2048, height: 2732, alpha: 1.0 }); speedOverlay.tint = 0x2F4F4F; speedOverlay.visible = false; // Add to front to ensure visibility above all other elements LK.gui.center.addChild(speedOverlay); // Create language overlay background var languageOverlay = LK.getAsset('topPipe', { 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 with modern rectangular design var turkishButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 260, height: 65, alpha: 1.0 }); turkishButton.tint = 0x27AE60; turkishButton.visible = false; LK.gui.center.addChild(turkishButton); turkishButton.y = -80; turkishButton.x = -220; // Add Turkish button shadow var turkishButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 260, height: 65, alpha: 0.3 }); turkishButtonShadow.tint = 0x1E8449; turkishButtonShadow.visible = false; LK.gui.center.addChild(turkishButtonShadow); turkishButtonShadow.y = -75; turkishButtonShadow.x = -217; // Add Turkish button highlight var turkishButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 240, height: 50, alpha: 0.4 }); turkishButtonHighlight.tint = 0x58D68D; turkishButtonHighlight.visible = false; LK.gui.center.addChild(turkishButtonHighlight); turkishButtonHighlight.y = -85; turkishButtonHighlight.x = -220; var turkishText = new Text2('TÜRKÇE', { size: 32, fill: 0xFFFFFF }); turkishText.anchor.set(0.5, 0.5); turkishText.stroke = 0x1E8449; turkishText.strokeThickness = 2; turkishText.visible = false; LK.gui.center.addChild(turkishText); turkishText.y = -80; turkishText.x = -220; var englishButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 260, height: 65, alpha: 1.0 }); englishButton.tint = 0x3498DB; englishButton.visible = false; LK.gui.center.addChild(englishButton); englishButton.y = -80; englishButton.x = 220; // Add English button shadow var englishButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 260, height: 65, alpha: 0.3 }); englishButtonShadow.tint = 0x2980B9; englishButtonShadow.visible = false; LK.gui.center.addChild(englishButtonShadow); englishButtonShadow.y = -75; englishButtonShadow.x = 223; // Add English button highlight var englishButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 240, height: 50, alpha: 0.4 }); englishButtonHighlight.tint = 0x85C1E9; englishButtonHighlight.visible = false; LK.gui.center.addChild(englishButtonHighlight); englishButtonHighlight.y = -85; englishButtonHighlight.x = 220; var englishText = new Text2('ENGLISH', { size: 32, fill: 0xFFFFFF }); englishText.anchor.set(0.5, 0.5); englishText.stroke = 0x2980B9; 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 with modern rectangular design var languageBackButton = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 65, alpha: 1.0 }); languageBackButton.tint = 0x7F8C8D; languageBackButton.visible = false; LK.gui.center.addChild(languageBackButton); languageBackButton.y = 150; // Add language back button shadow var languageBackButtonShadow = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 65, alpha: 0.3 }); languageBackButtonShadow.tint = 0x566573; languageBackButtonShadow.visible = false; LK.gui.center.addChild(languageBackButtonShadow); languageBackButtonShadow.y = 155; languageBackButtonShadow.x = 3; // Add language back button highlight var languageBackButtonHighlight = LK.getAsset('settingsButtonRect', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 50, alpha: 0.4 }); languageBackButtonHighlight.tint = 0xABB2B9; languageBackButtonHighlight.visible = false; LK.gui.center.addChild(languageBackButtonHighlight); languageBackButtonHighlight.y = 145; var languageBackText = new Text2('GERİ', { size: 36, fill: 0xFFFFFF }); languageBackText.anchor.set(0.5, 0.5); languageBackText.stroke = 0x566573; languageBackText.strokeThickness = 2; 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; closeSettingsButtonShadow.visible = true; closeSettingsButtonHighlight.visible = true; closeSettingsText.visible = true; speedMenuButton.visible = true; speedMenuButtonShadow.visible = true; speedMenuButtonHighlight.visible = true; speedMenuText.visible = true; languageMenuButton.visible = true; languageMenuButtonShadow.visible = true; languageMenuButtonHighlight.visible = true; languageMenuText.visible = true; } // Function to hide settings menu function hideSettingsMenu() { settingsOverlay.visible = false; settingsTitle.visible = false; closeSettingsButton.visible = false; closeSettingsButtonShadow.visible = false; closeSettingsButtonHighlight.visible = false; closeSettingsText.visible = false; speedMenuButton.visible = false; speedMenuButtonShadow.visible = false; speedMenuButtonHighlight.visible = false; speedMenuText.visible = false; languageMenuButton.visible = false; languageMenuButtonShadow.visible = false; languageMenuButtonHighlight.visible = false; languageMenuText.visible = false; hideSpeedControls(); hideLanguageControls(); } // Function to show language controls function showLanguageControls() { hideSpeedControls(); languageMenuButton.visible = false; languageMenuText.visible = false; languageOverlay.visible = true; languageTitle.visible = true; turkishButton.visible = true; turkishButtonShadow.visible = true; turkishButtonHighlight.visible = true; turkishText.visible = true; englishButton.visible = true; englishButtonShadow.visible = true; englishButtonHighlight.visible = true; englishText.visible = true; currentLanguageText.visible = true; languageBackButton.visible = true; languageBackButtonShadow.visible = true; languageBackButtonHighlight.visible = true; languageBackText.visible = true; updateLanguageDisplay(); } // Function to hide language controls function hideLanguageControls() { languageOverlay.visible = false; languageTitle.visible = false; turkishButton.visible = false; turkishButtonShadow.visible = false; turkishButtonHighlight.visible = false; turkishText.visible = false; englishButton.visible = false; englishButtonShadow.visible = false; englishButtonHighlight.visible = false; englishText.visible = false; currentLanguageText.visible = false; languageBackButton.visible = false; languageBackButtonShadow.visible = false; languageBackButtonHighlight.visible = false; languageBackText.visible = false; // Show language menu button again if settings overlay is visible if (settingsOverlay.visible) { languageMenuButton.visible = true; languageMenuButtonShadow.visible = true; languageMenuButtonHighlight.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() { try { if (instructionTxt && instructionTxt.setText) instructionTxt.setText(getText('instruction')); if (playButtonText && playButtonText.setText) playButtonText.setText(getText('playButton')); if (gameOverTitle && gameOverTitle.setText) gameOverTitle.setText(getText('gameOver')); if (retryButtonText && retryButtonText.setText) retryButtonText.setText(getText('retry')); if (menuButtonText && menuButtonText.setText) menuButtonText.setText(getText('mainMenu')); if (settingsTitle && settingsTitle.setText) settingsTitle.setText(getText('settings')); if (closeSettingsText && closeSettingsText.setText) closeSettingsText.setText(getText('close')); if (speedMenuText && speedMenuText.setText) speedMenuText.setText(getText('speed')); if (languageMenuText && languageMenuText.setText) languageMenuText.setText(getText('language')); if (speedTitle && speedTitle.setText) speedTitle.setText(getText('speedTitle')); if (languageTitle && languageTitle.setText) languageTitle.setText(getText('languageTitle')); if (normalSpeedText && normalSpeedText.setText) normalSpeedText.setText(getText('normal')); if (speedBackText && speedBackText.setText) speedBackText.setText(getText('back')); if (languageBackText && languageBackText.setText) 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';else if (gameSpeed === 2.5) speedText = '2.5X'; if (currentSpeedText && currentSpeedText.setText) currentSpeedText.setText(getText('current') + ': ' + speedText); // Update final and best score texts if (finalScoreText && finalScoreText.setText) { var currentScore = LK.getScore(); finalScoreText.setText(getText('score') + ': ' + currentScore); } if (bestScoreText && bestScoreText.setText) { var currentHighScore = _storage.highScore || 0; bestScoreText.setText(getText('bestScore') + ': ' + currentHighScore); } } catch (e) { console.log("Text update error:", e); } } // Function to update language display function updateLanguageDisplay() { var langText = currentLanguage === 'tr' ? 'TÜRKÇE' : 'ENGLISH'; var currentText = currentLanguage === 'tr' ? 'MEVCUT' : 'CURRENT'; currentLanguageText.setText(currentText + ': ' + langText); turkishButton.tint = currentLanguage === 'tr' ? 0x2ECC71 : 0x27AE60; englishButton.tint = currentLanguage === 'en' ? 0x5DADE2 : 0x3498DB; if (turkishText && turkishText.setText) turkishText.setText('TÜRKÇE'); if (englishText && englishText.setText) englishText.setText('ENGLISH'); } // Function to set language function setLanguage(lang) { currentLanguage = lang; _storage.language = lang; // Update all text elements immediately updateAllTexts(); // Update language display updateLanguageDisplay(); // Update speed display to use correct language updateSpeedDisplay(); } // Function to show speed controls function showSpeedControls() { hideLanguageControls(); speedMenuButton.visible = false; speedMenuText.visible = false; speedOverlay.visible = true; speedTitle.visible = true; normalSpeedButton.visible = true; normalSpeedButtonShadow.visible = true; normalSpeedButtonHighlight.visible = true; normalSpeedText.visible = true; speed15xButton.visible = true; speed15xButtonShadow.visible = true; speed15xButtonHighlight.visible = true; speed15xText.visible = true; speed2xButton.visible = true; speed2xButtonShadow.visible = true; speed2xButtonHighlight.visible = true; speed2xText.visible = true; speed25xButton.visible = true; speed25xButtonShadow.visible = true; speed25xButtonHighlight.visible = true; speed25xText.visible = true; currentSpeedText.visible = true; speedBackButton.visible = true; speedBackButtonShadow.visible = true; speedBackButtonHighlight.visible = true; speedBackText.visible = true; updateSpeedDisplay(); } // Function to hide speed controls function hideSpeedControls() { speedOverlay.visible = false; speedTitle.visible = false; normalSpeedButton.visible = false; normalSpeedButtonShadow.visible = false; normalSpeedButtonHighlight.visible = false; normalSpeedText.visible = false; speed2xButton.visible = false; speed2xButtonShadow.visible = false; speed2xButtonHighlight.visible = false; speed2xText.visible = false; speed25xButton.visible = false; speed25xButtonShadow.visible = false; speed25xButtonHighlight.visible = false; speed25xText.visible = false; speed15xButton.visible = false; speed15xButtonShadow.visible = false; speed15xButtonHighlight.visible = false; speed15xText.visible = false; currentSpeedText.visible = false; speedBackButton.visible = false; speedBackButtonShadow.visible = false; speedBackButtonHighlight.visible = false; speedBackText.visible = false; // Show speed menu button again if settings overlay is visible if (settingsOverlay.visible) { speedMenuButton.visible = true; speedMenuButtonShadow.visible = true; speedMenuButtonHighlight.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';else if (gameSpeed === 2.5) speedText = '2.5X'; currentSpeedText.setText(getText('current') + ': ' + speedText); normalSpeedButton.tint = gameSpeed === 1 ? 0x1ABC9C : 0x27AE60; speed2xButton.tint = gameSpeed === 2 ? 0xFF6B6B : 0xE74C3C; speed15xButton.tint = gameSpeed === 1.5 ? 0xFFE066 : 0xF39C12; speed25xButton.tint = gameSpeed === 2.5 ? 0xE91E63 : 0x9C27B0; if (normalSpeedText && normalSpeedText.setText) normalSpeedText.setText(getText('normal')); } // 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; // Update gap size for existing pipes pipes[i].gapSize = 750 + (gameSpeed - 1) * 50; } } } // Current language variable var currentLanguage = 'tr'; // Default to Turkish // Initialize local storage arrays if they don't exist try { // Use persistent storage directly _storage = storage; // Initialize arrays and values if they don't exist, but preserve existing values if (!_storage.globalLeaderboardNames) _storage.globalLeaderboardNames = []; if (!_storage.globalLeaderboardScores) _storage.globalLeaderboardScores = []; if (typeof _storage.highScore === 'undefined') _storage.highScore = 0; if (typeof _storage.lastScore === 'undefined') _storage.lastScore = 0; if (!_storage.language) _storage.language = 'tr'; if (!_storage.username) _storage.username = 'Oyuncu1'; currentLanguage = _storage.language; } catch (e) { console.log("Storage initialization error:", e); _storage = { globalLeaderboardNames: [], globalLeaderboardScores: [], highScore: 0, lastScore: 0, language: 'tr', username: 'Oyuncu1' }; } // Initialize username if not exists if (!_storage.username) { var playerNumber = 1; while (_storage.globalLeaderboardNames.indexOf('Oyuncu ' + playerNumber) !== -1) { playerNumber++; } _storage.username = 'Oyuncu ' + playerNumber; } // Create animated play button for main menu var playButton = LK.getAsset('playButtonMain', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 120, alpha: 1.0 }); playButton.tint = 0xFF9800; // Flappy Bird orange try { if (LK.gui && LK.gui.center) { LK.gui.center.addChild(playButton); playButton.y = -100; } } catch (e) { console.log("Play button error:", e); } // Create separate play button shadow element var playButtonShadow = LK.getAsset('playButtonShadow', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 120, alpha: 0.4 }); playButtonShadow.tint = 0xE65100; // Darker orange shadow try { if (LK.gui && LK.gui.center) { LK.gui.center.addChild(playButtonShadow); playButtonShadow.y = -92; // Offset shadow slightly up playButtonShadow.x = 4; // Offset shadow slightly right } } catch (e) { console.log("Play button shadow error:", e); } // Create separate play button highlight element var playButtonHighlight = LK.getAsset('playButtonHighlight', { anchorX: 0.5, anchorY: 0.5, width: 370, height: 95, alpha: 0.5 }); playButtonHighlight.tint = 0xFFB74D; // Lighter orange highlight try { if (LK.gui && LK.gui.center) { LK.gui.center.addChild(playButtonHighlight); playButtonHighlight.y = -108; // Offset highlight slightly down } } catch (e) { console.log("Play button highlight error:", e); } // Create separate play button text element var playButtonText = new Text2('OYNA', { size: 50, fill: 0xFFFFFF }); playButtonText.anchor.set(0.5, 0.5); playButtonText.stroke = 0xE65100; playButtonText.strokeThickness = 4; try { if (LK.gui && LK.gui.center) { LK.gui.center.addChild(playButtonText); playButtonText.y = -100; } } catch (e) { console.log("Play button text error:", e); } // 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; // Simple visual feedback without complex animations showSettingsMenu(); return; } // Check close settings button if settings menu is open if (settingsOverlay.visible) { // Add invisible barriers between menu sections to prevent overlapping clicks // Speed menu section barrier (between speed and language menus) if (speedMenuButton.visible && !speedOverlay.visible && !languageOverlay.visible) { // Check speed menu button (HIZ) with isolated click area if (x >= 824 && x <= 1224 && y >= 1166 && y <= 1266) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; // Simple visual feedback speedMenuButton.tint = 0x5DADE2; LK.setTimeout(function () { speedMenuButton.tint = 0x3498DB; }, 150); showSpeedControls(); return; } // Barrier zone between speed and language buttons (y: 1266-1296) if (y >= 1266 && y <= 1296) { return; // Block clicks in the barrier zone } } // Language menu section barrier if (languageMenuButton.visible && !speedOverlay.visible && !languageOverlay.visible) { // Check language menu button (DIL) with isolated click area if (x >= 824 && x <= 1224 && y >= 1296 && y <= 1396) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; // Simple visual feedback languageMenuButton.tint = 0xBB8FCE; LK.setTimeout(function () { languageMenuButton.tint = 0x9B59B6; }, 150); showLanguageControls(); return; } } // Language control buttons with barriers - only when language overlay is visible if (languageOverlay.visible) { // Turkish language button with isolated click area if (turkishButton.visible && x >= 654 && x <= 954 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; // Simple visual feedback turkishButton.tint = 0x58D68D; LK.setTimeout(function () { turkishButton.tint = 0x27AE60; }, 150); setLanguage('tr'); return; } // Barrier zone between Turkish and English buttons (x: 954-1094) if (x >= 954 && x <= 1094 && y >= 1246 && y <= 1326) { return; // Block clicks in barrier zone } // English language button with isolated click area if (englishButton.visible && x >= 1094 && x <= 1394 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; // Simple visual feedback englishButton.tint = 0x85C1E9; LK.setTimeout(function () { englishButton.tint = 0x3498DB; }, 150); setLanguage('en'); return; } } // Speed control buttons with barriers - only when speed overlay is visible if (speedOverlay.visible) { // Normal speed button with isolated click area if (normalSpeedButton.visible && x >= 644 && x <= 844 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; // Simple visual feedback normalSpeedButton.tint = 0x58D68D; LK.setTimeout(function () { normalSpeedButton.tint = 0x27AE60; }, 150); setGameSpeed(1); return; } // Barrier zone between normal and 1.5x buttons (x: 844-924) if (x >= 844 && x <= 924 && y >= 1246 && y <= 1326) { return; // Block clicks in barrier zone } // 1.5X speed button with isolated click area if (speed15xButton.visible && x >= 924 && x <= 1124 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; // Simple visual feedback speed15xButton.tint = 0xF7DC6F; LK.setTimeout(function () { speed15xButton.tint = 0xF39C12; }, 150); setGameSpeed(1.5); return; } // Barrier zone between 1.5x and 2x buttons (x: 1124-1164) if (x >= 1124 && x <= 1164 && y >= 1246 && y <= 1326) { return; // Block clicks in barrier zone } // 2X speed button with isolated click area if (speed2xButton.visible && x >= 1164 && x <= 1344 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; // Simple visual feedback speed2xButton.tint = 0xF1948A; LK.setTimeout(function () { speed2xButton.tint = 0xE74C3C; }, 150); setGameSpeed(2); return; } // Barrier zone between 2x and 2.5x buttons (x: 1344-1384) if (x >= 1344 && x <= 1384 && y >= 1246 && y <= 1326) { return; // Block clicks in barrier zone } // 2.5X speed button with isolated click area if (speed25xButton.visible && x >= 1384 && x <= 1564 && y >= 1246 && y <= 1326) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) return; lastButtonClickTime = currentTime; // Simple visual feedback speed25xButton.tint = 0xBA68C8; LK.setTimeout(function () { speed25xButton.tint = 0x9C27B0; }, 150); setGameSpeed(2.5); 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; // Simple visual feedback speedBackButton.tint = 0xABB2B9; LK.setTimeout(function () { speedBackButton.tint = 0x7F8C8D; }, 150); 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; // Simple visual feedback languageBackButton.tint = 0xABB2B9; LK.setTimeout(function () { languageBackButton.tint = 0x7F8C8D; }, 150); 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; // Simple visual feedback closeSettingsButton.tint = 0xBDC3C7; LK.setTimeout(function () { closeSettingsButton.tint = 0x95A5A6; }, 150); 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) { var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 500) return; lastButtonClickTime = currentTime; // Simple high score display var highScore = _storage && _storage.highScore || 0; console.log(getText('highestScore') + ': ' + highScore); return; } if (gameOver || showGameOver) { // Check retry button (TEKRAR DENE) - centered at 1024x1466, button is 380x110 if (x >= 834 && x <= 1214 && y >= 1411 && y <= 1521) { // Prevent rapid clicks var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) { return; // Ignore click if too recent } lastButtonClickTime = currentTime; // Simple visual feedback retryButton.tint = 0xFFB74D; LK.setTimeout(function () { retryButton.tint = 0xFF9800; }, 150); hideGameOverScreen(); resetGame(); // Show instruction screen instead of starting game directly startGameFromMenu(); return; } // Check menu button (ANA MENÜ) - centered at 1024x1616, button is 380x110 if (x >= 834 && x <= 1214 && y >= 1561 && y <= 1671) { // Prevent rapid clicks var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) { return; // Ignore click if too recent } lastButtonClickTime = currentTime; // Simple visual feedback menuButton.tint = 0xF1948A; LK.setTimeout(function () { menuButton.tint = 0xF44336; }, 150); hideGameOverScreen(); resetGame(); return; } return; } if (showMainMenu) { // Check play button click - centered at 1024x1266 (center.y = 1366 + playButton.y = -100), button is 400x120 if (playButton && playButton.visible && x >= 824 && x <= 1224 && y >= 1206 && y <= 1326) { // Prevent rapid clicks var currentTime = Date.now(); if (currentTime - lastButtonClickTime < 300) { return; // Ignore click if too recent } lastButtonClickTime = currentTime; // Simple click feedback without heavy animations playButton.tint = 0xFFB74D; LK.setTimeout(function () { playButton.tint = 0xFF9800; }, 100); startGameFromMenu(); return; } return; } if (!gameStarted) { gameStarted = true; instructionTxt.visible = false; } 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; // High score is automatically saved to persistent storage via _storage reference } // 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; } // Simplified pipe cleanup - remove pipes that are far behind bird for (var i = pipes.length - 1; i >= 0; i--) { var pipe = pipes[i]; if (!pipe || pipe.destroyed) { pipes.splice(i, 1); continue; } // Remove pipes that are very far behind (more than 800px) if (pipe.x < bird.x - 800) { pipe.destroy(); pipes.splice(i, 1); } } // Process only nearby pipes for collision and scoring for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; // Skip pipes that are too far away if (Math.abs(pipe.x - bird.x) > 300) continue; // Initialize lastX tracking if (typeof pipe.lastX === 'undefined') { pipe.lastX = pipe.x; } // Scoring check if (!pipe.passed && pipe.lastX >= bird.x && pipe.x < bird.x) { pipe.passed = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore().toString()); try { LK.getSound('score').play(); } catch (e) {} } // Update last position pipe.lastX = pipe.x; // Simplified collision check - only if bird is very close var xDiff = Math.abs(pipe.x - bird.x); if (xDiff < 80) { // Quick horizontal collision check if (bird.x + 40 > pipe.x - 60 && bird.x - 40 < pipe.x + 60) { // Quick vertical collision check var gapTop = pipe.gapCenterY - pipe.gapSize / 2; var gapBottom = pipe.gapCenterY + pipe.gapSize / 2; if (bird.y - 40 < gapTop || bird.y + 40 > gapBottom) { gameOver = true; var currentScore = LK.getScore(); _storage.lastScore = currentScore; if (currentScore > (_storage.highScore || 0)) { _storage.highScore = currentScore; } showGameOverScreen(currentScore); return; } } } } } };
===================================================================
--- original.js
+++ change.js
@@ -39,21 +39,21 @@
self.y = 1366;
return;
}
// Simple physics
- var gravity = baseGravity * gameSpeed;
- self.velocity += gravity;
+ self.velocity += baseGravity * gameSpeed;
self.y += self.velocity;
- // Simple rotation
- birdGraphics.rotation = Math.max(-0.6, Math.min(1.2, self.velocity * 0.08));
+ // Simple rotation - reduce calculation frequency
+ if (LK.ticks % 3 === 0) {
+ birdGraphics.rotation = Math.max(-0.6, Math.min(1.2, self.velocity * 0.08));
+ }
// Screen bounds collision
- var birdRadius = 40;
- if (self.y - birdRadius < 0) {
- self.y = birdRadius;
+ if (self.y < 40) {
+ self.y = 40;
self.velocity = 0;
}
- if (self.y + birdRadius > 2732 - 150) {
- self.y = 2732 - 150 - birdRadius;
+ if (self.y > 2582) {
+ self.y = 2582;
self.velocity = 0;
}
};
return self;
@@ -106,9 +106,9 @@
self.update = function () {
if (!gameStarted) {
return;
}
- self.speed = basePipeSpeed * gameSpeed;
+ // Use pre-calculated speed instead of calculating every frame
self.x += self.speed;
};
return self;
});
@@ -1947,44 +1947,26 @@
}
showGameOverScreen(currentScore);
return;
}
- // Efficient pipe management system - keep only 10 pipes ahead and remove 10 pipes behind
- var pipesAhead = [];
- var pipesBehind = [];
- var activePipes = [];
- // Categorize pipes based on bird position
- for (var i = 0; i < pipes.length; i++) {
+ // Simplified pipe cleanup - remove pipes that are far behind bird
+ for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
- if (!pipe || pipe.destroyed) continue;
- if (pipe.x > bird.x) {
- pipesAhead.push(pipe);
- } else if (pipe.x < bird.x - 200) {
- pipesBehind.push(pipe);
- } else {
- activePipes.push(pipe);
+ if (!pipe || pipe.destroyed) {
+ pipes.splice(i, 1);
+ continue;
}
- }
- // Remove excess pipes behind bird (keep only 10 behind)
- if (pipesBehind.length > 10) {
- // Sort by x position and remove the furthest back pipes
- pipesBehind.sort(function (a, b) {
- return a.x - b.x;
- });
- var pipesToRemove = pipesBehind.length - 10;
- for (var i = 0; i < pipesToRemove; i++) {
- var pipeToRemove = pipesBehind[i];
- pipeToRemove.destroy();
- // Remove from main pipes array
- var pipeIndex = pipes.indexOf(pipeToRemove);
- if (pipeIndex !== -1) {
- pipes.splice(pipeIndex, 1);
- }
+ // Remove pipes that are very far behind (more than 800px)
+ if (pipe.x < bird.x - 800) {
+ pipe.destroy();
+ pipes.splice(i, 1);
}
}
- // Process only active pipes for collision and scoring
- for (var i = 0; i < activePipes.length; i++) {
- var pipe = activePipes[i];
+ // Process only nearby pipes for collision and scoring
+ for (var i = 0; i < pipes.length; i++) {
+ var pipe = pipes[i];
+ // Skip pipes that are too far away
+ if (Math.abs(pipe.x - bird.x) > 300) continue;
// Initialize lastX tracking
if (typeof pipe.lastX === 'undefined') {
pipe.lastX = pipe.x;
}
@@ -1998,17 +1980,17 @@
} catch (e) {}
}
// Update last position
pipe.lastX = pipe.x;
- // Quick collision check - only if bird is very close
- if (Math.abs(pipe.x - bird.x) < 80) {
- var pipeHalfWidth = 60; // Fixed width for performance
- if (bird.x + 40 > pipe.x - pipeHalfWidth && bird.x - 40 < pipe.x + pipeHalfWidth) {
- var birdTop = bird.y - 40;
- var birdBottom = bird.y + 40;
+ // Simplified collision check - only if bird is very close
+ var xDiff = Math.abs(pipe.x - bird.x);
+ if (xDiff < 80) {
+ // Quick horizontal collision check
+ if (bird.x + 40 > pipe.x - 60 && bird.x - 40 < pipe.x + 60) {
+ // Quick vertical collision check
var gapTop = pipe.gapCenterY - pipe.gapSize / 2;
var gapBottom = pipe.gapCenterY + pipe.gapSize / 2;
- if (birdTop < gapTop || birdBottom > gapBottom) {
+ if (bird.y - 40 < gapTop || bird.y + 40 > gapBottom) {
gameOver = true;
var currentScore = LK.getScore();
_storage.lastScore = currentScore;
if (currentScore > (_storage.highScore || 0)) {