/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var AnswerButton = Container.expand(function () { var self = Container.call(this); self.defaultBackground = self.attachAsset('answerButton', { anchorX: 0.5, anchorY: 0.5 }); self.answerText = new Text2('', { size: 48, fill: 0xFFFFFF, wordWrap: true, wordWrapWidth: 750 }); self.answerText.anchor.set(0.5, 0.5); self.addChild(self.answerText); self.isCorrect = false; self.isClickable = true; self.setAnswer = function (text, correct) { self.answerText.setText(text); self.isCorrect = correct; self.isClickable = true; self.resetVisual(); }; self.resetVisual = function () { self.removeChild(self.defaultBackground); self.defaultBackground = self.attachAsset('answerButton', { anchorX: 0.5, anchorY: 0.5 }); self.addChildAt(self.defaultBackground, 0); }; self.showResult = function () { self.removeChild(self.defaultBackground); if (self.isCorrect) { self.defaultBackground = self.attachAsset('correctButton', { anchorX: 0.5, anchorY: 0.5 }); } else { self.defaultBackground = self.attachAsset('incorrectButton', { anchorX: 0.5, anchorY: 0.5 }); } self.addChildAt(self.defaultBackground, 0); self.isClickable = false; }; self.down = function (x, y, obj) { if (!self.isClickable) return; self.isClickable = false; game.answerSelected(self); }; return self; }); var QuestionCard = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('questionBackground', { anchorX: 0.5, anchorY: 0.5 }); self.questionText = new Text2('', { size: 60, fill: 0xFFFFFF, wordWrap: true, wordWrapWidth: 1700 }); self.questionText.anchor.set(0.5, 0.5); self.addChild(self.questionText); self.setQuestion = function (questionData) { self.questionText.setText(questionData.question); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a252f }); /**** * Game Code ****/ // Bonus questions function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } var bonusQuestions = [{ q: "Who is known as the King in the North?", answers: ["Jaime Lannister", "Robb Stark", "Jon Snow", "The Hound"], correct: 2 }, { q: "What is Daenerys Targaryen's title?", answers: ["Lady of Casterly Rock", "Breaker of Chains", "Warden of the East", "Queen of the Vale"], correct: 1 }]; // Multilingual questions var questionsData = { en: [{ question: "What is Jon Snow's true parentage?", answers: ["Ned Stark and unknown mother", "Lyanna Stark and Rhaegar Targaryen", "Catelyn Stark and Ned Stark", "Cersei Lannister and Robert Baratheon"], correct: 1 }, { question: "What is the name of Daenerys' largest dragon?", answers: ["Viserion", "Rhaegal", "Drogon", "Balerion"], correct: 2 }, { question: "Which city is known as the Free City across the Narrow Sea?", answers: ["King's Landing", "Winterfell", "Braavos", "Oldtown"], correct: 2 }, { question: "Who is known as the 'King in the North'?", answers: ["Jon Snow", "Robb Stark", "Ned Stark", "Both A and B"], correct: 3 }, { question: "What is the motto of House Stark?", answers: ["Fire and Blood", "Winter is Coming", "Hear Me Roar", "Ours is the Fury"], correct: 1 }], tr: [{ question: "Jon Snow'un gerçek adı nedir?", answers: ["Aegon Targaryen", "Robb Stark", "Eddard Stark", "Bran Stark"], correct: 0 }, { question: "Demir Taht'ta ilk oturan kişi kimdir?", answers: ["Robert Baratheon", "Aerys II", "Aegon the Conqueror", "Joffrey Baratheon"], correct: 2 }, { question: "Arya Stark'ın eğitildiği şehir hangisidir?", answers: ["Braavos", "Meereen", "Qarth", "Winterfell"], correct: 0 }, { question: "Daenerys'in en büyük ejderhasının adı nedir?", answers: ["Viserion", "Rhaegal", "Drogon", "Balerion"], correct: 2 }, { question: "Stark Hanesi'nin sloganı nedir?", answers: ["Ateş ve Kan", "Kış Geliyor", "Beni Duy Kükreyişimi", "Bizimdir Öfke"], correct: 1 }] }; // Game state management var gameState = 'menu'; // 'menu', 'settings', 'playing', 'finished' var currentQuestionIndex = 0; var correctAnswers = 0; var questionCard; var answerButtons = []; var scoreText; var isAnswering = false; var difficulty = 'medium'; // 'easy', 'medium', 'hard' var language = 'en'; // 'en', 'tr' var questionTimer; var countdownInterval; var timeLeft = 7; // Reference to current questions based on language var questions = questionsData[language]; var totalQuestions = questions.length; // Translation objects var translations = { en: { title: "Game of Thrones Quiz", subtitle: "Test your knowledge of Westeros!", startGame: "Start Game", settings: "Settings", settingsTitle: "Settings", difficulty: "Difficulty Level:", language: "Language:", easy: "Easy", medium: "Medium", hard: "Hard", backToMenu: "Back to Menu", quizComplete: "Quiz Complete!", finalScore: "Final Score:", returnToMenu: "Return to Menu", score: "Score:", turkish: "Turkish", english: "English", confirmBackToMenu: "Are you sure you want to return to the main menu?", saveSettings: "Save Settings", settingsSaved: "Settings saved!", langHint: "You can change the language from settings" }, tr: { title: "Game of Thrones Quiz", subtitle: "Westeros'un bilgini test etmeye hazır mısın?", startGame: "Başla", settings: "Ayarlar", settingsTitle: "Ayarlar", difficulty: "Zorluk Seviyesi:", language: "Dil:", easy: "Kolay", medium: "Orta", hard: "Zor", backToMenu: "Ana Menüye Dön", quizComplete: "Quiz Bitti!", finalScore: "Skorunuz:", returnToMenu: "Ana Menüye Dön", score: "Skor:", turkish: "Türkçe", english: "İngilizce", confirmBackToMenu: "Ana menüye dönmek istediğinizden emin misiniz?", saveSettings: "Ayarları Kaydet", settingsSaved: "Ayarlar kaydedildi!", langHint: "Dili ayarlardan değiştirebilirsiniz" } }; // Menu UI elements var menuContainer; var gameContainer; var endContainer; var settingsContainer; // UI text elements for language updates var menuTitle; var menuSubtitle; var startButton; var settingsButton; var settingsTitle; var difficultyLabel; var languageLabel; var easyButton; var mediumButton; var hardButton; var backButton; var languageButton; var headerScoreText; var backToMenuButton; var saveButton; var langHintText; var timerText; // Create UI elements function initializeUI() { // Create main containers menuContainer = game.addChild(new Container()); gameContainer = game.addChild(new Container()); endContainer = game.addChild(new Container()); settingsContainer = game.addChild(new Container()); // Setup menu screen // Add background image var menuBg = menuContainer.addChild(LK.getAsset('menuBackground', { anchorX: 0, anchorY: 0 })); menuBg.x = 0; menuBg.y = 0; menuBg.width = 2048; menuBg.height = 2732; // Add semi-transparent overlay var menuOverlay = menuContainer.addChild(LK.getAsset('correctButton', { anchorX: 0, anchorY: 0 })); menuOverlay.x = 0; menuOverlay.y = 0; menuOverlay.width = 2048; menuOverlay.height = 2732; menuOverlay.tint = 0x000000; menuOverlay.alpha = 0.3; menuTitle = new Text2('Game of Thrones Quiz', { size: 80, fill: 0xFFFFFF }); menuTitle.anchor.set(0.5, 0.5); menuTitle.x = 1024; menuTitle.y = 800; menuContainer.addChild(menuTitle); menuSubtitle = new Text2('Test your knowledge of Westeros!', { size: 48, fill: 0xFFFFFF }); menuSubtitle.anchor.set(0.5, 0.5); menuSubtitle.x = 1024; menuSubtitle.y = 950; menuContainer.addChild(menuSubtitle); startButton = menuContainer.addChild(new AnswerButton()); startButton.setAnswer('Start Game', false); startButton.x = 1024; startButton.y = 1100; startButton.down = function () { startGame(); }; settingsButton = menuContainer.addChild(new AnswerButton()); settingsButton.setAnswer('Settings', false); settingsButton.x = 1024; settingsButton.y = 1300; settingsButton.down = function () { showSettings(); }; // Setup game screen // Add footer credit text var creditText = new Text2('David tarafından yapıldı', { size: 32, fill: 0xeeeeee }); creditText.anchor.set(0, 1); creditText.x = 12; creditText.y = 2732 - 36; menuContainer.addChild(creditText); // Add language hint text langHintText = new Text2('You can change the language from settings', { size: 22, fill: 0xeeeeee, wordWrap: true, wordWrapWidth: 400 }); langHintText.anchor.set(1, 1); langHintText.x = 2048 - 12; langHintText.y = 2732 - 12; langHintText.visible = false; langHintText.fontWeight = 700; menuContainer.addChild(langHintText); gameContainer.visible = false; // Question card questionCard = gameContainer.addChild(new QuestionCard()); questionCard.x = 1024; questionCard.y = 600; // Answer buttons for (var i = 0; i < 4; i++) { var button = gameContainer.addChild(new AnswerButton()); button.x = i % 2 === 0 ? 524 : 1524; button.y = i < 2 ? 1200 : 1400; answerButtons.push(button); } // Score display var scoreBackground = gameContainer.addChild(LK.getAsset('scoreBackground', { anchorX: 0.5, anchorY: 0.5 })); scoreBackground.x = 1024; scoreBackground.y = 200; scoreText = new Text2('Score: 0/0', { size: 48, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0.5); scoreBackground.addChild(scoreText); // Score display for quiz header var headerScoreText = new Text2('Score: 0', { size: 36, fill: 0xFFFFFF }); headerScoreText.anchor.set(0, 0.5); headerScoreText.x = 100; headerScoreText.y = 150; gameContainer.addChild(headerScoreText); // Timer display timerText = new Text2('7', { size: 80, fill: 0xFF0000, fontWeight: 'bold' }); timerText.anchor.set(0.5, 1); timerText.x = 1024; timerText.y = 2732 - 40; gameContainer.addChild(timerText); // Back to menu button in quiz screen backToMenuButton = gameContainer.addChild(new AnswerButton()); backToMenuButton.setAnswer('Back to Menu', false); backToMenuButton.x = 1800; backToMenuButton.y = 150; backToMenuButton.defaultBackground.width = 300; backToMenuButton.defaultBackground.height = 80; backToMenuButton.answerText.size = 32; // Add ID for HTML compatibility backToMenuButton.id = 'menuBtnInQuiz'; backToMenuButton.down = function () { confirmGoToMenu(); }; // Setup settings screen settingsContainer.visible = false; settingsTitle = new Text2('Settings', { size: 80, fill: 0xF39C12 }); settingsTitle.anchor.set(0.5, 0.5); settingsTitle.x = 1024; settingsTitle.y = 700; settingsContainer.addChild(settingsTitle); difficultyLabel = new Text2('Difficulty Level:', { size: 48, fill: 0xFFFFFF }); difficultyLabel.anchor.set(0.5, 0.5); difficultyLabel.x = 1024; difficultyLabel.y = 900; settingsContainer.addChild(difficultyLabel); easyButton = settingsContainer.addChild(new AnswerButton()); easyButton.setAnswer('Easy', false); easyButton.x = 1024; easyButton.y = 1050; easyButton.down = function () { setDifficulty('easy'); }; mediumButton = settingsContainer.addChild(new AnswerButton()); mediumButton.setAnswer('Medium', false); mediumButton.x = 1024; mediumButton.y = 1200; mediumButton.down = function () { setDifficulty('medium'); }; hardButton = settingsContainer.addChild(new AnswerButton()); hardButton.setAnswer('Hard', false); hardButton.x = 1024; hardButton.y = 1350; hardButton.down = function () { setDifficulty('hard'); }; languageLabel = new Text2('Language:', { size: 48, fill: 0xFFFFFF }); languageLabel.anchor.set(0.5, 0.5); languageLabel.x = 1024; languageLabel.y = 1500; settingsContainer.addChild(languageLabel); languageButton = settingsContainer.addChild(new AnswerButton()); languageButton.setAnswer('English', false); languageButton.x = 1024; languageButton.y = 1650; languageButton.down = function () { toggleLanguage(); }; var saveButton = settingsContainer.addChild(new AnswerButton()); saveButton.setAnswer('Save Settings', false); saveButton.x = 1024; saveButton.y = 1800; saveButton.down = function () { saveSettings(); }; backButton = settingsContainer.addChild(new AnswerButton()); backButton.setAnswer('Back to Menu', false); backButton.x = 1024; backButton.y = 1950; backButton.down = function () { goToMenu(); }; // Setup end screen // Add language change hint text to settings screen var settingsHintText = new Text2('Dili ayarlar kısmında değiştirebilirsin', { size: 36, fill: 0x333333 }); settingsHintText.anchor.set(1, 1); settingsHintText.x = 2048 - 50; settingsHintText.y = 2732 - 50; settingsContainer.addChild(settingsHintText); endContainer.visible = false; } function displayQuestion() { // Update questions reference for current language questions = questionsData[language]; if (currentQuestionIndex >= questions.length) { showFinalScore(); return; } var questionData = questions[currentQuestionIndex]; questionCard.setQuestion(questionData); for (var i = 0; i < 4; i++) { answerButtons[i].setAnswer(questionData.answers[i], i === questionData.correct); } updateScore(); isAnswering = false; // Clear any existing timer if (questionTimer) { LK.clearInterval(questionTimer); } // Start question timer (7 seconds) timeLeft = 7; timerText.setText(timeLeft); questionTimer = LK.setInterval(function () { timeLeft--; timerText.setText(timeLeft); if (timeLeft <= 0) { LK.clearInterval(questionTimer); // Auto-advance to next question when time runs out if (!isAnswering) { isAnswering = true; // Show results for all buttons for (var i = 0; i < answerButtons.length; i++) { answerButtons[i].showResult(); } LK.getSound('incorrect').play(); // Move to next question after delay LK.setTimeout(function () { currentQuestionIndex++; displayQuestion(); }, 2000); } } }, 1000); } function updateScore() { var isTR = language === "tr"; var scoreLabel = isTR ? "Skor" : "Score"; var diffLabel = isTR ? "Zorluk" : "Difficulty"; var diffText = ""; if (difficulty === "easy") diffText = isTR ? "Kolay" : "Easy";else if (difficulty === "medium") diffText = isTR ? "Orta" : "Medium";else if (difficulty === "hard") diffText = isTR ? "Zor" : "Hard"; scoreText.setText(translations[language].score + ' ' + correctAnswers + '/' + (currentQuestionIndex + 1)); // Update header score text if it exists if (typeof headerScoreText !== 'undefined') { headerScoreText.setText("".concat(scoreLabel, ": ").concat(correctAnswers, " | ").concat(diffLabel, ": ").concat(diffText)); } } function updateLanguage() { var t = translations[language]; // Update menu texts menuTitle.setText(t.title); menuSubtitle.setText(t.subtitle); startButton.setAnswer(t.startGame, false); settingsButton.setAnswer(t.settings, false); // Update settings texts settingsTitle.setText(t.settingsTitle); difficultyLabel.setText(t.difficulty); languageLabel.setText(t.language); easyButton.setAnswer(t.easy, false); mediumButton.setAnswer(t.medium, false); hardButton.setAnswer(t.hard, false); backButton.setAnswer(t.backToMenu, false); languageButton.setAnswer(language === 'en' ? t.turkish : t.english, false); // Update back to menu button in quiz screen if (typeof backToMenuButton !== 'undefined') { backToMenuButton.setAnswer(t.backToMenu, false); } // Update save button text if (typeof saveButton !== 'undefined') { saveButton.setAnswer(language === 'tr' ? 'Ayarları Kaydet' : 'Save Settings', false); } // Update language hint text if (typeof langHintText !== 'undefined') { langHintText.setText(t.langHint); // Show language hint when English is selected, hide when Turkish if (language === "en") { langHintText.visible = true; } else { langHintText.visible = false; } } // Update questions reference questions = questionsData[language]; totalQuestions = questions.length; // Update score if in game if (gameState === 'playing') { updateScore(); } // Update timer text if it exists if (typeof timerText !== 'undefined' && timerText.text) { var currentTime = timerText.text || '7'; timerText.setText(currentTime); } } function toggleLanguage() { language = language === 'en' ? 'tr' : 'en'; updateLanguage(); } function startGame() { gameState = 'playing'; currentQuestionIndex = 0; correctAnswers = 0; // Randomly select 5 questions from all available questions var allQuestions = _toConsumableArray(questionsData[language]); questions = allQuestions.sort(function () { return Math.random() - 0.5; }) // shuffle .slice(0, 5); // take first 5 updateScore(); updateLanguage(); isAnswering = false; // Hide menu, show game menuContainer.visible = false; gameContainer.visible = true; endContainer.visible = false; settingsContainer.visible = false; displayQuestion(); } function showSettings() { gameState = 'settings'; // Hide all screens, show settings menuContainer.visible = false; gameContainer.visible = false; endContainer.visible = false; settingsContainer.visible = true; } function setDifficulty(newDifficulty) { difficulty = newDifficulty; // Visual feedback could be added here in the future goToMenu(); } function goToMenu() { gameState = 'menu'; // Hide all screens, show menu menuContainer.visible = true; gameContainer.visible = false; endContainer.visible = false; settingsContainer.visible = false; } function showResult() { // Clear timer when showing result if (questionTimer) { LK.clearInterval(questionTimer); } if (countdownInterval) { LK.clearInterval(countdownInterval); } // Bonus soruyu rastgele seç var bonus = bonusQuestions[Math.floor(Math.random() * bonusQuestions.length)]; questions = [bonus]; // sadece bonus soruyu göster currentQuestionIndex = 0; // Hide all screens, show game screen menuContainer.visible = false; gameContainer.visible = true; endContainer.visible = false; settingsContainer.visible = false; displayQuestion(); // bonus soruyu göster } function showFinalResult() { gameState = 'finished'; // Clear timer when showing final result if (questionTimer) { LK.clearInterval(questionTimer); } if (countdownInterval) { LK.clearInterval(countdownInterval); } // Hide all screens, show end container menuContainer.visible = false; gameContainer.visible = false; endContainer.visible = true; settingsContainer.visible = false; // Create final result display if not exists if (endContainer.children.length === 0) { var finalTitle = new Text2(translations[language].quizComplete, { size: 80, fill: 0xF39C12 }); finalTitle.anchor.set(0.5, 0.5); finalTitle.x = 1024; finalTitle.y = 800; endContainer.addChild(finalTitle); var finalScoreText = new Text2(translations[language].finalScore + ' ' + correctAnswers + '/' + questions.length, { size: 60, fill: 0xFFFFFF }); finalScoreText.anchor.set(0.5, 0.5); finalScoreText.x = 1024; finalScoreText.y = 1000; endContainer.addChild(finalScoreText); var returnButton = endContainer.addChild(new AnswerButton()); returnButton.setAnswer(translations[language].returnToMenu, false); returnButton.x = 1024; returnButton.y = 1300; returnButton.down = function () { goToMenu(); }; } } function showFinalScore() { showResult(); } function checkAnswer(selected) { if (isAnswering) return; isAnswering = true; // Show results for all buttons for (var i = 0; i < answerButtons.length; i++) { answerButtons[i].showResult(); } // Check if answer is correct if (selected.isCorrect) { correctAnswers++; LK.setScore(correctAnswers); LK.getSound('correct').play(); updateScore(); } else { LK.getSound('incorrect').play(); } // Move to next question after delay LK.setTimeout(function () { currentQuestionIndex++; displayQuestion(); }, 2000); } function saveSettings() { // Save settings to persistent storage storage.difficulty = difficulty; storage.language = language; updateLanguage(); updateScore(); // Update difficulty display in score // Show confirmation message using screen flash effect LK.effects.flashScreen(0x27ae60, 500); // Green flash for confirmation goToMenu(); } function confirmGoToMenu() { // Create a simple confirmation by going directly to menu // In a mobile game environment, we skip the confirmation dialog goToMenu(); } game.answerSelected = function (selectedButton) { if (isAnswering) return; isAnswering = true; // Clear timer when answer is selected if (questionTimer) { LK.clearInterval(questionTimer); } // Show results for all buttons for (var i = 0; i < answerButtons.length; i++) { answerButtons[i].showResult(); } // Check if answer is correct if (selectedButton.isCorrect) { correctAnswers++; LK.setScore(correctAnswers); LK.getSound('correct').play(); } else { LK.getSound('incorrect').play(); } // Move to next question after delay LK.setTimeout(function () { currentQuestionIndex++; displayQuestion(); }, 2000); }; // Load saved settings function loadSettings() { var savedDifficulty = storage.difficulty; var savedLanguage = storage.language; if (savedDifficulty) { difficulty = savedDifficulty; } if (savedLanguage) { language = savedLanguage; } } function selectAnswer(selectedIndex) { // Clear timer when answer is selected if (questionTimer) { LK.clearInterval(questionTimer); } if (countdownInterval) { LK.clearInterval(countdownInterval); } if (isAnswering) return; isAnswering = true; var question = questions[currentQuestionIndex]; var isCorrect = selectedIndex === question.correct; if (isCorrect) { correctAnswers++; LK.setScore(correctAnswers); LK.getSound('correct').play(); } else { LK.getSound('incorrect').play(); } // Show results for all buttons for (var i = 0; i < answerButtons.length; i++) { answerButtons[i].showResult(); } // Move to next question after delay LK.setTimeout(function () { currentQuestionIndex++; if (currentQuestionIndex < questions.length) { displayQuestion(); } else { // Bonus sorudan sonra sonuç ekranı if (questions.length === 1 && (question.q.includes("Jon Snow") || question.q.includes("Daenerys"))) { showFinalResult(); } else { showResult(); } } }, 2000); } // Initialize the game loadSettings(); initializeUI(); updateLanguage(); goToMenu();
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var AnswerButton = Container.expand(function () {
var self = Container.call(this);
self.defaultBackground = self.attachAsset('answerButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.answerText = new Text2('', {
size: 48,
fill: 0xFFFFFF,
wordWrap: true,
wordWrapWidth: 750
});
self.answerText.anchor.set(0.5, 0.5);
self.addChild(self.answerText);
self.isCorrect = false;
self.isClickable = true;
self.setAnswer = function (text, correct) {
self.answerText.setText(text);
self.isCorrect = correct;
self.isClickable = true;
self.resetVisual();
};
self.resetVisual = function () {
self.removeChild(self.defaultBackground);
self.defaultBackground = self.attachAsset('answerButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChildAt(self.defaultBackground, 0);
};
self.showResult = function () {
self.removeChild(self.defaultBackground);
if (self.isCorrect) {
self.defaultBackground = self.attachAsset('correctButton', {
anchorX: 0.5,
anchorY: 0.5
});
} else {
self.defaultBackground = self.attachAsset('incorrectButton', {
anchorX: 0.5,
anchorY: 0.5
});
}
self.addChildAt(self.defaultBackground, 0);
self.isClickable = false;
};
self.down = function (x, y, obj) {
if (!self.isClickable) return;
self.isClickable = false;
game.answerSelected(self);
};
return self;
});
var QuestionCard = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('questionBackground', {
anchorX: 0.5,
anchorY: 0.5
});
self.questionText = new Text2('', {
size: 60,
fill: 0xFFFFFF,
wordWrap: true,
wordWrapWidth: 1700
});
self.questionText.anchor.set(0.5, 0.5);
self.addChild(self.questionText);
self.setQuestion = function (questionData) {
self.questionText.setText(questionData.question);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a252f
});
/****
* Game Code
****/
// Bonus questions
function _toConsumableArray(r) {
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _iterableToArray(r) {
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
}
function _arrayWithoutHoles(r) {
if (Array.isArray(r)) return _arrayLikeToArray(r);
}
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
var bonusQuestions = [{
q: "Who is known as the King in the North?",
answers: ["Jaime Lannister", "Robb Stark", "Jon Snow", "The Hound"],
correct: 2
}, {
q: "What is Daenerys Targaryen's title?",
answers: ["Lady of Casterly Rock", "Breaker of Chains", "Warden of the East", "Queen of the Vale"],
correct: 1
}];
// Multilingual questions
var questionsData = {
en: [{
question: "What is Jon Snow's true parentage?",
answers: ["Ned Stark and unknown mother", "Lyanna Stark and Rhaegar Targaryen", "Catelyn Stark and Ned Stark", "Cersei Lannister and Robert Baratheon"],
correct: 1
}, {
question: "What is the name of Daenerys' largest dragon?",
answers: ["Viserion", "Rhaegal", "Drogon", "Balerion"],
correct: 2
}, {
question: "Which city is known as the Free City across the Narrow Sea?",
answers: ["King's Landing", "Winterfell", "Braavos", "Oldtown"],
correct: 2
}, {
question: "Who is known as the 'King in the North'?",
answers: ["Jon Snow", "Robb Stark", "Ned Stark", "Both A and B"],
correct: 3
}, {
question: "What is the motto of House Stark?",
answers: ["Fire and Blood", "Winter is Coming", "Hear Me Roar", "Ours is the Fury"],
correct: 1
}],
tr: [{
question: "Jon Snow'un gerçek adı nedir?",
answers: ["Aegon Targaryen", "Robb Stark", "Eddard Stark", "Bran Stark"],
correct: 0
}, {
question: "Demir Taht'ta ilk oturan kişi kimdir?",
answers: ["Robert Baratheon", "Aerys II", "Aegon the Conqueror", "Joffrey Baratheon"],
correct: 2
}, {
question: "Arya Stark'ın eğitildiği şehir hangisidir?",
answers: ["Braavos", "Meereen", "Qarth", "Winterfell"],
correct: 0
}, {
question: "Daenerys'in en büyük ejderhasının adı nedir?",
answers: ["Viserion", "Rhaegal", "Drogon", "Balerion"],
correct: 2
}, {
question: "Stark Hanesi'nin sloganı nedir?",
answers: ["Ateş ve Kan", "Kış Geliyor", "Beni Duy Kükreyişimi", "Bizimdir Öfke"],
correct: 1
}]
};
// Game state management
var gameState = 'menu'; // 'menu', 'settings', 'playing', 'finished'
var currentQuestionIndex = 0;
var correctAnswers = 0;
var questionCard;
var answerButtons = [];
var scoreText;
var isAnswering = false;
var difficulty = 'medium'; // 'easy', 'medium', 'hard'
var language = 'en'; // 'en', 'tr'
var questionTimer;
var countdownInterval;
var timeLeft = 7;
// Reference to current questions based on language
var questions = questionsData[language];
var totalQuestions = questions.length;
// Translation objects
var translations = {
en: {
title: "Game of Thrones Quiz",
subtitle: "Test your knowledge of Westeros!",
startGame: "Start Game",
settings: "Settings",
settingsTitle: "Settings",
difficulty: "Difficulty Level:",
language: "Language:",
easy: "Easy",
medium: "Medium",
hard: "Hard",
backToMenu: "Back to Menu",
quizComplete: "Quiz Complete!",
finalScore: "Final Score:",
returnToMenu: "Return to Menu",
score: "Score:",
turkish: "Turkish",
english: "English",
confirmBackToMenu: "Are you sure you want to return to the main menu?",
saveSettings: "Save Settings",
settingsSaved: "Settings saved!",
langHint: "You can change the language from settings"
},
tr: {
title: "Game of Thrones Quiz",
subtitle: "Westeros'un bilgini test etmeye hazır mısın?",
startGame: "Başla",
settings: "Ayarlar",
settingsTitle: "Ayarlar",
difficulty: "Zorluk Seviyesi:",
language: "Dil:",
easy: "Kolay",
medium: "Orta",
hard: "Zor",
backToMenu: "Ana Menüye Dön",
quizComplete: "Quiz Bitti!",
finalScore: "Skorunuz:",
returnToMenu: "Ana Menüye Dön",
score: "Skor:",
turkish: "Türkçe",
english: "İngilizce",
confirmBackToMenu: "Ana menüye dönmek istediğinizden emin misiniz?",
saveSettings: "Ayarları Kaydet",
settingsSaved: "Ayarlar kaydedildi!",
langHint: "Dili ayarlardan değiştirebilirsiniz"
}
};
// Menu UI elements
var menuContainer;
var gameContainer;
var endContainer;
var settingsContainer;
// UI text elements for language updates
var menuTitle;
var menuSubtitle;
var startButton;
var settingsButton;
var settingsTitle;
var difficultyLabel;
var languageLabel;
var easyButton;
var mediumButton;
var hardButton;
var backButton;
var languageButton;
var headerScoreText;
var backToMenuButton;
var saveButton;
var langHintText;
var timerText;
// Create UI elements
function initializeUI() {
// Create main containers
menuContainer = game.addChild(new Container());
gameContainer = game.addChild(new Container());
endContainer = game.addChild(new Container());
settingsContainer = game.addChild(new Container());
// Setup menu screen
// Add background image
var menuBg = menuContainer.addChild(LK.getAsset('menuBackground', {
anchorX: 0,
anchorY: 0
}));
menuBg.x = 0;
menuBg.y = 0;
menuBg.width = 2048;
menuBg.height = 2732;
// Add semi-transparent overlay
var menuOverlay = menuContainer.addChild(LK.getAsset('correctButton', {
anchorX: 0,
anchorY: 0
}));
menuOverlay.x = 0;
menuOverlay.y = 0;
menuOverlay.width = 2048;
menuOverlay.height = 2732;
menuOverlay.tint = 0x000000;
menuOverlay.alpha = 0.3;
menuTitle = new Text2('Game of Thrones Quiz', {
size: 80,
fill: 0xFFFFFF
});
menuTitle.anchor.set(0.5, 0.5);
menuTitle.x = 1024;
menuTitle.y = 800;
menuContainer.addChild(menuTitle);
menuSubtitle = new Text2('Test your knowledge of Westeros!', {
size: 48,
fill: 0xFFFFFF
});
menuSubtitle.anchor.set(0.5, 0.5);
menuSubtitle.x = 1024;
menuSubtitle.y = 950;
menuContainer.addChild(menuSubtitle);
startButton = menuContainer.addChild(new AnswerButton());
startButton.setAnswer('Start Game', false);
startButton.x = 1024;
startButton.y = 1100;
startButton.down = function () {
startGame();
};
settingsButton = menuContainer.addChild(new AnswerButton());
settingsButton.setAnswer('Settings', false);
settingsButton.x = 1024;
settingsButton.y = 1300;
settingsButton.down = function () {
showSettings();
};
// Setup game screen
// Add footer credit text
var creditText = new Text2('David tarafından yapıldı', {
size: 32,
fill: 0xeeeeee
});
creditText.anchor.set(0, 1);
creditText.x = 12;
creditText.y = 2732 - 36;
menuContainer.addChild(creditText);
// Add language hint text
langHintText = new Text2('You can change the language from settings', {
size: 22,
fill: 0xeeeeee,
wordWrap: true,
wordWrapWidth: 400
});
langHintText.anchor.set(1, 1);
langHintText.x = 2048 - 12;
langHintText.y = 2732 - 12;
langHintText.visible = false;
langHintText.fontWeight = 700;
menuContainer.addChild(langHintText);
gameContainer.visible = false;
// Question card
questionCard = gameContainer.addChild(new QuestionCard());
questionCard.x = 1024;
questionCard.y = 600;
// Answer buttons
for (var i = 0; i < 4; i++) {
var button = gameContainer.addChild(new AnswerButton());
button.x = i % 2 === 0 ? 524 : 1524;
button.y = i < 2 ? 1200 : 1400;
answerButtons.push(button);
}
// Score display
var scoreBackground = gameContainer.addChild(LK.getAsset('scoreBackground', {
anchorX: 0.5,
anchorY: 0.5
}));
scoreBackground.x = 1024;
scoreBackground.y = 200;
scoreText = new Text2('Score: 0/0', {
size: 48,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0.5);
scoreBackground.addChild(scoreText);
// Score display for quiz header
var headerScoreText = new Text2('Score: 0', {
size: 36,
fill: 0xFFFFFF
});
headerScoreText.anchor.set(0, 0.5);
headerScoreText.x = 100;
headerScoreText.y = 150;
gameContainer.addChild(headerScoreText);
// Timer display
timerText = new Text2('7', {
size: 80,
fill: 0xFF0000,
fontWeight: 'bold'
});
timerText.anchor.set(0.5, 1);
timerText.x = 1024;
timerText.y = 2732 - 40;
gameContainer.addChild(timerText);
// Back to menu button in quiz screen
backToMenuButton = gameContainer.addChild(new AnswerButton());
backToMenuButton.setAnswer('Back to Menu', false);
backToMenuButton.x = 1800;
backToMenuButton.y = 150;
backToMenuButton.defaultBackground.width = 300;
backToMenuButton.defaultBackground.height = 80;
backToMenuButton.answerText.size = 32;
// Add ID for HTML compatibility
backToMenuButton.id = 'menuBtnInQuiz';
backToMenuButton.down = function () {
confirmGoToMenu();
};
// Setup settings screen
settingsContainer.visible = false;
settingsTitle = new Text2('Settings', {
size: 80,
fill: 0xF39C12
});
settingsTitle.anchor.set(0.5, 0.5);
settingsTitle.x = 1024;
settingsTitle.y = 700;
settingsContainer.addChild(settingsTitle);
difficultyLabel = new Text2('Difficulty Level:', {
size: 48,
fill: 0xFFFFFF
});
difficultyLabel.anchor.set(0.5, 0.5);
difficultyLabel.x = 1024;
difficultyLabel.y = 900;
settingsContainer.addChild(difficultyLabel);
easyButton = settingsContainer.addChild(new AnswerButton());
easyButton.setAnswer('Easy', false);
easyButton.x = 1024;
easyButton.y = 1050;
easyButton.down = function () {
setDifficulty('easy');
};
mediumButton = settingsContainer.addChild(new AnswerButton());
mediumButton.setAnswer('Medium', false);
mediumButton.x = 1024;
mediumButton.y = 1200;
mediumButton.down = function () {
setDifficulty('medium');
};
hardButton = settingsContainer.addChild(new AnswerButton());
hardButton.setAnswer('Hard', false);
hardButton.x = 1024;
hardButton.y = 1350;
hardButton.down = function () {
setDifficulty('hard');
};
languageLabel = new Text2('Language:', {
size: 48,
fill: 0xFFFFFF
});
languageLabel.anchor.set(0.5, 0.5);
languageLabel.x = 1024;
languageLabel.y = 1500;
settingsContainer.addChild(languageLabel);
languageButton = settingsContainer.addChild(new AnswerButton());
languageButton.setAnswer('English', false);
languageButton.x = 1024;
languageButton.y = 1650;
languageButton.down = function () {
toggleLanguage();
};
var saveButton = settingsContainer.addChild(new AnswerButton());
saveButton.setAnswer('Save Settings', false);
saveButton.x = 1024;
saveButton.y = 1800;
saveButton.down = function () {
saveSettings();
};
backButton = settingsContainer.addChild(new AnswerButton());
backButton.setAnswer('Back to Menu', false);
backButton.x = 1024;
backButton.y = 1950;
backButton.down = function () {
goToMenu();
};
// Setup end screen
// Add language change hint text to settings screen
var settingsHintText = new Text2('Dili ayarlar kısmında değiştirebilirsin', {
size: 36,
fill: 0x333333
});
settingsHintText.anchor.set(1, 1);
settingsHintText.x = 2048 - 50;
settingsHintText.y = 2732 - 50;
settingsContainer.addChild(settingsHintText);
endContainer.visible = false;
}
function displayQuestion() {
// Update questions reference for current language
questions = questionsData[language];
if (currentQuestionIndex >= questions.length) {
showFinalScore();
return;
}
var questionData = questions[currentQuestionIndex];
questionCard.setQuestion(questionData);
for (var i = 0; i < 4; i++) {
answerButtons[i].setAnswer(questionData.answers[i], i === questionData.correct);
}
updateScore();
isAnswering = false;
// Clear any existing timer
if (questionTimer) {
LK.clearInterval(questionTimer);
}
// Start question timer (7 seconds)
timeLeft = 7;
timerText.setText(timeLeft);
questionTimer = LK.setInterval(function () {
timeLeft--;
timerText.setText(timeLeft);
if (timeLeft <= 0) {
LK.clearInterval(questionTimer);
// Auto-advance to next question when time runs out
if (!isAnswering) {
isAnswering = true;
// Show results for all buttons
for (var i = 0; i < answerButtons.length; i++) {
answerButtons[i].showResult();
}
LK.getSound('incorrect').play();
// Move to next question after delay
LK.setTimeout(function () {
currentQuestionIndex++;
displayQuestion();
}, 2000);
}
}
}, 1000);
}
function updateScore() {
var isTR = language === "tr";
var scoreLabel = isTR ? "Skor" : "Score";
var diffLabel = isTR ? "Zorluk" : "Difficulty";
var diffText = "";
if (difficulty === "easy") diffText = isTR ? "Kolay" : "Easy";else if (difficulty === "medium") diffText = isTR ? "Orta" : "Medium";else if (difficulty === "hard") diffText = isTR ? "Zor" : "Hard";
scoreText.setText(translations[language].score + ' ' + correctAnswers + '/' + (currentQuestionIndex + 1));
// Update header score text if it exists
if (typeof headerScoreText !== 'undefined') {
headerScoreText.setText("".concat(scoreLabel, ": ").concat(correctAnswers, " | ").concat(diffLabel, ": ").concat(diffText));
}
}
function updateLanguage() {
var t = translations[language];
// Update menu texts
menuTitle.setText(t.title);
menuSubtitle.setText(t.subtitle);
startButton.setAnswer(t.startGame, false);
settingsButton.setAnswer(t.settings, false);
// Update settings texts
settingsTitle.setText(t.settingsTitle);
difficultyLabel.setText(t.difficulty);
languageLabel.setText(t.language);
easyButton.setAnswer(t.easy, false);
mediumButton.setAnswer(t.medium, false);
hardButton.setAnswer(t.hard, false);
backButton.setAnswer(t.backToMenu, false);
languageButton.setAnswer(language === 'en' ? t.turkish : t.english, false);
// Update back to menu button in quiz screen
if (typeof backToMenuButton !== 'undefined') {
backToMenuButton.setAnswer(t.backToMenu, false);
}
// Update save button text
if (typeof saveButton !== 'undefined') {
saveButton.setAnswer(language === 'tr' ? 'Ayarları Kaydet' : 'Save Settings', false);
}
// Update language hint text
if (typeof langHintText !== 'undefined') {
langHintText.setText(t.langHint);
// Show language hint when English is selected, hide when Turkish
if (language === "en") {
langHintText.visible = true;
} else {
langHintText.visible = false;
}
}
// Update questions reference
questions = questionsData[language];
totalQuestions = questions.length;
// Update score if in game
if (gameState === 'playing') {
updateScore();
}
// Update timer text if it exists
if (typeof timerText !== 'undefined' && timerText.text) {
var currentTime = timerText.text || '7';
timerText.setText(currentTime);
}
}
function toggleLanguage() {
language = language === 'en' ? 'tr' : 'en';
updateLanguage();
}
function startGame() {
gameState = 'playing';
currentQuestionIndex = 0;
correctAnswers = 0;
// Randomly select 5 questions from all available questions
var allQuestions = _toConsumableArray(questionsData[language]);
questions = allQuestions.sort(function () {
return Math.random() - 0.5;
}) // shuffle
.slice(0, 5); // take first 5
updateScore();
updateLanguage();
isAnswering = false;
// Hide menu, show game
menuContainer.visible = false;
gameContainer.visible = true;
endContainer.visible = false;
settingsContainer.visible = false;
displayQuestion();
}
function showSettings() {
gameState = 'settings';
// Hide all screens, show settings
menuContainer.visible = false;
gameContainer.visible = false;
endContainer.visible = false;
settingsContainer.visible = true;
}
function setDifficulty(newDifficulty) {
difficulty = newDifficulty;
// Visual feedback could be added here in the future
goToMenu();
}
function goToMenu() {
gameState = 'menu';
// Hide all screens, show menu
menuContainer.visible = true;
gameContainer.visible = false;
endContainer.visible = false;
settingsContainer.visible = false;
}
function showResult() {
// Clear timer when showing result
if (questionTimer) {
LK.clearInterval(questionTimer);
}
if (countdownInterval) {
LK.clearInterval(countdownInterval);
}
// Bonus soruyu rastgele seç
var bonus = bonusQuestions[Math.floor(Math.random() * bonusQuestions.length)];
questions = [bonus]; // sadece bonus soruyu göster
currentQuestionIndex = 0;
// Hide all screens, show game screen
menuContainer.visible = false;
gameContainer.visible = true;
endContainer.visible = false;
settingsContainer.visible = false;
displayQuestion(); // bonus soruyu göster
}
function showFinalResult() {
gameState = 'finished';
// Clear timer when showing final result
if (questionTimer) {
LK.clearInterval(questionTimer);
}
if (countdownInterval) {
LK.clearInterval(countdownInterval);
}
// Hide all screens, show end container
menuContainer.visible = false;
gameContainer.visible = false;
endContainer.visible = true;
settingsContainer.visible = false;
// Create final result display if not exists
if (endContainer.children.length === 0) {
var finalTitle = new Text2(translations[language].quizComplete, {
size: 80,
fill: 0xF39C12
});
finalTitle.anchor.set(0.5, 0.5);
finalTitle.x = 1024;
finalTitle.y = 800;
endContainer.addChild(finalTitle);
var finalScoreText = new Text2(translations[language].finalScore + ' ' + correctAnswers + '/' + questions.length, {
size: 60,
fill: 0xFFFFFF
});
finalScoreText.anchor.set(0.5, 0.5);
finalScoreText.x = 1024;
finalScoreText.y = 1000;
endContainer.addChild(finalScoreText);
var returnButton = endContainer.addChild(new AnswerButton());
returnButton.setAnswer(translations[language].returnToMenu, false);
returnButton.x = 1024;
returnButton.y = 1300;
returnButton.down = function () {
goToMenu();
};
}
}
function showFinalScore() {
showResult();
}
function checkAnswer(selected) {
if (isAnswering) return;
isAnswering = true;
// Show results for all buttons
for (var i = 0; i < answerButtons.length; i++) {
answerButtons[i].showResult();
}
// Check if answer is correct
if (selected.isCorrect) {
correctAnswers++;
LK.setScore(correctAnswers);
LK.getSound('correct').play();
updateScore();
} else {
LK.getSound('incorrect').play();
}
// Move to next question after delay
LK.setTimeout(function () {
currentQuestionIndex++;
displayQuestion();
}, 2000);
}
function saveSettings() {
// Save settings to persistent storage
storage.difficulty = difficulty;
storage.language = language;
updateLanguage();
updateScore(); // Update difficulty display in score
// Show confirmation message using screen flash effect
LK.effects.flashScreen(0x27ae60, 500); // Green flash for confirmation
goToMenu();
}
function confirmGoToMenu() {
// Create a simple confirmation by going directly to menu
// In a mobile game environment, we skip the confirmation dialog
goToMenu();
}
game.answerSelected = function (selectedButton) {
if (isAnswering) return;
isAnswering = true;
// Clear timer when answer is selected
if (questionTimer) {
LK.clearInterval(questionTimer);
}
// Show results for all buttons
for (var i = 0; i < answerButtons.length; i++) {
answerButtons[i].showResult();
}
// Check if answer is correct
if (selectedButton.isCorrect) {
correctAnswers++;
LK.setScore(correctAnswers);
LK.getSound('correct').play();
} else {
LK.getSound('incorrect').play();
}
// Move to next question after delay
LK.setTimeout(function () {
currentQuestionIndex++;
displayQuestion();
}, 2000);
};
// Load saved settings
function loadSettings() {
var savedDifficulty = storage.difficulty;
var savedLanguage = storage.language;
if (savedDifficulty) {
difficulty = savedDifficulty;
}
if (savedLanguage) {
language = savedLanguage;
}
}
function selectAnswer(selectedIndex) {
// Clear timer when answer is selected
if (questionTimer) {
LK.clearInterval(questionTimer);
}
if (countdownInterval) {
LK.clearInterval(countdownInterval);
}
if (isAnswering) return;
isAnswering = true;
var question = questions[currentQuestionIndex];
var isCorrect = selectedIndex === question.correct;
if (isCorrect) {
correctAnswers++;
LK.setScore(correctAnswers);
LK.getSound('correct').play();
} else {
LK.getSound('incorrect').play();
}
// Show results for all buttons
for (var i = 0; i < answerButtons.length; i++) {
answerButtons[i].showResult();
}
// Move to next question after delay
LK.setTimeout(function () {
currentQuestionIndex++;
if (currentQuestionIndex < questions.length) {
displayQuestion();
} else {
// Bonus sorudan sonra sonuç ekranı
if (questions.length === 1 && (question.q.includes("Jon Snow") || question.q.includes("Daenerys"))) {
showFinalResult();
} else {
showResult();
}
}
}, 2000);
}
// Initialize the game
loadSettings();
initializeUI();
updateLanguage();
goToMenu();
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Game of Thrones Quiz Challenge" and with the description "Test your Game of Thrones knowledge with challenging multiple-choice questions about characters, locations, and major plot points from the epic series.". No text on banner!
game of thrones hakkında foto yap. In-Game asset. 2d. High contrast. No shadows