User prompt
her ekranda her satırın %40'ı engelle dolu olarak gelsin
User prompt
engeller %15 daha sık gelsin
User prompt
engellerin uzunluklarını düzeltiyorum; 1x, 2x, 3x ve4x boyutlarında gelsin. oyun hızı %5 artsın
User prompt
engellerin uzunlukları 2x ve 3x olarak değişerek gelsin.
User prompt
engeller her satırdan rastgele ve bölüm geçtikçe hızları %1 artsın
User prompt
geçilen her engel 1 puan kazandırsın, geçilen her seviyeye göre kazanılan puanlar 2 kat artırılsın
User prompt
geçilen her 10 engelde 1 seviye atlansın
User prompt
engeller her satırdan farklı renklerdeki kutucuklarla farklı hızlarla gelsin
User prompt
mouse ile kendine doğru gelen engeller arasında zıplayan yumurta oyunu yap
User prompt
Please fix the bug: 'storage is not defined' in or related to this line: 'var storedUsername = storage.username;' Line Number: 648 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
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 = safeReallyTrulyOneLevelLeaderboard;' Line Number: 586 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Timeout.tick error: tween is not defined' in or related to this line: 'tween(instructionTxt, {' Line Number: 652 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'storage is not defined' in or related to this line: 'var storedUsername = storage.username;' Line Number: 628 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'storage is not defined' in or related to this line: 'var storedUsername = storage.username;' Line Number: 628 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
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 = reallyTrulyOneLevelLeaderboard;' Line Number: 570 ↪💡 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 = trulyOneLevelLeaderboard;' Line Number: 550
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 = oneLevelLeaderboard;' Line Number: 530 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
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 = reallySafeLeaderboard;' Line Number: 510 ↪💡 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 = safeFinalLeaderboard;' Line Number: 489 ↪💡 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 = finalFlatLeaderboard;' Line Number: 468 ↪💡 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 = trulyFlatLeaderboard;' Line Number: 447
/**** * 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 ****/ // Username input overlay // --- Username and Leaderboard Overlay Logic --- // Level config // Backgrounds: always black function _typeof11(o) { "@babel/helpers - typeof"; return _typeof11 = "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; }, _typeof11(o); } function _typeof10(o) { "@babel/helpers - typeof"; return _typeof10 = "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; }, _typeof10(o); } function _typeof1(o) { "@babel/helpers - typeof"; return _typeof1 = "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; }, _typeof1(o); } function _typeof0(o) { "@babel/helpers - typeof"; return _typeof0 = "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; }, _typeof0(o); } function _typeof9(o) { "@babel/helpers - typeof"; return _typeof9 = "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; }, _typeof9(o); } function _typeof8(o) { "@babel/helpers - typeof"; return _typeof8 = "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; }, _typeof8(o); } function _typeof7(o) { "@babel/helpers - typeof"; return _typeof7 = "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; }, _typeof7(o); } function _typeof6(o) { "@babel/helpers - typeof"; return _typeof6 = "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; }, _typeof6(o); } function _typeof5(o) { "@babel/helpers - typeof"; return _typeof5 = "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; }, _typeof5(o); } function _typeof4(o) { "@babel/helpers - typeof"; return _typeof4 = "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; }, _typeof4(o); } function _typeof3(o) { "@babel/helpers - typeof"; return _typeof3 = "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; }, _typeof3(o); } function _typeof2(o) { "@babel/helpers - typeof"; return _typeof2 = "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; }, _typeof2(o); } 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 && _typeof2(entry) === "object" && typeof entry.username === "string" && typeof entry.score === "number") { // Only keep username and score as top-level properties 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); // Store leaderboard as a property (must be 1-level deep array of objects with only literals) // Defensive: ensure all entries are 1-level deep and only have string/number properties var finalLeaderboard = []; for (var i = 0; i < safeLeaderboard.length; i++) { var entry = safeLeaderboard[i]; // Only keep username and score, both must be string/number if (entry && _typeof3(entry) === "object" && typeof entry.username === "string" && typeof entry.score === "number") { finalLeaderboard.push({ username: entry.username, score: entry.score }); } } // Assign to storage (this is allowed as it's a 1-level deep array of objects with only literals) // Defensive: flatten any nested objects/arrays (should not exist, but just in case) var flatLeaderboard = []; for (var i = 0; i < finalLeaderboard.length; i++) { var entry = finalLeaderboard[i]; flatLeaderboard.push({ username: typeof entry.username === "string" ? entry.username : "", score: typeof entry.score === "number" ? entry.score : 0 }); } // Defensive: Only store if all entries are 1-level deep and only have string/number properties var validFlatLeaderboard = []; for (var i = 0; i < flatLeaderboard.length; i++) { var entry = flatLeaderboard[i]; if (entry && _typeof4(entry) === "object" && typeof entry.username === "string" && typeof entry.score === "number") { validFlatLeaderboard.push({ username: entry.username, score: entry.score }); } } // Store only if valid // Defensive: Only store if validFlatLeaderboard is an array of 1-level deep objects with only string/number properties var trulyFlatLeaderboard = []; for (var i = 0; i < validFlatLeaderboard.length; i++) { var entry = validFlatLeaderboard[i]; if (entry && _typeof5(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { trulyFlatLeaderboard.push({ username: entry.username, score: entry.score }); } } // Store only if all entries are valid // Defensive: Only store if trulyFlatLeaderboard is an array of 1-level deep objects with only string/number properties var finalFlatLeaderboard = []; for (var i = 0; i < trulyFlatLeaderboard.length; i++) { var entry = trulyFlatLeaderboard[i]; if (entry && _typeof6(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { finalFlatLeaderboard.push({ username: entry.username, score: entry.score }); } } // Only assign if all entries are valid and the array is 1-level deep // Defensive: Only store if finalFlatLeaderboard is an array of 1-level deep objects with only string/number properties var safeFinalLeaderboard = []; for (var i = 0; i < finalFlatLeaderboard.length; i++) { var entry = finalFlatLeaderboard[i]; if (entry && _typeof7(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { safeFinalLeaderboard.push({ username: entry.username, score: entry.score }); } } // Only assign if all entries are valid and the array is 1-level deep // Defensive: Only assign if all entries are valid and the array is 1-level deep var reallySafeLeaderboard = []; for (var i = 0; i < safeFinalLeaderboard.length; i++) { var entry = safeFinalLeaderboard[i]; if (entry && _typeof8(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { reallySafeLeaderboard.push({ username: entry.username, score: entry.score }); } } // Only assign if all entries are valid and the array is 1-level deep // Only assign if all entries are valid and the array is 1-level deep var oneLevelLeaderboard = []; for (var i = 0; i < reallySafeLeaderboard.length; i++) { var entry = reallySafeLeaderboard[i]; if (entry && _typeof9(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { oneLevelLeaderboard.push({ username: entry.username, score: entry.score }); } } // Defensive: Only assign if all entries are valid and the array is 1-level deep var trulyOneLevelLeaderboard = []; for (var i = 0; i < oneLevelLeaderboard.length; i++) { var entry = oneLevelLeaderboard[i]; if (entry && _typeof0(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { trulyOneLevelLeaderboard.push({ username: entry.username, score: entry.score }); } } // Defensive: Only assign if all entries are valid and the array is 1-level deep var reallyTrulyOneLevelLeaderboard = []; for (var i = 0; i < trulyOneLevelLeaderboard.length; i++) { var entry = trulyOneLevelLeaderboard[i]; if (entry && _typeof1(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { reallyTrulyOneLevelLeaderboard.push({ username: entry.username, score: entry.score }); } } // Defensive: Only assign if all entries are valid and the array is 1-level deep var safeReallyTrulyOneLevelLeaderboard = []; for (var i = 0; i < reallyTrulyOneLevelLeaderboard.length; i++) { var entry = reallyTrulyOneLevelLeaderboard[i]; if (entry && _typeof10(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { safeReallyTrulyOneLevelLeaderboard.push({ username: entry.username, score: entry.score }); } } // Defensive: Only assign if all entries are valid and the array is 1-level deep var storageReadyLeaderboard = []; for (var i = 0; i < safeReallyTrulyOneLevelLeaderboard.length; i++) { var entry = safeReallyTrulyOneLevelLeaderboard[i]; if (entry && _typeof11(entry) === "object" && !Array.isArray(entry) && Object.keys(entry).length === 2 && typeof entry.username === "string" && typeof entry.score === "number") { storageReadyLeaderboard.push({ username: entry.username, score: entry.score }); } } storage.leaderboard = storageReadyLeaderboard; } 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
@@ -1,11 +1,5 @@
/****
-* Plugins
-****/
-var storage = LK.import("@upit/storage.v1");
-var tween = LK.import("@upit/tween.v1");
-
-/****
* Classes
****/
// Swatter class
var Swatter = Container.expand(function () {
@@ -88,12 +82,12 @@
/****
* Game Code
****/
-// Backgrounds: always black
-// Level config
-// --- Username and Leaderboard Overlay Logic ---
// Username input overlay
+// --- Username and Leaderboard Overlay Logic ---
+// Level config
+// Backgrounds: always black
function _typeof11(o) {
"@babel/helpers - typeof";
return _typeof11 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;