User prompt
Yüksek skoru gösteren tablonun rengini daha belirgin yap.
User prompt
en yüksek skoru gösteren şeyi rengini daha belirgin yap
User prompt
Ən yüksək skoru sadəcə bir kərə deyil, hər tıxladığımızda göstərsin. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Kupaya dokununca en yüksek skorumuzu göstersin. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
kupaya dokununca en yüksek skorumuzu göstersin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Orta en üstte olan skor yazısını geri getir.
User prompt
Duvarın arasından geçerken oyunun donması ile ilgili hatayı düzelt.
User prompt
oyuna tuşunun altındaki skor yazısını ve tuşunu kaldır
User prompt
Score tablosunu sil
User prompt
Kupa logosunu biraz yukarı
User prompt
Kupa logosunu biraz yukarı
User prompt
Kupa logosunu biraz yukarı çok az
User prompt
Sadece kupa logosunu sağ alta al.
User prompt
skor yazısını tam ortaya en üstte al
User prompt
sarı yuvarlak şeyi sil skor yazısını sola çek
User prompt
Skor yazısını sağ 6'a alıp kupa şekline getir.
User prompt
Oynatışını yuvarlak ova şekle getir.
User prompt
Oyuncu ismini kaldır.
User prompt
Oyunu başlatan düğmeyi oval bir şekle getir.
User prompt
arka plandaki resmin niye yüklenmesi uzun sürüyor onu düzelt
User prompt
Oyunun açılmamasının sebebi başka cihazlarda veri toplamayla ilgili bir şey olabilir. Veri toplamayla ilgili herşeyi sil.
User prompt
Oyunun açılırken bekletmesi ve yüklenme hataları vermesiyle beraber tüm hataları düzelt.
User prompt
Arasından geçtiğimiz duvarların ikisini de açık yeşil rengine boya.
User prompt
Alttaki duvarda yeşil yapı
User prompt
Kızını eski haline getir.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.velocity = 0; self.gravity = 0.8; self.jumpStrength = -12; self.flap = function () { self.velocity = self.jumpStrength; try { LK.getSound('flap').play(); } catch (e) { console.log("Flap sound error:", e); } }; self.update = function () { if (!gameStarted) { // Don't apply physics before game starts - keep bird completely still self.velocity = 0; self.y = 1366; // Keep bird at starting position birdGraphics.rotation = 0; // Keep bird level return; } self.velocity += self.gravity; self.y += self.velocity; // Rotate bird based on velocity birdGraphics.rotation = Math.max(-0.5, Math.min(1.5, self.velocity * 0.1)); // Limit bird movement to screen bounds if (self.y < 30) { self.y = 30; } }; return self; }); var Pipe = Container.expand(function (gapCenterY) { var self = Container.call(this); self.gapSize = 600; self.speed = -3; self.passed = false; self.gapCenterY = gapCenterY; // Create top pipe 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; // Create bottom pipe 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; self.update = function () { if (!gameStarted) { // Don't move pipes before game starts return; } self.x += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game(); /**** * Game Code ****/ // Game variables var bird; var pipes = []; var ground; var topBarrier; var bottomBarrier; var gameStarted = false; var gameOver = false; var showMainMenu = true; var showLeaderboard = false; var pipeSpacing = 500; // Increased spacing between pipes to make them further apart // Initialize local storage object to prevent undefined errors var _storage = {}; // Create score display var scoreTxt = new Text2('SKOR: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); scoreTxt.stroke = 0x000000; scoreTxt.strokeThickness = 4; LK.gui.top.addChild(scoreTxt); scoreTxt.y = 100; scoreTxt.x = 0; // Create cup shape for score var cupShape = LK.getAsset('cup', { anchorX: 0.5, anchorY: 0 }); cupShape.tint = 0xFFD700; LK.gui.top.addChild(cupShape); cupShape.y = 50; cupShape.x = 0; // Create main menu elements var mainMenuTitle = new Text2('FLAPPY BIRD', { size: 100, fill: 0xFFD700 }); mainMenuTitle.anchor.set(0.5, 0.5); mainMenuTitle.stroke = 0x000000; mainMenuTitle.strokeThickness = 5; LK.gui.center.addChild(mainMenuTitle); mainMenuTitle.y = -200; // 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 score button var scoreButton = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80, alpha: 0.9 }); scoreButton.tint = 0x9370DB; LK.gui.center.addChild(scoreButton); scoreButton.y = 150; var scoreButtonText = new Text2('SKOR', { size: 50, fill: 0xFFFFFF }); scoreButtonText.anchor.set(0.5, 0.5); scoreButtonText.stroke = 0x000000; scoreButtonText.strokeThickness = 3; LK.gui.center.addChild(scoreButtonText); scoreButtonText.y = 150; // 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 leaderboard background var leaderboardBg = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 1800, height: 2200, alpha: 0.95 }); leaderboardBg.tint = 0x2F4F4F; leaderboardBg.visible = false; LK.gui.center.addChild(leaderboardBg); // Create leaderboard elements var leaderboardTitle = new Text2('SKOR TABLOSU', { size: 80, fill: 0xFFD700 }); leaderboardTitle.anchor.set(0.5, 0.5); leaderboardTitle.stroke = 0x000000; leaderboardTitle.strokeThickness = 4; leaderboardTitle.visible = false; LK.gui.center.addChild(leaderboardTitle); leaderboardTitle.y = -350; var highScoreText = new Text2('EN YÜKSEK SKOR: 0', { size: 50, fill: 0xFFFFFF }); highScoreText.anchor.set(0.5, 0.5); highScoreText.stroke = 0x000000; highScoreText.strokeThickness = 3; highScoreText.visible = false; LK.gui.center.addChild(highScoreText); highScoreText.y = -250; var currentScoreText = new Text2('SON SKOR: 0', { size: 50, fill: 0xFFFFFF }); currentScoreText.anchor.set(0.5, 0.5); currentScoreText.stroke = 0x000000; currentScoreText.strokeThickness = 3; currentScoreText.visible = false; LK.gui.center.addChild(currentScoreText); currentScoreText.y = -180; // Create back button for leaderboard var backButton = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80, alpha: 0.9 }); backButton.tint = 0xDC143C; backButton.visible = false; LK.gui.center.addChild(backButton); backButton.y = 350; var backButtonText = new Text2('GERİ', { size: 50, fill: 0xFFFFFF }); backButtonText.anchor.set(0.5, 0.5); backButtonText.stroke = 0x000000; backButtonText.strokeThickness = 3; backButtonText.visible = false; LK.gui.center.addChild(backButtonText); backButtonText.y = 350; // Create pagination buttons var prevPageButton = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 60, alpha: 0.9 }); prevPageButton.tint = 0x20B2AA; prevPageButton.visible = false; LK.gui.center.addChild(prevPageButton); prevPageButton.y = 280; prevPageButton.x = -300; var prevPageText = new Text2('ÖNCEKİ', { size: 35, fill: 0xFFFFFF }); prevPageText.anchor.set(0.5, 0.5); prevPageText.stroke = 0x000000; prevPageText.strokeThickness = 2; prevPageText.visible = false; LK.gui.center.addChild(prevPageText); prevPageText.y = 280; prevPageText.x = -300; var nextPageButton = LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 60, alpha: 0.9 }); nextPageButton.tint = 0x20B2AA; nextPageButton.visible = false; LK.gui.center.addChild(nextPageButton); nextPageButton.y = 280; nextPageButton.x = 300; var nextPageText = new Text2('SONRAKİ', { size: 35, fill: 0xFFFFFF }); nextPageText.anchor.set(0.5, 0.5); nextPageText.stroke = 0x000000; nextPageText.strokeThickness = 2; nextPageText.visible = false; LK.gui.center.addChild(nextPageText); nextPageText.y = 280; nextPageText.x = 300; // Create page indicator var pageIndicator = new Text2('SAYFA 1/10', { size: 40, fill: 0xFFFFFF }); pageIndicator.anchor.set(0.5, 0.5); pageIndicator.stroke = 0x000000; pageIndicator.strokeThickness = 2; pageIndicator.visible = false; LK.gui.center.addChild(pageIndicator); pageIndicator.y = 280; // Create invisible barrier blocks to constrain bird before game starts var topBarrier = game.addChild(LK.getAsset('barrier', { anchorX: 0.5, anchorY: 1 })); topBarrier.x = 400; topBarrier.y = 1316; // 50 pixels above bird topBarrier.alpha = 0; // Make invisible var bottomBarrier = game.addChild(LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0 })); bottomBarrier.x = 400; bottomBarrier.y = 1416; // 50 pixels below bird bottomBarrier.alpha = 0; // Make invisible // Create and add background image (appears behind barriers but in front of other elements) var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0 })); background.x = 0; background.y = 0; // Scale background to fill screen for better performance background.scaleX = 2; background.scaleY = 2; // Create ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1 })); ground.x = 0; ground.y = 2732; ground.tint = 0x654321; // Create bird bird = game.addChild(new Bird()); bird.x = 400; bird.y = 1366; // Create pipe function function createPipe() { // Define safe boundaries for gap center to ensure both pipes have reasonable heights var minGapY = 800; // Minimum gap center position (ensures top pipe has decent height) var maxGapY = 1800; // Maximum gap center position (ensures bottom pipe has decent height) var gapCenterY = minGapY + Math.random() * (maxGapY - minGapY); var pipe = new Pipe(gapCenterY); // Calculate position based on last pipe position + consistent spacing if (pipes.length === 0) { pipe.x = 2048 + 100; // First pipe position - brought closer } else { pipe.x = pipes[pipes.length - 1].x + pipeSpacing; // Consistent spacing from last pipe } pipes.push(pipe); game.addChild(pipe); } // Reset game function function resetGame() { // Reset bird bird.x = 400; bird.y = 1366; bird.velocity = 0; // Clear pipes for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].destroy(); } pipes = []; // Reset variables gameStarted = false; gameOver = false; showMainMenu = true; showLeaderboard = false; LK.setScore(0); scoreTxt.setText('SKOR: 0'); // Show main menu mainMenuTitle.visible = true; playButton.visible = true; playButtonText.visible = true; scoreButton.visible = true; scoreButtonText.visible = true; // Hide instruction instructionTxt.visible = false; instructionBg.visible = false; // Hide leaderboard elements leaderboardBg.visible = false; leaderboardTitle.visible = false; highScoreText.visible = false; currentScoreText.visible = false; backButton.visible = false; backButtonText.visible = false; // Clear existing barriers if they exist if (topBarrier) { topBarrier.destroy(); topBarrier = null; } if (bottomBarrier) { bottomBarrier.destroy(); bottomBarrier = null; } // Recreate invisible barriers topBarrier = game.addChild(LK.getAsset('barrier', { anchorX: 0.5, anchorY: 1 })); topBarrier.x = 400; topBarrier.y = 1316; // 50 pixels above bird topBarrier.alpha = 0; // Make invisible bottomBarrier = game.addChild(LK.getAsset('barrier', { anchorX: 0.5, anchorY: 0 })); bottomBarrier.x = 400; bottomBarrier.y = 1416; // 50 pixels below bird bottomBarrier.alpha = 0; // Make invisible // Create initial pipes createPipe(); createPipe(); } // Function to start game from main menu function startGameFromMenu() { showMainMenu = false; // Hide main menu elements mainMenuTitle.visible = false; playButton.visible = false; playButtonText.visible = false; scoreButton.visible = false; scoreButtonText.visible = false; // Show instruction instructionTxt.visible = true; instructionBg.visible = true; } // Create global leaderboard display elements var globalLeaderboardText = new Text2('GLOBAL LIDERLER:', { size: 50, fill: 0xFFD700 }); globalLeaderboardText.anchor.set(0.5, 0.5); globalLeaderboardText.stroke = 0x000000; globalLeaderboardText.strokeThickness = 3; globalLeaderboardText.visible = false; LK.gui.center.addChild(globalLeaderboardText); globalLeaderboardText.y = -80; var globalScoresList = []; for (var i = 0; i < 5; i++) { var scoreText = new Text2('', { size: 40, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0.5); scoreText.stroke = 0x000000; scoreText.strokeThickness = 2; scoreText.visible = false; LK.gui.center.addChild(scoreText); scoreText.y = -10 + i * 50; globalScoresList.push(scoreText); } // Function to show leaderboard function showLeaderboardScreen() { showMainMenu = false; showLeaderboard = true; // Hide main menu elements mainMenuTitle.visible = false; playButton.visible = false; playButtonText.visible = false; scoreButton.visible = false; scoreButtonText.visible = false; // Show leaderboard elements leaderboardBg.visible = true; leaderboardTitle.visible = true; highScoreText.visible = true; currentScoreText.visible = true; backButton.visible = true; backButtonText.visible = true; globalLeaderboardText.visible = true; prevPageButton.visible = true; prevPageText.visible = true; nextPageButton.visible = true; nextPageText.visible = true; pageIndicator.visible = true; // Update score displays highScoreText.setText('EN YÜKSEK SKOR: ' + (_storage.highScore || 0)); currentScoreText.setText('SON SKOR: ' + (_storage.lastScore || 0)); // Get global leaderboard from storage var globalNames = _storage.globalLeaderboardNames || []; var globalScores = _storage.globalLeaderboardScores || []; // Add current player's high score if it doesn't exist and is greater than 0 var playerExists = false; var currentUsername = _storage.username || 'Oyuncu'; var highScore = _storage.highScore || 0; for (var i = 0; i < globalNames.length; i++) { if (globalNames[i] === currentUsername) { globalScores[i] = Math.max(globalScores[i], highScore); playerExists = true; break; } } if (!playerExists && (_storage.highScore || 0) > 0) { globalNames.push(currentUsername); globalScores.push(_storage.highScore || 0); } // Sort scores in descending order by creating index array var indices = []; for (var i = 0; i < globalScores.length; i++) { indices.push(i); } indices.sort(function (a, b) { return globalScores[b] - globalScores[a]; }); // Create sorted arrays var sortedNames = []; var sortedScores = []; for (var i = 0; i < indices.length; i++) { sortedNames.push(globalNames[indices[i]]); sortedScores.push(globalScores[indices[i]]); } // Save updated leaderboard _storage.globalLeaderboardNames = sortedNames; _storage.globalLeaderboardScores = sortedScores; // Initialize current page if not exists if (!_storage.leaderboardPage) { _storage.leaderboardPage = 0; } // Display global scores with pagination (10 per page) var currentPage = _storage.leaderboardPage || 0; var totalPages = Math.max(1, Math.ceil(sortedNames.length / 10)); var startIndex = currentPage * 10; var endIndex = Math.min(startIndex + 10, sortedNames.length); // Update page indicator if (sortedNames.length === 0) { pageIndicator.setText('HENÜZ OYUNCU YOK'); } else { pageIndicator.setText('SAYFA ' + (currentPage + 1) + '/' + totalPages); } // Update pagination button states prevPageButton.alpha = currentPage > 0 ? 0.9 : 0.3; prevPageText.alpha = currentPage > 0 ? 1.0 : 0.3; nextPageButton.alpha = currentPage < totalPages - 1 ? 0.9 : 0.3; nextPageText.alpha = currentPage < totalPages - 1 ? 1.0 : 0.3; for (var i = 0; i < globalScoresList.length; i++) { var dataIndex = startIndex + i; if (dataIndex < sortedNames.length && dataIndex < endIndex) { var displayText = dataIndex + 1 + '. ' + sortedNames[dataIndex] + ': ' + sortedScores[dataIndex]; globalScoresList[i].setText(displayText); globalScoresList[i].visible = true; // Reset tint for regular players globalScoresList[i].tint = 0xFFFFFF; } else if (i === 0 && sortedNames.length === 0) { // Show message when no players exist yet after clearing data globalScoresList[i].setText('OYUNCU VERİLERİ TEMİZLENDİ - YENİ OYUNCULAR BEKLENİYOR'); globalScoresList[i].visible = true; globalScoresList[i].tint = 0xFFD700; } else { globalScoresList[i].visible = false; } } // Find current player's rank if not in top 100 var playerRank = -1; var playerScore = highScore; for (var i = 0; i < sortedNames.length; i++) { if (sortedNames[i] === currentUsername) { playerRank = i + 1; playerScore = sortedScores[i]; break; } } // Show player's rank separately if not in current page view if (playerRank > 100 || playerRank > endIndex || playerRank <= startIndex) { if (globalScoresList.length > 0) { var lastVisibleIndex = -1; for (var i = globalScoresList.length - 1; i >= 0; i--) { if (globalScoresList[i].visible) { lastVisibleIndex = i; break; } } if (lastVisibleIndex >= 0 && lastVisibleIndex < globalScoresList.length - 1) { var playerText = '--- SİZ: ' + playerRank + '. ' + currentUsername + ': ' + playerScore + ' ---'; globalScoresList[lastVisibleIndex + 1].setText(playerText); globalScoresList[lastVisibleIndex + 1].visible = true; globalScoresList[lastVisibleIndex + 1].tint = 0xFFD700; } } } } // Function to hide leaderboard and return to main menu function hideLeaderboard() { showLeaderboard = false; showMainMenu = true; // Hide leaderboard elements leaderboardBg.visible = false; leaderboardTitle.visible = false; highScoreText.visible = false; currentScoreText.visible = false; backButton.visible = false; backButtonText.visible = false; globalLeaderboardText.visible = false; prevPageButton.visible = false; prevPageText.visible = false; nextPageButton.visible = false; nextPageText.visible = false; pageIndicator.visible = false; // Hide global scores list for (var i = 0; i < globalScoresList.length; i++) { globalScoresList[i].visible = false; } // Show main menu elements mainMenuTitle.visible = true; playButton.visible = true; playButtonText.visible = true; scoreButton.visible = true; scoreButtonText.visible = true; } // Initialize local storage arrays if they don't exist if (!_storage.globalLeaderboardNames) _storage.globalLeaderboardNames = []; if (!_storage.globalLeaderboardScores) _storage.globalLeaderboardScores = []; if (!_storage.highScore) _storage.highScore = 0; if (!_storage.lastScore) _storage.lastScore = 0; if (!_storage.leaderboardPage) _storage.leaderboardPage = 0; // Initialize username if not exists if (!_storage.username) { var playerNumber = 1; while (_storage.globalLeaderboardNames.indexOf('Oyuncu ' + playerNumber) !== -1) { playerNumber++; } _storage.username = 'Oyuncu ' + playerNumber; } // Global leaderboard is now initialized in showLeaderboardScreen function // Initialize game createPipe(); createPipe(); // Touch/click handler game.down = function (x, y, obj) { if (gameOver) { resetGame(); return; } if (showMainMenu) { // Check play button (OYNA) - centered at 1024x1366, button is 300x80 if (x >= 874 && x <= 1174 && y >= 1326 && y <= 1406) { // 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 LK.setTimeout(function () { startGameFromMenu(); }, 150); return; } // Check score button (SKOR) - centered at 1024x1366, button is 300x80 if (x >= 874 && x <= 1174 && y >= 1476 && y <= 1556) { // Add visual feedback with tween tween(scoreButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(scoreButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); // Add small delay to prevent double clicks LK.setTimeout(function () { showLeaderboardScreen(); }, 150); return; } return; } if (showLeaderboard) { // Check back button (GERİ) - centered at 1024x1716, button is 300x80 if (x >= 874 && x <= 1174 && y >= 1676 && y <= 1756) { // Add visual feedback with tween tween(backButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(backButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 100 }); } }); // Add small delay to prevent double clicks LK.setTimeout(function () { hideLeaderboard(); }, 150); return; } // Check previous page button - centered at 724x1646, button is 200x60 if (x >= 624 && x <= 824 && y >= 1616 && y <= 1676) { var currentPage = _storage.leaderboardPage || 0; if (currentPage > 0) { _storage.leaderboardPage = currentPage - 1; showLeaderboardScreen(); } return; } // Check next page button - centered at 1324x1646, button is 200x60 if (x >= 1224 && x <= 1424 && y >= 1616 && y <= 1676) { var currentPage = _storage.leaderboardPage || 0; var totalPages = Math.ceil((_storage.globalLeaderboardNames || []).length / 10); if (currentPage < totalPages - 1) { _storage.leaderboardPage = currentPage + 1; showLeaderboardScreen(); } return; } return; } if (!gameStarted) { gameStarted = true; instructionTxt.visible = false; instructionBg.visible = false; // Remove invisible barriers when game starts if (topBarrier) { topBarrier.destroy(); topBarrier = null; } if (bottomBarrier) { bottomBarrier.destroy(); bottomBarrier = null; } } bird.flap(); }; // Main game loop game.update = function () { if (gameOver || showMainMenu || showLeaderboard) return; // Only run game logic if game has started if (gameStarted) { // Check ground and ceiling collision if (bird.y + 20 >= 2732 - 150 || bird.y - 20 <= 0) { gameOver = true; var currentScore = LK.getScore(); _storage.lastScore = currentScore; if (currentScore > (_storage.highScore || 0)) { _storage.highScore = currentScore; } // Add to leaderboard if score > 0 if (currentScore > 0) { var currentUsername = _storage.username; var playerExists = false; for (var i = 0; i < _storage.globalLeaderboardNames.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); } } resetGame(); return; } // Check pipe collisions and scoring for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; if (!pipe || !bird) continue; // Only check pipes near the bird if (Math.abs(pipe.x - bird.x) < 200) { // Check if bird is within pipe horizontally if (bird.x + 30 > pipe.x - 50 && bird.x - 30 < pipe.x + 50) { // Check collision with top or bottom pipe if (bird.y - 20 < pipe.gapCenterY - pipe.gapSize / 2 || bird.y + 20 > pipe.gapCenterY + pipe.gapSize / 2) { gameOver = true; var currentScore = LK.getScore(); _storage.lastScore = currentScore; if (currentScore > (_storage.highScore || 0)) { _storage.highScore = currentScore; } // Add to leaderboard if score > 0 if (currentScore > 0) { var currentUsername = _storage.username; var playerExists = false; for (var j = 0; j < _storage.globalLeaderboardNames.length; j++) { if (_storage.globalLeaderboardNames[j] === currentUsername) { if (currentScore > _storage.globalLeaderboardScores[j]) { _storage.globalLeaderboardScores[j] = currentScore; } playerExists = true; break; } } if (!playerExists) { _storage.globalLeaderboardNames.push(currentUsername); _storage.globalLeaderboardScores.push(currentScore); } } resetGame(); return; } } } // Check scoring - 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('SKOR: ' + LK.getScore()); try { LK.getSound('score').play(); } catch (e) { console.log("Sound error:", e); } } } // 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 every 30 frames if (LK.ticks % 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
@@ -101,23 +101,23 @@
var scoreTxt = new Text2('SKOR: 0', {
size: 80,
fill: 0xFFFFFF
});
-scoreTxt.anchor.set(0, 0);
+scoreTxt.anchor.set(0.5, 0);
scoreTxt.stroke = 0x000000;
scoreTxt.strokeThickness = 4;
-LK.gui.topLeft.addChild(scoreTxt);
+LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
-scoreTxt.x = 120;
+scoreTxt.x = 0;
// Create cup shape for score
var cupShape = LK.getAsset('cup', {
- anchorX: 0,
+ anchorX: 0.5,
anchorY: 0
});
cupShape.tint = 0xFFD700;
-LK.gui.topLeft.addChild(cupShape);
+LK.gui.top.addChild(cupShape);
cupShape.y = 50;
-cupShape.x = 120;
+cupShape.x = 0;
// Create main menu elements
var mainMenuTitle = new Text2('FLAPPY BIRD', {
size: 100,
fill: 0xFFD700