User prompt
arkadaki arka planı bariyerin önüne ama diğer herşeyin arkasına koy
User prompt
arka plandaki eklediğimiz resim ekranın tamamını kaplasın boşver
User prompt
Arka plana eklediğimiz duvarın boyutu aşırı büyük ama hala ekranın tamamını kaplasın ama biraz küçült, daralt.
User prompt
Arkaya eklediğimiz duvarın önünde duvarlar ve kuşumuz gözükecek.
User prompt
Eklediğim fotoğraf gözükmüyor arka plandaki.
User prompt
Arka plana eklediğin siyah veya sarı bir duvar yüzünden bizim kuşumuz gözükmüyor.
User prompt
Arka plandaki mavi şeyin de bir fotoğrafı olsun onu da değiştirebilelim diye.
User prompt
Please fix the bug: 'Timeout.tick error: highScore is not defined' in or related to this line: 'if (!playerExists && highScore > 0) {' Line Number: 520
User prompt
Oyunun hiçbir şeyini bozmadan gereksiz dosyaları sil ve aşırı oyunu takıltan şeyleri de düzelt.
User prompt
Flappy Bird oyunundan bakarak veya böyle oyunlara benzer oyunlardan bakarak duvarları düzgün yap bazıları çok uzun bazıları çok kısa
User prompt
Yukarıdaki duvar ile aşağıdaki duvar farklı fotoğraflar olsunlar yani tek fotoğrafla ikisi etkilenmesin.
User prompt
Oyundaki duvarları birbirinden uzaklaştır.
User prompt
Duvarların yaxlaşdırılmasını istəmədim. Uzaqlaşdır. Duvarların yuqarı çıxarkən tıxlamamız gərəkən sayı çox fazla.
User prompt
Oyundaki duvarlar birbirine aşırı uzak Onun için çok fazla tıklamamız gerekiyor Duvarlar arası yüksekliği düzgün ayarla
User prompt
oyundaki herşeyin görsellerini baştan yap
User prompt
Kuşun boyutunu büyüt ve duvarların boyutundan iki kat küçük olsun ama boyunu büyüt.
User prompt
Hər qullanıcın adı da farqlı olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'globalLeaderboardNames')' in or related to this line: 'if (!storage.globalLeaderboardNames) {' Line Number: 666 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
deneme kısmında çalışıyor fakat başka bir kullanıcı başka bir cihazdan girerken oyun açılmıyor
User prompt
eğer bu oyunu daha önce oynayan kişiler varsa onları kaldır ve gerçekten bundan sonra oynayan kişilerin verilerini topla ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
yapay zk veya botlar değil sadece gerçekten boni oynayanların verilenli topları ve score ekleniyor. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
düğmelere tıklayınca geri ileri olmuyor sadece düğmelerin altına üstüne yanına dokununca algılıyor
User prompt
düğmelerin algılaması için algılama butonunu büyüt
User prompt
Harika, oyunun sorunsuz çalıştığını duymak sevindirici! SS alırken duvarların görünmemesi anlaşılabilir bir durum. Skor tablosunda birinci olmanız da tebrikler! Şimdi, bahsettiğiniz skor tablosuna diğer oyuncuların verilerini yansıtmak için yapay zekaya aşağıdaki gibi bir talimat vermeniz gerekecek: "Skor tablosunda ('SKOR TABLOSU' menüsü), şu anda sadece kendi skorunuz ve 'Oyuncu538' adıyla birinci sıranız gözüküyor. Bu tabloya diğer gerçek oyuncuların skorlarını ve kullanıcı adlarını/isimlerini de ekle. Tablo, en yüksek skordan başlayarak sıralanmalı ve sayfa sayfa geçiş sistemi ile çalışmalı (her sayfada örneğin 10 oyuncu olacak şekilde). Eğer oyuncu ilk 100'de değilse, kendi sırası ve skoru listenin altında ayrı olarak gösterilmeye devam etmeli." Bu talimat, skor tablosunun gerçek oyuncuların verileriyle nasıl doldurulması gerektiğini ve daha önce konuştuğumuz sıralama ve sayfalama özelliklerinin de dahil edilmesini sağlayacaktır. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Her düğmenin algılama sistemi ve butonları ayrı olsun birbirlerine girmesinler ve düğmelerin iç içe girmesi ile ilgili hatalar da var.
/****
* 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('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
// 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 username background panel
var usernamePanel = LK.getAsset('barrier', {
anchorX: 0.5,
anchorY: 0.5,
width: 500,
height: 90,
alpha: 0.9
});
usernamePanel.tint = 0x4B0082;
LK.gui.center.addChild(usernamePanel);
usernamePanel.y = -100;
// Create username display
var usernameText = new Text2('', {
size: 60,
fill: 0x00FF00
});
usernameText.anchor.set(0.5, 0.5);
usernameText.stroke = 0x000000;
usernameText.strokeThickness = 3;
LK.gui.center.addChild(usernameText);
usernameText.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('barrier', {
anchorX: 0.5,
anchorY: 0.5,
width: 300,
height: 80,
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;
// 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 + 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
usernamePanel.visible = true;
usernameText.visible = true;
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
usernamePanel.visible = false;
usernameText.visible = false;
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
usernamePanel.visible = false;
usernameText.visible = false;
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';
for (var i = 0; i < globalNames.length; i++) {
if (globalNames[i] === currentUsername) {
globalScores[i] = Math.max(globalScores[i], highScore);
playerExists = true;
break;
}
}
var highScore = storage.highScore || 0;
if (!playerExists && highScore > 0) {
globalNames.push(currentUsername);
globalScores.push(highScore);
}
// 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
usernamePanel.visible = true;
usernameText.visible = true;
mainMenuTitle.visible = true;
playButton.visible = true;
playButtonText.visible = true;
scoreButton.visible = true;
scoreButtonText.visible = true;
}
// Initialize 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;
}
// Display username in main menu
usernameText.setText(storage.username);
// 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];
// 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());
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 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
@@ -315,9 +315,24 @@
pageIndicator.strokeThickness = 2;
pageIndicator.visible = false;
LK.gui.center.addChild(pageIndicator);
pageIndicator.y = 280;
-// Create and add background image first (so it appears behind other elements)
+// 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
}));
@@ -334,23 +349,8 @@
// 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 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)