User prompt
Oyunun açılmasıyla ilgili hataları düzelt
User prompt
kuşun hızıyla ilgili hataları düzelt
User prompt
oyun başladığında ayarlar kısmıyla yüksek skor kısmı gözükmesin
User prompt
en iyi skoru kaydetmesiyle ilgili bir hata var kaydetmiyor
User prompt
hız seçenekleri sırayla normal 1.5x 1.5x ve 2x
User prompt
ayarlara tıklayınca hız diye bir seçenek olsun ona tıklayınca hız ayarlama kısmı çıksın ortaya
User prompt
3x olmak yerine seçenekler normal 1x, 2x, 1.5x gibi
User prompt
ayarlara tıklayınca hız ayarlama logosu çıksın oradan istediğimiz hızı seçelim normal, 2x ve 3x gibi seçenek olsun
User prompt
AYARLAR LOGOSUNUN BOYUTUNU BÜYÜT
User prompt
sağ üst köşeye ayarlar kısmına ekle
User prompt
şu an hiç bir işe yaramayan kodları sil fazladan olanları oyunu bozma
User prompt
Bazı cihazlarda oyunun açılmaması ile ilgili hatalar var. Düzelt.
User prompt
Oyunun Daha İyi Çalışması İçin Daha Önce Kullandığın Fakat Şu An Kullanmadığın Kodları Sil İşine Yaramayan
User prompt
Oyun bittiği yazısını beyaz yap
User prompt
Oyunu bozmadan hata veren her şeyi düzelt.
User prompt
Yanlış anladın oyuncu tekrar denetüşüne basarsa oyun direk başlamıyor tıkla ve oyna menüsü var ya oraya yönlendiriliyor
User prompt
oyuncu eğer tekrar da net ucuna basarsa direkt tıkla ve oyuna kısmına yönlendirmeliyiz
User prompt
Oynayan Kişi Yenildiğinde Tekrar Oynayın Tuşu Tekrar Deneyin Tuşu Gibi Birşey Olsun
User prompt
Duvarın üstüne koyduğun daha güzel dursun diye koyduğun şeyleri daha güzel görsellerle değiştir.
User prompt
Duvarda oluşan hataları düzelt ama bozma.
User prompt
Duvarların görünümünü iyileştir. Daha iyi olsun.
User prompt
Duvar ile kuşun hatasını düzelt.
User prompt
butonlara çok hızlı tıklayınca oyundan atıyor
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
/****
* 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;
try {
LK.getSound('flap').play();
} catch (e) {
console.log("Flap sound error:", e);
}
};
self.update = function () {
if (!gameStarted) {
// Don't apply physics before game starts - keep bird completely still
self.velocity = 0;
self.y = 1366; // Keep bird at starting position
birdGraphics.rotation = 0; // Keep bird level
return;
}
self.velocity += self.gravity;
self.y += self.velocity;
// Rotate bird based on velocity
birdGraphics.rotation = Math.max(-0.5, Math.min(1.5, self.velocity * 0.1));
// Limit bird movement to screen bounds with proper collision detection
var birdRadius = 40; // Half of bird height for collision detection
if (self.y - birdRadius < 0) {
self.y = birdRadius;
self.velocity = 0;
}
if (self.y + birdRadius > 2732 - 150) {
self.y = 2732 - 150 - birdRadius;
self.velocity = 0;
}
};
return self;
});
var Pipe = Container.expand(function (gapCenterY) {
var self = Container.call(this);
self.gapSize = 600;
self.speed = -3;
self.passed = false;
self.gapCenterY = gapCenterY;
// Create top pipe body
var topPipe = self.attachAsset('topPipe', {
anchorX: 0.5,
anchorY: 1
});
topPipe.y = gapCenterY - self.gapSize / 2;
// Set reasonable height for top pipe (minimum 200px, maximum based on gap position)
var topPipeHeight = Math.max(200, gapCenterY - self.gapSize / 2);
topPipe.height = topPipeHeight;
// Create top pipe highlight for 3D effect
var topPipeHighlight = self.attachAsset('pipeHighlight', {
anchorX: 0.5,
anchorY: 1
});
topPipeHighlight.y = gapCenterY - self.gapSize / 2;
topPipeHighlight.height = topPipeHeight;
topPipeHighlight.width = 30;
topPipeHighlight.x = -25;
// Create top pipe cap
var topPipeCap = self.attachAsset('pipeTop', {
anchorX: 0.5,
anchorY: 1
});
topPipeCap.y = gapCenterY - self.gapSize / 2;
// Create bottom pipe body
var bottomPipe = self.attachAsset('bottomPipe', {
anchorX: 0.5,
anchorY: 0
});
bottomPipe.y = gapCenterY + self.gapSize / 2;
// Set reasonable height for bottom pipe (minimum 200px, maximum based on available space)
var bottomPipeHeight = Math.max(200, 2732 - 150 - (gapCenterY + self.gapSize / 2));
bottomPipe.height = bottomPipeHeight;
// Create bottom pipe highlight for 3D effect
var bottomPipeHighlight = self.attachAsset('pipeHighlight', {
anchorX: 0.5,
anchorY: 0
});
bottomPipeHighlight.y = gapCenterY + self.gapSize / 2;
bottomPipeHighlight.height = bottomPipeHeight;
bottomPipeHighlight.width = 30;
bottomPipeHighlight.x = -25;
// Create bottom pipe cap
var bottomPipeCap = self.attachAsset('pipeBottom', {
anchorX: 0.5,
anchorY: 0
});
bottomPipeCap.y = 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();
/****
* 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
var buttonClickTimeout = null; // Prevent rapid button clicks
var lastButtonClickTime = 0; // Track last button click time
// Initialize storage with defaults
var _storage = storage;
// Create score text display
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.stroke = 0x000000;
scoreTxt.strokeThickness = 5;
LK.gui.top.addChild(scoreTxt);
// Create cup shape for score
var cupShape = LK.getAsset('cup', {
anchorX: 0.5,
anchorY: 0
});
cupShape.tint = 0xFFD700;
LK.gui.bottomRight.addChild(cupShape);
cupShape.y = -230;
cupShape.x = -100;
// 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 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('0');
// Show main menu
mainMenuTitle.visible = true;
playButton.visible = true;
playButtonText.visible = true;
// Hide instruction
instructionTxt.visible = false;
instructionBg.visible = false;
// Hide leaderboard elements
leaderboardBg.visible = false;
leaderboardTitle.visible = false;
highScoreText.visible = false;
currentScoreText.visible = false;
backButton.visible = false;
backButtonText.visible = false;
// Clear existing barriers if they exist
if (topBarrier) {
topBarrier.destroy();
topBarrier = null;
}
if (bottomBarrier) {
bottomBarrier.destroy();
bottomBarrier = null;
}
// Recreate invisible barriers
topBarrier = game.addChild(LK.getAsset('barrier', {
anchorX: 0.5,
anchorY: 1
}));
topBarrier.x = 400;
topBarrier.y = 1316; // 50 pixels above bird
topBarrier.alpha = 0; // Make invisible
bottomBarrier = game.addChild(LK.getAsset('barrier', {
anchorX: 0.5,
anchorY: 0
}));
bottomBarrier.x = 400;
bottomBarrier.y = 1416; // 50 pixels below bird
bottomBarrier.alpha = 0; // Make invisible
// Create initial pipes
createPipe();
createPipe();
}
// Function to start game from main menu
function startGameFromMenu() {
showMainMenu = false;
// Hide main menu elements
mainMenuTitle.visible = false;
playButton.visible = false;
playButtonText.visible = false;
// Show instruction
instructionTxt.visible = true;
instructionBg.visible = true;
}
// 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;
// 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;
}
// 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) {
// Check cup click - cup is positioned at bottomRight with offset
var cupX = 2048 - 100; // bottomRight.x + cupShape.x offset
var cupY = 2732 - 230; // bottomRight.y + cupShape.y offset
var cupSize = 120; // Cup asset size
if (x >= cupX - cupSize / 2 && x <= cupX + cupSize / 2 && y >= cupY && y <= cupY + cupSize) {
// Prevent rapid clicks
var currentTime = Date.now();
if (currentTime - lastButtonClickTime < 500) {
return; // Ignore click if too recent
}
lastButtonClickTime = currentTime;
// Clear any existing high score displays first
var existingDisplays = LK.gui.center.children;
for (var k = existingDisplays.length - 1; k >= 0; k--) {
var child = existingDisplays[k];
if (child && child.getText && child.getText().indexOf('EN YÜKSEK:') !== -1) {
try {
child.destroy();
} catch (e) {
console.log("Error destroying high score display:", e);
}
}
}
// Clear any existing backgrounds
for (var k = existingDisplays.length - 1; k >= 0; k--) {
var child = existingDisplays[k];
if (child && child.tint === 0x000000 && child.width === 700) {
try {
child.destroy();
} catch (e) {
console.log("Error destroying background:", e);
}
}
}
// Show highest score in a temporary display using storage
var highScore = storage.highScore || 0;
var highScoreDisplay = new Text2('EN YÜKSEK: ' + highScore, {
size: 90,
fill: 0xFFFF00
});
highScoreDisplay.anchor.set(0.5, 0.5);
highScoreDisplay.stroke = 0x000000;
highScoreDisplay.strokeThickness = 4;
LK.gui.center.addChild(highScoreDisplay);
highScoreDisplay.y = -100;
// Add background for better visibility
var highScoreBg = LK.getAsset('barrier', {
anchorX: 0.5,
anchorY: 0.5,
width: 700,
height: 160,
alpha: 0.98
});
highScoreBg.tint = 0x000000;
LK.gui.center.addChild(highScoreBg);
highScoreBg.y = -100;
// Move background behind text
LK.gui.center.removeChild(highScoreBg);
LK.gui.center.addChildAt(highScoreBg, LK.gui.center.getChildIndex(highScoreDisplay));
// Auto-hide after 3 seconds
LK.setTimeout(function () {
try {
if (highScoreDisplay && highScoreDisplay.parent) {
highScoreDisplay.destroy();
}
if (highScoreBg && highScoreBg.parent) {
highScoreBg.destroy();
}
} catch (e) {
console.log("Error in timeout cleanup:", e);
}
}, 3000);
return;
}
if (gameOver) {
resetGame();
return;
}
if (showMainMenu) {
// Check play button (OYNA) - centered at 1024x1366, button is 300x80
if (x >= 874 && x <= 1174 && y >= 1326 && y <= 1406) {
// Prevent rapid clicks
var currentTime = Date.now();
if (currentTime - lastButtonClickTime < 300) {
return; // Ignore click if too recent
}
lastButtonClickTime = currentTime;
// Clear any existing timeout
if (buttonClickTimeout) {
LK.clearTimeout(buttonClickTimeout);
buttonClickTimeout = null;
}
// Add visual feedback with tween
tween(playButton, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(playButton, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
}
});
// Add small delay to prevent double clicks
buttonClickTimeout = LK.setTimeout(function () {
buttonClickTimeout = null;
startGameFromMenu();
}, 150);
return;
}
return;
}
if (showLeaderboard) {
// Check back button (GERİ) - centered at 1024x1716, button is 300x80
if (x >= 874 && x <= 1174 && y >= 1676 && y <= 1756) {
// Prevent rapid clicks
var currentTime = Date.now();
if (currentTime - lastButtonClickTime < 300) {
return; // Ignore click if too recent
}
lastButtonClickTime = currentTime;
// Clear any existing timeout
if (buttonClickTimeout) {
LK.clearTimeout(buttonClickTimeout);
buttonClickTimeout = null;
}
// Add visual feedback with tween
tween(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
buttonClickTimeout = LK.setTimeout(function () {
buttonClickTimeout = null;
hideLeaderboard();
}, 150);
return;
}
// Check previous page button - centered at 724x1646, button is 200x60
if (x >= 624 && x <= 824 && y >= 1616 && y <= 1676) {
// Prevent rapid clicks
var currentTime = Date.now();
if (currentTime - lastButtonClickTime < 200) {
return; // Ignore click if too recent
}
lastButtonClickTime = currentTime;
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) {
// Prevent rapid clicks
var currentTime = Date.now();
if (currentTime - lastButtonClickTime < 200) {
return; // Ignore click if too recent
}
lastButtonClickTime = currentTime;
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 with proper bird size (bird is 80px tall, 120px wide)
var birdRadius = 40; // Half of bird height for collision detection
if (bird.y + birdRadius >= 2732 - 150 || bird.y - birdRadius <= 0) {
gameOver = true;
var currentScore = LK.getScore();
_storage.lastScore = currentScore;
if (currentScore > (_storage.highScore || 0)) {
_storage.highScore = currentScore;
}
// Add to leaderboard if score > 0
if (currentScore > 0) {
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;
// Check scoring first - only for pipes that haven't been passed yet
if (!pipe.passed && pipe.x + 50 < bird.x) {
pipe.passed = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore().toString());
try {
LK.getSound('score').play();
} catch (e) {
console.log("Sound error:", e);
}
}
// Only check collision for pipes that are close to the bird
if (Math.abs(pipe.x - bird.x) < 150) {
// Check if bird is within pipe horizontally with more precise bounds (accounting for wider pipes)
if (bird.x + 40 > pipe.x - 60 && bird.x - 40 < pipe.x + 60) {
// Check collision with top or bottom pipe - bird is 80px tall, so use 40px radius
var birdTop = bird.y - 40;
var birdBottom = bird.y + 40;
var gapTop = pipe.gapCenterY - pipe.gapSize / 2;
var gapBottom = pipe.gapCenterY + pipe.gapSize / 2;
// Collision occurs if bird overlaps with pipe (outside the gap)
if (birdTop < gapTop || birdBottom > gapBottom) {
gameOver = true;
var currentScore = LK.getScore();
_storage.lastScore = currentScore;
if (currentScore > (_storage.highScore || 0)) {
_storage.highScore = currentScore;
}
// Add to leaderboard if score > 0
if (currentScore > 0) {
var currentUsername = _storage.username;
var playerExists = false;
for (var j = 0; j < _storage.globalLeaderboardNames.length; j++) {
if (_storage.globalLeaderboardNames[j] === currentUsername) {
if (currentScore > _storage.globalLeaderboardScores[j]) {
_storage.globalLeaderboardScores[j] = currentScore;
}
playerExists = true;
break;
}
}
if (!playerExists) {
_storage.globalLeaderboardNames.push(currentUsername);
_storage.globalLeaderboardScores.push(currentScore);
}
}
resetGame();
return;
}
}
}
}
// Create new pipes - maintain consistent spacing
if (pipes.length === 0 || pipes.length > 0 && pipes[pipes.length - 1].x <= 2048 + 100 - pipeSpacing) {
createPipe();
}
// Remove off-screen pipes 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
@@ -54,26 +54,56 @@
self.gapSize = 600;
self.speed = -3;
self.passed = false;
self.gapCenterY = gapCenterY;
- // Create top pipe
+ // Create top pipe body
var topPipe = self.attachAsset('topPipe', {
anchorX: 0.5,
anchorY: 1
});
topPipe.y = gapCenterY - self.gapSize / 2;
// Set reasonable height for top pipe (minimum 200px, maximum based on gap position)
var topPipeHeight = Math.max(200, gapCenterY - self.gapSize / 2);
topPipe.height = topPipeHeight;
- // Create bottom pipe
+ // Create top pipe highlight for 3D effect
+ var topPipeHighlight = self.attachAsset('pipeHighlight', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ topPipeHighlight.y = gapCenterY - self.gapSize / 2;
+ topPipeHighlight.height = topPipeHeight;
+ topPipeHighlight.width = 30;
+ topPipeHighlight.x = -25;
+ // Create top pipe cap
+ var topPipeCap = self.attachAsset('pipeTop', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ topPipeCap.y = gapCenterY - self.gapSize / 2;
+ // Create bottom pipe body
var bottomPipe = self.attachAsset('bottomPipe', {
anchorX: 0.5,
anchorY: 0
});
bottomPipe.y = gapCenterY + self.gapSize / 2;
// Set reasonable height for bottom pipe (minimum 200px, maximum based on available space)
var bottomPipeHeight = Math.max(200, 2732 - 150 - (gapCenterY + self.gapSize / 2));
bottomPipe.height = bottomPipeHeight;
+ // Create bottom pipe highlight for 3D effect
+ var bottomPipeHighlight = self.attachAsset('pipeHighlight', {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ bottomPipeHighlight.y = gapCenterY + self.gapSize / 2;
+ bottomPipeHighlight.height = bottomPipeHeight;
+ bottomPipeHighlight.width = 30;
+ bottomPipeHighlight.x = -25;
+ // Create bottom pipe cap
+ var bottomPipeCap = self.attachAsset('pipeBottom', {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ bottomPipeCap.y = gapCenterY + self.gapSize / 2;
self.update = function () {
if (!gameStarted) {
// Don't move pipes before game starts
return;
@@ -870,10 +900,10 @@
}
}
// Only check collision for pipes that are close to the bird
if (Math.abs(pipe.x - bird.x) < 150) {
- // Check if bird is within pipe horizontally with more precise bounds
- if (bird.x + 40 > pipe.x - 50 && bird.x - 40 < pipe.x + 50) {
+ // Check if bird is within pipe horizontally with more precise bounds (accounting for wider pipes)
+ if (bird.x + 40 > pipe.x - 60 && bird.x - 40 < pipe.x + 60) {
// Check collision with top or bottom pipe - bird is 80px tall, so use 40px radius
var birdTop = bird.y - 40;
var birdBottom = bird.y + 40;
var gapTop = pipe.gapCenterY - pipe.gapSize / 2;