User prompt
kullanıcı adını giremiyorum?, etrafı yuvarlak hatlı dikdörtgen (orta boy) beyaz bir text kutusu (kullanıcı adı girmek için) oluştur
User prompt
oyun başlamadan ekranda kullanıcı adını girmek için kutucuk oluştur. oyuncu kaydolduktan sonra oyun direktifi yazısını gösterirsin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
oyun başlamadan önce kullanıcı adı sor, kullanıcı adı girilince oyun sonunda skor tablosu gösterilsin, skor tablosu her zaman en yüksek skoru yapan oyuncuları kaydetsin ve listelersin.
User prompt
havada tutmak yerine düşürmemek için yaz
User prompt
Sinek kelimesi yerine Yumurta yaz
User prompt
Please fix the bug: 'TypeError: LK.setGameOverMessage is not a function' in or related to this line: 'LK.setGameOverMessage("Seviye: " + currentLevel + "\nSkor: " + LK.getScore());' Line Number: 325
User prompt
oyun bitince hem seviyeyi hem de kazanılan puanı göster
User prompt
Please fix the bug: 'TypeError: LK.setGameOverMessage is not a function' in or related to this line: 'LK.setGameOverMessage("Skorun: " + LK.getScore());' Line Number: 325
User prompt
Please fix the bug: 'TypeError: LK.setGameOverText is not a function' in or related to this line: 'LK.setGameOverText("Skorun: " + LK.getScore());' Line Number: 325
User prompt
oyun bittiğinde ekrana kullanıcının aldığı skoru yaz
User prompt
sineği gerçek sinek silüetinde beyaz renk yap, arkaplan rengi sabit siyah olsun.
User prompt
seviye atlama hızını %10 azalt.
User prompt
10. Seviyeden sonra sinekliklerin hızı her 10 bölümde %1 artsın.
User prompt
sinekliklerin gelme hızını %25 azalt
User prompt
gelen sinekliklerin uzunlukları da rastgele değişsin, örneğin normal sinekliğin 2 katı uzunluğunda da sineklik gelsin. sinekliklerin gelme zamanlamaları her satır için rastgele değişsin. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
sineklikler hep aynı düzende geliyor, geliş düzenlerini rastgele yap.
User prompt
oyun başlamadan gösterdiğin mesajı bölerek 2 satırda göster
User prompt
oyun başlamadan önce şunu ekrana yaz "Sinek ilk 5 saniye havada kalır, onu havada tutmak için mouse ile tıklayın" bu mesaj 2 saniye gözüksin ve solarak kaybolsun, sonra oyun başlasın. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
oyunun arkaplan rengi siyah renk yap, değişen renkler olmasın.
User prompt
oyunun arkaplanı siyah olsun
User prompt
arkaplan siyah olsun
User prompt
oyunda 100 seviye olsun, zorluk derecesi artmasın, bu zorluk edrecesi iyi. gerçek sinek silüeti kullan, gerçek sineklik silüeti kullan.
User prompt
oyun başlayınca 5 saniye boyunca sinek havada kalsın, daha sonra kullanıcı mouse ile tıklamazsa sinek yere düşsün ve oyun sona ersin. sineğin kalçtığı renkli aparatlar daha fazla ve her satırda gelsin,
Code edit (1 edits merged)
Please save this source code
User prompt
Sinek Kaçışı: Renkli Tuzaklardan Kurtul!
/**** * 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 ****/ // Username and leaderboard // --- Ava: High Score Table & Username Prompt --- // Use storage plugin for persistent data var username = ""; var leaderboard = []; // [{name, score}] // Helper to load leaderboard from storage function loadLeaderboard() { var data = storage.get('leaderboard'); if (data && Array.isArray(data)) { leaderboard = data; } else { leaderboard = []; } } // Helper to save leaderboard to storage function saveLeaderboard() { storage.set('leaderboard', leaderboard); } // Helper to show username prompt before game starts function showUsernamePrompt(onDone) { // Remove any old prompt if (typeof usernamePromptTxt !== "undefined" && usernamePromptTxt.parent) { usernamePromptTxt.parent.removeChild(usernamePromptTxt); } if (typeof usernameInput !== "undefined" && usernameInput.parent) { usernameInput.parent.removeChild(usernameInput); } if (typeof usernameInputBg !== "undefined" && usernameInputBg.parent) { usernameInputBg.parent.removeChild(usernameInputBg); } // Show prompt text usernamePromptTxt = new Text2("Kullanıcı adını gir:", { size: 90, fill: 0xffffff, align: "center" }); usernamePromptTxt.anchor.set(0.5, 0.5); usernamePromptTxt.x = 2048 / 2; usernamePromptTxt.y = 2732 / 2 - 120; game.addChild(usernamePromptTxt); // Create a rounded, medium-sized white rectangle as background for input var usernameInputBg = LK.getAsset('bg_forest', { width: 600, height: 140, color: 0xffffff, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 40 }); usernameInputBg.alpha = 1; usernameInputBg.radius = 60; // visually hint: rounded corners (if supported) game.addChild(usernameInputBg); // Username input text (on top of bg) usernameInput = new Text2("_", { size: 90, fill: 0x222222, align: "center" }); usernameInput.anchor.set(0.5, 0.5); usernameInput.x = 2048 / 2; usernameInput.y = 2732 / 2 + 40; usernameInput.textValue = ""; game.addChild(usernameInput); // Show instructions var usernameHint = new Text2("Adını yazmak için ekrana dokun\nveya klavyeni kullan", { size: 60, fill: 0xcccccc, align: "center" }); usernameHint.anchor.set(0.5, 0.5); usernameHint.x = 2048 / 2; usernameHint.y = 2732 / 2 + 180; game.addChild(usernameHint); // Listen for input (simulate with prompt for desktop, or use browser prompt fallback) var inputActive = true; function finishInput() { if (usernameInput.textValue.length > 0) { username = usernameInput.textValue; if (usernamePromptTxt.parent) usernamePromptTxt.parent.removeChild(usernamePromptTxt); if (usernameInput.parent) usernameInput.parent.removeChild(usernameInput); if (typeof usernameInputBg !== "undefined" && usernameInputBg.parent) usernameInputBg.parent.removeChild(usernameInputBg); if (usernameHint.parent) usernameHint.parent.removeChild(usernameHint); inputActive = false; if (onDone) onDone(); } } // Touch to open prompt (mobile) usernameInput.interactive = true; usernameInput.down = function (x, y, obj) { if (!inputActive) return; // Use browser prompt for input var val = ""; try { val = window.prompt("Kullanıcı adını gir:", usernameInput.textValue); } catch (e) { val = ""; } if (typeof val === "string" && val.length > 0) { usernameInput.textValue = val.substring(0, 16); usernameInput.setText(usernameInput.textValue); finishInput(); } }; // Keyboard input (desktop) LK.on('keydown', function (e) { if (!inputActive) return; var key = e && e.key; if (!key) return; if (key === "Enter") { finishInput(); return; } if (key === "Backspace") { usernameInput.textValue = usernameInput.textValue.slice(0, -1); } else if (key.length === 1 && usernameInput.textValue.length < 16) { usernameInput.textValue += key; } usernameInput.setText(usernameInput.textValue.length > 0 ? usernameInput.textValue : "_"); }); } // Helper to show leaderboard after game over function showLeaderboard() { loadLeaderboard(); // Add current score if not already in var score = LK.getScore(); if (username && score > 0) { leaderboard.push({ name: username, score: score }); // Sort descending leaderboard.sort(function (a, b) { return b.score - a.score; }); // Keep top 10 leaderboard = leaderboard.slice(0, 10); saveLeaderboard(); } // Remove old leaderboard if any if (typeof leaderboardTxt !== "undefined" && leaderboardTxt.parent) { leaderboardTxt.parent.removeChild(leaderboardTxt); } // Build leaderboard text var text = "En Yüksek Skorlar\n"; for (var i = 0; i < leaderboard.length; i++) { var entry = leaderboard[i]; text += i + 1 + ". " + entry.name + " - " + entry.score + "\n"; } leaderboardTxt = new Text2(text, { size: 70, fill: 0xffffff, align: "center" }); leaderboardTxt.anchor.set(0.5, 0.5); leaderboardTxt.x = 2048 / 2; leaderboardTxt.y = 2732 / 2; game.addChild(leaderboardTxt); // Remove after 4 seconds LK.setTimeout(function () { if (leaderboardTxt.parent) leaderboardTxt.parent.removeChild(leaderboardTxt); }, 4000); } // --- Ava: End High Score Table & Username Prompt --- // Level config // Backgrounds: always black 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 = new Yumurta(); game.addChild(fly); fly.x = 400; fly.y = 2732 / 2; // 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 showUsernamePrompt(function () { // 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; } 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.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); // Show game over popup (score will be shown by LK engine) // Oyun bittiğinde seviye ve skor gösterimi LK.showGameOver ile yapılır LK.showGameOver(); showLeaderboard(); 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); // Show game over popup (score will be shown by LK engine) // Oyun bittiğinde seviye ve skor gösterimi LK.showGameOver ile yapılır LK.showGameOver(); showLeaderboard(); 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 fly.x = 400; fly.y = 2732 / 2; fly.vy = 0; flyActive = false; flyFell = false; // Reset username and leaderboard prompt 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 showUsernamePrompt(function () { 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
@@ -115,8 +115,11 @@
}
if (typeof usernameInput !== "undefined" && usernameInput.parent) {
usernameInput.parent.removeChild(usernameInput);
}
+ if (typeof usernameInputBg !== "undefined" && usernameInputBg.parent) {
+ usernameInputBg.parent.removeChild(usernameInputBg);
+ }
// Show prompt text
usernamePromptTxt = new Text2("Kullanıcı adını gir:", {
size: 90,
fill: 0xffffff,
@@ -125,12 +128,26 @@
usernamePromptTxt.anchor.set(0.5, 0.5);
usernamePromptTxt.x = 2048 / 2;
usernamePromptTxt.y = 2732 / 2 - 120;
game.addChild(usernamePromptTxt);
- // Create a simple input using LK.gui (simulate with Text2 and touch)
+ // Create a rounded, medium-sized white rectangle as background for input
+ var usernameInputBg = LK.getAsset('bg_forest', {
+ width: 600,
+ height: 140,
+ color: 0xffffff,
+ shape: 'box',
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2 + 40
+ });
+ usernameInputBg.alpha = 1;
+ usernameInputBg.radius = 60; // visually hint: rounded corners (if supported)
+ game.addChild(usernameInputBg);
+ // Username input text (on top of bg)
usernameInput = new Text2("_", {
size: 90,
- fill: 0xffff00,
+ fill: 0x222222,
align: "center"
});
usernameInput.anchor.set(0.5, 0.5);
usernameInput.x = 2048 / 2;
@@ -153,8 +170,9 @@
if (usernameInput.textValue.length > 0) {
username = usernameInput.textValue;
if (usernamePromptTxt.parent) usernamePromptTxt.parent.removeChild(usernamePromptTxt);
if (usernameInput.parent) usernameInput.parent.removeChild(usernameInput);
+ if (typeof usernameInputBg !== "undefined" && usernameInputBg.parent) usernameInputBg.parent.removeChild(usernameInputBg);
if (usernameHint.parent) usernameHint.parent.removeChild(usernameHint);
inputActive = false;
if (onDone) onDone();
}