User prompt
header kısmını aşağıya kaydır
User prompt
sayıları ekranın ortasına ortala
User prompt
aşağıya doğru uzat
User prompt
kare şeklinde olsun
User prompt
oraya header koy
User prompt
yazıyı kaldır
User prompt
Bir hedef sayı seçin kısmını kaldır
User prompt
Hedef bir sayı seçin Kısmına title dikdörgeni koy
User prompt
1 sayısınıda ekle
User prompt
artarak azalarak kısmını sayılardan alt kısma koy
User prompt
sol tarafa tıklayınca sayı kendisi kadar azalsın
User prompt
sağ taraf ve sol taraf tıklanabilir olsun
User prompt
sayı seçildikten sonra ilk başta sayının kendisi gözüksün ekranda
User prompt
çizgiyi görünmez yap
User prompt
null yazmasın
User prompt
sayı seçildikten sonra ekranı sağ ve sol olarak tam ortadan 2 eş parçaya böl
User prompt
artarak ve azalarak yerine sayılar seçildikten sonra ekranı 2 eş parçaya böl sağa tıklayınca sayı artsın sola tıklayınca sayı azalsın
User prompt
5x5 şeklinde gözüksün ekranda
User prompt
2 den 25 e kadar yap baştaki sayıları
User prompt
game over kısmını kaldır onun yerine baştan başlat
User prompt
10x olunca gameover popupunin üstünde gerçeklesen confetiler çıksın
User prompt
10x olunca you win yazmasın tekrar başa dönsün
User prompt
game over popupini sil
User prompt
game over yazısı çıkmasın
User prompt
renklendir confetileri
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xffffff // White background for clarity }); /**** * Game Code ****/ // --- GLOBALS --- var countingDirection = 1; // 1: up, -1: down var startNumber = 0; var targetNumber = 10; var currentNumber = 0; var gameStarted = false; // UI elements var numberText = null; var infoText = null; var optionButtons = []; var directionButtons = []; var selectedTarget = null; var selectedDirection = null; var dividerLine = null; // --- 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 --- // Show the pre-game menu: select target number and direction function showMenu() { gameStarted = false; // Remove previous UI if any if (numberText) { numberText.destroy(); numberText = null; } if (typeof dividerLine !== "undefined" && dividerLine) { dividerLine.destroy(); dividerLine = null; } // Remove tap zones if present updateTapZones(false); 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 = []; // Info text infoText = new Text2("Bir hedef sayı seçin", { size: 90, fill: 0x222222 }); infoText.anchor.set(0.5, 0); infoText.x = 2048 / 2; infoText.y = 250; game.addChild(infoText); // Target number options (2-25) as a 5x5 grid var targets = []; for (var i = 2; i <= 25; i++) { targets.push(i); } var btnW = 200, btnH = 180; var gapX = 40; var gapY = 40; var gridCols = 5; var gridRows = 5; var gridStartX = (2048 - (gridCols * btnW + (gridCols - 1) * gapX)) / 2 + btnW / 2; var gridStartY = 500; // Start a bit lower to leave space for infoText 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); }); optionButtons.push(btn); game.addChild(btn); })(i); } // No direction selection UI needed anymore } // When a target number is selected function selectTarget(t, idx) { targetNumber = t; selectedTarget = idx; // Highlight selected for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].children[0].tint = i === idx ? 0xffc107 : 0xffffff; } // Start game immediately after selecting target startGame(); } // When a direction is selected function selectDirection(dir, idx) { // No longer used } // --- GAMEPLAY --- function startGame() { // Remove menu UI if (infoText) { infoText.destroy(); infoText = null; } for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].destroy(); } optionButtons = []; // No direction buttons to clean up directionButtons = []; // Wait for first tap to determine direction and start number startNumber = null; currentNumber = null; countingDirection = null; // Show current number (show targetNumber immediately after selection) numberText = new Text2("" + targetNumber, { size: 350, fill: 0x222222 }); numberText.anchor.set(0.5, 0.5); numberText.x = 2048 / 2; numberText.y = 2732 / 2; game.addChild(numberText); // Draw a vertical line dividing the screen into two equal parts if (typeof dividerLine !== "undefined" && dividerLine) { dividerLine.destroy(); dividerLine = null; } // Divider line is now invisible (not added to game) dividerLine = null; gameStarted = true; updateTapZones(true); } // --- GAME INTERACTION --- // Create invisible left and right tap zones for the two halves of the screen var leftZone = null; var rightZone = null; // Helper to create or destroy tap zones function updateTapZones(enable) { // Remove old zones if any if (leftZone) { leftZone.destroy(); leftZone = null; } if (rightZone) { rightZone.destroy(); rightZone = null; } if (!enable) return; // Left zone (0,0) to (1024,2732) leftZone = new Container(); var leftBox = leftZone.attachAsset('centerCircle', { width: 1024, height: 2732, color: 0xffffff, alpha: 0, // invisible anchorX: 0, anchorY: 0 }); leftZone.x = 0; leftZone.y = 0; leftZone.interactive = true; leftZone.down = function (x, y, obj) { handleTapZone('left', x, y, obj); }; game.addChild(leftZone); // Right zone (1024,0) to (2048,2732) rightZone = new Container(); var rightBox = rightZone.attachAsset('centerCircle', { width: 1024, height: 2732, color: 0xffffff, alpha: 0, // invisible anchorX: 0, anchorY: 0 }); rightZone.x = 1024; rightZone.y = 0; rightZone.interactive = true; rightZone.down = function (x, y, obj) { handleTapZone('right', x, y, obj); }; game.addChild(rightZone); } // Handle tap on left or right zone function handleTapZone(side, x, y, obj) { if (!gameStarted) return; // If startNumber is not set, this is the first tap: determine direction and set startNumber/currentNumber if (startNumber === null) { if (side === 'right') { // Right side: increase countingDirection = 1; startNumber = targetNumber; } else { // Left side: decrease countingDirection = -1; startNumber = targetNumber * 10; } currentNumber = startNumber; numberText.setText("" + currentNumber); // Animate numberText (scale up and back) tween(numberText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 80, easing: tween.easeOut, onFinish: function onFinish() { tween(numberText, { scaleX: 1, scaleY: 1 }, { duration: 80, easing: tween.easeIn }); } }); return; } // Animate numberText (scale up and back) tween(numberText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 80, easing: tween.easeOut, onFinish: function onFinish() { tween(numberText, { scaleX: 1, scaleY: 1 }, { duration: 80, easing: tween.easeIn }); } }); // Update number based on tap side if (side === 'right') { // Right side: increase if (countingDirection !== 1) return; // Only allow correct direction currentNumber += targetNumber; } else { // Left side: decrease if (countingDirection !== -1) return; // Only allow correct direction currentNumber -= targetNumber; } numberText.setText("" + currentNumber); // Check for win if (countingDirection === 1 && currentNumber >= targetNumber * 10 || countingDirection === -1 && currentNumber <= 0) { // Disable further input gameStarted = false; // Remove tap zones updateTapZones(false); // Wait 1.3 seconds before restarting the game (showMenu) LK.setTimeout(function () { showMenu(); }, 1300); } } // Remove default game.down handler (all tap logic is now in tap zones) game.down = function (x, y, obj) {}; // Update tap zones when game starts or ends // Add to startGame and showMenu // --- GAME RESET --- // When game is reset, show menu again game.on('reset', function () { showMenu(); }); // --- INITIALIZE --- showMenu();
===================================================================
--- original.js
+++ change.js
@@ -66,8 +66,10 @@
if (typeof dividerLine !== "undefined" && dividerLine) {
dividerLine.destroy();
dividerLine = null;
}
+ // Remove tap zones if present
+ updateTapZones(false);
if (infoText) {
infoText.destroy();
infoText = null;
}
@@ -165,16 +167,69 @@
}
// Divider line is now invisible (not added to game)
dividerLine = null;
gameStarted = true;
+ updateTapZones(true);
}
// --- GAME INTERACTION ---
-// On tap/click anywhere, increment or decrement number
-game.down = function (x, y, obj) {
+// Create invisible left and right tap zones for the two halves of the screen
+var leftZone = null;
+var rightZone = null;
+// Helper to create or destroy tap zones
+function updateTapZones(enable) {
+ // Remove old zones if any
+ if (leftZone) {
+ leftZone.destroy();
+ leftZone = null;
+ }
+ if (rightZone) {
+ rightZone.destroy();
+ rightZone = null;
+ }
+ if (!enable) return;
+ // Left zone (0,0) to (1024,2732)
+ leftZone = new Container();
+ var leftBox = leftZone.attachAsset('centerCircle', {
+ width: 1024,
+ height: 2732,
+ color: 0xffffff,
+ alpha: 0,
+ // invisible
+ anchorX: 0,
+ anchorY: 0
+ });
+ leftZone.x = 0;
+ leftZone.y = 0;
+ leftZone.interactive = true;
+ leftZone.down = function (x, y, obj) {
+ handleTapZone('left', x, y, obj);
+ };
+ game.addChild(leftZone);
+ // Right zone (1024,0) to (2048,2732)
+ rightZone = new Container();
+ var rightBox = rightZone.attachAsset('centerCircle', {
+ width: 1024,
+ height: 2732,
+ color: 0xffffff,
+ alpha: 0,
+ // invisible
+ anchorX: 0,
+ anchorY: 0
+ });
+ rightZone.x = 1024;
+ rightZone.y = 0;
+ rightZone.interactive = true;
+ rightZone.down = function (x, y, obj) {
+ handleTapZone('right', x, y, obj);
+ };
+ game.addChild(rightZone);
+}
+// Handle tap on left or right zone
+function handleTapZone(side, x, y, obj) {
if (!gameStarted) return;
// If startNumber is not set, this is the first tap: determine direction and set startNumber/currentNumber
if (startNumber === null) {
- if (x > 2048 / 2) {
+ if (side === 'right') {
// Right side: increase
countingDirection = 1;
startNumber = targetNumber;
} else {
@@ -220,9 +275,9 @@
});
}
});
// Update number based on tap side
- if (x > 2048 / 2) {
+ if (side === 'right') {
// Right side: increase
if (countingDirection !== 1) return; // Only allow correct direction
currentNumber += targetNumber;
} else {
@@ -234,14 +289,20 @@
// Check for win
if (countingDirection === 1 && currentNumber >= targetNumber * 10 || countingDirection === -1 && currentNumber <= 0) {
// Disable further input
gameStarted = false;
+ // Remove tap zones
+ updateTapZones(false);
// Wait 1.3 seconds before restarting the game (showMenu)
LK.setTimeout(function () {
showMenu();
}, 1300);
}
-};
+}
+// Remove default game.down handler (all tap logic is now in tap zones)
+game.down = function (x, y, obj) {};
+// Update tap zones when game starts or ends
+// Add to startGame and showMenu
// --- GAME RESET ---
// When game is reset, show menu again
game.on('reset', function () {
showMenu();