User prompt
oyundaki düğmeleri kodları herşeyi düzelt
User prompt
oyuna ve skor tuşları da çalışsın oynaya basınca oyun başlasın skor tuşuna basınca hem bizim en yüksek rekorumuz ve diğer kullanıcıların rekorları gözüksün ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyun ilk açıldığında direkt oyunu başlatma yeri açılmasın. O menüden önce bir menü olsun ve oyuna giriş tuşu olsun, skor tuşumuz olsun gibi gibi.
User prompt
Tüm duvarlar birbirine eşit uzaklıkta olacak yeter artık.
User prompt
İlk iki duvarın bir-birinə uzaqlığı iyi ikən üçüncü duvar ikinci duvara aşırı uzaq.
User prompt
Duvarlar birbirine yani uzaklık olarak ne uzak ne yakın olacak.
User prompt
Oyun kasmasın diye stunları birbirinden uzak yapıyorsan bu kötü birşey. Oyundaki zaten amaç duvarların arasından geçmek. Oyuncuyu oyunda tutmak. O yüzden duvarlar arası uzaklığı eşit yap.
User prompt
İlk İki Duvar Yani İlk İki Skoru Kazanmak Kolayken Üçüncü Skor Yani Üçüncü Duvar Stunu Çok Uzak Aşırı Uzak Bu Stunları Eşit Yap Ve Uzaklıkları Eşit Olsun
User prompt
Tıkla ve oyna yazısına tıklayınca yazı kayboluyor ama arkasındaki renk yani siyah şey kaybolmuyor.
User prompt
Tıkla ve oyna yazısının altına renk koy. Böylece tıkla ve oyna yazısı gözükecek.
User prompt
İlk iki duvar arasında neredeyse hiç boşluk yokken, iki ile üçüncü duvar arasında aşırı uzun bir boşluk var. Orantıyı tuttur.
User prompt
Kuşu hareket ettirdikten sonra rahat bırakıp yere düştüğünü izlerken oyun kasıyor.
User prompt
Duvar aralıqlarını çox dar yapmışsın. Duvarlar arası boşluq yox. Gerçək Flappy Birddən əsinlənərək oyunu təkrar duvarlar arasını genişlət.
User prompt
tamam oyun başlamadığında kuş hareket etmiyor ama kuşu hareket ettirmeye başladığımızda kuşun en son gittiği yerden puan başlıyor yani kuş hareket etmese de dümdüz hareket ediyor ve duvarlardan hasar almıyor kuş hareket etmesin diye sıkıştır
User prompt
Oyun başlamadan önce kuş hareket etmesin diye kuşu bloklar arasına sıkıştır ama bu bloklar bize gözükmesin oyun başladığında bunlar silinsin.
User prompt
oyun başladığında ekranda yazık kalıyor ve duvarlar çok dar
User prompt
Oyundaki tüm kodları her şeyi sil ve baştan yaz.
User prompt
oyundaki tüm duvar kodlarını kontrol et ve tekrar yaz
User prompt
Arasından geçtiklerimizin yukarıdaki yok yani arasından geçmiyoruz üstünden geçiyor oluyoruz Flappy Bird'den örnek alarak oyunu düzelt
User prompt
Arasından geçtiğimiz sütunlar yukarıdakiler silindi ekle ve yukarıdaki en yüksek yere kadar çıksınlar hani ekranda gözüken
User prompt
Arasından Geçtiklerimizi Duvar Olarak Aşağı Ve Yukarıya Orantıla Boşluk Kalmasın Ve En Fazla
User prompt
şu ana kadar yaptığımız hiç kasmayan haline getir
User prompt
Arasından geçtiğimiz stumların kalitesini biraz düşür
User prompt
Her Geçtiğimiz İki Stun'dan Sonra Arkaya Giden Stun'ları Sil Yani Ekranda Gözükmeyen
User prompt
250 ms kapıyı aç
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); 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; LK.getSound('flap').play(); }; 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('pipe', { anchorX: 0.5, anchorY: 1 }); topPipe.y = gapCenterY - self.gapSize / 2; topPipe.height = gapCenterY - self.gapSize / 2; // Create bottom pipe var bottomPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0 }); bottomPipe.y = gapCenterY + self.gapSize / 2; bottomPipe.height = 2732 - 150 - (gapCenterY + self.gapSize / 2); 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({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var bird; var pipes = []; var ground; var gameStarted = false; var gameOver = false; var showMainMenu = true; var showLeaderboard = false; var pipeSpacing = 600; // Consistent spacing between all pipes - balanced distance // 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; // 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 var playButton = LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80, alpha: 0.9 }); playButton.tint = 0x32CD32; LK.gui.center.addChild(playButton); playButton.y = 0; 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 = 0; // Create score button var scoreButton = LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80, alpha: 0.9 }); scoreButton.tint = 0x4169E1; LK.gui.center.addChild(scoreButton); scoreButton.y = 100; 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 = 100; // 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('ground', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 100, alpha: 0.8 }); instructionBg.tint = 0x000000; instructionBg.visible = false; LK.gui.center.addChild(instructionBg); LK.gui.center.addChild(instructionTxt); // 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 = -250; 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 = -150; 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 = -50; // Create back button for leaderboard var backButton = LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80, alpha: 0.9 }); backButton.tint = 0xFF4500; backButton.visible = false; LK.gui.center.addChild(backButton); backButton.y = 100; 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 = 100; // Create bird bird = game.addChild(new Bird()); bird.x = 400; bird.y = 1366; // 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 ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1 })); ground.x = 0; ground.y = 2732; // Create pipe function function createPipe() { var minGapY = 500; var maxGapY = 2032; // 2732 - 150 - 600 (adjusted for larger gap) 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 + 200; // First pipe position } 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 leaderboardTitle.visible = false; highScoreText.visible = false; currentScoreText.visible = false; backButton.visible = false; backButtonText.visible = false; // 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; } // 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 leaderboardTitle.visible = true; highScoreText.visible = true; currentScoreText.visible = true; backButton.visible = true; backButtonText.visible = true; // Update score displays var highScore = storage.highScore || 0; var lastScore = storage.lastScore || 0; highScoreText.setText('EN YÜKSEK SKOR: ' + highScore); currentScoreText.setText('SON SKOR: ' + lastScore); } // Function to hide leaderboard and return to main menu function hideLeaderboard() { showLeaderboard = false; showMainMenu = true; // Hide leaderboard elements leaderboardTitle.visible = false; highScoreText.visible = false; currentScoreText.visible = false; backButton.visible = false; backButtonText.visible = false; // Show main menu elements mainMenuTitle.visible = true; playButton.visible = true; playButtonText.visible = true; scoreButton.visible = true; scoreButtonText.visible = true; } // Initialize game createPipe(); createPipe(); // Touch/click handler game.down = function (x, y, obj) { if (gameOver) { resetGame(); return; } if (showMainMenu) { // Convert screen coordinates to GUI coordinates var guiPos = LK.gui.center.toLocal({ x: x, y: y }); // Check if play button was clicked if (guiPos.x >= -150 && guiPos.x <= 150 && guiPos.y >= -40 && guiPos.y <= 40) { startGameFromMenu(); return; } // Check if score button was clicked if (guiPos.x >= -150 && guiPos.x <= 150 && guiPos.y >= 60 && guiPos.y <= 140) { showLeaderboardScreen(); return; } return; } if (showLeaderboard) { // Convert screen coordinates to GUI coordinates var guiPos = LK.gui.center.toLocal({ x: x, y: y }); // Check if back button was clicked if (guiPos.x >= -150 && guiPos.x <= 150 && guiPos.y >= 60 && guiPos.y <= 140) { hideLeaderboard(); 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 collision if (bird.y + 20 >= 2732 - 150) { gameOver = true; // Save score before showing game over var currentScore = LK.getScore(); storage.lastScore = currentScore; if (currentScore > (storage.highScore || 0)) { storage.highScore = currentScore; } LK.showGameOver(); return; } // Check ceiling collision if (bird.y - 20 <= 0) { gameOver = true; // Save score before showing game over var currentScore = LK.getScore(); storage.lastScore = currentScore; if (currentScore > (storage.highScore || 0)) { storage.highScore = currentScore; } LK.showGameOver(); return; } // Check pipe collisions and scoring - only check pipes that are near the bird for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; // Only check pipes that are within reasonable distance of 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 pipe if (bird.y - 20 < pipe.gapCenterY - pipe.gapSize / 2) { gameOver = true; // Save score before showing game over var currentScore = LK.getScore(); storage.lastScore = currentScore; if (currentScore > (storage.highScore || 0)) { storage.highScore = currentScore; } LK.showGameOver(); return; } // Check collision with bottom pipe if (bird.y + 20 > pipe.gapCenterY + pipe.gapSize / 2) { gameOver = true; // Save score before showing game over var currentScore = LK.getScore(); storage.lastScore = currentScore; if (currentScore > (storage.highScore || 0)) { storage.highScore = currentScore; } LK.showGameOver(); 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()); LK.getSound('score').play(); } } // Create new pipes - maintain consistent spacing if (pipes.length === 0 || pipes.length > 0 && pipes[pipes.length - 1].x <= 2048 + 200 - pipeSpacing) { createPipe(); } // Remove off-screen pipes - only check every 10 frames to reduce lag if (LK.ticks % 10 === 0) { for (var j = pipes.length - 1; j >= 0; j--) { if (pipes[j].x < -150) { pipes[j].destroy(); pipes.splice(j, 1); } } } } };
===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,9 @@
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
@@ -84,8 +85,9 @@
var ground;
var gameStarted = false;
var gameOver = false;
var showMainMenu = true;
+var showLeaderboard = false;
var pipeSpacing = 600; // Consistent spacing between all pipes - balanced distance
// Create score display
var scoreTxt = new Text2('SKOR: 0', {
size: 80,
@@ -166,8 +168,61 @@
instructionBg.tint = 0x000000;
instructionBg.visible = false;
LK.gui.center.addChild(instructionBg);
LK.gui.center.addChild(instructionTxt);
+// 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 = -250;
+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 = -150;
+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 = -50;
+// Create back button for leaderboard
+var backButton = LK.getAsset('ground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 300,
+ height: 80,
+ alpha: 0.9
+});
+backButton.tint = 0xFF4500;
+backButton.visible = false;
+LK.gui.center.addChild(backButton);
+backButton.y = 100;
+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 = 100;
// Create bird
bird = game.addChild(new Bird());
bird.x = 400;
bird.y = 1366;
@@ -222,8 +277,9 @@
// Reset variables
gameStarted = false;
gameOver = false;
showMainMenu = true;
+ showLeaderboard = false;
LK.setScore(0);
scoreTxt.setText('SKOR: 0');
// Show main menu
mainMenuTitle.visible = true;
@@ -233,8 +289,14 @@
scoreButtonText.visible = true;
// Hide instruction
instructionTxt.visible = false;
instructionBg.visible = false;
+ // Hide leaderboard elements
+ leaderboardTitle.visible = false;
+ highScoreText.visible = false;
+ currentScoreText.visible = false;
+ backButton.visible = false;
+ backButtonText.visible = false;
// Recreate invisible barriers
topBarrier = game.addChild(LK.getAsset('barrier', {
anchorX: 0.5,
anchorY: 1
@@ -265,8 +327,47 @@
// Show instruction
instructionTxt.visible = true;
instructionBg.visible = true;
}
+// 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
+ leaderboardTitle.visible = true;
+ highScoreText.visible = true;
+ currentScoreText.visible = true;
+ backButton.visible = true;
+ backButtonText.visible = true;
+ // Update score displays
+ var highScore = storage.highScore || 0;
+ var lastScore = storage.lastScore || 0;
+ highScoreText.setText('EN YÜKSEK SKOR: ' + highScore);
+ currentScoreText.setText('SON SKOR: ' + lastScore);
+}
+// Function to hide leaderboard and return to main menu
+function hideLeaderboard() {
+ showLeaderboard = false;
+ showMainMenu = true;
+ // Hide leaderboard elements
+ leaderboardTitle.visible = false;
+ highScoreText.visible = false;
+ currentScoreText.visible = false;
+ backButton.visible = false;
+ backButtonText.visible = false;
+ // Show main menu elements
+ mainMenuTitle.visible = true;
+ playButton.visible = true;
+ playButtonText.visible = true;
+ scoreButton.visible = true;
+ scoreButtonText.visible = true;
+}
// Initialize game
createPipe();
createPipe();
// Touch/click handler
@@ -287,13 +388,26 @@
return;
}
// Check if score button was clicked
if (guiPos.x >= -150 && guiPos.x <= 150 && guiPos.y >= 60 && guiPos.y <= 140) {
- LK.showLeaderboard();
+ showLeaderboardScreen();
return;
}
return;
}
+ if (showLeaderboard) {
+ // Convert screen coordinates to GUI coordinates
+ var guiPos = LK.gui.center.toLocal({
+ x: x,
+ y: y
+ });
+ // Check if back button was clicked
+ if (guiPos.x >= -150 && guiPos.x <= 150 && guiPos.y >= 60 && guiPos.y <= 140) {
+ hideLeaderboard();
+ return;
+ }
+ return;
+ }
if (!gameStarted) {
gameStarted = true;
instructionTxt.visible = false;
instructionBg.visible = false;
@@ -310,20 +424,32 @@
bird.flap();
};
// Main game loop
game.update = function () {
- if (gameOver || showMainMenu) return;
+ if (gameOver || showMainMenu || showLeaderboard) return;
// Only run game logic if game has started
if (gameStarted) {
// Check ground collision
if (bird.y + 20 >= 2732 - 150) {
gameOver = true;
+ // Save score before showing game over
+ var currentScore = LK.getScore();
+ storage.lastScore = currentScore;
+ if (currentScore > (storage.highScore || 0)) {
+ storage.highScore = currentScore;
+ }
LK.showGameOver();
return;
}
// Check ceiling collision
if (bird.y - 20 <= 0) {
gameOver = true;
+ // Save score before showing game over
+ var currentScore = LK.getScore();
+ storage.lastScore = currentScore;
+ if (currentScore > (storage.highScore || 0)) {
+ storage.highScore = currentScore;
+ }
LK.showGameOver();
return;
}
// Check pipe collisions and scoring - only check pipes that are near the bird
@@ -335,14 +461,26 @@
if (bird.x + 30 > pipe.x - 50 && bird.x - 30 < pipe.x + 50) {
// Check collision with top pipe
if (bird.y - 20 < pipe.gapCenterY - pipe.gapSize / 2) {
gameOver = true;
+ // Save score before showing game over
+ var currentScore = LK.getScore();
+ storage.lastScore = currentScore;
+ if (currentScore > (storage.highScore || 0)) {
+ storage.highScore = currentScore;
+ }
LK.showGameOver();
return;
}
// Check collision with bottom pipe
if (bird.y + 20 > pipe.gapCenterY + pipe.gapSize / 2) {
gameOver = true;
+ // Save score before showing game over
+ var currentScore = LK.getScore();
+ storage.lastScore = currentScore;
+ if (currentScore > (storage.highScore || 0)) {
+ storage.highScore = currentScore;
+ }
LK.showGameOver();
return;
}
}