/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Player name input system var playerName = ""; var inputChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var currentCharIndex = 0; var nameInputActive = true; // Show name input interface var namePromptTxt = new Text2('Oyuncu İsmine Gir', { size: 150, fill: 0xFFD700 }); namePromptTxt.anchor.set(0.5, 0.5); namePromptTxt.x = 2048 / 2; namePromptTxt.y = 800; game.addChild(namePromptTxt); var playerNameTxt = new Text2(playerName || '_', { size: 120, fill: 0xFFFFFF }); playerNameTxt.anchor.set(0.5, 0.5); playerNameTxt.x = 2048 / 2; playerNameTxt.y = 1200; game.addChild(playerNameTxt); // Virtual keyboard interface var keyboardRows = ["QWERTYUIOP", "ASDFGHJKL", "ZXCVBNM"]; var keyboardButtons = []; var keySize = 150; var keySpacing = 10; // Create virtual keyboard for (var row = 0; row < keyboardRows.length; row++) { var rowString = keyboardRows[row]; var rowWidth = rowString.length * (keySize + keySpacing) - keySpacing; var startX = (2048 - rowWidth) / 2; for (var col = 0; col < rowString.length; col++) { var keyChar = rowString[col]; var keyBtn = new Container(); var keyBg = LK.getAsset('iqBtnBg', { width: keySize, height: keySize, color: 0x444444, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); keyBtn.addChild(keyBg); var keyTxt = new Text2(keyChar, { size: 60, fill: "#fff" }); keyTxt.anchor.set(0.5, 0.5); keyBtn.addChild(keyTxt); keyBtn.x = startX + col * (keySize + keySpacing) + keySize / 2; keyBtn.y = 1400 + row * (keySize + keySpacing); keyBtn.keyChar = keyChar; keyBtn.down = function (x, y, obj) { if (!nameInputActive) return; if (playerName.length < 12) { playerName += this.keyChar; playerNameTxt.setText(playerName || '_'); } }; game.addChild(keyBtn); keyboardButtons.push(keyBtn); } } // Instruction text var instructionTxt = new Text2('Harflere Dokunarak İsim Yaz', { size: 80, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 2048 / 2; instructionTxt.y = 1300; game.addChild(instructionTxt); // Add character button var addCharBtn = new Container(); var addCharBg = LK.getAsset('iqBtnBg', { width: 300, height: 100, color: 0x00AA00, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); addCharBtn.addChild(addCharBg); var addCharTxt = new Text2('Boşluk', { size: 60, fill: "#fff" }); addCharTxt.anchor.set(0.5, 0.5); addCharBtn.addChild(addCharTxt); addCharBtn.x = 1024; addCharBtn.y = 1800; game.addChild(addCharBtn); // Finish button var finishBtn = new Container(); var finishBg = LK.getAsset('iqBtnBg', { width: 300, height: 100, color: 0x0000AA, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); finishBtn.addChild(finishBg); var finishTxt = new Text2('Tamam', { size: 60, fill: "#fff" }); finishTxt.anchor.set(0.5, 0.5); finishBtn.addChild(finishTxt); finishBtn.x = 1524; finishBtn.y = 1800; game.addChild(finishBtn); // Delete button var deleteBtn = new Container(); var deleteBg = LK.getAsset('iqBtnBg', { width: 300, height: 100, color: 0xAA0000, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); deleteBtn.addChild(deleteBg); var deleteTxt = new Text2('Sil', { size: 60, fill: "#fff" }); deleteTxt.anchor.set(0.5, 0.5); deleteBtn.addChild(deleteTxt); deleteBtn.x = 524; deleteBtn.y = 1800; game.addChild(deleteBtn); // Game touch handler for name input game.down = function (x, y, obj) { if (!nameInputActive) return; }; // Add space button handler addCharBtn.down = function (x, y, obj) { if (!nameInputActive) return; if (playerName.length < 12) { // Add space character playerName += " "; playerNameTxt.setText(playerName || '_'); } }; // Finish button handler finishBtn.down = function (x, y, obj) { if (!nameInputActive) return; if (playerName.length > 0) { nameInputActive = false; // Remove name input interface if (namePromptTxt.parent) namePromptTxt.parent.removeChild(namePromptTxt); if (playerNameTxt.parent) playerNameTxt.parent.removeChild(playerNameTxt); if (instructionTxt.parent) instructionTxt.parent.removeChild(instructionTxt); if (addCharBtn.parent) addCharBtn.parent.removeChild(addCharBtn); if (finishBtn.parent) finishBtn.parent.removeChild(finishBtn); if (deleteBtn.parent) deleteBtn.parent.removeChild(deleteBtn); // Remove keyboard buttons for (var k = 0; k < keyboardButtons.length; k++) { if (keyboardButtons[k].parent) keyboardButtons[k].parent.removeChild(keyboardButtons[k]); } // Show welcome message with player name showWelcomeMessage(); } }; // Delete button handler deleteBtn.down = function (x, y, obj) { if (!nameInputActive) return; if (playerName.length > 0) { playerName = playerName.slice(0, -1); playerNameTxt.setText(playerName || '_'); } }; function showWelcomeMessage() { // Show opening text: 'hoş geldin' and player name var welcomeTxt = new Text2('hoş geldin', { size: 180, fill: 0xFFD700 }); welcomeTxt.anchor.set(0.5, 0.5); welcomeTxt.x = 2048 / 2; welcomeTxt.y = 1200; game.addChild(welcomeTxt); var devNameTxt = new Text2(playerName, { size: 180, fill: 0xFFD700 }); devNameTxt.anchor.set(0.5, 0.5); devNameTxt.x = 2048 / 2; devNameTxt.y = 1532; game.addChild(devNameTxt); // Remove opening texts after 2 seconds, then show IQ mini-game sequence LK.setTimeout(function () { if (welcomeTxt && welcomeTxt.parent) { welcomeTxt.parent.removeChild(welcomeTxt); } if (devNameTxt && devNameTxt.parent) { devNameTxt.parent.removeChild(devNameTxt); } startIQGameSequence(); }, 2000); } // --- IQ Mini-Game Sequence with 20 levels --- var totalIQScore = 0; // Toplam IQ puanı // Background colors for different levels var backgroundColors = [0xFF0000, // Level 1: Red 0xFFFFFF, // Level 2: White 0x0000FF, // Level 3: Blue 0x00FF00, // Level 4: Green 0xFFFF00, // Level 5: Yellow 0xFF00FF, // Level 6: Magenta 0x00FFFF, // Level 7: Cyan 0xFFA500, // Level 8: Orange 0x800080, // Level 9: Purple 0xFFC0CB, // Level 10: Pink 0x808080, // Level 11: Gray 0x8B4513, // Level 12: Brown 0x90EE90, // Level 13: Light Green 0xFFB6C1, // Level 14: Light Pink 0x87CEEB, // Level 15: Sky Blue 0xDDA0DD, // Level 16: Plum 0xF0E68C, // Level 17: Khaki 0xE6E6FA, // Level 18: Lavender 0xFAF0E6, // Level 19: Linen 0x2F4F4F // Level 20: Dark Slate Gray ]; // Function to change background color based on level function changeBackgroundColor(levelIndex) { var colorIndex = levelIndex; if (colorIndex >= backgroundColors.length) { colorIndex = backgroundColors.length - 1; } var targetColor = backgroundColors[colorIndex]; // Create a dummy object to tween the color var colorObj = { r: 0, g: 0, b: 0 }; // Extract current background color components var currentColor = game.backgroundColor || 0x000000; colorObj.r = currentColor >> 16 & 0xFF; colorObj.g = currentColor >> 8 & 0xFF; colorObj.b = currentColor & 0xFF; // Extract target color components var targetR = targetColor >> 16 & 0xFF; var targetG = targetColor >> 8 & 0xFF; var targetB = targetColor & 0xFF; // Tween to new color tween(colorObj, { r: targetR, g: targetG, b: targetB }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { // Update background color during tween var newColor = Math.floor(colorObj.r) << 16 | Math.floor(colorObj.g) << 8 | Math.floor(colorObj.b); game.setBackgroundColor(newColor); } }); // Also update immediately for smooth transition var updateColorInterval = LK.setInterval(function () { var newColor = Math.floor(colorObj.r) << 16 | Math.floor(colorObj.g) << 8 | Math.floor(colorObj.b); game.setBackgroundColor(newColor); }, 16); // ~60fps updates // Clear interval after animation LK.setTimeout(function () { LK.clearInterval(updateColorInterval); }, 1000); } var iqLevels = [ // 20 different IQ questions, increasing in difficulty and variety { q: "3 + 4 = ?", a: [5, 7, 8], c: 1 }, { q: "9 - 2 = ?", a: [6, 7, 8], c: 1 }, { q: "2 x 6 = ?", a: [12, 14, 10], c: 0 }, { q: "15 / 3 = ?", a: [5, 4, 6], c: 0 }, { q: "Hangi sayı çift?", a: [7, 8, 9], c: 1 }, { q: "Hangisi en büyük?", a: [21, 19, 20], c: 0 }, { q: "5, 10, 15, ?", a: [20, 18, 25], c: 0 }, { q: "Hangisi harf?", a: ["3", "A", "7"], c: 1 }, { q: "Hangisi bir renk?", a: ["Elma", "Kırmızı", "Kedi"], c: 1 }, { q: "4 + 4 x 2 = ?", a: [16, 12, 8], c: 1 }, { q: "Hangisi üçgen?", a: ["▲", "■", "●"], c: 0 }, { q: "Hangisi meyve?", a: ["Armut", "Köpek", "Araba"], c: 0 }, { q: "Hangisi haftanın günü?", a: ["Salı", "Ay", "Kış"], c: 0 }, { q: "Hangisi daha hafif?", a: ["Tüy", "Taş", "Demir"], c: 0 }, { q: "Hangisi bir sayı?", a: ["Elma", "5", "Kuş"], c: 1 }, { q: "Hangisi bir ülke?", a: ["İstanbul", "Türkiye", "Ankara"], c: 1 }, { q: "Hangisi bir hayvan?", a: ["Kedi", "Masa", "Kalem"], c: 0 }, { q: "Hangisi bir araç?", a: ["Araba", "Elma", "Kuş"], c: 0 }, { q: "Hangisi bir meslek?", a: ["Doktor", "Muz", "Kedi"], c: 0 }, { q: "Hangisi bir içecek?", a: ["Su", "Tahta", "Kuş"], c: 0 }]; var currentIQLevel = 0; // Start the IQ game sequence function startIQGameSequence() { currentIQLevel = 0; showIQMiniGameLevel(currentIQLevel); } // Show a specific IQ mini-game level function showIQMiniGameLevel(levelIndex) { if (levelIndex >= iqLevels.length) { // All levels complete, show congratulations showIQGameEnd(true); return; } // Change background color based on level changeBackgroundColor(levelIndex); var level = iqLevels[levelIndex]; var question = level.q; var answers = level.a; var correctIndex = level.c; // Show level name at the top var levelNameTxt = new Text2(levelIndex + 1 + ". Bölüm", { size: 100, fill: 0xFFD700 }); levelNameTxt.anchor.set(0.5, 0.5); levelNameTxt.x = 2048 / 2; levelNameTxt.y = 500; game.addChild(levelNameTxt); // Show question with better visibility var iqQuestionTxt = new Text2(question, { size: 150, fill: 0xFFFFFF }); iqQuestionTxt.anchor.set(0.5, 0.5); iqQuestionTxt.x = 2048 / 2; iqQuestionTxt.y = 800; game.addChild(iqQuestionTxt); // Add a background box for the question to make it more visible var questionBg = LK.getAsset('iqBtnBg', { width: 1800, height: 200, color: 0x333333, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); questionBg.x = 2048 / 2; questionBg.y = 800; game.addChild(questionBg); // Move question text to front game.removeChild(iqQuestionTxt); game.addChild(iqQuestionTxt); // Show answer buttons var answerButtons = []; var buttonWidth = 400; var buttonHeight = 180; var spacing = 80; var startY = 1200; for (var i = 0; i < answers.length; i++) { var btn = new Container(); var btnBg = LK.getAsset('iqBtnBg', { width: buttonWidth, height: buttonHeight, color: 0x2222aa, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); btn.addChild(btnBg); var btnTxt = new Text2(answers[i] + "", { size: 100, fill: "#fff" }); btnTxt.anchor.set(0.5, 0.5); btnTxt.x = 0; btnTxt.y = 0; btn.addChild(btnTxt); btn.x = 2048 / 2; btn.y = startY + i * (buttonHeight + spacing); btn.iqIndex = i; // Touch/click event btn.down = function (x, y, obj) { var isCorrect = this.iqIndex === correctIndex; // Remove all buttons and question for (var j = 0; j < answerButtons.length; j++) { if (answerButtons[j].parent) answerButtons[j].parent.removeChild(answerButtons[j]); } if (iqQuestionTxt.parent) iqQuestionTxt.parent.removeChild(iqQuestionTxt); if (questionBg && questionBg.parent) questionBg.parent.removeChild(questionBg); // Remove level name text if present if (typeof levelNameTxt !== "undefined" && levelNameTxt.parent) levelNameTxt.parent.removeChild(levelNameTxt); showIQResultLevel(isCorrect, levelIndex); }; game.addChild(btn); answerButtons.push(btn); } } // Track wrong answers for each level var wrongAnswers = []; // Show result of IQ mini-game level and go to next or end function showIQResultLevel(isCorrect, levelIndex) { // Initialize wrongAnswers for this level if not exists if (!wrongAnswers[levelIndex]) { wrongAnswers[levelIndex] = 0; } var resultTxt = new Text2(isCorrect ? "Doğru!" : "Yanlış!", { size: 120, fill: isCorrect ? "#00ff00" : "#ff0000" }); resultTxt.anchor.set(0.5, 0.5); resultTxt.x = 2048 / 2; resultTxt.y = 1800; game.addChild(resultTxt); LK.setTimeout(function () { if (resultTxt.parent) resultTxt.parent.removeChild(resultTxt); if (isCorrect) { // Doğru cevap - seviye geç currentIQLevel++; showIQMiniGameLevel(currentIQLevel); } else { // Yanlış cevap - eksi puan ver ve seviye geç wrongAnswers[levelIndex]++; totalIQScore -= 2; // Yanlış cevap için eksi puan currentIQLevel++; showIQMiniGameLevel(currentIQLevel); } }, 1200); } // Show end of IQ game function showIQGameEnd(success) { // Calculate final IQ score var totalWrongAnswers = 0; for (var i = 0; i < wrongAnswers.length; i++) { if (wrongAnswers[i]) { totalWrongAnswers += wrongAnswers[i]; } } var finalIQScore; if (totalWrongAnswers === 0) { // Hepsi doğru - 100 puan finalIQScore = 100; } else if (totalWrongAnswers >= 10) { // 10 veya daha fazla yanlış - 50 puan finalIQScore = 50; } else { // Diğer durumlar için hesaplama finalIQScore = Math.max(50, 100 - totalWrongAnswers * 5); } // Add emoji based on score var scoreEmoji = ""; if (finalIQScore >= 100) { scoreEmoji = "🤓"; // Glasses emoji for perfect score } else if (finalIQScore >= 90) { scoreEmoji = "😎"; // Cool sunglasses emoji } else if (finalIQScore >= 80) { scoreEmoji = "🧠"; // Brain emoji } else if (finalIQScore >= 70) { scoreEmoji = "👍"; // Thumbs up } else if (finalIQScore >= 60) { scoreEmoji = "😊"; // Happy face } else { scoreEmoji = "😔"; // Disappointed face } // Show final IQ score with emoji var finalScoreTxt = new Text2(scoreEmoji + ' IQ Puanınız: ' + finalIQScore + ' ' + scoreEmoji, { size: 150, fill: 0xFFD700 }); finalScoreTxt.anchor.set(0.5, 0.5); finalScoreTxt.x = 2048 / 2; finalScoreTxt.y = 1200; game.addChild(finalScoreTxt); LK.setTimeout(function () { if (finalScoreTxt && finalScoreTxt.parent) { finalScoreTxt.parent.removeChild(finalScoreTxt); } showDevNameEnd(); }, 3000); } // Show developer name at the end (on game over or win) function showDevNameEnd() { var endDevNameTxt = new Text2('ayaz26 tarafından yapılmıştır', { size: 120, fill: 0xFFD700 }); endDevNameTxt.anchor.set(0.5, 0.5); endDevNameTxt.x = 2048 / 2; endDevNameTxt.y = 2732 / 2; game.addChild(endDevNameTxt); LK.setTimeout(function () { if (endDevNameTxt && endDevNameTxt.parent) { endDevNameTxt.parent.removeChild(endDevNameTxt); } }, 2000); } // Listen for game over and win events to show developer name LK.on('gameover', showDevNameEnd); LK.on('youwin', showDevNameEnd);
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Player name input system
var playerName = "";
var inputChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var currentCharIndex = 0;
var nameInputActive = true;
// Show name input interface
var namePromptTxt = new Text2('Oyuncu İsmine Gir', {
size: 150,
fill: 0xFFD700
});
namePromptTxt.anchor.set(0.5, 0.5);
namePromptTxt.x = 2048 / 2;
namePromptTxt.y = 800;
game.addChild(namePromptTxt);
var playerNameTxt = new Text2(playerName || '_', {
size: 120,
fill: 0xFFFFFF
});
playerNameTxt.anchor.set(0.5, 0.5);
playerNameTxt.x = 2048 / 2;
playerNameTxt.y = 1200;
game.addChild(playerNameTxt);
// Virtual keyboard interface
var keyboardRows = ["QWERTYUIOP", "ASDFGHJKL", "ZXCVBNM"];
var keyboardButtons = [];
var keySize = 150;
var keySpacing = 10;
// Create virtual keyboard
for (var row = 0; row < keyboardRows.length; row++) {
var rowString = keyboardRows[row];
var rowWidth = rowString.length * (keySize + keySpacing) - keySpacing;
var startX = (2048 - rowWidth) / 2;
for (var col = 0; col < rowString.length; col++) {
var keyChar = rowString[col];
var keyBtn = new Container();
var keyBg = LK.getAsset('iqBtnBg', {
width: keySize,
height: keySize,
color: 0x444444,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
keyBtn.addChild(keyBg);
var keyTxt = new Text2(keyChar, {
size: 60,
fill: "#fff"
});
keyTxt.anchor.set(0.5, 0.5);
keyBtn.addChild(keyTxt);
keyBtn.x = startX + col * (keySize + keySpacing) + keySize / 2;
keyBtn.y = 1400 + row * (keySize + keySpacing);
keyBtn.keyChar = keyChar;
keyBtn.down = function (x, y, obj) {
if (!nameInputActive) return;
if (playerName.length < 12) {
playerName += this.keyChar;
playerNameTxt.setText(playerName || '_');
}
};
game.addChild(keyBtn);
keyboardButtons.push(keyBtn);
}
}
// Instruction text
var instructionTxt = new Text2('Harflere Dokunarak İsim Yaz', {
size: 80,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.x = 2048 / 2;
instructionTxt.y = 1300;
game.addChild(instructionTxt);
// Add character button
var addCharBtn = new Container();
var addCharBg = LK.getAsset('iqBtnBg', {
width: 300,
height: 100,
color: 0x00AA00,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
addCharBtn.addChild(addCharBg);
var addCharTxt = new Text2('Boşluk', {
size: 60,
fill: "#fff"
});
addCharTxt.anchor.set(0.5, 0.5);
addCharBtn.addChild(addCharTxt);
addCharBtn.x = 1024;
addCharBtn.y = 1800;
game.addChild(addCharBtn);
// Finish button
var finishBtn = new Container();
var finishBg = LK.getAsset('iqBtnBg', {
width: 300,
height: 100,
color: 0x0000AA,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
finishBtn.addChild(finishBg);
var finishTxt = new Text2('Tamam', {
size: 60,
fill: "#fff"
});
finishTxt.anchor.set(0.5, 0.5);
finishBtn.addChild(finishTxt);
finishBtn.x = 1524;
finishBtn.y = 1800;
game.addChild(finishBtn);
// Delete button
var deleteBtn = new Container();
var deleteBg = LK.getAsset('iqBtnBg', {
width: 300,
height: 100,
color: 0xAA0000,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
deleteBtn.addChild(deleteBg);
var deleteTxt = new Text2('Sil', {
size: 60,
fill: "#fff"
});
deleteTxt.anchor.set(0.5, 0.5);
deleteBtn.addChild(deleteTxt);
deleteBtn.x = 524;
deleteBtn.y = 1800;
game.addChild(deleteBtn);
// Game touch handler for name input
game.down = function (x, y, obj) {
if (!nameInputActive) return;
};
// Add space button handler
addCharBtn.down = function (x, y, obj) {
if (!nameInputActive) return;
if (playerName.length < 12) {
// Add space character
playerName += " ";
playerNameTxt.setText(playerName || '_');
}
};
// Finish button handler
finishBtn.down = function (x, y, obj) {
if (!nameInputActive) return;
if (playerName.length > 0) {
nameInputActive = false;
// Remove name input interface
if (namePromptTxt.parent) namePromptTxt.parent.removeChild(namePromptTxt);
if (playerNameTxt.parent) playerNameTxt.parent.removeChild(playerNameTxt);
if (instructionTxt.parent) instructionTxt.parent.removeChild(instructionTxt);
if (addCharBtn.parent) addCharBtn.parent.removeChild(addCharBtn);
if (finishBtn.parent) finishBtn.parent.removeChild(finishBtn);
if (deleteBtn.parent) deleteBtn.parent.removeChild(deleteBtn);
// Remove keyboard buttons
for (var k = 0; k < keyboardButtons.length; k++) {
if (keyboardButtons[k].parent) keyboardButtons[k].parent.removeChild(keyboardButtons[k]);
}
// Show welcome message with player name
showWelcomeMessage();
}
};
// Delete button handler
deleteBtn.down = function (x, y, obj) {
if (!nameInputActive) return;
if (playerName.length > 0) {
playerName = playerName.slice(0, -1);
playerNameTxt.setText(playerName || '_');
}
};
function showWelcomeMessage() {
// Show opening text: 'hoş geldin' and player name
var welcomeTxt = new Text2('hoş geldin', {
size: 180,
fill: 0xFFD700
});
welcomeTxt.anchor.set(0.5, 0.5);
welcomeTxt.x = 2048 / 2;
welcomeTxt.y = 1200;
game.addChild(welcomeTxt);
var devNameTxt = new Text2(playerName, {
size: 180,
fill: 0xFFD700
});
devNameTxt.anchor.set(0.5, 0.5);
devNameTxt.x = 2048 / 2;
devNameTxt.y = 1532;
game.addChild(devNameTxt);
// Remove opening texts after 2 seconds, then show IQ mini-game sequence
LK.setTimeout(function () {
if (welcomeTxt && welcomeTxt.parent) {
welcomeTxt.parent.removeChild(welcomeTxt);
}
if (devNameTxt && devNameTxt.parent) {
devNameTxt.parent.removeChild(devNameTxt);
}
startIQGameSequence();
}, 2000);
}
// --- IQ Mini-Game Sequence with 20 levels ---
var totalIQScore = 0; // Toplam IQ puanı
// Background colors for different levels
var backgroundColors = [0xFF0000,
// Level 1: Red
0xFFFFFF,
// Level 2: White
0x0000FF,
// Level 3: Blue
0x00FF00,
// Level 4: Green
0xFFFF00,
// Level 5: Yellow
0xFF00FF,
// Level 6: Magenta
0x00FFFF,
// Level 7: Cyan
0xFFA500,
// Level 8: Orange
0x800080,
// Level 9: Purple
0xFFC0CB,
// Level 10: Pink
0x808080,
// Level 11: Gray
0x8B4513,
// Level 12: Brown
0x90EE90,
// Level 13: Light Green
0xFFB6C1,
// Level 14: Light Pink
0x87CEEB,
// Level 15: Sky Blue
0xDDA0DD,
// Level 16: Plum
0xF0E68C,
// Level 17: Khaki
0xE6E6FA,
// Level 18: Lavender
0xFAF0E6,
// Level 19: Linen
0x2F4F4F // Level 20: Dark Slate Gray
];
// Function to change background color based on level
function changeBackgroundColor(levelIndex) {
var colorIndex = levelIndex;
if (colorIndex >= backgroundColors.length) {
colorIndex = backgroundColors.length - 1;
}
var targetColor = backgroundColors[colorIndex];
// Create a dummy object to tween the color
var colorObj = {
r: 0,
g: 0,
b: 0
};
// Extract current background color components
var currentColor = game.backgroundColor || 0x000000;
colorObj.r = currentColor >> 16 & 0xFF;
colorObj.g = currentColor >> 8 & 0xFF;
colorObj.b = currentColor & 0xFF;
// Extract target color components
var targetR = targetColor >> 16 & 0xFF;
var targetG = targetColor >> 8 & 0xFF;
var targetB = targetColor & 0xFF;
// Tween to new color
tween(colorObj, {
r: targetR,
g: targetG,
b: targetB
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Update background color during tween
var newColor = Math.floor(colorObj.r) << 16 | Math.floor(colorObj.g) << 8 | Math.floor(colorObj.b);
game.setBackgroundColor(newColor);
}
});
// Also update immediately for smooth transition
var updateColorInterval = LK.setInterval(function () {
var newColor = Math.floor(colorObj.r) << 16 | Math.floor(colorObj.g) << 8 | Math.floor(colorObj.b);
game.setBackgroundColor(newColor);
}, 16); // ~60fps updates
// Clear interval after animation
LK.setTimeout(function () {
LK.clearInterval(updateColorInterval);
}, 1000);
}
var iqLevels = [
// 20 different IQ questions, increasing in difficulty and variety
{
q: "3 + 4 = ?",
a: [5, 7, 8],
c: 1
}, {
q: "9 - 2 = ?",
a: [6, 7, 8],
c: 1
}, {
q: "2 x 6 = ?",
a: [12, 14, 10],
c: 0
}, {
q: "15 / 3 = ?",
a: [5, 4, 6],
c: 0
}, {
q: "Hangi sayı çift?",
a: [7, 8, 9],
c: 1
}, {
q: "Hangisi en büyük?",
a: [21, 19, 20],
c: 0
}, {
q: "5, 10, 15, ?",
a: [20, 18, 25],
c: 0
}, {
q: "Hangisi harf?",
a: ["3", "A", "7"],
c: 1
}, {
q: "Hangisi bir renk?",
a: ["Elma", "Kırmızı", "Kedi"],
c: 1
}, {
q: "4 + 4 x 2 = ?",
a: [16, 12, 8],
c: 1
}, {
q: "Hangisi üçgen?",
a: ["▲", "■", "●"],
c: 0
}, {
q: "Hangisi meyve?",
a: ["Armut", "Köpek", "Araba"],
c: 0
}, {
q: "Hangisi haftanın günü?",
a: ["Salı", "Ay", "Kış"],
c: 0
}, {
q: "Hangisi daha hafif?",
a: ["Tüy", "Taş", "Demir"],
c: 0
}, {
q: "Hangisi bir sayı?",
a: ["Elma", "5", "Kuş"],
c: 1
}, {
q: "Hangisi bir ülke?",
a: ["İstanbul", "Türkiye", "Ankara"],
c: 1
}, {
q: "Hangisi bir hayvan?",
a: ["Kedi", "Masa", "Kalem"],
c: 0
}, {
q: "Hangisi bir araç?",
a: ["Araba", "Elma", "Kuş"],
c: 0
}, {
q: "Hangisi bir meslek?",
a: ["Doktor", "Muz", "Kedi"],
c: 0
}, {
q: "Hangisi bir içecek?",
a: ["Su", "Tahta", "Kuş"],
c: 0
}];
var currentIQLevel = 0;
// Start the IQ game sequence
function startIQGameSequence() {
currentIQLevel = 0;
showIQMiniGameLevel(currentIQLevel);
}
// Show a specific IQ mini-game level
function showIQMiniGameLevel(levelIndex) {
if (levelIndex >= iqLevels.length) {
// All levels complete, show congratulations
showIQGameEnd(true);
return;
}
// Change background color based on level
changeBackgroundColor(levelIndex);
var level = iqLevels[levelIndex];
var question = level.q;
var answers = level.a;
var correctIndex = level.c;
// Show level name at the top
var levelNameTxt = new Text2(levelIndex + 1 + ". Bölüm", {
size: 100,
fill: 0xFFD700
});
levelNameTxt.anchor.set(0.5, 0.5);
levelNameTxt.x = 2048 / 2;
levelNameTxt.y = 500;
game.addChild(levelNameTxt);
// Show question with better visibility
var iqQuestionTxt = new Text2(question, {
size: 150,
fill: 0xFFFFFF
});
iqQuestionTxt.anchor.set(0.5, 0.5);
iqQuestionTxt.x = 2048 / 2;
iqQuestionTxt.y = 800;
game.addChild(iqQuestionTxt);
// Add a background box for the question to make it more visible
var questionBg = LK.getAsset('iqBtnBg', {
width: 1800,
height: 200,
color: 0x333333,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
questionBg.x = 2048 / 2;
questionBg.y = 800;
game.addChild(questionBg);
// Move question text to front
game.removeChild(iqQuestionTxt);
game.addChild(iqQuestionTxt);
// Show answer buttons
var answerButtons = [];
var buttonWidth = 400;
var buttonHeight = 180;
var spacing = 80;
var startY = 1200;
for (var i = 0; i < answers.length; i++) {
var btn = new Container();
var btnBg = LK.getAsset('iqBtnBg', {
width: buttonWidth,
height: buttonHeight,
color: 0x2222aa,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
btn.addChild(btnBg);
var btnTxt = new Text2(answers[i] + "", {
size: 100,
fill: "#fff"
});
btnTxt.anchor.set(0.5, 0.5);
btnTxt.x = 0;
btnTxt.y = 0;
btn.addChild(btnTxt);
btn.x = 2048 / 2;
btn.y = startY + i * (buttonHeight + spacing);
btn.iqIndex = i;
// Touch/click event
btn.down = function (x, y, obj) {
var isCorrect = this.iqIndex === correctIndex;
// Remove all buttons and question
for (var j = 0; j < answerButtons.length; j++) {
if (answerButtons[j].parent) answerButtons[j].parent.removeChild(answerButtons[j]);
}
if (iqQuestionTxt.parent) iqQuestionTxt.parent.removeChild(iqQuestionTxt);
if (questionBg && questionBg.parent) questionBg.parent.removeChild(questionBg);
// Remove level name text if present
if (typeof levelNameTxt !== "undefined" && levelNameTxt.parent) levelNameTxt.parent.removeChild(levelNameTxt);
showIQResultLevel(isCorrect, levelIndex);
};
game.addChild(btn);
answerButtons.push(btn);
}
}
// Track wrong answers for each level
var wrongAnswers = [];
// Show result of IQ mini-game level and go to next or end
function showIQResultLevel(isCorrect, levelIndex) {
// Initialize wrongAnswers for this level if not exists
if (!wrongAnswers[levelIndex]) {
wrongAnswers[levelIndex] = 0;
}
var resultTxt = new Text2(isCorrect ? "Doğru!" : "Yanlış!", {
size: 120,
fill: isCorrect ? "#00ff00" : "#ff0000"
});
resultTxt.anchor.set(0.5, 0.5);
resultTxt.x = 2048 / 2;
resultTxt.y = 1800;
game.addChild(resultTxt);
LK.setTimeout(function () {
if (resultTxt.parent) resultTxt.parent.removeChild(resultTxt);
if (isCorrect) {
// Doğru cevap - seviye geç
currentIQLevel++;
showIQMiniGameLevel(currentIQLevel);
} else {
// Yanlış cevap - eksi puan ver ve seviye geç
wrongAnswers[levelIndex]++;
totalIQScore -= 2; // Yanlış cevap için eksi puan
currentIQLevel++;
showIQMiniGameLevel(currentIQLevel);
}
}, 1200);
}
// Show end of IQ game
function showIQGameEnd(success) {
// Calculate final IQ score
var totalWrongAnswers = 0;
for (var i = 0; i < wrongAnswers.length; i++) {
if (wrongAnswers[i]) {
totalWrongAnswers += wrongAnswers[i];
}
}
var finalIQScore;
if (totalWrongAnswers === 0) {
// Hepsi doğru - 100 puan
finalIQScore = 100;
} else if (totalWrongAnswers >= 10) {
// 10 veya daha fazla yanlış - 50 puan
finalIQScore = 50;
} else {
// Diğer durumlar için hesaplama
finalIQScore = Math.max(50, 100 - totalWrongAnswers * 5);
}
// Add emoji based on score
var scoreEmoji = "";
if (finalIQScore >= 100) {
scoreEmoji = "🤓"; // Glasses emoji for perfect score
} else if (finalIQScore >= 90) {
scoreEmoji = "😎"; // Cool sunglasses emoji
} else if (finalIQScore >= 80) {
scoreEmoji = "🧠"; // Brain emoji
} else if (finalIQScore >= 70) {
scoreEmoji = "👍"; // Thumbs up
} else if (finalIQScore >= 60) {
scoreEmoji = "😊"; // Happy face
} else {
scoreEmoji = "😔"; // Disappointed face
}
// Show final IQ score with emoji
var finalScoreTxt = new Text2(scoreEmoji + ' IQ Puanınız: ' + finalIQScore + ' ' + scoreEmoji, {
size: 150,
fill: 0xFFD700
});
finalScoreTxt.anchor.set(0.5, 0.5);
finalScoreTxt.x = 2048 / 2;
finalScoreTxt.y = 1200;
game.addChild(finalScoreTxt);
LK.setTimeout(function () {
if (finalScoreTxt && finalScoreTxt.parent) {
finalScoreTxt.parent.removeChild(finalScoreTxt);
}
showDevNameEnd();
}, 3000);
}
// Show developer name at the end (on game over or win)
function showDevNameEnd() {
var endDevNameTxt = new Text2('ayaz26 tarafından yapılmıştır', {
size: 120,
fill: 0xFFD700
});
endDevNameTxt.anchor.set(0.5, 0.5);
endDevNameTxt.x = 2048 / 2;
endDevNameTxt.y = 2732 / 2;
game.addChild(endDevNameTxt);
LK.setTimeout(function () {
if (endDevNameTxt && endDevNameTxt.parent) {
endDevNameTxt.parent.removeChild(endDevNameTxt);
}
}, 2000);
}
// Listen for game over and win events to show developer name
LK.on('gameover', showDevNameEnd);
LK.on('youwin', showDevNameEnd);