User prompt
2. Sayfada tebrikler yazısı 1 kere çıksın
User prompt
2. Sayfada rakamların okunuşları olan harf kısmını yukarı kaydır biraz
User prompt
Yeniden başla dediğimde random verdiğin sayıyı yenile
User prompt
Sayıyı bulun üstündeki rakamı 150 den küçük olucak şekilde rastgele ver
User prompt
Butonun içindeki yazıyı biraz küçült
User prompt
Butonu biraz büyült
User prompt
Yeniden başla butonu yazı olarak butona sığsın
User prompt
Alt bölümdeki kısmı biraz yukarı kaydır
User prompt
Sayıyı bul sayısının hemen altına restart butonu koy
User prompt
Sayıyı bul un üstündeki rakam 150 den küçük olsun
User prompt
2 ekranın altına sayaç koy 10dan geri gitsin
User prompt
Sayıyı bul ve rakam kısmını yukarı al biraz
User prompt
Englis türkçe vegeri butonları aynı hizada olsun
User prompt
Geri butonunu dil seçme kutusu büyüklüğünde olsun
User prompt
Geri tuşunu sağ yukarı al
User prompt
Geri botununu biraz küçült
User prompt
Back butonu sadece 2. Ekranda olsun
User prompt
2. Ekrandan geri tuşuna basmadıkça geri dönme
User prompt
Tebrikler yazdıktan sonra başa dönme
User prompt
Rastgele verdiğin sayı ve 2. Ekrandaki sayı aynı olursa tebrikler yaz ekrana
User prompt
250 den büyük sayıyı ve altındaki cümleyi yukarı kaydır azıcık
User prompt
Sayının hemen altına sayıyı bul yaz
User prompt
250 den küçük olan sayı asal olmasın
User prompt
250 den küçük sayıyı yukarı kaydır
User prompt
Sayıyı yukarı kaydır
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Black background }); /**** * Game Code ****/ // --- GLOBALS --- var countingDirection = 1; // 1: up, -1: down var startNumber = 0; var targetNumber = 10; var currentNumber = 0; var gameStarted = false; // --- LANGUAGE SUPPORT --- var LANGUAGES = [{ code: "en", label: "English" }, { code: "tr", label: "Türkçe" }]; var lang = "tr"; // default language // Localization dictionary var L10N = { tr: { increase: "Artarak", decrease: "Azalarak", selectTarget: "Hedef Seç", selectDirection: "Yön Seç", win: "Tebrikler!", tapToCount: "Ekrana tıkla", numberReading: function numberReading(n) { return getNumberReadingTR(n); } }, en: { increase: "Increasing", decrease: "Decreasing", selectTarget: "Select Target", selectDirection: "Select Direction", win: "Congratulations!", tapToCount: "Tap to count", numberReading: function numberReading(n) { return getNumberReadingEN(n); } } }; // UI elements var numberText = null; var numberReadingText = null; var infoText = null; var optionButtons = []; var directionButtons = []; var selectedTarget = null; var selectedDirection = null; var langButtons = []; var selectText = null; // Make selectText global for cleanup // --- UI HELPERS --- // Create a button as a colored box with text, returns a Container function createButton(label, x, y, width, height, color, onTap) { var btn = new Container(); var box = btn.attachAsset('buttonBox', { width: width, height: height, color: color, anchorX: 0.5, anchorY: 0.5 }); var txt = new Text2(label, { size: 80, fill: 0xFFFFFF }); txt.anchor.set(0.5, 0.5); txt.x = 0; txt.y = 0; btn.addChild(txt); btn.x = x; btn.y = y; btn.interactive = true; btn.down = function (x, y, obj) { if (onTap) { onTap(); } }; return btn; } // --- GAME SETUP --- // Helper to check if a number is prime function isPrime(n) { if (n < 2) return false; for (var i = 2; i * i <= n; i++) { if (n % i === 0) return false; } return true; } // Show a random number less than 250 and not prime at the bottom of the screen var randomNumber; do { randomNumber = Math.floor(Math.random() * 250); } while (isPrime(randomNumber)); var randomNumberText = new Text2("" + randomNumber, { size: 120, fill: 0xFFFFFF }); randomNumberText.anchor.set(0.5, 1); randomNumberText.x = 2048 / 2; randomNumberText.y = 2732 - 120; // moved up by 80px game.addChild(randomNumberText); // Add 'Sayiyi bul' text just below the random number var findNumberText = new Text2("Sayıyı bul", { size: 120, // 150'den küçük, daha büyük görünürlük için 120 seçildi fill: 0xFFFFFF }); findNumberText.anchor.set(0.5, 0); findNumberText.x = 2048 / 2; findNumberText.y = randomNumberText.y + 20; game.addChild(findNumberText); // Show the pre-game menu: select target number and direction function showMenu() { gameStarted = false; selectedTarget = null; selectedDirection = null; // Remove previous UI if any if (numberText) { numberText.destroy(); numberText = null; } if (numberReadingText) { numberReadingText.destroy(); numberReadingText = null; } if (infoText) { infoText.destroy(); infoText = null; } for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].destroy(); } optionButtons = []; for (var i = 0; i < directionButtons.length; i++) { if (directionButtons[i]) { directionButtons[i].destroy(); } } directionButtons = []; for (var i = 0; i < langButtons.length; i++) { langButtons[i].destroy(); } langButtons = []; // Remove infoText usage, but keep for cleanup infoText = null; // Remove back button if it exists (should not be visible in menu) if (typeof backButton !== "undefined" && backButton) { backButton.destroy(); backButton = null; } // --- LANGUAGE BUTTONS --- var langBtnW = 320, langBtnH = 100, langBtnGap = 40; var langBtnStartX = (2048 - (LANGUAGES.length * langBtnW + (LANGUAGES.length - 1) * langBtnGap)) / 2 + langBtnW / 2; var langBtnY = 120; for (var i = 0; i < LANGUAGES.length; i++) { (function (idx) { var l = LANGUAGES[idx]; var btn = createButton(l.label, langBtnStartX + idx * (langBtnW + langBtnGap), langBtnY, langBtnW, langBtnH, 0x888888, function () { lang = l.code; showMenu(); }); // Highlight selected language btn.children[0].tint = lang === l.code ? 0xff0000 : 0xffffff; langButtons.push(btn); game.addChild(btn); })(i); } // --- HEADER RECTANGLE --- var headerHeight = 320; // Increased height for a more vertically extended header var headerY = 420; // Moved header further down var headerAssetId = lang === "en" ? "centerCircle1" : "centerCircle"; var headerRect = game.attachAsset(headerAssetId, { width: 720, // 10% smaller than 800 height: headerHeight, anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: headerY }); // So it gets cleaned up with the rest of the menu // Target number options (1-25) as a 5x5 grid var targets = []; for (var i = 1; i <= 25; i++) { targets.push(i); } var btnW = 220 * 1.1, // 10% larger btnH = 220 * 1.1; // 10% larger, keep square var gapX = 40; var gapY = 40; var gridCols = 5; var gridRows = 5; // Calculate total grid width and height var gridTotalWidth = gridCols * btnW + (gridCols - 1) * gapX; var gridTotalHeight = gridRows * btnH + (gridRows - 1) * gapY; // Center grid on screen var gridStartX = (2048 - gridTotalWidth) / 2 + btnW / 2; var gridStartY = (2732 - gridTotalHeight) / 2 + btnH / 2; for (var i = 0; i < targets.length; i++) { (function (idx) { var t = targets[idx]; var col = idx % gridCols; var row = Math.floor(idx / gridCols); var x = gridStartX + col * (btnW + gapX); var y = gridStartY + row * (btnH + gapY); var btn = createButton("" + t, x, y, btnW, btnH, 0x4a90e2, function () { selectTarget(t, idx); }); // If this target was previously selected, keep it red if (selectedTarget !== null && selectedTarget === idx) { btn.children[0].tint = 0xff0000; } optionButtons.push(btn); game.addChild(btn); })(i); } // (Removed 'Saymak istediğimiz sayıyı seçelim' text below the grid) // No direction buttons on the first page } // When a target number is selected function selectTarget(t, idx) { LK.getSound('click').play(); targetNumber = t; selectedTarget = idx; // Highlight selected for (var i = 0; i < optionButtons.length; i++) { // Make selected target button red, others white optionButtons[i].children[0].tint = i === idx ? 0xff0000 : 0xffffff; } // Animate selected button: jump up and down once var btn = optionButtons[idx]; tween.stop(btn, { y: true }); var originalY = btn.y; tween(btn, { y: originalY - 80 }, { duration: 240, easing: tween.cubicOut, onFinish: function onFinish() { tween(btn, { y: originalY }, { duration: 360, easing: tween.bounceOut }); } }); // Enable direction buttons after a target is selected for (var i = 0; i < directionButtons.length; i++) { directionButtons[i].directionActive = true; directionButtons[i].alpha = 1; } // Go to 2nd page (gameplay) immediately when a target is tapped startGame(); } // When a direction is selected function selectDirection(dir, idx) { LK.getSound('click').play(); countingDirection = dir; selectedDirection = idx; // Highlight selected for (var i = 0; i < directionButtons.length; i++) { // Make selected direction button red, others white directionButtons[i].children[0].tint = i === idx ? 0xff0000 : 0xffffff; // Animate selected direction button with jump effect if (i === idx) { tween.stop(directionButtons[i], { y: true }); var originalY = directionButtons[i].y; tween(directionButtons[i], { y: originalY - 80 }, { duration: 320, easing: tween.cubicOut, onFinish: function (btn, oy) { return function () { tween(btn, { y: oy }, { duration: 420, easing: tween.bounceOut }); }; }(directionButtons[i], originalY) }); } } // If target already selected, start game after 1 second if (selectedTarget !== null) { LK.setTimeout(function () { startGame(); }, 1000); } } // --- GAMEPLAY --- function startGame() { // Remove menu UI if (infoText) { infoText.destroy(); infoText = null; } for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].destroy(); } optionButtons = []; for (var i = 0; i < directionButtons.length; i++) { directionButtons[i].destroy(); } directionButtons = []; // Remove "Saymak istediğimiz sayıyı seçelim" text if it exists if (typeof selectText !== "undefined" && selectText) { selectText.destroy(); selectText = null; } // Always start from 0, regardless of direction startNumber = 0; currentNumber = startNumber; // Show current number // Calculate size to cover 50% of the screen height (2732 * 0.5 = 1366px) // Text2 size is font size, so we estimate a bit smaller to fit: try 1200px numberText = new Text2("" + currentNumber, { size: 1200, fill: 0xFFFFFF }); numberText.anchor.set(0.5, 0.5); numberText.x = 2048 / 2; numberText.y = 2732 / 2; game.addChild(numberText); // --- GAMEPLAY --- if (numberReadingText) { numberReadingText.destroy(); numberReadingText = null; } // Dynamically fit numberReadingText to always fit on screen var readingString = L10N[lang].numberReading(currentNumber); var maxWidth = 2048 * 0.9; // 90% of screen width var maxHeight = 220; // Max font size var minFontSize = 80; var fontSize = maxHeight; var testText = null; do { if (testText) testText.destroy(); testText = new Text2(readingString, { size: fontSize, fill: 0xFFFFFF }); testText.anchor.set(0.5, 0); } while ((testText.width > maxWidth || testText.height > 300) && fontSize-- > minFontSize); if (testText) testText.destroy(); numberReadingText = new Text2(readingString, { size: fontSize, fill: 0xFFFFFF }); numberReadingText.anchor.set(0.5, 0); numberReadingText.x = 2048 / 2; numberReadingText.y = numberText.y + numberText.height / 2 + 40; game.addChild(numberReadingText); gameStarted = true; // --- Add 'İleri' and 'Geri' overlays --- var ileriLabel = lang === "en" ? "Forward" : "İleri"; var ileriText = new Text2(ileriLabel, { size: 120, fill: 0xffffff }); ileriText.anchor.set(0.5, 0.5); ileriText.x = 2048 * 0.75; ileriText.y = 2732 / 2; game.addChild(ileriText); var geriLabel = lang === "en" ? "Back" : "Geri"; var geriText = new Text2(geriLabel, { size: 180, fill: 0xffffff }); geriText.anchor.set(0.5, 0.5); geriText.x = 2048 * 0.25; geriText.y = 2732 / 2; game.addChild(geriText); // Store for later removal game._ileriText = ileriText; game._geriText = geriText; // --- DIRECTION BUTTONS REMOVED FROM GAMEPLAY --- // No direction buttons in gameplay directionButtons = []; // --- BACK BUTTON IN GAMEPLAY --- if (typeof backButton !== "undefined" && backButton) { backButton.destroy(); backButton = null; } var backButtonLabel = lang === "en" ? "Back" : "Geri"; var langBtnW = 320, langBtnH = 100; // match language button size var backButton = createButton(backButtonLabel, 2048 - 100 - langBtnW / 2, // 100px margin from right, button width/2 offset for anchor 100 + langBtnH / 2, // 100px margin from top, plus half button height for anchor langBtnW, // width langBtnH, // height 0x888888, function () { // Defensive: prevent double tap if (!gameStarted) return; gameStarted = false; // Clean up gameplay UI if (numberText) { numberText.destroy(); numberText = null; } if (numberReadingText) { numberReadingText.destroy(); numberReadingText = null; } for (var i = 0; i < directionButtons.length; i++) { if (directionButtons[i]) directionButtons[i].destroy(); } directionButtons = []; if (typeof backButton !== "undefined" && backButton) { backButton.destroy(); backButton = null; } showMenu(); }); backButton.children[0].tint = 0xffffff; game.addChild(backButton); } // --- Number Reading Helper (Turkish) --- function getNumberReadingTR(n) { // Only works for 0-250, but covers all gameplay needs var birler = ["", "BİR", "İKİ", "ÜÇ", "DÖRT", "BEŞ", "ALTI", "YEDİ", "SEKİZ", "DOKUZ"]; var onlar = ["", "ON", "YİRMİ", "OTUZ", "KIRK", "ELLİ", "ALTMIŞ", "YETMİŞ", "SEKSEN", "DOKSAN"]; var yuzler = ["", "YÜZ", "İKİYÜZ"]; n = Math.floor(n); if (n < 0) { return ""; } if (n === 0) { return "SIFIR"; } if (n > 250) { return "" + n; } // fallback var y = Math.floor(n / 100); var o = Math.floor(n % 100 / 10); var b = n % 10; var parts = []; if (y > 0) { if (y === 1) { parts.push("YÜZ"); } else { parts.push(birler[y] + " YÜZ"); } } if (o > 0) { parts.push(onlar[o]); } if (b > 0) { parts.push(birler[b]); } return parts.join(" "); } // --- Number Reading Helper (English) --- function getNumberReadingEN(n) { // Only works for 0-250, covers all gameplay needs var ones = ["", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"]; var tens = ["", "TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY"]; var hundreds = ["", "ONE HUNDRED", "TWO HUNDRED"]; n = Math.floor(n); if (n < 0) { return ""; } if (n === 0) { return "ZERO"; } if (n > 250) { return "" + n; } // fallback var y = Math.floor(n / 100); var o = Math.floor(n % 100 / 10); var b = n % 10; var parts = []; if (y > 0) { if (y === 1 && o === 0 && b === 0) { parts.push("ONE HUNDRED"); } else { parts.push(ones[y] + " HUNDRED"); } } if (o > 0) { parts.push(tens[o]); } if (b > 0) { parts.push(ones[b]); } return parts.join(" "); } // --- GAME INTERACTION --- // On tap/click anywhere, increment or decrement number game.down = function (x, y, obj) { if (!gameStarted) { return; } // Remove 'İleri' and 'Geri' overlays on first tap if (game._ileriText) { game._ileriText.destroy(); game._ileriText = null; } if (game._geriText) { game._geriText.destroy(); game._geriText = null; } LK.getSound('click').play(); // Animate numberText (scale up and back) only if numberText exists if (numberText) { tween(numberText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 80, easing: tween.easeOut, onFinish: function onFinish() { if (numberText) { tween(numberText, { scaleX: 1, scaleY: 1 }, { duration: 80, easing: tween.easeIn }); } } }); } // Animate selected target button (jump effect) on every tap if (selectedTarget !== null && optionButtons[selectedTarget]) { var btn = optionButtons[selectedTarget]; tween.stop(btn, { y: true }); var originalY = btn.y; tween(btn, { y: originalY - 80 }, { duration: 240, easing: tween.cubicOut, onFinish: function onFinish() { tween(btn, { y: originalY }, { duration: 360, easing: tween.bounceOut }); } }); } // Increment if tapped on right half, decrement if tapped on left half if (x > 2048 / 2) { currentNumber += targetNumber; } else { currentNumber -= targetNumber; if (currentNumber < 0) { currentNumber = 0; } } numberText.setText("" + currentNumber); // Update number reading text if (numberReadingText) { // Dynamically fit numberReadingText to always fit on screen after increment/decrement var readingString = L10N[lang].numberReading(currentNumber); var maxWidth = 2048 * 0.9; var maxHeight = 220; var minFontSize = 80; var fontSize = maxHeight; var testText = null; do { if (testText) testText.destroy(); testText = new Text2(readingString, { size: fontSize, fill: 0xFFFFFF }); testText.anchor.set(0.5, 0); } while ((testText.width > maxWidth || testText.height > 300) && fontSize-- > minFontSize); if (testText) testText.destroy(); numberReadingText.setStyle({ size: fontSize }); numberReadingText.setText(readingString); } // Check for win if (currentNumber === randomNumber) { // Show 'Tebrikler!' (Congratulations!) in the center of the screen var congratsText = new Text2(L10N[lang].win, { size: 220, fill: 0x00ff00 }); congratsText.anchor.set(0.5, 0.5); congratsText.x = 2048 / 2; congratsText.y = 2732 / 2; game.addChild(congratsText); // Optionally, fade out after 2 seconds, but do NOT reset game automatically tween(congratsText, { alpha: 0 }, { duration: 1800, delay: 1200, onFinish: function onFinish() { congratsText.destroy(); // Do not call showMenu(); user must press back to return } }); } }; // --- GAME RESET --- // When game is reset, show menu again game.on('reset', function () { // Reset all global variables and UI state countingDirection = 1; startNumber = 0; targetNumber = 10; currentNumber = 0; gameStarted = false; selectedTarget = null; selectedDirection = null; // Reset all selections selectedTarget = null; selectedDirection = null; // Clean up UI elements if any remain if (numberText) { numberText.destroy(); numberText = null; } if (numberReadingText) { numberReadingText.destroy(); numberReadingText = null; } if (infoText) { infoText.destroy(); infoText = null; } for (var i = 0; i < optionButtons.length; i++) { if (optionButtons[i]) { optionButtons[i].destroy(); } } optionButtons = []; for (var i = 0; i < directionButtons.length; i++) { if (directionButtons[i]) { directionButtons[i].destroy(); } } directionButtons = []; showMenu(); }); // --- INITIALIZE --- showMenu(); // Play the start sound only once at the start of the game LK.getSound('startbeep').play(); ; // Play background music (loops by default) LK.playMusic('bgmusic');
===================================================================
--- original.js
+++ change.js
@@ -115,9 +115,10 @@
randomNumberText.y = 2732 - 120; // moved up by 80px
game.addChild(randomNumberText);
// Add 'Sayiyi bul' text just below the random number
var findNumberText = new Text2("Sayıyı bul", {
- size: 80,
+ size: 120,
+ // 150'den küçük, daha büyük görünürlük için 120 seçildi
fill: 0xFFFFFF
});
findNumberText.anchor.set(0.5, 0);
findNumberText.x = 2048 / 2;
@@ -161,17 +162,8 @@
if (typeof backButton !== "undefined" && backButton) {
backButton.destroy();
backButton = null;
}
- // Remove countdown timer if exists
- if (typeof game._timerText !== "undefined" && game._timerText) {
- game._timerText.destroy();
- game._timerText = null;
- }
- if (typeof game._timerInterval !== "undefined" && game._timerInterval) {
- LK.clearInterval(game._timerInterval);
- game._timerInterval = null;
- }
// --- LANGUAGE BUTTONS ---
var langBtnW = 320,
langBtnH = 100,
langBtnGap = 40;
@@ -384,65 +376,8 @@
numberReadingText.x = 2048 / 2;
numberReadingText.y = numberText.y + numberText.height / 2 + 40;
game.addChild(numberReadingText);
gameStarted = true;
- // --- Add countdown timer at the bottom of the screen ---
- if (typeof game._timerText !== "undefined" && game._timerText) {
- game._timerText.destroy();
- game._timerText = null;
- }
- if (typeof game._timerInterval !== "undefined" && game._timerInterval) {
- LK.clearInterval(game._timerInterval);
- game._timerInterval = null;
- }
- var timerValue = 10;
- var timerText = new Text2("" + timerValue, {
- size: 180,
- fill: 0xff0000
- });
- timerText.anchor.set(0.5, 1);
- timerText.x = 2048 / 2;
- timerText.y = 2732 - 40;
- game.addChild(timerText);
- game._timerText = timerText;
- game._timerInterval = LK.setInterval(function () {
- if (!gameStarted) return;
- timerValue--;
- if (timerValue < 0) timerValue = 0;
- if (game._timerText) game._timerText.setText("" + timerValue);
- if (timerValue === 0) {
- // Time's up! End game (showMenu or show a message, then back to menu)
- if (game._timerInterval) {
- LK.clearInterval(game._timerInterval);
- game._timerInterval = null;
- }
- if (game._timerText) {
- game._timerText.destroy();
- game._timerText = null;
- }
- // Show "Süre doldu!" or "Time's up!" in the center
- var timeoutMsg = new Text2(lang === "en" ? "Time's up!" : "Süre doldu!", {
- size: 220,
- fill: 0xff0000
- });
- timeoutMsg.anchor.set(0.5, 0.5);
- timeoutMsg.x = 2048 / 2;
- timeoutMsg.y = 2732 / 2;
- game.addChild(timeoutMsg);
- tween(timeoutMsg, {
- alpha: 0
- }, {
- duration: 1800,
- delay: 1200,
- onFinish: function onFinish() {
- timeoutMsg.destroy();
- // Return to menu
- showMenu();
- }
- });
- gameStarted = false;
- }
- }, 1000);
// --- Add 'İleri' and 'Geri' overlays ---
var ileriLabel = lang === "en" ? "Forward" : "İleri";
var ileriText = new Text2(ileriLabel, {
size: 120,
@@ -503,17 +438,8 @@
if (typeof backButton !== "undefined" && backButton) {
backButton.destroy();
backButton = null;
}
- // Remove countdown timer if exists
- if (typeof game._timerText !== "undefined" && game._timerText) {
- game._timerText.destroy();
- game._timerText = null;
- }
- if (typeof game._timerInterval !== "undefined" && game._timerInterval) {
- LK.clearInterval(game._timerInterval);
- game._timerInterval = null;
- }
showMenu();
});
backButton.children[0].tint = 0xffffff;
game.addChild(backButton);
@@ -681,17 +607,8 @@
numberReadingText.setText(readingString);
}
// Check for win
if (currentNumber === randomNumber) {
- // Stop countdown timer if exists
- if (typeof game._timerInterval !== "undefined" && game._timerInterval) {
- LK.clearInterval(game._timerInterval);
- game._timerInterval = null;
- }
- if (typeof game._timerText !== "undefined" && game._timerText) {
- game._timerText.destroy();
- game._timerText = null;
- }
// Show 'Tebrikler!' (Congratulations!) in the center of the screen
var congratsText = new Text2(L10N[lang].win, {
size: 220,
fill: 0x00ff00
@@ -751,17 +668,8 @@
directionButtons[i].destroy();
}
}
directionButtons = [];
- // Remove countdown timer if exists
- if (typeof game._timerText !== "undefined" && game._timerText) {
- game._timerText.destroy();
- game._timerText = null;
- }
- if (typeof game._timerInterval !== "undefined" && game._timerInterval) {
- LK.clearInterval(game._timerInterval);
- game._timerInterval = null;
- }
showMenu();
});
// --- INITIALIZE ---
showMenu();