User prompt
Tüm logoların renkleri gerçek olmayabilir değil, tüm logoların resmi olmayabilir, uyarısı olacak.
User prompt
biraz daha biraz daha aşağıya al kırmızı yazıyı ve biraz daha büyüt oynamaya başla düğmesine çarpmasın
User prompt
Oynamaya başla düğmesinin altında kırmızı renkli tüm logoların resmi olmayabilir uyarısı olsun.
User prompt
ilk girdiğimizde logo quiz oyununa hoşgeldin diye bir menü olsun orda oyuna tuşu olsun
User prompt
Son eklediğin düğmeyi kaldır.
User prompt
oyuna girmeden önce oyuna oyuna veya oyuna gir oynamaya başla gibi bir düğümü olsun ve oyuna düğmesinin altında tüm
User prompt
Aynı logo görselini kullanan kalmasın. Hepsi için ayrı.
User prompt
Özel logosu olmayan yani görseli olmayanlara görsel oluştur.
User prompt
20'den az olanları 20 yap Logo sayısını
User prompt
Dengeleme değişiklikleri yap. Oyun daha dengeli olsun.
User prompt
Twitter'ın adını X olarak değiştir.
User prompt
düğmeye basınca 2. sayfaya geçmiyor ve sağ kısımdan biraz düğmeyi küçült düzelt hataları
User prompt
Geçiş düğmesini biraz daha aşağıya al ve boyutunu büyüt, tıklanabilir ve geçiş yapılabilir bir düğme haline getir.
User prompt
her sayfada 12 tane logo olacak ama bu geçiş yani ikinci sayfaya geçiren tuşlar çalışmıyor veya boyutları ve yerleri yanlış düzelt logoların üstünde değil alttaki boşlukta
User prompt
Her sayfada 12'den fazla uygulama veya logo gözükmesin. Bunu her kategori için ayarla.
User prompt
bir sürü uygulama ekleyecektin teknoloji kısmına olmadı tekrar dene
User prompt
sayfa geçişini sağlayan düğme alt kısımda olsun ve daha çok bayrak ekle ülke yani
User prompt
Sayfa Geçişini Sağlayan Yazılar Logoların Üstüne Geliyor Biraz Düzeni Sağla
User prompt
oyunlar kısmında 12 tane oyun tek bir menüde sonra altında ikinci sekmeyi açmak için yan düğmeler olsun tıklayınca diğer oyunlar gözüksün
User prompt
Verileri sıfırlamamıza rağmen ipucu aldıklarımız silinmiyor. Düzelt
User prompt
Logo tahmin oyununda şöyle bir mekanik ekle. Mesela iki cümleli olanları bir cümleyi diğer cümleyi birbirinden ayır.
User prompt
oyun logoları kısmına ünlü bilgisayar oyunlarını da ekle
User prompt
verileri silmek istediğinden emin misin şıklarının olduğu yerde evet ve hayırı ve o ayarlar kısmındaki menülerin tuşlarını birbirinden ayır yazıları daha düzgün hale getir okunabilsin
User prompt
tüm verileri silmek istediğinden emin misin diye evet-hayır ışıklarının olduğu yerde nelerin silineceğini kırmızı yazıyla yaz
User prompt
Oyun kategorisi ekle ve mobil sektörde ünlü olan bir sürü oyun ekle.
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var AnswerSlot = Container.expand(function (index) {
var self = Container.call(this);
var bg = self.attachAsset('answerBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.index = index;
self.occupiedLetter = null;
return self;
});
var CategoryButton = Container.expand(function (category) {
var self = Container.call(this);
var bg = self.attachAsset('categoryButton', {
anchorX: 0.5,
anchorY: 0.5
});
// Set background color based on category
if (category === 'Cars') {
bg.tint = 0x000000; // Black background for Cars (Arabalar)
} else if (category === 'Food') {
bg.tint = 0xFF0000; // Red background for Food (Yemekler)
} else if (category === 'Football') {
bg.tint = 0x00FF00; // Green background for Football (Futbol)
} else if (category === 'Footballers') {
bg.tint = 0x0000FF; // Blue background for Footballers (Futbolcu)
} else if (category === 'Flags') {
bg.tint = 0xFF00FF; // Magenta background for Flags (Bayraqlar)
} else if (category === 'Games') {
bg.tint = 0x800080; // Purple background for Games (Oyunlar)
}
var text = new Text2(category, {
size: 80,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
self.category = category;
self.down = function (x, y, obj) {
self.scaleX = 0.95;
self.scaleY = 0.95;
showCategoryLogos(self.category);
};
self.up = function (x, y, obj) {
self.scaleX = 1;
self.scaleY = 1;
};
return self;
});
var ExitButton = Container.expand(function () {
var self = Container.call(this);
var bg = self.attachAsset('exitButton', {
anchorX: 0.5,
anchorY: 0.5
});
var text = new Text2('Exit', {
size: 50,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
self.down = function (x, y, obj) {
self.scaleX = 0.95;
self.scaleY = 0.95;
showCategoryLogos(currentCategory);
};
self.up = function (x, y, obj) {
self.scaleX = 1;
self.scaleY = 1;
};
return self;
});
var HintButton = Container.expand(function () {
var self = Container.call(this);
var bg = self.attachAsset('hintButton', {
anchorX: 0.5,
anchorY: 0.5
});
var text = new Text2('Hint (5 coins)', {
size: 50,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
self.down = function (x, y, obj) {
if (goldCoins >= 5) {
useHint();
}
};
return self;
});
var LetterTile = Container.expand(function (letter) {
var self = Container.call(this);
var bg = self.attachAsset('letterTile', {
anchorX: 0.5,
anchorY: 0.5
});
var text = new Text2(letter, {
size: 60,
fill: 0x333333
});
text.anchor.set(0.5, 0.5);
// Ensure text is visible and properly positioned
text.x = 0;
text.y = 0;
text.alpha = 1;
text.visible = true;
self.addChild(text);
self.letter = letter;
self.originalX = 0;
self.originalY = 0;
self.isPlaced = false;
self.targetSlot = null;
// Store reference to text for easier access
self.letterText = text;
self.down = function (x, y, obj) {
if (!self.isPlaced) {
// Find next available answer slot
var nextSlot = null;
for (var i = 0; i < answerSlots.length; i++) {
if (!answerSlots[i].occupiedLetter) {
nextSlot = answerSlots[i];
break;
}
}
if (nextSlot) {
placeLetter(self, nextSlot);
checkAnswer();
}
} else {
// Letter is placed, remove it from answer slot
removeLetter(self);
}
};
return self;
});
var LogoButton = Container.expand(function (logoName, logoData) {
var self = Container.call(this);
var bg = self.attachAsset('logoContainer', {
anchorX: 0.5,
anchorY: 0.5
});
// Get logo asset name from company name
var logoAssetName = logoData.name.toLowerCase() + 'Logo';
if (logoData.name === 'Real Madrid') {
logoAssetName = 'realmadridLogo';
}
if (logoData.name === 'Manchester United') {
logoAssetName = 'manchesterLogo';
}
if (logoData.name === 'McDonalds') {
logoAssetName = 'mcdonaldsLogo';
}
if (logoData.name === 'Pizza Hut') {
logoAssetName = 'pizzahutLogo';
}
if (logoData.name === 'Instagram') {
logoAssetName = 'instagramLogo';
}
if (logoData.name === 'TikTok') {
logoAssetName = 'tiktokLogo';
}
if (logoData.name === 'Burger King') {
logoAssetName = 'burgerkingLogo';
}
if (logoData.name === 'Bayern München') {
logoAssetName = 'bayernmunchenLogo';
}
if (logoData.name === 'Galatasaray') {
logoAssetName = 'galatasarayLogo';
}
if (logoData.name === 'Tesla') {
logoAssetName = 'teslaLogo';
}
if (logoData.name === 'Lamborghini') {
logoAssetName = 'lamborghiniLogo';
}
if (logoData.name === 'Tog') {
logoAssetName = 'togLogo';
}
if (logoData.name === 'ChatGPT') {
logoAssetName = 'chatgptLogo';
}
if (logoData.name === 'Xiaomi') {
logoAssetName = 'xiaomiLogo';
}
// Footballers category assets
if (logoData.name === 'Messi') {
logoAssetName = 'messiLogo';
}
if (logoData.name === 'Ronaldo') {
logoAssetName = 'ronaldoLogo';
}
if (logoData.name === 'Neymar') {
logoAssetName = 'neymarLogo';
}
if (logoData.name === 'Mbappe') {
logoAssetName = 'mbappeLogo';
}
if (logoData.name === 'Haaland') {
logoAssetName = 'haalandLogo';
}
if (logoData.name === 'Benzema') {
logoAssetName = 'benzemaLogo';
}
if (logoData.name === 'Lewandowski') {
logoAssetName = 'lewandowskiLogo';
}
if (logoData.name === 'Mesut Ozil') {
logoAssetName = 'mesutoezilLogo';
}
if (logoData.name === 'Arda Guler') {
logoAssetName = 'ardagulerLogo';
}
if (logoData.name === 'Luka Modric') {
logoAssetName = 'lukamodricLogo';
}
if (logoData.name === 'Vinicius Junior') {
logoAssetName = 'viniciusjuniorLogo';
}
if (logoData.name === 'Erling Haaland') {
logoAssetName = 'erlinghaalandLogo';
}
if (logoData.name === 'Lamin Yemal') {
logoAssetName = 'laminyemalLogo';
}
// Flags category assets
if (logoData.name === 'Turkey') {
logoAssetName = 'turkeyLogo';
}
if (logoData.name === 'Germany') {
logoAssetName = 'germanyLogo';
}
if (logoData.name === 'France') {
logoAssetName = 'franceLogo';
}
if (logoData.name === 'Spain') {
logoAssetName = 'spainLogo';
}
if (logoData.name === 'Italy') {
logoAssetName = 'italyLogo';
}
if (logoData.name === 'Brazil') {
logoAssetName = 'brazilLogo';
}
if (logoData.name === 'Argentina') {
logoAssetName = 'argentinaLogo';
}
// Games category assets
if (logoData.name === 'Minecraft') {
logoAssetName = 'minecraftLogo';
}
if (logoData.name === 'Fortnite') {
logoAssetName = 'fortniteLogo';
}
if (logoData.name === 'PUBG') {
logoAssetName = 'pubgLogo';
}
if (logoData.name === 'Among Us') {
logoAssetName = 'amongusLogo';
}
if (logoData.name === 'Clash of Clans') {
logoAssetName = 'clashofclansLogo';
}
if (logoData.name === 'Clash Royale') {
logoAssetName = 'clashroyaleLogo';
}
if (logoData.name === 'Candy Crush') {
logoAssetName = 'candycrushLogo';
}
if (logoData.name === 'Pokemon Go') {
logoAssetName = 'pokemongoLogo';
}
if (logoData.name === 'Subway Surfers') {
logoAssetName = 'subwaysurfersLogo';
}
if (logoData.name === 'Temple Run') {
logoAssetName = 'templerunLogo';
}
if (logoData.name === 'Angry Birds') {
logoAssetName = 'angrybirdsLogo';
}
if (logoData.name === 'Roblox') {
logoAssetName = 'robloxLogo';
}
var logoVisual = self.attachAsset(logoAssetName, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
self.logoData = logoData;
self.down = function (x, y, obj) {
// Check if logo is completed
var logoKey = currentCategory + '_' + self.logoData.name;
if (completedLogos[logoKey]) {
// Show completed logo name instead of starting the game
showCompletedLogo(self.logoData);
return;
}
self.scaleX = 0.95;
self.scaleY = 0.95;
startLogoGuess(self.logoData);
};
self.up = function (x, y, obj) {
self.scaleX = 1;
self.scaleY = 1;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2C3E50
});
/****
* Game Code
****/
// Game state variables
// Logo assets - Technology
// Logo assets - Football
// Logo assets - Cars
// Logo assets - Food
var gameState = 'menu'; // 'menu', 'category', 'guessing'
var goldCoins = storage.goldCoins || 10;
var currentLanguage = storage.currentLanguage || 'tr'; // 'tr' for Turkish, 'en' for English
var completedLogos = storage.completedLogos || {};
var completedWithoutHints = storage.completedWithoutHints || {};
var categoryCompletions = storage.categoryCompletions || {
'Technology': 0,
'Football': 0,
'Cars': 0,
'Food': 0,
'Footballers': 0,
'Flags': 0,
'Games': 0
};
var currentLogoUsedHint = false;
// Recalculate category completions based on completed logos to ensure accuracy
function updateCategoryCompletions() {
// Reset counts
for (var category in categoryCompletions) {
categoryCompletions[category] = 0;
}
// Count ALL completed logos for category unlocking
for (var logoKey in completedLogos) {
if (completedLogos[logoKey]) {
var category = logoKey.split('_')[0];
if (categoryCompletions[category] !== undefined) {
categoryCompletions[category]++;
}
}
}
storage.categoryCompletions = categoryCompletions;
}
// Update completions on game start
updateCategoryCompletions();
var currentCategory = '';
var currentLogo = null;
var draggedLetter = null;
var letterTiles = [];
var answerSlots = [];
var currentAnswer = '';
// Language configuration
var languageTexts = {
tr: {
title: 'Logo Quiz Challenge',
completed: 'Tamamlanan: ',
settings: 'Ayarlar',
language: 'Dil',
turkish: 'Türkçe',
english: 'İngilizce',
resetData: 'Tüm Verileri Sıfırla',
backToMenu: 'Ana Menüye Dön',
resetConfirm: 'Silmek İstediğinden Emin Misin?',
yes: 'Evet',
no: 'Hayır',
completedText: 'TAMAMLANDI'
},
en: {
title: 'Logo Quiz Challenge',
completed: 'Completed: ',
settings: 'Settings',
language: 'Language',
turkish: 'Turkish',
english: 'English',
resetData: 'Reset All Data',
backToMenu: 'Back to Menu',
resetConfirm: 'Are you sure you want to delete?',
yes: 'Yes',
no: 'No',
completedText: 'COMPLETED'
}
};
// Logo data
var logoDatabase = {
'Technology': [{
name: 'Apple',
answer: 'APPLE'
}, {
name: 'Google',
answer: 'GOOGLE'
}, {
name: 'Microsoft',
answer: 'MICROSOFT'
}, {
name: 'Samsung',
answer: 'SAMSUNG'
}, {
name: 'Instagram',
answer: 'INSTAGRAM'
}, {
name: 'TikTok',
answer: 'TIKTOK'
}, {
name: 'ChatGPT',
answer: 'CHATGPT'
}, {
name: 'Xiaomi',
answer: 'XIAOMI'
}],
'Football': [{
name: 'Barcelona',
answer: 'BARCELONA'
}, {
name: 'Real Madrid',
answer: 'REALMADRID'
}, {
name: 'Liverpool',
answer: 'LIVERPOOL'
}, {
name: 'Manchester United',
answer: 'MANCHESTER'
}, {
name: 'Arsenal',
answer: 'ARSENAL'
}, {
name: 'Bayern München',
answer: 'BAYERNMUNCHEN'
}, {
name: 'Galatasaray',
answer: 'GALATASARAY'
}],
'Cars': [{
name: 'BMW',
answer: 'BMW'
}, {
name: 'Mercedes',
answer: 'MERCEDES'
}, {
name: 'Toyota',
answer: 'TOYOTA'
}, {
name: 'Ferrari',
answer: 'FERRARI'
}, {
name: 'Audi',
answer: 'AUDI'
}, {
name: 'Tesla',
answer: 'TESLA'
}, {
name: 'Lamborghini',
answer: 'LAMBORGHINI'
}, {
name: 'Tog',
answer: 'TOGG'
}],
'Food': [{
name: 'McDonalds',
answer: 'MCDONALDS'
}, {
name: 'KFC',
answer: 'KFC'
}, {
name: 'Subway',
answer: 'SUBWAY'
}, {
name: 'Pizza Hut',
answer: 'PIZZAHUT'
}, {
name: 'Starbucks',
answer: 'STARBUCKS'
}, {
name: 'Dominos',
answer: 'DOMINOS'
}, {
name: 'Burger King',
answer: 'BURGERKING'
}],
'Footballers': [{
name: 'Messi',
answer: 'MESSI'
}, {
name: 'Ronaldo',
answer: 'RONALDO'
}, {
name: 'Neymar',
answer: 'NEYMAR'
}, {
name: 'Mbappe',
answer: 'MBAPPE'
}, {
name: 'Haaland',
answer: 'HAALAND'
}, {
name: 'Benzema',
answer: 'BENZEMA'
}, {
name: 'Lewandowski',
answer: 'LEWANDOWSKI'
}, {
name: 'Mesut Ozil',
answer: 'MESUTOEZIL'
}, {
name: 'Arda Guler',
answer: 'ARDAGULER'
}, {
name: 'Luka Modric',
answer: 'LUKAMODRIC'
}, {
name: 'Vinicius Junior',
answer: 'VINICIUSJUNIOR'
}, {
name: 'Lamin Yemal',
answer: 'LAMINYEMAL'
}],
'Flags': [{
name: 'Turkey',
answer: 'TURKEY',
answerTR: 'TURKIYE'
}, {
name: 'Germany',
answer: 'GERMANY',
answerTR: 'ALMANYA'
}, {
name: 'France',
answer: 'FRANCE',
answerTR: 'FRANSA'
}, {
name: 'Spain',
answer: 'SPAIN',
answerTR: 'ISPANYA'
}, {
name: 'Italy',
answer: 'ITALY',
answerTR: 'ITALYA'
}, {
name: 'Brazil',
answer: 'BRAZIL',
answerTR: 'BREZILYA'
}, {
name: 'Argentina',
answer: 'ARGENTINA',
answerTR: 'ARJANTIN'
}],
'Games': [{
name: 'Minecraft',
answer: 'MINECRAFT'
}, {
name: 'Fortnite',
answer: 'FORTNITE'
}, {
name: 'PUBG',
answer: 'PUBG'
}, {
name: 'Among Us',
answer: 'AMONGUS'
}, {
name: 'Clash of Clans',
answer: 'CLASHOFCLANS'
}, {
name: 'Clash Royale',
answer: 'CLASHROYALE'
}, {
name: 'Candy Crush',
answer: 'CANDYCRUSH'
}, {
name: 'Pokemon Go',
answer: 'POKEMONGO'
}, {
name: 'Subway Surfers',
answer: 'SUBWAYSURFERS'
}, {
name: 'Temple Run',
answer: 'TEMPLERUN'
}, {
name: 'Angry Birds',
answer: 'ANGRYBIRDS'
}, {
name: 'Roblox',
answer: 'ROBLOX'
}]
};
// UI Elements
var coinDisplay;
var backButton;
function isCategoryUnlocked(category) {
// Technology is always unlocked
if (category === 'Technology') return true;
// Football unlocks after 2 Technology completions
if (category === 'Football') return categoryCompletions['Technology'] >= 2;
// Cars unlocks after 2 Football completions
if (category === 'Cars') return categoryCompletions['Football'] >= 2;
// Food unlocks after 2 Cars completions
if (category === 'Food') return categoryCompletions['Cars'] >= 2;
// Footballers unlocks after 2 Food completions
if (category === 'Footballers') return categoryCompletions['Food'] >= 2;
// Flags unlocks after 2 Footballers completions
if (category === 'Flags') return categoryCompletions['Footballers'] >= 2;
// Games unlocks after 2 Flags completions
if (category === 'Games') return categoryCompletions['Flags'] >= 2;
return false;
}
function showLockedCategoryMessage(category) {
// Calculate requirements
var requiredCategory = '';
var requiredCount = 2;
var currentCompleted = 0;
var remaining = 0;
if (category === 'Football') {
requiredCategory = 'Technology';
currentCompleted = categoryCompletions['Technology'];
} else if (category === 'Cars') {
requiredCategory = 'Football';
currentCompleted = categoryCompletions['Football'];
} else if (category === 'Food') {
requiredCategory = 'Cars';
currentCompleted = categoryCompletions['Cars'];
} else if (category === 'Footballers') {
requiredCategory = 'Food';
currentCompleted = categoryCompletions['Food'];
} else if (category === 'Flags') {
requiredCategory = 'Footballers';
currentCompleted = categoryCompletions['Footballers'];
} else if (category === 'Games') {
requiredCategory = 'Flags';
currentCompleted = categoryCompletions['Flags'];
}
remaining = Math.max(0, requiredCount - currentCompleted);
// Create overlay message
var messageOverlay = new Container();
messageOverlay.x = 1024;
messageOverlay.y = 1366;
// Semi-transparent background
var bgShape = LK.getAsset('categoryButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 2.0
});
bgShape.tint = 0x000000;
bgShape.alpha = 0.8;
messageOverlay.addChild(bgShape);
// Main message text
var messageText = new Text2('Kilitli Kategori!', {
size: 80,
fill: 0xFF0000
});
messageText.anchor.set(0.5, 0.5);
messageText.y = -80;
messageOverlay.addChild(messageText);
// Requirement text showing remaining count
var requirementText = new Text2(remaining + ' tane daha ' + requiredCategory + ' çözmen gerekiyor', {
size: 60,
fill: 0xFFFFFF
});
requirementText.anchor.set(0.5, 0.5);
requirementText.y = 0;
messageOverlay.addChild(requirementText);
// Progress text showing current progress
var progressText = new Text2('Şu anda: ' + currentCompleted + '/' + requiredCount, {
size: 50,
fill: 0xFFD700
});
progressText.anchor.set(0.5, 0.5);
progressText.y = 60;
messageOverlay.addChild(progressText);
// Add to game
game.addChild(messageOverlay);
// Auto-remove after 3 seconds
LK.setTimeout(function () {
if (messageOverlay.parent) {
messageOverlay.parent.removeChild(messageOverlay);
messageOverlay.destroy();
}
}, 3000);
}
function initializeMenu() {
game.removeChildren();
gameState = 'menu';
// Title
var title = new Text2(languageTexts[currentLanguage].title, {
size: 120,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 500;
game.addChild(title);
// Calculate and display total completions
var totalCompleted = Object.keys(completedLogos).length;
var totalLogos = 0;
for (var category in logoDatabase) {
totalLogos += logoDatabase[category].length;
}
var progressText = new Text2(languageTexts[currentLanguage].completed + totalCompleted + '/' + totalLogos, {
size: 80,
fill: 0xFFD700
});
progressText.anchor.set(0.5, 0.5);
progressText.x = 1024;
progressText.y = 600;
game.addChild(progressText);
// Category buttons
var categories = ['Technology', 'Football', 'Cars', 'Food', 'Footballers', 'Flags', 'Games'];
for (var i = 0; i < categories.length; i++) {
var isUnlocked = isCategoryUnlocked(categories[i]);
var button = new CategoryButton(categories[i]);
button.x = 1024;
button.y = 800 + i * 220;
// Visual feedback for locked categories
if (!isUnlocked) {
button.alpha = 0.5;
// Override the down handler to show requirement message for locked categories
button.down = function (x, y, obj) {
showLockedCategoryMessage(categories[i]);
};
// Add lock symbol
var lockText = new Text2('🔒', {
size: 60,
fill: 0xFFFFFF
});
lockText.anchor.set(0.5, 0.5);
lockText.x = 300; // Position to the right of category name
lockText.y = 0;
button.addChild(lockText);
// Show completion requirement
var reqText = '';
if (categories[i] === 'Football') reqText = '(' + categoryCompletions['Technology'] + '/2 Technology)';else if (categories[i] === 'Cars') reqText = '(' + categoryCompletions['Football'] + '/2 Football)';else if (categories[i] === 'Food') reqText = '(' + categoryCompletions['Cars'] + '/2 Cars)';else if (categories[i] === 'Footballers') reqText = '(' + categoryCompletions['Food'] + '/2 Food)';else if (categories[i] === 'Flags') reqText = '(' + categoryCompletions['Footballers'] + '/2 Footballers)';else if (categories[i] === 'Games') reqText = '(' + categoryCompletions['Flags'] + '/2 Flags)';
if (reqText) {
var requirementText = new Text2(reqText, {
size: 40,
fill: 0xFFFFFF
});
requirementText.anchor.set(0.5, 0.5);
requirementText.x = 0;
requirementText.y = 60;
button.addChild(requirementText);
}
}
game.addChild(button);
}
// Settings icon - larger circular button below coin display
var settingsIcon = LK.getAsset('settingsIcon', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
settingsIcon.x = 1848; // Same X position as coin display
settingsIcon.y = 320; // Further below coin display
settingsIcon.down = function (x, y, obj) {
settingsIcon.scaleX = 0.95;
settingsIcon.scaleY = 0.95;
showSettings();
};
settingsIcon.up = function (x, y, obj) {
settingsIcon.scaleX = 1.0;
settingsIcon.scaleY = 1.0;
};
game.addChild(settingsIcon);
// Add gear symbol text on top of settings icon
var gearSymbol = new Text2('⚙', {
size: 60,
fill: 0xFFFFFF
});
gearSymbol.anchor.set(0.5, 0.5);
gearSymbol.x = 1848;
gearSymbol.y = 320;
game.addChild(gearSymbol);
updateCoinDisplay();
}
function showCategoryLogos(category) {
// Batch clear operations for better performance
while (game.children.length > 0) {
var child = game.children[0];
game.removeChild(child);
if (child.destroy) {
child.destroy();
}
}
gameState = 'category';
currentCategory = category;
// Category title
var title = new Text2(category + ' Logos', {
size: 100,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 400;
game.addChild(title);
// Show category completion stats
var categoryCompleted = categoryCompletions[category] || 0;
var categoryTotal = logoDatabase[category].length;
var statsText = new Text2('Tamamlanan: ' + categoryCompleted + '/' + categoryTotal, {
size: 60,
fill: 0xFFD700
});
statsText.anchor.set(0.5, 0.5);
statsText.x = 1024;
statsText.y = 480;
game.addChild(statsText);
// Logo buttons - filter out completed logos
var logos = logoDatabase[category];
var availableLogos = [];
for (var i = 0; i < logos.length; i++) {
var logoKey = category + '_' + logos[i].name;
if (!completedLogos[logoKey]) {
availableLogos.push(logos[i]);
}
}
var cols = 3;
var startX = 1024 - (cols - 1) * 250;
var startY = 700;
// Show all logos with completion status
var allLogos = logoDatabase[category];
for (var i = 0; i < allLogos.length; i++) {
var logoButton = new LogoButton(allLogos[i].name + 'Logo', allLogos[i]);
logoButton.x = startX + i % cols * 500;
logoButton.y = startY + Math.floor(i / cols) * 450;
game.addChild(logoButton);
// Check if this logo is completed and add checkmark
var logoKey = category + '_' + allLogos[i].name;
if (completedLogos[logoKey]) {
var checkmark = logoButton.attachAsset('checkmark', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
checkmark.x = 150; // Position in top-right corner of logo button
checkmark.y = -150;
}
}
// Exit button
var exitBtn = new ExitButton();
exitBtn.x = 1848; // Position in top right area, below coins
exitBtn.y = 350; // Further below the coin display
exitBtn.down = function (x, y, obj) {
exitBtn.scaleX = 0.95;
exitBtn.scaleY = 0.95;
initializeMenu(); // Return to main menu instead of category
};
exitBtn.up = function (x, y, obj) {
exitBtn.scaleX = 1;
exitBtn.scaleY = 1;
};
game.addChild(exitBtn);
updateCoinDisplay();
}
function startLogoGuess(logoData) {
// Efficient cleanup
while (game.children.length > 0) {
var child = game.children[0];
game.removeChild(child);
if (child.destroy) {
child.destroy();
}
}
gameState = 'guessing';
currentLogo = logoData;
currentLogoUsedHint = false;
// Clear arrays efficiently
letterTiles.length = 0;
answerSlots.length = 0;
// Logo display area - larger and more prominent visual logo
var logoAssetName = logoData.name.toLowerCase() + 'Logo';
if (logoData.name === 'Real Madrid') {
logoAssetName = 'realmadridLogo';
}
if (logoData.name === 'Manchester United') {
logoAssetName = 'manchesterLogo';
}
if (logoData.name === 'McDonalds') {
logoAssetName = 'mcdonaldsLogo';
}
if (logoData.name === 'Pizza Hut') {
logoAssetName = 'pizzahutLogo';
}
if (logoData.name === 'Instagram') {
logoAssetName = 'instagramLogo';
}
if (logoData.name === 'TikTok') {
logoAssetName = 'tiktokLogo';
}
if (logoData.name === 'Burger King') {
logoAssetName = 'burgerkingLogo';
}
if (logoData.name === 'Bayern München') {
logoAssetName = 'bayernmunchenLogo';
}
if (logoData.name === 'Galatasaray') {
logoAssetName = 'galatasarayLogo';
}
if (logoData.name === 'Tesla') {
logoAssetName = 'teslaLogo';
}
if (logoData.name === 'Lamborghini') {
logoAssetName = 'lamborghiniLogo';
}
if (logoData.name === 'Tog') {
logoAssetName = 'togLogo';
}
if (logoData.name === 'ChatGPT') {
logoAssetName = 'chatgptLogo';
}
if (logoData.name === 'Xiaomi') {
logoAssetName = 'xiaomiLogo';
}
// Footballers category assets
if (logoData.name === 'Messi') {
logoAssetName = 'messiLogo';
}
if (logoData.name === 'Ronaldo') {
logoAssetName = 'ronaldoLogo';
}
if (logoData.name === 'Neymar') {
logoAssetName = 'neymarLogo';
}
if (logoData.name === 'Mbappe') {
logoAssetName = 'mbappeLogo';
}
if (logoData.name === 'Haaland') {
logoAssetName = 'haalandLogo';
}
if (logoData.name === 'Benzema') {
logoAssetName = 'benzemaLogo';
}
if (logoData.name === 'Lewandowski') {
logoAssetName = 'lewandowskiLogo';
}
if (logoData.name === 'Mesut Ozil') {
logoAssetName = 'mesutoezilLogo';
}
if (logoData.name === 'Arda Guler') {
logoAssetName = 'ardagulerLogo';
}
if (logoData.name === 'Luka Modric') {
logoAssetName = 'lukamodricLogo';
}
if (logoData.name === 'Vinicius Junior') {
logoAssetName = 'viniciusjuniorLogo';
}
if (logoData.name === 'Erling Haaland') {
logoAssetName = 'erlinghaalandLogo';
}
if (logoData.name === 'Lamin Yemal') {
logoAssetName = 'laminyemalLogo';
}
// Flags category assets
if (logoData.name === 'Turkey') {
logoAssetName = 'turkeyLogo';
}
if (logoData.name === 'Germany') {
logoAssetName = 'germanyLogo';
}
if (logoData.name === 'France') {
logoAssetName = 'franceLogo';
}
if (logoData.name === 'Spain') {
logoAssetName = 'spainLogo';
}
if (logoData.name === 'Italy') {
logoAssetName = 'italyLogo';
}
if (logoData.name === 'Brazil') {
logoAssetName = 'brazilLogo';
}
if (logoData.name === 'Argentina') {
logoAssetName = 'argentinaLogo';
}
// Games category assets
if (logoData.name === 'Minecraft') {
logoAssetName = 'minecraftLogo';
}
if (logoData.name === 'Fortnite') {
logoAssetName = 'fortniteLogo';
}
if (logoData.name === 'PUBG') {
logoAssetName = 'pubgLogo';
}
if (logoData.name === 'Among Us') {
logoAssetName = 'amongusLogo';
}
if (logoData.name === 'Clash of Clans') {
logoAssetName = 'clashofclansLogo';
}
if (logoData.name === 'Clash Royale') {
logoAssetName = 'clashroyaleLogo';
}
if (logoData.name === 'Candy Crush') {
logoAssetName = 'candycrushLogo';
}
if (logoData.name === 'Pokemon Go') {
logoAssetName = 'pokemongoLogo';
}
if (logoData.name === 'Subway Surfers') {
logoAssetName = 'subwaysurfersLogo';
}
if (logoData.name === 'Temple Run') {
logoAssetName = 'templerunLogo';
}
if (logoData.name === 'Angry Birds') {
logoAssetName = 'angrybirdsLogo';
}
if (logoData.name === 'Roblox') {
logoAssetName = 'robloxLogo';
}
var logoVisual = LK.getAsset(logoAssetName, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
logoVisual.x = 1024;
logoVisual.y = 500;
game.addChild(logoVisual);
// Get the appropriate answer based on language and category
var currentAnswer = logoData.answer;
if (currentCategory === 'Flags' && currentLanguage === 'tr' && logoData.answerTR) {
currentAnswer = logoData.answerTR;
}
// Create answer slots
var answerLength = currentAnswer.length;
var slotSpacing = 140;
var startX = 1024 - (answerLength - 1) * slotSpacing / 2;
for (var i = 0; i < answerLength; i++) {
var slot = new AnswerSlot(i);
slot.x = startX + i * slotSpacing;
slot.y = 900;
answerSlots.push(slot);
game.addChild(slot);
}
// Create letter tiles
createLetterTiles(currentAnswer);
// Restore any existing hint letters from storage
var logoKey = currentCategory + '_' + currentLogo.name;
for (var i = 0; i < answerSlots.length; i++) {
var hintKey = logoKey + '_hint_' + i;
var hintLetter = storage[hintKey];
if (hintLetter) {
// Find the corresponding letter tile
for (var j = 0; j < letterTiles.length; j++) {
var tile = letterTiles[j];
if (tile.letter === hintLetter && !tile.isPlaced) {
placeLetter(tile, answerSlots[i]);
// Mark as hint letter with green color
answerSlots[i].letterCopy.isHintLetter = true;
answerSlots[i].letterCopy.letterText.fill = 0x00FF00;
answerSlots[i].letterCopy.letterText.tint = 0x00FF00;
// Create green background for hint letter
var hintBackground = LK.getAsset('letterTile', {
anchorX: 0.5,
anchorY: 0.5
});
hintBackground.tint = 0x00FF00; // Green background
hintBackground.x = answerSlots[i].x;
hintBackground.y = answerSlots[i].y;
answerSlots[i].hintBackground = hintBackground;
game.addChild(hintBackground);
// Move letter copy to front
game.removeChild(answerSlots[i].letterCopy);
game.addChild(answerSlots[i].letterCopy);
break;
}
}
}
}
// Hint button
var hintBtn = new HintButton();
hintBtn.x = 1024;
hintBtn.y = 1200;
game.addChild(hintBtn);
// Exit button
var exitBtn = new ExitButton();
exitBtn.x = 1848; // Position in top right area, below coins
exitBtn.y = 350; // Further below the coin display
game.addChild(exitBtn);
updateCoinDisplay();
}
// Pre-allocated letter pool for reuse
var letterPool = [];
var poolIndex = 0;
function createLetterTiles(answer) {
// Clear existing tiles efficiently
for (var i = 0; i < letterTiles.length; i++) {
letterTiles[i].destroy();
}
letterTiles.length = 0;
poolIndex = 0;
var letters = answer.split('');
var decoyLetters = ['X', 'Z', 'Q', 'J', 'K', 'W', 'V', 'Y', 'H', 'P', 'C', 'U', 'N', 'D', 'F'];
var allLetters = letters.slice(); // Copy answer letters
// Add decoy letters to reach exactly 15 total letters
var decoyCount = 15 - letters.length;
if (decoyCount > 0) {
// Add decoy letters, cycling through the decoy array if needed
for (var d = 0; d < decoyCount; d++) {
allLetters.push(decoyLetters[d % decoyLetters.length]);
}
}
// If answer is longer than 15, just use the first 15 letters
if (allLetters.length > 15) {
allLetters = allLetters.slice(0, 15);
}
// Shuffle letters using optimized Fisher-Yates
for (var i = allLetters.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
if (i !== j) {
var temp = allLetters[i];
allLetters[i] = allLetters[j];
allLetters[j] = temp;
}
}
// Create tiles with object pooling
var cols = 5;
var startX = 1024 - (cols - 1) * 80;
var startY = 1450;
for (var i = 0; i < allLetters.length; i++) {
var tile = new LetterTile(allLetters[i]);
var posX = startX + i % cols * 160;
var posY = startY + Math.floor(i / cols) * 160;
tile.x = posX;
tile.y = posY;
// Store original position for reset functionality
tile.originalX = posX;
tile.originalY = posY;
// Ensure tile is visible
tile.alpha = 1;
tile.visible = true;
letterTiles.push(tile);
game.addChild(tile);
}
}
function createBackButton() {
// Back button functionality removed
}
function updateCoinDisplay() {
if (coinDisplay) {
coinDisplay.parent.removeChild(coinDisplay);
}
coinDisplay = new Container();
var coinIcon = coinDisplay.addChild(LK.getAsset('coinIcon', {
anchorX: 0.5,
anchorY: 0.5
}));
var coinText = new Text2(goldCoins.toString(), {
size: 60,
fill: 0xFFD700
});
coinText.anchor.set(1, 0.5);
coinText.x = -50;
coinDisplay.addChild(coinText);
coinDisplay.x = -80;
coinDisplay.y = 150;
LK.gui.topRight.addChild(coinDisplay);
}
function useHint() {
if (goldCoins < 5 || !currentLogo) {
return;
}
goldCoins -= 5;
storage.goldCoins = goldCoins;
currentLogoUsedHint = true;
updateCoinDisplay();
// Get the appropriate answer based on language and category
var hintAnswer = currentLogo.answer;
if (currentCategory === 'Flags' && currentLanguage === 'tr' && currentLogo.answerTR) {
hintAnswer = currentLogo.answerTR;
}
// Find all empty slots first
var emptySlots = [];
for (var i = 0; i < answerSlots.length; i++) {
var slot = answerSlots[i];
if (!slot.occupiedLetter) {
emptySlots.push({
slot: slot,
index: i
});
}
}
// If no empty slots, return
if (emptySlots.length === 0) {
return;
}
// Pick the first empty slot
var targetSlotInfo = emptySlots[0];
var correctLetter = hintAnswer[targetSlotInfo.index];
// Find the letter tile
for (var j = 0; j < letterTiles.length; j++) {
var tile = letterTiles[j];
if (tile.letter === correctLetter && !tile.isPlaced) {
placeLetter(tile, targetSlotInfo.slot);
// Mark this as a hint letter - permanent and different color
targetSlotInfo.slot.letterCopy.isHintLetter = true;
targetSlotInfo.slot.letterCopy.letterText.fill = 0x00FF00; // Green color for hint letters
targetSlotInfo.slot.letterCopy.letterText.tint = 0x00FF00; // Apply green tint as well
// Create green background for hint letter
var hintBackground = LK.getAsset('letterTile', {
anchorX: 0.5,
anchorY: 0.5
});
hintBackground.tint = 0x00FF00; // Green background
hintBackground.x = targetSlotInfo.slot.x;
hintBackground.y = targetSlotInfo.slot.y;
targetSlotInfo.slot.hintBackground = hintBackground;
game.addChild(hintBackground);
// Move letter copy to front
game.removeChild(targetSlotInfo.slot.letterCopy);
game.addChild(targetSlotInfo.slot.letterCopy);
// Store hint letter data persistently
var logoKey = currentCategory + '_' + currentLogo.name;
var hintKey = logoKey + '_hint_' + targetSlotInfo.index;
storage[hintKey] = correctLetter;
break;
}
}
checkAnswer();
}
function removeLetter(letter) {
if (!letter.isPlaced || !letter.targetSlot) {
return;
}
var slot = letter.targetSlot;
// Check if this is a hint letter - if so, don't remove it
if (slot.letterCopy && slot.letterCopy.isHintLetter) {
return; // Cannot remove hint letters
}
// Clear slot
slot.occupiedLetter = null;
// Remove letter copy from answer slot
if (slot.letterCopy) {
if (slot.hintBackground) {
slot.hintBackground.destroy();
slot.hintBackground = null;
}
slot.letterCopy.destroy();
slot.letterCopy = null;
}
// Reset letter to original state
letter.isPlaced = false;
letter.targetSlot = null;
letter.alpha = 1;
letter.x = letter.originalX;
letter.y = letter.originalY;
}
function placeLetter(letter, slot) {
if (slot.occupiedLetter) {
// Check if the current letter in slot is a hint letter - if so, don't replace it
if (slot.letterCopy && slot.letterCopy.isHintLetter) {
return; // Cannot replace hint letters
}
// Return previous letter to pool
var prevLetter = slot.occupiedLetter;
prevLetter.isPlaced = false;
prevLetter.targetSlot = null;
prevLetter.alpha = 1;
// Remove the letter copy from answer slot
if (slot.letterCopy) {
if (slot.hintBackground) {
slot.hintBackground.destroy();
slot.hintBackground = null;
}
slot.letterCopy.destroy();
slot.letterCopy = null;
}
prevLetter.x = prevLetter.originalX;
prevLetter.y = prevLetter.originalY;
}
letter.isPlaced = true;
letter.targetSlot = slot;
slot.occupiedLetter = letter;
// Make the original tile appear faded/hidden
letter.alpha = 0.3;
// Create a copy of the letter in the answer slot
var letterCopy = new LetterTile(letter.letter);
letterCopy.x = slot.x;
letterCopy.y = slot.y;
letterCopy.isPlaced = true;
letterCopy.isHintLetter = false; // Initialize as not a hint letter
letterCopy.down = function (x, y, obj) {
// Only allow removal if not a hint letter
if (!letterCopy.isHintLetter) {
removeLetter(letter);
}
};
slot.letterCopy = letterCopy;
game.addChild(letterCopy);
}
function showSettings() {
game.removeChildren();
gameState = 'settings';
// Settings title
var title = new Text2(languageTexts[currentLanguage].settings, {
size: 120,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 400;
game.addChild(title);
// Language section title
var langTitle = new Text2(languageTexts[currentLanguage].language, {
size: 80,
fill: 0xFFD700
});
langTitle.anchor.set(0.5, 0.5);
langTitle.x = 1024;
langTitle.y = 600;
game.addChild(langTitle);
// Turkish language button
var turkishButton = new CategoryButton(languageTexts[currentLanguage].turkish);
turkishButton.x = 700;
turkishButton.y = 750;
if (currentLanguage === 'tr') {
turkishButton.alpha = 1.0; // Fully visible when selected
} else {
turkishButton.alpha = 0.6; // Dimmed when not selected
}
turkishButton.down = function (x, y, obj) {
turkishButton.scaleX = 0.95;
turkishButton.scaleY = 0.95;
currentLanguage = 'tr';
storage.currentLanguage = currentLanguage;
showSettings(); // Refresh settings screen
};
turkishButton.up = function (x, y, obj) {
turkishButton.scaleX = 1;
turkishButton.scaleY = 1;
};
game.addChild(turkishButton);
// English language button
var englishButton = new CategoryButton(languageTexts[currentLanguage].english);
englishButton.x = 1348;
englishButton.y = 750;
if (currentLanguage === 'en') {
englishButton.alpha = 1.0; // Fully visible when selected
} else {
englishButton.alpha = 0.6; // Dimmed when not selected
}
englishButton.down = function (x, y, obj) {
englishButton.scaleX = 0.95;
englishButton.scaleY = 0.95;
currentLanguage = 'en';
storage.currentLanguage = currentLanguage;
showSettings(); // Refresh settings screen
};
englishButton.up = function (x, y, obj) {
englishButton.scaleX = 1;
englishButton.scaleY = 1;
};
game.addChild(englishButton);
// Reset data button
var resetButton = new CategoryButton(languageTexts[currentLanguage].resetData);
resetButton.x = 1024;
resetButton.y = 950;
resetButton.down = function (x, y, obj) {
resetButton.scaleX = 0.95;
resetButton.scaleY = 0.95;
showResetConfirmation();
};
resetButton.up = function (x, y, obj) {
resetButton.scaleX = 1;
resetButton.scaleY = 1;
};
game.addChild(resetButton);
// Back to menu button
var backButton = new CategoryButton(languageTexts[currentLanguage].backToMenu);
backButton.x = 1024;
backButton.y = 1200;
backButton.down = function (x, y, obj) {
backButton.scaleX = 0.95;
backButton.scaleY = 0.95;
initializeMenu();
};
backButton.up = function (x, y, obj) {
backButton.scaleX = 1;
backButton.scaleY = 1;
};
game.addChild(backButton);
updateCoinDisplay();
}
function showResetConfirmation() {
game.removeChildren();
gameState = 'resetConfirm';
// Confirmation title
var title = new Text2(languageTexts[currentLanguage].resetConfirm, {
size: 100,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 600;
game.addChild(title);
// Yes button
var yesButton = new CategoryButton(languageTexts[currentLanguage].yes);
yesButton.x = 700;
yesButton.y = 1000;
yesButton.down = function (x, y, obj) {
yesButton.scaleX = 0.95;
yesButton.scaleY = 0.95;
// Reset all game progress except coins
storage.completedLogos = {};
completedLogos = {};
storage.completedWithoutHints = {};
completedWithoutHints = {};
storage.categoryCompletions = {
'Technology': 0,
'Football': 0,
'Cars': 0,
'Food': 0,
'Footballers': 0,
'Flags': 0,
'Games': 0
};
categoryCompletions = {
'Technology': 0,
'Football': 0,
'Cars': 0,
'Food': 0,
'Footballers': 0,
'Flags': 0,
'Games': 0
};
// Clear all hint letters from storage
for (var category in logoDatabase) {
var logos = logoDatabase[category];
for (var i = 0; i < logos.length; i++) {
var logoKey = category + '_' + logos[i].name;
// Clear all possible hint positions for this logo
for (var j = 0; j < 20; j++) {
// Using 20 as max possible answer length
var hintKey = logoKey + '_hint_' + j;
delete storage[hintKey];
}
}
}
// Flash screen to show reset happened
LK.effects.flashScreen(0xFF0000, 500);
// Go back to main menu after reset
LK.setTimeout(function () {
initializeMenu();
}, 1000);
};
yesButton.up = function (x, y, obj) {
yesButton.scaleX = 1;
yesButton.scaleY = 1;
};
game.addChild(yesButton);
// No button
var noButton = new CategoryButton(languageTexts[currentLanguage].no);
noButton.x = 1348;
noButton.y = 1000;
noButton.down = function (x, y, obj) {
noButton.scaleX = 0.95;
noButton.scaleY = 0.95;
showSettings();
};
noButton.up = function (x, y, obj) {
noButton.scaleX = 1;
noButton.scaleY = 1;
};
game.addChild(noButton);
updateCoinDisplay();
}
function showCompletedLogo(logoData) {
game.removeChildren();
gameState = 'completed';
currentLogo = logoData;
// Logo display area - larger and more prominent visual logo
var logoAssetName = logoData.name.toLowerCase() + 'Logo';
if (logoData.name === 'Real Madrid') {
logoAssetName = 'realmadridLogo';
}
if (logoData.name === 'Manchester United') {
logoAssetName = 'manchesterLogo';
}
if (logoData.name === 'McDonalds') {
logoAssetName = 'mcdonaldsLogo';
}
if (logoData.name === 'Pizza Hut') {
logoAssetName = 'pizzahutLogo';
}
if (logoData.name === 'Instagram') {
logoAssetName = 'instagramLogo';
}
if (logoData.name === 'TikTok') {
logoAssetName = 'tiktokLogo';
}
if (logoData.name === 'Burger King') {
logoAssetName = 'burgerkingLogo';
}
if (logoData.name === 'Bayern München') {
logoAssetName = 'bayernmunchenLogo';
}
if (logoData.name === 'Galatasaray') {
logoAssetName = 'galatasarayLogo';
}
if (logoData.name === 'Tesla') {
logoAssetName = 'teslaLogo';
}
if (logoData.name === 'Lamborghini') {
logoAssetName = 'lamborghiniLogo';
}
if (logoData.name === 'Tog') {
logoAssetName = 'togLogo';
}
if (logoData.name === 'ChatGPT') {
logoAssetName = 'chatgptLogo';
}
if (logoData.name === 'Xiaomi') {
logoAssetName = 'xiaomiLogo';
}
// Footballers category assets
if (logoData.name === 'Messi') {
logoAssetName = 'messiLogo';
}
if (logoData.name === 'Ronaldo') {
logoAssetName = 'ronaldoLogo';
}
if (logoData.name === 'Neymar') {
logoAssetName = 'neymarLogo';
}
if (logoData.name === 'Mbappe') {
logoAssetName = 'mbappeLogo';
}
if (logoData.name === 'Haaland') {
logoAssetName = 'haalandLogo';
}
if (logoData.name === 'Benzema') {
logoAssetName = 'benzemaLogo';
}
if (logoData.name === 'Lewandowski') {
logoAssetName = 'lewandowskiLogo';
}
if (logoData.name === 'Mesut Ozil') {
logoAssetName = 'mesutoezilLogo';
}
if (logoData.name === 'Arda Guler') {
logoAssetName = 'ardagulerLogo';
}
if (logoData.name === 'Luka Modric') {
logoAssetName = 'lukamodricLogo';
}
if (logoData.name === 'Vinicius Junior') {
logoAssetName = 'viniciusjuniorLogo';
}
if (logoData.name === 'Erling Haaland') {
logoAssetName = 'erlinghaalandLogo';
}
if (logoData.name === 'Lamin Yemal') {
logoAssetName = 'laminyemalLogo';
}
// Flags category assets
if (logoData.name === 'Turkey') {
logoAssetName = 'turkeyLogo';
}
if (logoData.name === 'Germany') {
logoAssetName = 'germanyLogo';
}
if (logoData.name === 'France') {
logoAssetName = 'franceLogo';
}
if (logoData.name === 'Spain') {
logoAssetName = 'spainLogo';
}
if (logoData.name === 'Italy') {
logoAssetName = 'italyLogo';
}
if (logoData.name === 'Brazil') {
logoAssetName = 'brazilLogo';
}
if (logoData.name === 'Argentina') {
logoAssetName = 'argentinaLogo';
}
// Games category assets
if (logoData.name === 'Minecraft') {
logoAssetName = 'minecraftLogo';
}
if (logoData.name === 'Fortnite') {
logoAssetName = 'fortniteLogo';
}
if (logoData.name === 'PUBG') {
logoAssetName = 'pubgLogo';
}
if (logoData.name === 'Among Us') {
logoAssetName = 'amongusLogo';
}
if (logoData.name === 'Clash of Clans') {
logoAssetName = 'clashofclansLogo';
}
if (logoData.name === 'Clash Royale') {
logoAssetName = 'clashroyaleLogo';
}
if (logoData.name === 'Candy Crush') {
logoAssetName = 'candycrushLogo';
}
if (logoData.name === 'Pokemon Go') {
logoAssetName = 'pokemongoLogo';
}
if (logoData.name === 'Subway Surfers') {
logoAssetName = 'subwaysurfersLogo';
}
if (logoData.name === 'Temple Run') {
logoAssetName = 'templerunLogo';
}
if (logoData.name === 'Angry Birds') {
logoAssetName = 'angrybirdsLogo';
}
if (logoData.name === 'Roblox') {
logoAssetName = 'robloxLogo';
}
var logoVisual = LK.getAsset(logoAssetName, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
logoVisual.x = 1024;
logoVisual.y = 500;
game.addChild(logoVisual);
// Show "COMPLETED" text
var completedText = new Text2(languageTexts[currentLanguage].completedText, {
size: 100,
fill: 0x00FF00
});
completedText.anchor.set(0.5, 0.5);
completedText.x = 1024;
completedText.y = 800;
game.addChild(completedText);
// Show the answer
var displayName = logoData.name;
if (logoData.name === 'Burger King') {
displayName = 'Burger King'; // Ensure space between Burger and King
}
if (logoData.name === 'Real Madrid') {
displayName = 'Real Madrid';
}
if (logoData.name === 'Manchester United') {
displayName = 'Manchester United';
}
if (logoData.name === 'Pizza Hut') {
displayName = 'Pizza Hut';
}
if (logoData.name === 'Bayern München') {
displayName = 'Bayern München';
}
if (logoData.name === 'Mesut Ozil') {
displayName = 'Mesut Özil';
}
if (logoData.name === 'Arda Guler') {
displayName = 'Arda Güler';
}
if (logoData.name === 'Luka Modric') {
displayName = 'Luka Modrić';
}
if (logoData.name === 'Vinicius Junior') {
displayName = 'Vinícius Jr.';
}
if (logoData.name === 'Erling Haaland') {
displayName = 'Erling Haaland';
}
if (logoData.name === 'Lamin Yemal') {
displayName = 'Lamine Yamal';
}
var answerText = new Text2(displayName, {
size: 80,
fill: 0xFFFFFF
});
answerText.anchor.set(0.5, 0.5);
answerText.x = 1024;
answerText.y = 900;
game.addChild(answerText);
// Show coin reward text
var coinRewardText = new Text2('+10', {
size: 60,
fill: 0xFFD700
});
coinRewardText.anchor.set(0.5, 0.5);
coinRewardText.x = 1024;
coinRewardText.y = 950;
game.addChild(coinRewardText);
// Add checkmark
var checkmark = LK.getAsset('checkmark', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
checkmark.x = 1024;
checkmark.y = 1050;
game.addChild(checkmark);
// Exit button
var exitBtn = new ExitButton();
exitBtn.x = 1024;
exitBtn.y = 1300;
exitBtn.down = function (x, y, obj) {
exitBtn.scaleX = 0.95;
exitBtn.scaleY = 0.95;
showCategoryLogos(currentCategory); // Return to category view
};
exitBtn.up = function (x, y, obj) {
exitBtn.scaleX = 1;
exitBtn.scaleY = 1;
};
game.addChild(exitBtn);
updateCoinDisplay();
}
function checkAnswer() {
var playerAnswer = '';
for (var i = 0; i < answerSlots.length; i++) {
var slot = answerSlots[i];
if (slot.occupiedLetter) {
playerAnswer += slot.occupiedLetter.letter;
} else {
return; // Not all slots filled
}
}
// Get the appropriate answer based on language and category
var correctAnswer = currentLogo.answer;
if (currentCategory === 'Flags' && currentLanguage === 'tr' && currentLogo.answerTR) {
correctAnswer = currentLogo.answerTR;
}
if (playerAnswer === correctAnswer) {
// Correct answer
goldCoins += 10;
storage.goldCoins = goldCoins;
// Mark logo as completed
var logoKey = currentCategory + '_' + currentLogo.name;
if (!completedLogos[logoKey]) {
completedLogos[logoKey] = true;
storage.completedLogos = completedLogos;
// Only count towards hint-free completion tracking if no hint was used
if (!currentLogoUsedHint) {
completedWithoutHints[logoKey] = true;
storage.completedWithoutHints = completedWithoutHints;
}
// Update category completions - count all completed logos for category unlocking
updateCategoryCompletions();
}
LK.getSound('correctAnswer').play();
LK.getSound('coinEarned').play();
LK.effects.flashScreen(0x00FF00, 500);
LK.setTimeout(function () {
showCategoryLogos(currentCategory);
}, 1000);
} else {
// Wrong answer - flash all answer slots red using optimized method
var wrongAnswerSlots = [];
for (var j = 0; j < answerSlots.length; j++) {
if (answerSlots[j] && answerSlots[j].letterCopy) {
wrongAnswerSlots.push(answerSlots[j].letterCopy);
}
}
// Batch tween operations for better performance
if (wrongAnswerSlots.length > 0) {
for (var k = 0; k < wrongAnswerSlots.length; k++) {
var letterRef = wrongAnswerSlots[k];
letterRef.tint = 0xFF0000;
// Use single tween back to normal instead of chained tweens
tween(letterRef, {
tint: 0xFFFFFF
}, {
duration: 500,
delay: 200
});
}
}
// Also flash the screen red briefly
LK.effects.flashScreen(0xFF0000, 300);
}
}
function handleMove(x, y, obj) {
// Move handler no longer needed for letter dragging
}
game.move = handleMove;
game.up = function (x, y, obj) {
// Up handler no longer needed for letter dragging
};
// Performance optimization variables
var lastFrameTime = 0;
var targetFPS = 60;
var frameInterval = 1000 / targetFPS;
// Optimize memory management
var memoryCleanupCounter = 0;
game.update = function () {
// Limit frame rate for stability
var currentTime = Date.now();
if (currentTime - lastFrameTime < frameInterval) {
return;
}
lastFrameTime = currentTime;
// Periodic memory cleanup
memoryCleanupCounter++;
if (memoryCleanupCounter > 300) {
// Every 5 seconds at 60fps
memoryCleanupCounter = 0;
// Force garbage collection hints
if (window.gc) {
window.gc();
}
}
};
// Initialize the game
initializeMenu(); /****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var AnswerSlot = Container.expand(function (index) {
var self = Container.call(this);
var bg = self.attachAsset('answerBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.index = index;
self.occupiedLetter = null;
return self;
});
var CategoryButton = Container.expand(function (category) {
var self = Container.call(this);
var bg = self.attachAsset('categoryButton', {
anchorX: 0.5,
anchorY: 0.5
});
// Set background color based on category
if (category === 'Cars') {
bg.tint = 0x000000; // Black background for Cars (Arabalar)
} else if (category === 'Food') {
bg.tint = 0xFF0000; // Red background for Food (Yemekler)
} else if (category === 'Football') {
bg.tint = 0x00FF00; // Green background for Football (Futbol)
} else if (category === 'Footballers') {
bg.tint = 0x0000FF; // Blue background for Footballers (Futbolcu)
} else if (category === 'Flags') {
bg.tint = 0xFF00FF; // Magenta background for Flags (Bayraqlar)
} else if (category === 'Games') {
bg.tint = 0x800080; // Purple background for Games (Oyunlar)
}
var text = new Text2(category, {
size: 80,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
self.category = category;
self.down = function (x, y, obj) {
self.scaleX = 0.95;
self.scaleY = 0.95;
showCategoryLogos(self.category);
};
self.up = function (x, y, obj) {
self.scaleX = 1;
self.scaleY = 1;
};
return self;
});
var ExitButton = Container.expand(function () {
var self = Container.call(this);
var bg = self.attachAsset('exitButton', {
anchorX: 0.5,
anchorY: 0.5
});
var text = new Text2('Exit', {
size: 50,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
self.down = function (x, y, obj) {
self.scaleX = 0.95;
self.scaleY = 0.95;
showCategoryLogos(currentCategory);
};
self.up = function (x, y, obj) {
self.scaleX = 1;
self.scaleY = 1;
};
return self;
});
var HintButton = Container.expand(function () {
var self = Container.call(this);
var bg = self.attachAsset('hintButton', {
anchorX: 0.5,
anchorY: 0.5
});
var text = new Text2('Hint (5 coins)', {
size: 50,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
self.down = function (x, y, obj) {
if (goldCoins >= 5) {
useHint();
}
};
return self;
});
var LetterTile = Container.expand(function (letter) {
var self = Container.call(this);
var bg = self.attachAsset('letterTile', {
anchorX: 0.5,
anchorY: 0.5
});
var text = new Text2(letter, {
size: 60,
fill: 0x333333
});
text.anchor.set(0.5, 0.5);
// Ensure text is visible and properly positioned
text.x = 0;
text.y = 0;
text.alpha = 1;
text.visible = true;
self.addChild(text);
self.letter = letter;
self.originalX = 0;
self.originalY = 0;
self.isPlaced = false;
self.targetSlot = null;
// Store reference to text for easier access
self.letterText = text;
self.down = function (x, y, obj) {
if (!self.isPlaced) {
// Find next available answer slot
var nextSlot = null;
for (var i = 0; i < answerSlots.length; i++) {
if (!answerSlots[i].occupiedLetter) {
nextSlot = answerSlots[i];
break;
}
}
if (nextSlot) {
placeLetter(self, nextSlot);
checkAnswer();
}
} else {
// Letter is placed, remove it from answer slot
removeLetter(self);
}
};
return self;
});
var LogoButton = Container.expand(function (logoName, logoData) {
var self = Container.call(this);
var bg = self.attachAsset('logoContainer', {
anchorX: 0.5,
anchorY: 0.5
});
// Get logo asset name from company name
var logoAssetName = logoData.name.toLowerCase() + 'Logo';
if (logoData.name === 'Real Madrid') {
logoAssetName = 'realmadridLogo';
}
if (logoData.name === 'Manchester United') {
logoAssetName = 'manchesterLogo';
}
if (logoData.name === 'McDonalds') {
logoAssetName = 'mcdonaldsLogo';
}
if (logoData.name === 'Pizza Hut') {
logoAssetName = 'pizzahutLogo';
}
if (logoData.name === 'Instagram') {
logoAssetName = 'instagramLogo';
}
if (logoData.name === 'TikTok') {
logoAssetName = 'tiktokLogo';
}
if (logoData.name === 'Burger King') {
logoAssetName = 'burgerkingLogo';
}
if (logoData.name === 'Bayern München') {
logoAssetName = 'bayernmunchenLogo';
}
if (logoData.name === 'Galatasaray') {
logoAssetName = 'galatasarayLogo';
}
if (logoData.name === 'Tesla') {
logoAssetName = 'teslaLogo';
}
if (logoData.name === 'Lamborghini') {
logoAssetName = 'lamborghiniLogo';
}
if (logoData.name === 'Tog') {
logoAssetName = 'togLogo';
}
if (logoData.name === 'ChatGPT') {
logoAssetName = 'chatgptLogo';
}
if (logoData.name === 'Xiaomi') {
logoAssetName = 'xiaomiLogo';
}
// Footballers category assets
if (logoData.name === 'Messi') {
logoAssetName = 'messiLogo';
}
if (logoData.name === 'Ronaldo') {
logoAssetName = 'ronaldoLogo';
}
if (logoData.name === 'Neymar') {
logoAssetName = 'neymarLogo';
}
if (logoData.name === 'Mbappe') {
logoAssetName = 'mbappeLogo';
}
if (logoData.name === 'Haaland') {
logoAssetName = 'haalandLogo';
}
if (logoData.name === 'Benzema') {
logoAssetName = 'benzemaLogo';
}
if (logoData.name === 'Lewandowski') {
logoAssetName = 'lewandowskiLogo';
}
if (logoData.name === 'Mesut Ozil') {
logoAssetName = 'mesutoezilLogo';
}
if (logoData.name === 'Arda Guler') {
logoAssetName = 'ardagulerLogo';
}
if (logoData.name === 'Luka Modric') {
logoAssetName = 'lukamodricLogo';
}
if (logoData.name === 'Vinicius Junior') {
logoAssetName = 'viniciusjuniorLogo';
}
if (logoData.name === 'Erling Haaland') {
logoAssetName = 'erlinghaalandLogo';
}
if (logoData.name === 'Lamin Yemal') {
logoAssetName = 'laminyemalLogo';
}
// Flags category assets
if (logoData.name === 'Turkey') {
logoAssetName = 'turkeyLogo';
}
if (logoData.name === 'Germany') {
logoAssetName = 'germanyLogo';
}
if (logoData.name === 'France') {
logoAssetName = 'franceLogo';
}
if (logoData.name === 'Spain') {
logoAssetName = 'spainLogo';
}
if (logoData.name === 'Italy') {
logoAssetName = 'italyLogo';
}
if (logoData.name === 'Brazil') {
logoAssetName = 'brazilLogo';
}
if (logoData.name === 'Argentina') {
logoAssetName = 'argentinaLogo';
}
// Games category assets
if (logoData.name === 'Minecraft') {
logoAssetName = 'minecraftLogo';
}
if (logoData.name === 'Fortnite') {
logoAssetName = 'fortniteLogo';
}
if (logoData.name === 'PUBG') {
logoAssetName = 'pubgLogo';
}
if (logoData.name === 'Among Us') {
logoAssetName = 'amongusLogo';
}
if (logoData.name === 'Clash of Clans') {
logoAssetName = 'clashofclansLogo';
}
if (logoData.name === 'Clash Royale') {
logoAssetName = 'clashroyaleLogo';
}
if (logoData.name === 'Candy Crush') {
logoAssetName = 'candycrushLogo';
}
if (logoData.name === 'Pokemon Go') {
logoAssetName = 'pokemongoLogo';
}
if (logoData.name === 'Subway Surfers') {
logoAssetName = 'subwaysurfersLogo';
}
if (logoData.name === 'Temple Run') {
logoAssetName = 'templerunLogo';
}
if (logoData.name === 'Angry Birds') {
logoAssetName = 'angrybirdsLogo';
}
if (logoData.name === 'Roblox') {
logoAssetName = 'robloxLogo';
}
var logoVisual = self.attachAsset(logoAssetName, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
self.logoData = logoData;
self.down = function (x, y, obj) {
// Check if logo is completed
var logoKey = currentCategory + '_' + self.logoData.name;
if (completedLogos[logoKey]) {
// Show completed logo name instead of starting the game
showCompletedLogo(self.logoData);
return;
}
self.scaleX = 0.95;
self.scaleY = 0.95;
startLogoGuess(self.logoData);
};
self.up = function (x, y, obj) {
self.scaleX = 1;
self.scaleY = 1;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2C3E50
});
/****
* Game Code
****/
// Game state variables
// Logo assets - Technology
// Logo assets - Football
// Logo assets - Cars
// Logo assets - Food
var gameState = 'menu'; // 'menu', 'category', 'guessing'
var goldCoins = storage.goldCoins || 10;
var currentLanguage = storage.currentLanguage || 'tr'; // 'tr' for Turkish, 'en' for English
var completedLogos = storage.completedLogos || {};
var completedWithoutHints = storage.completedWithoutHints || {};
var categoryCompletions = storage.categoryCompletions || {
'Technology': 0,
'Football': 0,
'Cars': 0,
'Food': 0,
'Footballers': 0,
'Flags': 0,
'Games': 0
};
var currentLogoUsedHint = false;
// Recalculate category completions based on completed logos to ensure accuracy
function updateCategoryCompletions() {
// Reset counts
for (var category in categoryCompletions) {
categoryCompletions[category] = 0;
}
// Count ALL completed logos for category unlocking
for (var logoKey in completedLogos) {
if (completedLogos[logoKey]) {
var category = logoKey.split('_')[0];
if (categoryCompletions[category] !== undefined) {
categoryCompletions[category]++;
}
}
}
storage.categoryCompletions = categoryCompletions;
}
// Update completions on game start
updateCategoryCompletions();
var currentCategory = '';
var currentLogo = null;
var draggedLetter = null;
var letterTiles = [];
var answerSlots = [];
var currentAnswer = '';
// Language configuration
var languageTexts = {
tr: {
title: 'Logo Quiz Challenge',
completed: 'Tamamlanan: ',
settings: 'Ayarlar',
language: 'Dil',
turkish: 'Türkçe',
english: 'İngilizce',
resetData: 'Tüm Verileri Sıfırla',
backToMenu: 'Ana Menüye Dön',
resetConfirm: 'Silmek İstediğinden Emin Misin?',
yes: 'Evet',
no: 'Hayır',
completedText: 'TAMAMLANDI'
},
en: {
title: 'Logo Quiz Challenge',
completed: 'Completed: ',
settings: 'Settings',
language: 'Language',
turkish: 'Turkish',
english: 'English',
resetData: 'Reset All Data',
backToMenu: 'Back to Menu',
resetConfirm: 'Are you sure you want to delete?',
yes: 'Yes',
no: 'No',
completedText: 'COMPLETED'
}
};
// Logo data
var logoDatabase = {
'Technology': [{
name: 'Apple',
answer: 'APPLE'
}, {
name: 'Google',
answer: 'GOOGLE'
}, {
name: 'Microsoft',
answer: 'MICROSOFT'
}, {
name: 'Samsung',
answer: 'SAMSUNG'
}, {
name: 'Instagram',
answer: 'INSTAGRAM'
}, {
name: 'TikTok',
answer: 'TIKTOK'
}, {
name: 'ChatGPT',
answer: 'CHATGPT'
}, {
name: 'Xiaomi',
answer: 'XIAOMI'
}],
'Football': [{
name: 'Barcelona',
answer: 'BARCELONA'
}, {
name: 'Real Madrid',
answer: 'REALMADRID'
}, {
name: 'Liverpool',
answer: 'LIVERPOOL'
}, {
name: 'Manchester United',
answer: 'MANCHESTER'
}, {
name: 'Arsenal',
answer: 'ARSENAL'
}, {
name: 'Bayern München',
answer: 'BAYERNMUNCHEN'
}, {
name: 'Galatasaray',
answer: 'GALATASARAY'
}],
'Cars': [{
name: 'BMW',
answer: 'BMW'
}, {
name: 'Mercedes',
answer: 'MERCEDES'
}, {
name: 'Toyota',
answer: 'TOYOTA'
}, {
name: 'Ferrari',
answer: 'FERRARI'
}, {
name: 'Audi',
answer: 'AUDI'
}, {
name: 'Tesla',
answer: 'TESLA'
}, {
name: 'Lamborghini',
answer: 'LAMBORGHINI'
}, {
name: 'Tog',
answer: 'TOGG'
}],
'Food': [{
name: 'McDonalds',
answer: 'MCDONALDS'
}, {
name: 'KFC',
answer: 'KFC'
}, {
name: 'Subway',
answer: 'SUBWAY'
}, {
name: 'Pizza Hut',
answer: 'PIZZAHUT'
}, {
name: 'Starbucks',
answer: 'STARBUCKS'
}, {
name: 'Dominos',
answer: 'DOMINOS'
}, {
name: 'Burger King',
answer: 'BURGERKING'
}],
'Footballers': [{
name: 'Messi',
answer: 'MESSI'
}, {
name: 'Ronaldo',
answer: 'RONALDO'
}, {
name: 'Neymar',
answer: 'NEYMAR'
}, {
name: 'Mbappe',
answer: 'MBAPPE'
}, {
name: 'Haaland',
answer: 'HAALAND'
}, {
name: 'Benzema',
answer: 'BENZEMA'
}, {
name: 'Lewandowski',
answer: 'LEWANDOWSKI'
}, {
name: 'Mesut Ozil',
answer: 'MESUTOEZIL'
}, {
name: 'Arda Guler',
answer: 'ARDAGULER'
}, {
name: 'Luka Modric',
answer: 'LUKAMODRIC'
}, {
name: 'Vinicius Junior',
answer: 'VINICIUSJUNIOR'
}, {
name: 'Lamin Yemal',
answer: 'LAMINYEMAL'
}],
'Flags': [{
name: 'Turkey',
answer: 'TURKEY',
answerTR: 'TURKIYE'
}, {
name: 'Germany',
answer: 'GERMANY',
answerTR: 'ALMANYA'
}, {
name: 'France',
answer: 'FRANCE',
answerTR: 'FRANSA'
}, {
name: 'Spain',
answer: 'SPAIN',
answerTR: 'ISPANYA'
}, {
name: 'Italy',
answer: 'ITALY',
answerTR: 'ITALYA'
}, {
name: 'Brazil',
answer: 'BRAZIL',
answerTR: 'BREZILYA'
}, {
name: 'Argentina',
answer: 'ARGENTINA',
answerTR: 'ARJANTIN'
}],
'Games': [{
name: 'Minecraft',
answer: 'MINECRAFT'
}, {
name: 'Fortnite',
answer: 'FORTNITE'
}, {
name: 'PUBG',
answer: 'PUBG'
}, {
name: 'Among Us',
answer: 'AMONGUS'
}, {
name: 'Clash of Clans',
answer: 'CLASHOFCLANS'
}, {
name: 'Clash Royale',
answer: 'CLASHROYALE'
}, {
name: 'Candy Crush',
answer: 'CANDYCRUSH'
}, {
name: 'Pokemon Go',
answer: 'POKEMONGO'
}, {
name: 'Subway Surfers',
answer: 'SUBWAYSURFERS'
}, {
name: 'Temple Run',
answer: 'TEMPLERUN'
}, {
name: 'Angry Birds',
answer: 'ANGRYBIRDS'
}, {
name: 'Roblox',
answer: 'ROBLOX'
}]
};
// UI Elements
var coinDisplay;
var backButton;
function isCategoryUnlocked(category) {
// Technology is always unlocked
if (category === 'Technology') return true;
// Football unlocks after 2 Technology completions
if (category === 'Football') return categoryCompletions['Technology'] >= 2;
// Cars unlocks after 2 Football completions
if (category === 'Cars') return categoryCompletions['Football'] >= 2;
// Food unlocks after 2 Cars completions
if (category === 'Food') return categoryCompletions['Cars'] >= 2;
// Footballers unlocks after 2 Food completions
if (category === 'Footballers') return categoryCompletions['Food'] >= 2;
// Flags unlocks after 2 Footballers completions
if (category === 'Flags') return categoryCompletions['Footballers'] >= 2;
// Games unlocks after 2 Flags completions
if (category === 'Games') return categoryCompletions['Flags'] >= 2;
return false;
}
function showLockedCategoryMessage(category) {
// Calculate requirements
var requiredCategory = '';
var requiredCount = 2;
var currentCompleted = 0;
var remaining = 0;
if (category === 'Football') {
requiredCategory = 'Technology';
currentCompleted = categoryCompletions['Technology'];
} else if (category === 'Cars') {
requiredCategory = 'Football';
currentCompleted = categoryCompletions['Football'];
} else if (category === 'Food') {
requiredCategory = 'Cars';
currentCompleted = categoryCompletions['Cars'];
} else if (category === 'Footballers') {
requiredCategory = 'Food';
currentCompleted = categoryCompletions['Food'];
} else if (category === 'Flags') {
requiredCategory = 'Footballers';
currentCompleted = categoryCompletions['Footballers'];
} else if (category === 'Games') {
requiredCategory = 'Flags';
currentCompleted = categoryCompletions['Flags'];
}
remaining = Math.max(0, requiredCount - currentCompleted);
// Create overlay message
var messageOverlay = new Container();
messageOverlay.x = 1024;
messageOverlay.y = 1366;
// Semi-transparent background
var bgShape = LK.getAsset('categoryButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 2.0
});
bgShape.tint = 0x000000;
bgShape.alpha = 0.8;
messageOverlay.addChild(bgShape);
// Main message text
var messageText = new Text2('Kilitli Kategori!', {
size: 80,
fill: 0xFF0000
});
messageText.anchor.set(0.5, 0.5);
messageText.y = -80;
messageOverlay.addChild(messageText);
// Requirement text showing remaining count
var requirementText = new Text2(remaining + ' tane daha ' + requiredCategory + ' çözmen gerekiyor', {
size: 60,
fill: 0xFFFFFF
});
requirementText.anchor.set(0.5, 0.5);
requirementText.y = 0;
messageOverlay.addChild(requirementText);
// Progress text showing current progress
var progressText = new Text2('Şu anda: ' + currentCompleted + '/' + requiredCount, {
size: 50,
fill: 0xFFD700
});
progressText.anchor.set(0.5, 0.5);
progressText.y = 60;
messageOverlay.addChild(progressText);
// Add to game
game.addChild(messageOverlay);
// Auto-remove after 3 seconds
LK.setTimeout(function () {
if (messageOverlay.parent) {
messageOverlay.parent.removeChild(messageOverlay);
messageOverlay.destroy();
}
}, 3000);
}
function initializeMenu() {
game.removeChildren();
gameState = 'menu';
// Title
var title = new Text2(languageTexts[currentLanguage].title, {
size: 120,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 500;
game.addChild(title);
// Calculate and display total completions
var totalCompleted = Object.keys(completedLogos).length;
var totalLogos = 0;
for (var category in logoDatabase) {
totalLogos += logoDatabase[category].length;
}
var progressText = new Text2(languageTexts[currentLanguage].completed + totalCompleted + '/' + totalLogos, {
size: 80,
fill: 0xFFD700
});
progressText.anchor.set(0.5, 0.5);
progressText.x = 1024;
progressText.y = 600;
game.addChild(progressText);
// Category buttons
var categories = ['Technology', 'Football', 'Cars', 'Food', 'Footballers', 'Flags', 'Games'];
for (var i = 0; i < categories.length; i++) {
var isUnlocked = isCategoryUnlocked(categories[i]);
var button = new CategoryButton(categories[i]);
button.x = 1024;
button.y = 800 + i * 220;
// Visual feedback for locked categories
if (!isUnlocked) {
button.alpha = 0.5;
// Override the down handler to show requirement message for locked categories
button.down = function (x, y, obj) {
showLockedCategoryMessage(categories[i]);
};
// Add lock symbol
var lockText = new Text2('🔒', {
size: 60,
fill: 0xFFFFFF
});
lockText.anchor.set(0.5, 0.5);
lockText.x = 300; // Position to the right of category name
lockText.y = 0;
button.addChild(lockText);
// Show completion requirement
var reqText = '';
if (categories[i] === 'Football') reqText = '(' + categoryCompletions['Technology'] + '/2 Technology)';else if (categories[i] === 'Cars') reqText = '(' + categoryCompletions['Football'] + '/2 Football)';else if (categories[i] === 'Food') reqText = '(' + categoryCompletions['Cars'] + '/2 Cars)';else if (categories[i] === 'Footballers') reqText = '(' + categoryCompletions['Food'] + '/2 Food)';else if (categories[i] === 'Flags') reqText = '(' + categoryCompletions['Footballers'] + '/2 Footballers)';else if (categories[i] === 'Games') reqText = '(' + categoryCompletions['Flags'] + '/2 Flags)';
if (reqText) {
var requirementText = new Text2(reqText, {
size: 40,
fill: 0xFFFFFF
});
requirementText.anchor.set(0.5, 0.5);
requirementText.x = 0;
requirementText.y = 60;
button.addChild(requirementText);
}
}
game.addChild(button);
}
// Settings icon - larger circular button below coin display
var settingsIcon = LK.getAsset('settingsIcon', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
settingsIcon.x = 1848; // Same X position as coin display
settingsIcon.y = 320; // Further below coin display
settingsIcon.down = function (x, y, obj) {
settingsIcon.scaleX = 0.95;
settingsIcon.scaleY = 0.95;
showSettings();
};
settingsIcon.up = function (x, y, obj) {
settingsIcon.scaleX = 1.0;
settingsIcon.scaleY = 1.0;
};
game.addChild(settingsIcon);
// Add gear symbol text on top of settings icon
var gearSymbol = new Text2('⚙', {
size: 60,
fill: 0xFFFFFF
});
gearSymbol.anchor.set(0.5, 0.5);
gearSymbol.x = 1848;
gearSymbol.y = 320;
game.addChild(gearSymbol);
updateCoinDisplay();
}
function showCategoryLogos(category) {
// Batch clear operations for better performance
while (game.children.length > 0) {
var child = game.children[0];
game.removeChild(child);
if (child.destroy) {
child.destroy();
}
}
gameState = 'category';
currentCategory = category;
// Category title
var title = new Text2(category + ' Logos', {
size: 100,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 400;
game.addChild(title);
// Show category completion stats
var categoryCompleted = categoryCompletions[category] || 0;
var categoryTotal = logoDatabase[category].length;
var statsText = new Text2('Tamamlanan: ' + categoryCompleted + '/' + categoryTotal, {
size: 60,
fill: 0xFFD700
});
statsText.anchor.set(0.5, 0.5);
statsText.x = 1024;
statsText.y = 480;
game.addChild(statsText);
// Logo buttons - filter out completed logos
var logos = logoDatabase[category];
var availableLogos = [];
for (var i = 0; i < logos.length; i++) {
var logoKey = category + '_' + logos[i].name;
if (!completedLogos[logoKey]) {
availableLogos.push(logos[i]);
}
}
var cols = 3;
var startX = 1024 - (cols - 1) * 250;
var startY = 700;
// Show all logos with completion status
var allLogos = logoDatabase[category];
for (var i = 0; i < allLogos.length; i++) {
var logoButton = new LogoButton(allLogos[i].name + 'Logo', allLogos[i]);
logoButton.x = startX + i % cols * 500;
logoButton.y = startY + Math.floor(i / cols) * 450;
game.addChild(logoButton);
// Check if this logo is completed and add checkmark
var logoKey = category + '_' + allLogos[i].name;
if (completedLogos[logoKey]) {
var checkmark = logoButton.attachAsset('checkmark', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
checkmark.x = 150; // Position in top-right corner of logo button
checkmark.y = -150;
}
}
// Exit button
var exitBtn = new ExitButton();
exitBtn.x = 1848; // Position in top right area, below coins
exitBtn.y = 350; // Further below the coin display
exitBtn.down = function (x, y, obj) {
exitBtn.scaleX = 0.95;
exitBtn.scaleY = 0.95;
initializeMenu(); // Return to main menu instead of category
};
exitBtn.up = function (x, y, obj) {
exitBtn.scaleX = 1;
exitBtn.scaleY = 1;
};
game.addChild(exitBtn);
updateCoinDisplay();
}
function startLogoGuess(logoData) {
// Efficient cleanup
while (game.children.length > 0) {
var child = game.children[0];
game.removeChild(child);
if (child.destroy) {
child.destroy();
}
}
gameState = 'guessing';
currentLogo = logoData;
currentLogoUsedHint = false;
// Clear arrays efficiently
letterTiles.length = 0;
answerSlots.length = 0;
// Logo display area - larger and more prominent visual logo
var logoAssetName = logoData.name.toLowerCase() + 'Logo';
if (logoData.name === 'Real Madrid') {
logoAssetName = 'realmadridLogo';
}
if (logoData.name === 'Manchester United') {
logoAssetName = 'manchesterLogo';
}
if (logoData.name === 'McDonalds') {
logoAssetName = 'mcdonaldsLogo';
}
if (logoData.name === 'Pizza Hut') {
logoAssetName = 'pizzahutLogo';
}
if (logoData.name === 'Instagram') {
logoAssetName = 'instagramLogo';
}
if (logoData.name === 'TikTok') {
logoAssetName = 'tiktokLogo';
}
if (logoData.name === 'Burger King') {
logoAssetName = 'burgerkingLogo';
}
if (logoData.name === 'Bayern München') {
logoAssetName = 'bayernmunchenLogo';
}
if (logoData.name === 'Galatasaray') {
logoAssetName = 'galatasarayLogo';
}
if (logoData.name === 'Tesla') {
logoAssetName = 'teslaLogo';
}
if (logoData.name === 'Lamborghini') {
logoAssetName = 'lamborghiniLogo';
}
if (logoData.name === 'Tog') {
logoAssetName = 'togLogo';
}
if (logoData.name === 'ChatGPT') {
logoAssetName = 'chatgptLogo';
}
if (logoData.name === 'Xiaomi') {
logoAssetName = 'xiaomiLogo';
}
// Footballers category assets
if (logoData.name === 'Messi') {
logoAssetName = 'messiLogo';
}
if (logoData.name === 'Ronaldo') {
logoAssetName = 'ronaldoLogo';
}
if (logoData.name === 'Neymar') {
logoAssetName = 'neymarLogo';
}
if (logoData.name === 'Mbappe') {
logoAssetName = 'mbappeLogo';
}
if (logoData.name === 'Haaland') {
logoAssetName = 'haalandLogo';
}
if (logoData.name === 'Benzema') {
logoAssetName = 'benzemaLogo';
}
if (logoData.name === 'Lewandowski') {
logoAssetName = 'lewandowskiLogo';
}
if (logoData.name === 'Mesut Ozil') {
logoAssetName = 'mesutoezilLogo';
}
if (logoData.name === 'Arda Guler') {
logoAssetName = 'ardagulerLogo';
}
if (logoData.name === 'Luka Modric') {
logoAssetName = 'lukamodricLogo';
}
if (logoData.name === 'Vinicius Junior') {
logoAssetName = 'viniciusjuniorLogo';
}
if (logoData.name === 'Erling Haaland') {
logoAssetName = 'erlinghaalandLogo';
}
if (logoData.name === 'Lamin Yemal') {
logoAssetName = 'laminyemalLogo';
}
// Flags category assets
if (logoData.name === 'Turkey') {
logoAssetName = 'turkeyLogo';
}
if (logoData.name === 'Germany') {
logoAssetName = 'germanyLogo';
}
if (logoData.name === 'France') {
logoAssetName = 'franceLogo';
}
if (logoData.name === 'Spain') {
logoAssetName = 'spainLogo';
}
if (logoData.name === 'Italy') {
logoAssetName = 'italyLogo';
}
if (logoData.name === 'Brazil') {
logoAssetName = 'brazilLogo';
}
if (logoData.name === 'Argentina') {
logoAssetName = 'argentinaLogo';
}
// Games category assets
if (logoData.name === 'Minecraft') {
logoAssetName = 'minecraftLogo';
}
if (logoData.name === 'Fortnite') {
logoAssetName = 'fortniteLogo';
}
if (logoData.name === 'PUBG') {
logoAssetName = 'pubgLogo';
}
if (logoData.name === 'Among Us') {
logoAssetName = 'amongusLogo';
}
if (logoData.name === 'Clash of Clans') {
logoAssetName = 'clashofclansLogo';
}
if (logoData.name === 'Clash Royale') {
logoAssetName = 'clashroyaleLogo';
}
if (logoData.name === 'Candy Crush') {
logoAssetName = 'candycrushLogo';
}
if (logoData.name === 'Pokemon Go') {
logoAssetName = 'pokemongoLogo';
}
if (logoData.name === 'Subway Surfers') {
logoAssetName = 'subwaysurfersLogo';
}
if (logoData.name === 'Temple Run') {
logoAssetName = 'templerunLogo';
}
if (logoData.name === 'Angry Birds') {
logoAssetName = 'angrybirdsLogo';
}
if (logoData.name === 'Roblox') {
logoAssetName = 'robloxLogo';
}
var logoVisual = LK.getAsset(logoAssetName, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
logoVisual.x = 1024;
logoVisual.y = 500;
game.addChild(logoVisual);
// Get the appropriate answer based on language and category
var currentAnswer = logoData.answer;
if (currentCategory === 'Flags' && currentLanguage === 'tr' && logoData.answerTR) {
currentAnswer = logoData.answerTR;
}
// Create answer slots
var answerLength = currentAnswer.length;
var slotSpacing = 140;
var startX = 1024 - (answerLength - 1) * slotSpacing / 2;
for (var i = 0; i < answerLength; i++) {
var slot = new AnswerSlot(i);
slot.x = startX + i * slotSpacing;
slot.y = 900;
answerSlots.push(slot);
game.addChild(slot);
}
// Create letter tiles
createLetterTiles(currentAnswer);
// Restore any existing hint letters from storage
var logoKey = currentCategory + '_' + currentLogo.name;
for (var i = 0; i < answerSlots.length; i++) {
var hintKey = logoKey + '_hint_' + i;
var hintLetter = storage[hintKey];
if (hintLetter) {
// Find the corresponding letter tile
for (var j = 0; j < letterTiles.length; j++) {
var tile = letterTiles[j];
if (tile.letter === hintLetter && !tile.isPlaced) {
placeLetter(tile, answerSlots[i]);
// Mark as hint letter with green color
answerSlots[i].letterCopy.isHintLetter = true;
answerSlots[i].letterCopy.letterText.fill = 0x00FF00;
answerSlots[i].letterCopy.letterText.tint = 0x00FF00;
// Create green background for hint letter
var hintBackground = LK.getAsset('letterTile', {
anchorX: 0.5,
anchorY: 0.5
});
hintBackground.tint = 0x00FF00; // Green background
hintBackground.x = answerSlots[i].x;
hintBackground.y = answerSlots[i].y;
answerSlots[i].hintBackground = hintBackground;
game.addChild(hintBackground);
// Move letter copy to front
game.removeChild(answerSlots[i].letterCopy);
game.addChild(answerSlots[i].letterCopy);
break;
}
}
}
}
// Hint button
var hintBtn = new HintButton();
hintBtn.x = 1024;
hintBtn.y = 1200;
game.addChild(hintBtn);
// Exit button
var exitBtn = new ExitButton();
exitBtn.x = 1848; // Position in top right area, below coins
exitBtn.y = 350; // Further below the coin display
game.addChild(exitBtn);
updateCoinDisplay();
}
// Pre-allocated letter pool for reuse
var letterPool = [];
var poolIndex = 0;
function createLetterTiles(answer) {
// Clear existing tiles efficiently
for (var i = 0; i < letterTiles.length; i++) {
letterTiles[i].destroy();
}
letterTiles.length = 0;
poolIndex = 0;
var letters = answer.split('');
var decoyLetters = ['X', 'Z', 'Q', 'J', 'K', 'W', 'V', 'Y', 'H', 'P', 'C', 'U', 'N', 'D', 'F'];
var allLetters = letters.slice(); // Copy answer letters
// Add decoy letters to reach exactly 15 total letters
var decoyCount = 15 - letters.length;
if (decoyCount > 0) {
// Add decoy letters, cycling through the decoy array if needed
for (var d = 0; d < decoyCount; d++) {
allLetters.push(decoyLetters[d % decoyLetters.length]);
}
}
// If answer is longer than 15, just use the first 15 letters
if (allLetters.length > 15) {
allLetters = allLetters.slice(0, 15);
}
// Shuffle letters using optimized Fisher-Yates
for (var i = allLetters.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
if (i !== j) {
var temp = allLetters[i];
allLetters[i] = allLetters[j];
allLetters[j] = temp;
}
}
// Create tiles with object pooling
var cols = 5;
var startX = 1024 - (cols - 1) * 80;
var startY = 1450;
for (var i = 0; i < allLetters.length; i++) {
var tile = new LetterTile(allLetters[i]);
var posX = startX + i % cols * 160;
var posY = startY + Math.floor(i / cols) * 160;
tile.x = posX;
tile.y = posY;
// Store original position for reset functionality
tile.originalX = posX;
tile.originalY = posY;
// Ensure tile is visible
tile.alpha = 1;
tile.visible = true;
letterTiles.push(tile);
game.addChild(tile);
}
}
function createBackButton() {
// Back button functionality removed
}
function updateCoinDisplay() {
if (coinDisplay) {
coinDisplay.parent.removeChild(coinDisplay);
}
coinDisplay = new Container();
var coinIcon = coinDisplay.addChild(LK.getAsset('coinIcon', {
anchorX: 0.5,
anchorY: 0.5
}));
var coinText = new Text2(goldCoins.toString(), {
size: 60,
fill: 0xFFD700
});
coinText.anchor.set(1, 0.5);
coinText.x = -50;
coinDisplay.addChild(coinText);
coinDisplay.x = -80;
coinDisplay.y = 150;
LK.gui.topRight.addChild(coinDisplay);
}
function useHint() {
if (goldCoins < 5 || !currentLogo) {
return;
}
goldCoins -= 5;
storage.goldCoins = goldCoins;
currentLogoUsedHint = true;
updateCoinDisplay();
// Get the appropriate answer based on language and category
var hintAnswer = currentLogo.answer;
if (currentCategory === 'Flags' && currentLanguage === 'tr' && currentLogo.answerTR) {
hintAnswer = currentLogo.answerTR;
}
// Find all empty slots first
var emptySlots = [];
for (var i = 0; i < answerSlots.length; i++) {
var slot = answerSlots[i];
if (!slot.occupiedLetter) {
emptySlots.push({
slot: slot,
index: i
});
}
}
// If no empty slots, return
if (emptySlots.length === 0) {
return;
}
// Pick the first empty slot
var targetSlotInfo = emptySlots[0];
var correctLetter = hintAnswer[targetSlotInfo.index];
// Find the letter tile
for (var j = 0; j < letterTiles.length; j++) {
var tile = letterTiles[j];
if (tile.letter === correctLetter && !tile.isPlaced) {
placeLetter(tile, targetSlotInfo.slot);
// Mark this as a hint letter - permanent and different color
targetSlotInfo.slot.letterCopy.isHintLetter = true;
targetSlotInfo.slot.letterCopy.letterText.fill = 0x00FF00; // Green color for hint letters
targetSlotInfo.slot.letterCopy.letterText.tint = 0x00FF00; // Apply green tint as well
// Create green background for hint letter
var hintBackground = LK.getAsset('letterTile', {
anchorX: 0.5,
anchorY: 0.5
});
hintBackground.tint = 0x00FF00; // Green background
hintBackground.x = targetSlotInfo.slot.x;
hintBackground.y = targetSlotInfo.slot.y;
targetSlotInfo.slot.hintBackground = hintBackground;
game.addChild(hintBackground);
// Move letter copy to front
game.removeChild(targetSlotInfo.slot.letterCopy);
game.addChild(targetSlotInfo.slot.letterCopy);
// Store hint letter data persistently
var logoKey = currentCategory + '_' + currentLogo.name;
var hintKey = logoKey + '_hint_' + targetSlotInfo.index;
storage[hintKey] = correctLetter;
break;
}
}
checkAnswer();
}
function removeLetter(letter) {
if (!letter.isPlaced || !letter.targetSlot) {
return;
}
var slot = letter.targetSlot;
// Check if this is a hint letter - if so, don't remove it
if (slot.letterCopy && slot.letterCopy.isHintLetter) {
return; // Cannot remove hint letters
}
// Clear slot
slot.occupiedLetter = null;
// Remove letter copy from answer slot
if (slot.letterCopy) {
if (slot.hintBackground) {
slot.hintBackground.destroy();
slot.hintBackground = null;
}
slot.letterCopy.destroy();
slot.letterCopy = null;
}
// Reset letter to original state
letter.isPlaced = false;
letter.targetSlot = null;
letter.alpha = 1;
letter.x = letter.originalX;
letter.y = letter.originalY;
}
function placeLetter(letter, slot) {
if (slot.occupiedLetter) {
// Check if the current letter in slot is a hint letter - if so, don't replace it
if (slot.letterCopy && slot.letterCopy.isHintLetter) {
return; // Cannot replace hint letters
}
// Return previous letter to pool
var prevLetter = slot.occupiedLetter;
prevLetter.isPlaced = false;
prevLetter.targetSlot = null;
prevLetter.alpha = 1;
// Remove the letter copy from answer slot
if (slot.letterCopy) {
if (slot.hintBackground) {
slot.hintBackground.destroy();
slot.hintBackground = null;
}
slot.letterCopy.destroy();
slot.letterCopy = null;
}
prevLetter.x = prevLetter.originalX;
prevLetter.y = prevLetter.originalY;
}
letter.isPlaced = true;
letter.targetSlot = slot;
slot.occupiedLetter = letter;
// Make the original tile appear faded/hidden
letter.alpha = 0.3;
// Create a copy of the letter in the answer slot
var letterCopy = new LetterTile(letter.letter);
letterCopy.x = slot.x;
letterCopy.y = slot.y;
letterCopy.isPlaced = true;
letterCopy.isHintLetter = false; // Initialize as not a hint letter
letterCopy.down = function (x, y, obj) {
// Only allow removal if not a hint letter
if (!letterCopy.isHintLetter) {
removeLetter(letter);
}
};
slot.letterCopy = letterCopy;
game.addChild(letterCopy);
}
function showSettings() {
game.removeChildren();
gameState = 'settings';
// Settings title
var title = new Text2(languageTexts[currentLanguage].settings, {
size: 120,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 400;
game.addChild(title);
// Language section title
var langTitle = new Text2(languageTexts[currentLanguage].language, {
size: 80,
fill: 0xFFD700
});
langTitle.anchor.set(0.5, 0.5);
langTitle.x = 1024;
langTitle.y = 600;
game.addChild(langTitle);
// Turkish language button
var turkishButton = new CategoryButton(languageTexts[currentLanguage].turkish);
turkishButton.x = 700;
turkishButton.y = 750;
if (currentLanguage === 'tr') {
turkishButton.alpha = 1.0; // Fully visible when selected
} else {
turkishButton.alpha = 0.6; // Dimmed when not selected
}
turkishButton.down = function (x, y, obj) {
turkishButton.scaleX = 0.95;
turkishButton.scaleY = 0.95;
currentLanguage = 'tr';
storage.currentLanguage = currentLanguage;
showSettings(); // Refresh settings screen
};
turkishButton.up = function (x, y, obj) {
turkishButton.scaleX = 1;
turkishButton.scaleY = 1;
};
game.addChild(turkishButton);
// English language button
var englishButton = new CategoryButton(languageTexts[currentLanguage].english);
englishButton.x = 1348;
englishButton.y = 750;
if (currentLanguage === 'en') {
englishButton.alpha = 1.0; // Fully visible when selected
} else {
englishButton.alpha = 0.6; // Dimmed when not selected
}
englishButton.down = function (x, y, obj) {
englishButton.scaleX = 0.95;
englishButton.scaleY = 0.95;
currentLanguage = 'en';
storage.currentLanguage = currentLanguage;
showSettings(); // Refresh settings screen
};
englishButton.up = function (x, y, obj) {
englishButton.scaleX = 1;
englishButton.scaleY = 1;
};
game.addChild(englishButton);
// Reset data button
var resetButton = new CategoryButton(languageTexts[currentLanguage].resetData);
resetButton.x = 1024;
resetButton.y = 950;
resetButton.down = function (x, y, obj) {
resetButton.scaleX = 0.95;
resetButton.scaleY = 0.95;
showResetConfirmation();
};
resetButton.up = function (x, y, obj) {
resetButton.scaleX = 1;
resetButton.scaleY = 1;
};
game.addChild(resetButton);
// Back to menu button
var backButton = new CategoryButton(languageTexts[currentLanguage].backToMenu);
backButton.x = 1024;
backButton.y = 1200;
backButton.down = function (x, y, obj) {
backButton.scaleX = 0.95;
backButton.scaleY = 0.95;
initializeMenu();
};
backButton.up = function (x, y, obj) {
backButton.scaleX = 1;
backButton.scaleY = 1;
};
game.addChild(backButton);
updateCoinDisplay();
}
function showResetConfirmation() {
game.removeChildren();
gameState = 'resetConfirm';
// Confirmation title
var title = new Text2(languageTexts[currentLanguage].resetConfirm, {
size: 100,
fill: 0xFFFFFF
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 600;
game.addChild(title);
// Yes button
var yesButton = new CategoryButton(languageTexts[currentLanguage].yes);
yesButton.x = 700;
yesButton.y = 1000;
yesButton.down = function (x, y, obj) {
yesButton.scaleX = 0.95;
yesButton.scaleY = 0.95;
// Reset all game progress except coins
storage.completedLogos = {};
completedLogos = {};
storage.completedWithoutHints = {};
completedWithoutHints = {};
storage.categoryCompletions = {
'Technology': 0,
'Football': 0,
'Cars': 0,
'Food': 0,
'Footballers': 0,
'Flags': 0,
'Games': 0
};
categoryCompletions = {
'Technology': 0,
'Football': 0,
'Cars': 0,
'Food': 0,
'Footballers': 0,
'Flags': 0,
'Games': 0
};
// Clear all hint letters from storage
for (var category in logoDatabase) {
var logos = logoDatabase[category];
for (var i = 0; i < logos.length; i++) {
var logoKey = category + '_' + logos[i].name;
// Clear all possible hint positions for this logo
for (var j = 0; j < 20; j++) {
// Using 20 as max possible answer length
var hintKey = logoKey + '_hint_' + j;
delete storage[hintKey];
}
}
}
// Flash screen to show reset happened
LK.effects.flashScreen(0xFF0000, 500);
// Go back to main menu after reset
LK.setTimeout(function () {
initializeMenu();
}, 1000);
};
yesButton.up = function (x, y, obj) {
yesButton.scaleX = 1;
yesButton.scaleY = 1;
};
game.addChild(yesButton);
// No button
var noButton = new CategoryButton(languageTexts[currentLanguage].no);
noButton.x = 1348;
noButton.y = 1000;
noButton.down = function (x, y, obj) {
noButton.scaleX = 0.95;
noButton.scaleY = 0.95;
showSettings();
};
noButton.up = function (x, y, obj) {
noButton.scaleX = 1;
noButton.scaleY = 1;
};
game.addChild(noButton);
updateCoinDisplay();
}
function showCompletedLogo(logoData) {
game.removeChildren();
gameState = 'completed';
currentLogo = logoData;
// Logo display area - larger and more prominent visual logo
var logoAssetName = logoData.name.toLowerCase() + 'Logo';
if (logoData.name === 'Real Madrid') {
logoAssetName = 'realmadridLogo';
}
if (logoData.name === 'Manchester United') {
logoAssetName = 'manchesterLogo';
}
if (logoData.name === 'McDonalds') {
logoAssetName = 'mcdonaldsLogo';
}
if (logoData.name === 'Pizza Hut') {
logoAssetName = 'pizzahutLogo';
}
if (logoData.name === 'Instagram') {
logoAssetName = 'instagramLogo';
}
if (logoData.name === 'TikTok') {
logoAssetName = 'tiktokLogo';
}
if (logoData.name === 'Burger King') {
logoAssetName = 'burgerkingLogo';
}
if (logoData.name === 'Bayern München') {
logoAssetName = 'bayernmunchenLogo';
}
if (logoData.name === 'Galatasaray') {
logoAssetName = 'galatasarayLogo';
}
if (logoData.name === 'Tesla') {
logoAssetName = 'teslaLogo';
}
if (logoData.name === 'Lamborghini') {
logoAssetName = 'lamborghiniLogo';
}
if (logoData.name === 'Tog') {
logoAssetName = 'togLogo';
}
if (logoData.name === 'ChatGPT') {
logoAssetName = 'chatgptLogo';
}
if (logoData.name === 'Xiaomi') {
logoAssetName = 'xiaomiLogo';
}
// Footballers category assets
if (logoData.name === 'Messi') {
logoAssetName = 'messiLogo';
}
if (logoData.name === 'Ronaldo') {
logoAssetName = 'ronaldoLogo';
}
if (logoData.name === 'Neymar') {
logoAssetName = 'neymarLogo';
}
if (logoData.name === 'Mbappe') {
logoAssetName = 'mbappeLogo';
}
if (logoData.name === 'Haaland') {
logoAssetName = 'haalandLogo';
}
if (logoData.name === 'Benzema') {
logoAssetName = 'benzemaLogo';
}
if (logoData.name === 'Lewandowski') {
logoAssetName = 'lewandowskiLogo';
}
if (logoData.name === 'Mesut Ozil') {
logoAssetName = 'mesutoezilLogo';
}
if (logoData.name === 'Arda Guler') {
logoAssetName = 'ardagulerLogo';
}
if (logoData.name === 'Luka Modric') {
logoAssetName = 'lukamodricLogo';
}
if (logoData.name === 'Vinicius Junior') {
logoAssetName = 'viniciusjuniorLogo';
}
if (logoData.name === 'Erling Haaland') {
logoAssetName = 'erlinghaalandLogo';
}
if (logoData.name === 'Lamin Yemal') {
logoAssetName = 'laminyemalLogo';
}
// Flags category assets
if (logoData.name === 'Turkey') {
logoAssetName = 'turkeyLogo';
}
if (logoData.name === 'Germany') {
logoAssetName = 'germanyLogo';
}
if (logoData.name === 'France') {
logoAssetName = 'franceLogo';
}
if (logoData.name === 'Spain') {
logoAssetName = 'spainLogo';
}
if (logoData.name === 'Italy') {
logoAssetName = 'italyLogo';
}
if (logoData.name === 'Brazil') {
logoAssetName = 'brazilLogo';
}
if (logoData.name === 'Argentina') {
logoAssetName = 'argentinaLogo';
}
// Games category assets
if (logoData.name === 'Minecraft') {
logoAssetName = 'minecraftLogo';
}
if (logoData.name === 'Fortnite') {
logoAssetName = 'fortniteLogo';
}
if (logoData.name === 'PUBG') {
logoAssetName = 'pubgLogo';
}
if (logoData.name === 'Among Us') {
logoAssetName = 'amongusLogo';
}
if (logoData.name === 'Clash of Clans') {
logoAssetName = 'clashofclansLogo';
}
if (logoData.name === 'Clash Royale') {
logoAssetName = 'clashroyaleLogo';
}
if (logoData.name === 'Candy Crush') {
logoAssetName = 'candycrushLogo';
}
if (logoData.name === 'Pokemon Go') {
logoAssetName = 'pokemongoLogo';
}
if (logoData.name === 'Subway Surfers') {
logoAssetName = 'subwaysurfersLogo';
}
if (logoData.name === 'Temple Run') {
logoAssetName = 'templerunLogo';
}
if (logoData.name === 'Angry Birds') {
logoAssetName = 'angrybirdsLogo';
}
if (logoData.name === 'Roblox') {
logoAssetName = 'robloxLogo';
}
var logoVisual = LK.getAsset(logoAssetName, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
logoVisual.x = 1024;
logoVisual.y = 500;
game.addChild(logoVisual);
// Show "COMPLETED" text
var completedText = new Text2(languageTexts[currentLanguage].completedText, {
size: 100,
fill: 0x00FF00
});
completedText.anchor.set(0.5, 0.5);
completedText.x = 1024;
completedText.y = 800;
game.addChild(completedText);
// Show the answer
var displayName = logoData.name;
if (logoData.name === 'Burger King') {
displayName = 'Burger King'; // Ensure space between Burger and King
}
if (logoData.name === 'Real Madrid') {
displayName = 'Real Madrid';
}
if (logoData.name === 'Manchester United') {
displayName = 'Manchester United';
}
if (logoData.name === 'Pizza Hut') {
displayName = 'Pizza Hut';
}
if (logoData.name === 'Bayern München') {
displayName = 'Bayern München';
}
if (logoData.name === 'Mesut Ozil') {
displayName = 'Mesut Özil';
}
if (logoData.name === 'Arda Guler') {
displayName = 'Arda Güler';
}
if (logoData.name === 'Luka Modric') {
displayName = 'Luka Modrić';
}
if (logoData.name === 'Vinicius Junior') {
displayName = 'Vinícius Jr.';
}
if (logoData.name === 'Erling Haaland') {
displayName = 'Erling Haaland';
}
if (logoData.name === 'Lamin Yemal') {
displayName = 'Lamine Yamal';
}
var answerText = new Text2(displayName, {
size: 80,
fill: 0xFFFFFF
});
answerText.anchor.set(0.5, 0.5);
answerText.x = 1024;
answerText.y = 900;
game.addChild(answerText);
// Show coin reward text
var coinRewardText = new Text2('+10', {
size: 60,
fill: 0xFFD700
});
coinRewardText.anchor.set(0.5, 0.5);
coinRewardText.x = 1024;
coinRewardText.y = 950;
game.addChild(coinRewardText);
// Add checkmark
var checkmark = LK.getAsset('checkmark', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
checkmark.x = 1024;
checkmark.y = 1050;
game.addChild(checkmark);
// Exit button
var exitBtn = new ExitButton();
exitBtn.x = 1024;
exitBtn.y = 1300;
exitBtn.down = function (x, y, obj) {
exitBtn.scaleX = 0.95;
exitBtn.scaleY = 0.95;
showCategoryLogos(currentCategory); // Return to category view
};
exitBtn.up = function (x, y, obj) {
exitBtn.scaleX = 1;
exitBtn.scaleY = 1;
};
game.addChild(exitBtn);
updateCoinDisplay();
}
function checkAnswer() {
var playerAnswer = '';
for (var i = 0; i < answerSlots.length; i++) {
var slot = answerSlots[i];
if (slot.occupiedLetter) {
playerAnswer += slot.occupiedLetter.letter;
} else {
return; // Not all slots filled
}
}
// Get the appropriate answer based on language and category
var correctAnswer = currentLogo.answer;
if (currentCategory === 'Flags' && currentLanguage === 'tr' && currentLogo.answerTR) {
correctAnswer = currentLogo.answerTR;
}
if (playerAnswer === correctAnswer) {
// Correct answer
goldCoins += 10;
storage.goldCoins = goldCoins;
// Mark logo as completed
var logoKey = currentCategory + '_' + currentLogo.name;
if (!completedLogos[logoKey]) {
completedLogos[logoKey] = true;
storage.completedLogos = completedLogos;
// Only count towards hint-free completion tracking if no hint was used
if (!currentLogoUsedHint) {
completedWithoutHints[logoKey] = true;
storage.completedWithoutHints = completedWithoutHints;
}
// Update category completions - count all completed logos for category unlocking
updateCategoryCompletions();
}
LK.getSound('correctAnswer').play();
LK.getSound('coinEarned').play();
LK.effects.flashScreen(0x00FF00, 500);
LK.setTimeout(function () {
showCategoryLogos(currentCategory);
}, 1000);
} else {
// Wrong answer - flash all answer slots red using optimized method
var wrongAnswerSlots = [];
for (var j = 0; j < answerSlots.length; j++) {
if (answerSlots[j] && answerSlots[j].letterCopy) {
wrongAnswerSlots.push(answerSlots[j].letterCopy);
}
}
// Batch tween operations for better performance
if (wrongAnswerSlots.length > 0) {
for (var k = 0; k < wrongAnswerSlots.length; k++) {
var letterRef = wrongAnswerSlots[k];
letterRef.tint = 0xFF0000;
// Use single tween back to normal instead of chained tweens
tween(letterRef, {
tint: 0xFFFFFF
}, {
duration: 500,
delay: 200
});
}
}
// Also flash the screen red briefly
LK.effects.flashScreen(0xFF0000, 300);
}
}
function handleMove(x, y, obj) {
// Move handler no longer needed for letter dragging
}
game.move = handleMove;
game.up = function (x, y, obj) {
// Up handler no longer needed for letter dragging
};
// Performance optimization variables
var lastFrameTime = 0;
var targetFPS = 60;
var frameInterval = 1000 / targetFPS;
// Optimize memory management
var memoryCleanupCounter = 0;
game.update = function () {
// Limit frame rate for stability
var currentTime = Date.now();
if (currentTime - lastFrameTime < frameInterval) {
return;
}
lastFrameTime = currentTime;
// Periodic memory cleanup
memoryCleanupCounter++;
if (memoryCleanupCounter > 300) {
// Every 5 seconds at 60fps
memoryCleanupCounter = 0;
// Force garbage collection hints
if (window.gc) {
window.gc();
}
}
};
// Initialize the game
initializeMenu();