User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = validFlatLeaderboard;' Line Number: 426
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = flatLeaderboard;' Line Number: 405
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = finalLeaderboard;' Line Number: 396 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Compilation error[L374]: TypeError: storage.set is not a function hatasını ve Compilation error[L374]: Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed. hatasını çözümle
User prompt
Please fix the bug: 'TypeError: storage.set is not a function' in or related to this line: 'storage.set("leaderboard", safeLeaderboard);' Line Number: 374
User prompt
Compilation error[L334]: Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed. hatasını çözüme kavuştur.
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = safeLeaderboard;' Line Number: 363
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'leaderboard.push({' Line Number: 334 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
oyun başlangıcında oyundan hariç bir usernama ve Ok butonu olan bir inputbox aç. kullanıcı adını yazan oyuncunun skor bilgisini bir dosyada sakla. en yüksekten en aza doğru ilk 5 skoru oyunun sonunda yine harici bir pencerede liste halide numaralandırarak göster. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Compilation error[L378]: ReferenceError: showLeaderboard is not defined hatasını çözümle.
User prompt
Please fix the bug: 'ReferenceError: showLeaderboard is not defined' in or related to this line: 'showLeaderboard();' Line Number: 378
User prompt
kodlardan leaderboard ile ilgili herşeyi kaldır
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlatTop10SafeFinalSafeFinalSafe;' Line Number: 944 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'TypeError: storage.set is not a function' in or related to this line: 'storage.set("leaderboard", leaderboardToStoreLiteralsSafeFlatTop10SafeFinalSafeFinalSafe);' Line Number: 944 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlatTop10SafeFinalSafeFinalSafe;' Line Number: 944
User prompt
Please fix the bug: 'TypeError: storage.set is not a function' in or related to this line: 'storage.set("leaderboard", leaderboardToStoreLiteralsSafeFlatTop10SafeFinalSafeFinalSafe);' Line Number: 944 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
oyun bitince meydana gelen hatayı çöz
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlatTop10SafeFinalSafeFinal;' Line Number: 935 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlatTop10SafeFinalSafe;' Line Number: 926 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlatTop10SafeFinal;' Line Number: 917 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlatTop10Safe;' Line Number: 908 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlatTop10;' Line Number: 899 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlat.length > 10 ? leaderboardToStoreLiteralsSafeFlat.slice(0, 10) : leaderboardToStoreLiteralsSafeFlat;' Line Number: 891
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlat.length > 10 ? leaderboardToStoreLiteralsSafeFlat.slice(0, 10) : leaderboardToStoreLiteralsSafeFlat;' Line Number: 891 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboardToStoreLiteralsSafeFlat.slice(0, 10);' Line Number: 891 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Swatter class var Swatter = Container.expand(function () { var self = Container.call(this); // Swatter types and their point values var swatterTypes = [{ id: 'swatter_red', points: 50 }, { id: 'swatter_yellow', points: 35 }, { id: 'swatter_green', points: 20 }, { id: 'swatter_blue', points: 60 }]; // Randomly select a type var typeIndex = Math.floor(Math.random() * swatterTypes.length); self.type = swatterTypes[typeIndex]; self.points = self.type.points; // Attach asset var swatterAsset = self.attachAsset(self.type.id, { anchorX: 0.5, anchorY: 0.5 }); // Set initial position and speed self.x = 2048 + 120; // Start just off the right edge self.y = 200 + Math.floor(Math.random() * (2732 - 400)); self.speed = (12 + Math.random() * 6) * 0.75; // 25% slower // Allow scaleX to be set after creation for random length self.scaleX = 1; // For collision detection self.update = function () { self.x -= self.speed; }; return self; }); // Yumurta class (formerly Fly) var Yumurta = Container.expand(function () { var self = Container.call(this); var flyAsset = self.attachAsset('fly', { anchorX: 0.5, anchorY: 0.5 }); self.width = flyAsset.width; self.height = flyAsset.height; // Physics self.vy = 0; self.gravity = 1.2; self.lift = -28; // For touch controls self.flap = function () { self.vy = self.lift; }; // Update position self.update = function () { self.vy += self.gravity; self.y += self.vy; // Clamp to screen if (self.y < self.height / 2) { self.y = self.height / 2; self.vy = 0; } if (self.y > 2732 - self.height / 2) { self.y = 2732 - self.height / 2; self.vy = 0; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Initial background: black }); /**** * Game Code ****/ // Backgrounds: always black // Level config // --- Username and Leaderboard Overlay Logic --- // Username input overlay function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var usernameInputOverlay = null; var usernameInput = null; var usernameOkBtn = null; var username = ""; var leaderboardOverlay = null; var leaderboardListTxt = null; // Helper: Show username prompt overlay function showUsernamePrompt(onOk) { // If already exists, do nothing if (usernameInputOverlay && usernameInputOverlay.parent) return; // Overlay container usernameInputOverlay = new Container(); // Semi-transparent background var bg = LK.getAsset('bg_forest', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); bg.alpha = 0.7; usernameInputOverlay.addChild(bg); // Input box (simulate with Text2 and focus logic) var inputBg = LK.getAsset('bg_forest', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 120 }); inputBg.width = 700; inputBg.height = 120; inputBg.alpha = 0.85; usernameInputOverlay.addChild(inputBg); usernameInput = new Text2("", { size: 80, fill: 0x222222 }); usernameInput.anchor.set(0.5, 0.5); usernameInput.x = 2048 / 2; usernameInput.y = 2732 / 2 - 120; usernameInputOverlay.addChild(usernameInput); // Placeholder var placeholderTxt = new Text2("Kullanıcı adınızı girin", { size: 50, fill: 0x888888 }); placeholderTxt.anchor.set(0.5, 0.5); placeholderTxt.x = 2048 / 2; placeholderTxt.y = 2732 / 2 - 120; usernameInputOverlay.addChild(placeholderTxt); // Ok button usernameOkBtn = new Text2("OK", { size: 80, fill: 0xFFFFFF }); usernameOkBtn.anchor.set(0.5, 0.5); usernameOkBtn.x = 2048 / 2; usernameOkBtn.y = 2732 / 2 + 40; usernameOkBtn.bg = LK.getAsset('bg_forest', { anchorX: 0.5, anchorY: 0.5, x: usernameOkBtn.x, y: usernameOkBtn.y }); usernameOkBtn.bg.width = 300; usernameOkBtn.bg.height = 100; usernameOkBtn.bg.alpha = 0.8; usernameInputOverlay.addChild(usernameOkBtn.bg); usernameInputOverlay.addChild(usernameOkBtn); // Add overlay to GUI (so it's always on top) LK.gui.center.addChild(usernameInputOverlay); // Input state var inputValue = ""; var focused = true; // Simulate input: tap to focus, then type (mobile will show keyboard) usernameInputOverlay.down = function (x, y, obj) { // If tap on Ok button var dx = x - usernameOkBtn.x; var dy = y - usernameOkBtn.y; if (Math.abs(dx) < 150 && Math.abs(dy) < 50) { // Only allow if input is not empty if (inputValue.trim().length > 0) { username = inputValue.trim().substring(0, 16); storage.username = username; // Remove overlay if (usernameInputOverlay.parent) usernameInputOverlay.parent.removeChild(usernameInputOverlay); if (typeof onOk === "function") onOk(); } return; } // If tap on input box, focus var dx2 = x - usernameInput.x; var dy2 = y - usernameInput.y; if (Math.abs(dx2) < 350 && Math.abs(dy2) < 60) { focused = true; } }; // Simulate text input (mobile: show keyboard, desktop: type) usernameInputOverlay.key = function (e) { if (!focused) return; var k = e.key; if (k === "Backspace") { inputValue = inputValue.slice(0, -1); } else if (k.length === 1 && inputValue.length < 16) { // Only allow letters, numbers, underscore if (/^[a-zA-Z0-9_ğüşıöçĞÜŞİÖÇ ]$/.test(k)) { inputValue += k; } } usernameInput.setText(inputValue); placeholderTxt.visible = inputValue.length === 0; }; // Autofocus setTimeout(function () { focused = true; }, 100); // Show blinking cursor var cursorVisible = true; var cursorTimer = LK.setInterval(function () { if (!focused) return; cursorVisible = !cursorVisible; usernameInput.setText(inputValue + (cursorVisible ? "|" : "")); }, 500); // Remove overlay cleanup usernameInputOverlay.destroy = function () { LK.clearInterval(cursorTimer); }; // Listen for key events LK.on("key", function (e) { if (usernameInputOverlay && usernameInputOverlay.parent) { usernameInputOverlay.key(e); } }); } // Helper: Show leaderboard overlay function showLeaderboardOverlay() { // Remove if already exists if (leaderboardOverlay && leaderboardOverlay.parent) leaderboardOverlay.parent.removeChild(leaderboardOverlay); leaderboardOverlay = new Container(); // BG var bg = LK.getAsset('bg_forest', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); bg.alpha = 0.7; leaderboardOverlay.addChild(bg); // Title var title = new Text2("En İyi 5 Skor", { size: 90, fill: "#fff" }); title.anchor.set(0.5, 0.5); title.x = 2048 / 2; title.y = 2732 / 2 - 400; leaderboardOverlay.addChild(title); // List leaderboardListTxt = new Text2("", { size: 70, fill: "#fff" }); leaderboardListTxt.anchor.set(0.5, 0); leaderboardListTxt.x = 2048 / 2; leaderboardListTxt.y = 2732 / 2 - 300; leaderboardOverlay.addChild(leaderboardListTxt); // Ok button to close var okBtn = new Text2("Kapat", { size: 80, fill: 0xFFFFFF }); okBtn.anchor.set(0.5, 0.5); okBtn.x = 2048 / 2; okBtn.y = 2732 / 2 + 400; okBtn.bg = LK.getAsset('bg_forest', { anchorX: 0.5, anchorY: 0.5, x: okBtn.x, y: okBtn.y }); okBtn.bg.width = 300; okBtn.bg.height = 100; okBtn.bg.alpha = 0.8; leaderboardOverlay.addChild(okBtn.bg); leaderboardOverlay.addChild(okBtn); leaderboardOverlay.down = function (x, y, obj) { var dx = x - okBtn.x; var dy = y - okBtn.y; if (Math.abs(dx) < 150 && Math.abs(dy) < 50) { if (leaderboardOverlay.parent) leaderboardOverlay.parent.removeChild(leaderboardOverlay); } }; // Get leaderboard from storage var leaderboard = storage.leaderboard || []; // Sort by score descending leaderboard = leaderboard.slice().sort(function (a, b) { return b.score - a.score; }); // Show top 5 var txt = ""; for (var i = 0; i < Math.min(5, leaderboard.length); i++) { var entry = leaderboard[i]; txt += i + 1 + ". " + (entry.username || "-") + " : " + entry.score + "\n"; } leaderboardListTxt.setText(txt); LK.gui.center.addChild(leaderboardOverlay); } // Save score to leaderboard function saveScoreToLeaderboard(username, score) { if (!username || typeof username !== "string") return; var leaderboard = storage.leaderboard || []; // Only keep 1-level deep objects with username and score // Defensive: ensure leaderboard is an array of objects with only username and score as string/number var safeLeaderboard = []; for (var i = 0; i < leaderboard.length; i++) { var entry = leaderboard[i]; if (entry && _typeof(entry) === "object" && typeof entry.username === "string" && typeof entry.score === "number") { safeLeaderboard.push({ username: entry.username, score: entry.score }); } } // Add new score safeLeaderboard.push({ username: username, score: score }); // Sort and keep top 5 safeLeaderboard = safeLeaderboard.slice().sort(function (a, b) { return b.score - a.score; }).slice(0, 5); storage.leaderboard = safeLeaderboard; } var levelCount = 100; var currentLevel = 1; var swatterInterval = 90; // ticks between swatters, stays constant var swatterSpeedBonus = 0; // stays constant // Score var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Level text var levelTxt = new Text2('Seviye 1', { size: 70, fill: 0xFFFFFF }); levelTxt.anchor.set(0.5, 0); LK.gui.top.addChild(levelTxt); levelTxt.y = 120; // Background node var bgNode = LK.getAsset('bg_forest', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); bgNode.tint = 0x000000; game.addChild(bgNode); // Yumurta var fly = null; // Will be created after username is entered // Swatters array var swatters = []; // For touch controls var isTouching = false; // --- Ava: Fly stays in air for 5 seconds, then falls if not touched --- // Instruction message before game starts var instructionTxt = new Text2("Yumurta ilk 5 saniye havada kalır\nOnu düşürmemek için mouse ile tıklayın", { size: 90, fill: 0xffffff, align: "center" }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2; instructionTxt.alpha = 1; // Block game logic until instruction is gone or username entered var gameBlocked = true; // Show username prompt first, then show instruction, then fade out instruction var storedUsername = storage.username; if (typeof storedUsername === "string" && storedUsername.length > 0) { username = storedUsername.substring(0, 16); // Username already set, skip prompt if (!fly) { fly = new Yumurta(); game.addChild(fly); fly.x = 400; fly.y = 2732 / 2; } if (!instructionTxt.parent) game.addChild(instructionTxt); instructionTxt.alpha = 1; instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2; LK.setTimeout(function () { tween(instructionTxt, { alpha: 0 }, { duration: 700, easing: tween.easeOut, onFinish: function onFinish() { if (instructionTxt.parent) instructionTxt.parent.removeChild(instructionTxt); gameBlocked = false; flyStartTime = Date.now(); // Start fly grace period after message } }); }, 2000); } else { showUsernamePrompt(function () { // After username entered, create and show the egg (fly) if (!fly) { fly = new Yumurta(); game.addChild(fly); fly.x = 400; fly.y = 2732 / 2; } // After username entered, show instruction if (!instructionTxt.parent) game.addChild(instructionTxt); instructionTxt.alpha = 1; instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2; LK.setTimeout(function () { tween(instructionTxt, { alpha: 0 }, { duration: 700, easing: tween.easeOut, onFinish: function onFinish() { if (instructionTxt.parent) instructionTxt.parent.removeChild(instructionTxt); gameBlocked = false; flyStartTime = Date.now(); // Start fly grace period after message } }); }, 2000); }); } var flyStartTime = Date.now(); var flyGracePeriod = 5000; // ms var flyActive = false; // becomes true after first touch or after grace period var flyFell = false; // if fly has fallen var swatterRows = 6; // number of swatter rows per spawn var swatterRowYs = []; for (var r = 0; r < swatterRows; r++) { // Evenly space rows, avoid top/bottom 100px var minY = 100 + 60; var maxY = 2732 - 100 - 60; var rowY = minY + r * ((maxY - minY) / (swatterRows - 1)); swatterRowYs.push(rowY); } // For level progression var nextLevelScore = 100; var levelScoreStep = 110; // %10 daha yavaş seviye atlama // Set background for level function setBackgroundForLevel(level) { // Always keep background black, do not change or add any colored backgrounds // Remove old background if any if (bgNode && bgNode.parent) { bgNode.parent.removeChild(bgNode); } // Create a black background node bgNode = LK.getAsset('bg_forest', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); bgNode.tint = 0x000000; game.addChildAt(bgNode, 0); } // Level up function levelUp() { currentLevel++; if (currentLevel > levelCount) { LK.showYouWin(); return; } setBackgroundForLevel(currentLevel); levelTxt.setText('Seviye ' + currentLevel); // Difficulty stays constant except for speed scaling after level 10 swatterInterval = 90; // After level 10, increase swatterSpeedBonus by 1% every 10 levels if (currentLevel > 10) { var speedupSteps = Math.floor((currentLevel - 1) / 10); swatterSpeedBonus = 0 * 0.75 + speedupSteps * 0.01; } else { swatterSpeedBonus = 0 * 0.75; } nextLevelScore += levelScoreStep; // Flash background for level up LK.effects.flashScreen(0xffff00, 600); } // Touch/drag controls game.down = function (x, y, obj) { isTouching = true; if (!flyActive) { flyActive = true; } if (fly && typeof fly.flap === "function") { fly.flap(); } }; game.up = function (x, y, obj) { isTouching = false; }; game.move = function (x, y, obj) { // Optional: allow dragging fly up/down if (isTouching && fly) { fly.y = y; } }; // Main update loop game.update = function () { // --- Ava: Block all game logic until instruction message is gone --- if (gameBlocked) { return; } // --- Ava: Fly grace period and falling logic --- if (!flyActive && !flyFell) { // During grace period, keep fly in air if (Date.now() - flyStartTime < flyGracePeriod) { fly.vy = 0; // Keep fly at initial y fly.y = 2732 / 2; } else { // Grace period over, fly falls unless touched flyActive = true; isTouching = false; } } if (flyActive && !isTouching && !flyFell) { // If not touching after grace, let fly fall fly.update(); if (fly.y >= 2732 - fly.height / 2 - 1) { // Fly hit the ground flyFell = true; LK.effects.flashScreen(0x222222, 800); // Save score to leaderboard saveScoreToLeaderboard(username, LK.getScore()); // Show leaderboard overlay showLeaderboardOverlay(); // Show game over popup (score will be shown by LK engine) LK.showGameOver(); return; } } else if (!flyActive) { // During grace, don't update physics } else if (isTouching && !flyFell) { fly.update(); } else if (!flyFell) { fly.update(); } // --- Ava: Swatters spawn in every row --- if (LK.ticks % swatterInterval === 0) { // --- Ava: Randomize swatter spawn order each wave --- // Create a shuffled copy of swatterRowYs var shuffledRows = []; for (var i = 0; i < swatterRowYs.length; i++) { shuffledRows[i] = swatterRowYs[i]; } // Fisher-Yates shuffle for (var i = shuffledRows.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = shuffledRows[i]; shuffledRows[i] = shuffledRows[j]; shuffledRows[j] = temp; } // --- Ava: For each row, spawn swatter with random delay and random length --- for (var r = 0; r < swatterRows; r++) { (function (rowIdx, rowY) { // Random delay for this row (0-40 ticks, up to ~0.66s) var delayTicks = Math.floor(Math.random() * 40); LK.setTimeout(function () { var swatter = new Swatter(); swatter.speed += swatterSpeedBonus * 0.75; swatter.y = rowY; // Randomize swatter length (scaleX 1.0 to 2.0) var scale = 1 + Math.random(); swatter.scaleX = scale; // Adjust anchor so left edge stays at same place if (swatter.children && swatter.children.length > 0) { // Set anchorX to 0.5 (center) for scaling, already set in Swatter class } swatters.push(swatter); game.addChild(swatter); }, delayTicks * 1000 / 60); // convert ticks to ms })(r, shuffledRows[r]); } } // Update swatters for (var i = swatters.length - 1; i >= 0; i--) { var sw = swatters[i]; sw.update(); // Collision if (fly.intersects(sw)) { LK.effects.flashScreen(0xff0000, 1000); // Save score to leaderboard saveScoreToLeaderboard(username, LK.getScore()); // Show leaderboard overlay showLeaderboardOverlay(); // Show game over popup (score will be shown by LK engine) LK.showGameOver(); return; } // Off screen if (sw.x < -200) { // Award points for successful dodge LK.setScore(LK.getScore() + sw.points); scoreTxt.setText(LK.getScore()); // Level up if needed if (LK.getScore() >= nextLevelScore) { levelUp(); } sw.destroy(); swatters.splice(i, 1); } } }; // Reset game state on restart LK.on('gameStart', function () { // Reset variables currentLevel = 1; swatterInterval = 90; swatterSpeedBonus = 0 * 0.75; // Reset speed scaling on restart nextLevelScore = 100; levelScoreStep = 110; // %10 daha yavaş seviye atlama (reset) setBackgroundForLevel(currentLevel); levelTxt.setText('Seviye 1'); LK.setScore(0); scoreTxt.setText('0'); // Remove all swatters for (var i = 0; i < swatters.length; i++) { swatters[i].destroy(); } swatters = []; // Reset fly if (fly && fly.parent) { fly.parent.removeChild(fly); fly = null; } flyActive = false; flyFell = false; // Do not reset username, so user is not prompted again // username = ""; // Show instruction message again and block game gameBlocked = true; instructionTxt.setText("Yumurta ilk 5 saniye havada kalır\nOnu düşürmemek için mouse ile tıklayın"); instructionTxt.alpha = 1; instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2; // Show username prompt first, then show instruction, then fade out instruction var storedUsername = storage.username; if (typeof storedUsername === "string" && storedUsername.length > 0) { username = storedUsername.substring(0, 16); // Username already set, skip prompt if (!fly) { fly = new Yumurta(); game.addChild(fly); fly.x = 400; fly.y = 2732 / 2; } if (!instructionTxt.parent) game.addChild(instructionTxt); instructionTxt.alpha = 1; instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2; LK.setTimeout(function () { tween(instructionTxt, { alpha: 0 }, { duration: 700, easing: tween.easeOut, onFinish: function onFinish() { if (instructionTxt.parent) instructionTxt.parent.removeChild(instructionTxt); gameBlocked = false; flyStartTime = Date.now(); } }); }, 2000); } else { showUsernamePrompt(function () { // After username entered, create and show the egg (fly) if (!fly) { fly = new Yumurta(); game.addChild(fly); fly.x = 400; fly.y = 2732 / 2; } if (!instructionTxt.parent) game.addChild(instructionTxt); instructionTxt.alpha = 1; instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2; LK.setTimeout(function () { tween(instructionTxt, { alpha: 0 }, { duration: 700, easing: tween.easeOut, onFinish: function onFinish() { if (instructionTxt.parent) instructionTxt.parent.removeChild(instructionTxt); gameBlocked = false; flyStartTime = Date.now(); } }); }, 2000); }); } }); /* End of MVP */
===================================================================
--- original.js
+++ change.js
@@ -92,8 +92,16 @@
// Backgrounds: always black
// Level config
// --- Username and Leaderboard Overlay Logic ---
// Username input overlay
+function _typeof(o) {
+ "@babel/helpers - typeof";
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
+ return typeof o;
+ } : function (o) {
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
+ }, _typeof(o);
+}
var usernameInputOverlay = null;
var usernameInput = null;
var usernameOkBtn = null;
var username = "";
@@ -303,17 +311,29 @@
function saveScoreToLeaderboard(username, score) {
if (!username || typeof username !== "string") return;
var leaderboard = storage.leaderboard || [];
// Only keep 1-level deep objects with username and score
- leaderboard.push({
+ // Defensive: ensure leaderboard is an array of objects with only username and score as string/number
+ var safeLeaderboard = [];
+ for (var i = 0; i < leaderboard.length; i++) {
+ var entry = leaderboard[i];
+ if (entry && _typeof(entry) === "object" && typeof entry.username === "string" && typeof entry.score === "number") {
+ safeLeaderboard.push({
+ username: entry.username,
+ score: entry.score
+ });
+ }
+ }
+ // Add new score
+ safeLeaderboard.push({
username: username,
score: score
});
// Sort and keep top 5
- leaderboard = leaderboard.slice().sort(function (a, b) {
+ safeLeaderboard = safeLeaderboard.slice().sort(function (a, b) {
return b.score - a.score;
}).slice(0, 5);
- storage.leaderboard = leaderboard;
+ storage.leaderboard = safeLeaderboard;
}
var levelCount = 100;
var currentLevel = 1;
var swatterInterval = 90; // ticks between swatters, stays constant