Code edit (1 edits merged)
Please save this source code
User prompt
Tıkladığımızda anında 99 kurabiye veren butonu kaldır
User prompt
Tıkladığımız anında 29 kurabiye veren buton artık anında 99 kurabiye versin
Code edit (1 edits merged)
Please save this source code
User prompt
Eyer kullanıcı 100 kurabiye toplarsa Usta yerine "Kral" Yazsın
User prompt
sol üst tarafa bir buton ekle eyer oraya tıklarsak anında 29 kurabiye kazanalım
User prompt
Eyer kullanıcı 30 kurabiye toplarsa Oyuncu yerine "Usta" Yazsın
User prompt
Eyer kullanıcı 10 kurabiye toplarsa orta üst tarafta "Oyuncu" Yazsın.
User prompt
Ünlem işaretine tıkladığımızda açılan menü yuvarlak ve mavi renginden olsun
User prompt
Ünlem işareti birazcık daha büyük olsun
User prompt
Ünlem işareti sol alt tarafta olsun
User prompt
Uyarı işareti biraz daha yukarıda ve soru işareti gibi biraz solda olsun
User prompt
O soru işaretli simgenin üzerine ise ünlem işaretli bir simge koy. Kullanıcı tıkladığında onu uyarı metni karşılasın. Metin şu: "Eyer aynı anda bir çok kez tıklarsanız oyun algılayamaz, sadece ilk tıkladığınızı anlar"
User prompt
Oyunu bilmeyenler için sağ alt tarafa bir soru işareti butonu koy. Eyer oyuncu tıklarsa bir menü açılsın ve ona oyunu tanıtan bir metin çıksın. Metin bu: "Oyunda bu üç şekle tıklayarak her üç saniyede bir kurabiye üretebilirsiniz ve böyle oyun devam eder."
Code edit (1 edits merged)
Please save this source code
User prompt
Kurabiye Fabrikası: Buton Tıklama
Initial prompt
Bana her butona tıkladığımızda 3 saniye sonra bir kurabiye ürettiğimiz ve sağ üst tarafta ne kadar kurabiye yaptığımız gösteren sayaçlı bir oyun yap
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // CookieButton: A clickable button that, when pressed, starts a 3s timer and produces a cookie after the timer. var CookieButton = Container.expand(function () { var self = Container.call(this); // Attach the button asset (color is set by config) var btnAsset = null; self.setButtonType = function (type) { if (btnAsset) { btnAsset.destroy(); } btnAsset = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); }; // Default type self.setButtonType('cookieBtn1'); // Cookie icon (hidden by default, shown on production) var cookieIcon = self.attachAsset('cookieIcon', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, scaleX: 0.7, scaleY: 0.7, alpha: 0 }); // Button label var label = new Text2('ÜRET', { size: 90, fill: "#fff" }); label.anchor.set(0.5, 0.5); label.y = 0; self.addChild(label); // State self.isWaiting = false; self.timer = null; // Show a progress arc (simulate with alpha fade) var progressOverlay = self.attachAsset('cookieBtn1', { anchorX: 0.5, anchorY: 0.5, alpha: 0.4, tint: 0x000000 }); progressOverlay.visible = false; // Start the 3s timer self.startTimer = function () { if (self.isWaiting) { return; } self.isWaiting = true; label.setText('...'); // Show overlay and animate alpha from 0.4 to 0.8 over 3s progressOverlay.visible = true; progressOverlay.alpha = 0.4; tween(progressOverlay, { alpha: 0.8 }, { duration: 3000, easing: tween.linear }); self.timer = LK.setTimeout(function () { self.isWaiting = false; label.setText('ÜRET'); progressOverlay.visible = false; progressOverlay.alpha = 0.4; self.produceCookie(); }, 3000); }; // Cancel timer if needed self.cancelTimer = function () { if (self.timer) { LK.clearTimeout(self.timer); self.timer = null; } self.isWaiting = false; label.setText('ÜRET'); progressOverlay.visible = false; progressOverlay.alpha = 0.4; }; // Show cookie icon and call callback self.produceCookie = function () { // Animate cookie icon: fade in, scale up, then fade out cookieIcon.alpha = 0; cookieIcon.scaleX = 0.7; cookieIcon.scaleY = 0.7; cookieIcon.visible = true; tween(cookieIcon, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 250, easing: tween.easeOut, onFinish: function onFinish() { tween(cookieIcon, { alpha: 0, scaleX: 1.2, scaleY: 1.2 }, { duration: 350, easing: tween.easeIn, onFinish: function onFinish() { cookieIcon.visible = false; } }); } }); // Notify game if (typeof self.onProduced === 'function') { self.onProduced(); } }; // Touch/click event self.down = function (x, y, obj) { if (!self.isWaiting) { self.startTimer(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf7e9d2 }); /**** * Game Code ****/ // Cookie icon // 3 different big buttons (different colors) // Global cookie count var cookieCount = 0; // Cookie counter text (top right) var cookieCounter = new Text2('0', { size: 110, fill: 0x7C4A03 }); cookieCounter.anchor.set(1, 0); // right-top // Add a cookie icon next to the counter var counterIcon = LK.getAsset('cookieIcon', { anchorX: 1, anchorY: 0, x: 0, y: 0, scaleX: 0.7, scaleY: 0.7 }); counterIcon.tint = 0x7c4a03; counterIcon.alpha = 0.85; // Container for counter and icon var counterBox = new Container(); counterBox.addChild(cookieCounter); counterIcon.x = -cookieCounter.width - 30; counterIcon.y = 0; counterBox.addChild(counterIcon); // Position at top right, with margin counterBox.x = LK.gui.topRight.width - 40; counterBox.y = 40; LK.gui.topRight.addChild(counterBox); // Update counter function updateCounter() { cookieCounter.setText(cookieCount); counterIcon.x = -cookieCounter.width - 30; // Show 'Kral' at top center if cookieCount >= 100, 'Usta' if >= 30, 'Oyuncu' if >= 10 if (cookieCount >= 100) { if (!window.oyuncuText) { window.oyuncuText = new Text2('Kral', { size: 120, fill: 0x1A237E }); window.oyuncuText.anchor.set(0.5, 0); window.oyuncuText.x = LK.gui.top.width / 2; window.oyuncuText.y = 40; LK.gui.top.addChild(window.oyuncuText); } else if (window.oyuncuText.text !== 'Kral') { window.oyuncuText.setText('Kral'); } } else if (cookieCount >= 30) { if (!window.oyuncuText) { window.oyuncuText = new Text2('Usta', { size: 120, fill: 0x1A237E }); window.oyuncuText.anchor.set(0.5, 0); window.oyuncuText.x = LK.gui.top.width / 2; window.oyuncuText.y = 40; LK.gui.top.addChild(window.oyuncuText); } else if (window.oyuncuText.text !== 'Usta') { window.oyuncuText.setText('Usta'); } } else if (cookieCount >= 10) { if (!window.oyuncuText) { window.oyuncuText = new Text2('Oyuncu', { size: 120, fill: 0x1A237E }); window.oyuncuText.anchor.set(0.5, 0); window.oyuncuText.x = LK.gui.top.width / 2; window.oyuncuText.y = 40; LK.gui.top.addChild(window.oyuncuText); } else if (window.oyuncuText.text !== 'Oyuncu') { window.oyuncuText.setText('Oyuncu'); } } else { if (window.oyuncuText && window.oyuncuText.parent) { window.oyuncuText.parent.removeChild(window.oyuncuText); window.oyuncuText = null; } } } // Create 3 big buttons, spaced vertically var buttons = []; var buttonTypes = ['cookieBtn1', 'cookieBtn2', 'cookieBtn3']; var btnCount = 3; var spacing = 520; var startY = 700; var centerX = 2048 / 2; for (var i = 0; i < btnCount; i++) { var btn = new CookieButton(); btn.setButtonType(buttonTypes[i]); btn.x = centerX; btn.y = startY + i * spacing; btn.onProduced = function () { cookieCount += 1; updateCounter(); }; game.addChild(btn); buttons.push(btn); } // Make sure buttons are not in the top left 100x100 area (they are centered and far below) // --- HELP BUTTON & MENU --- // Create a help button (question mark) for the bottom right var helpBtn = new Container(); var helpCircle = LK.getAsset('cookieBtn2', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5, x: 0, y: 0 }); helpCircle.alpha = 0.85; helpBtn.addChild(helpCircle); var helpText = new Text2('?', { size: 160, fill: "#fff" }); helpText.anchor.set(0.5, 0.5); helpBtn.addChild(helpText); // Add exclamation mark icon overlay (now as a separate button in the bottom left) var warnBtn = new Container(); var warnCircle = LK.getAsset('cookieBtn3', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.32, scaleY: 0.32, x: 0, y: 0 }); warnCircle.alpha = 0.95; warnBtn.addChild(warnCircle); var warnText = new Text2('!', { size: 110, fill: "#fff" }); warnText.anchor.set(0.5, 0.5); warnText.x = 0; warnText.y = 0; warnBtn.addChild(warnText); // Position warn button at bottom left, with margin, and keep it inside visible area warnBtn.x = 100 + 60; // 100px margin from left, 60px for button size warnBtn.y = LK.gui.bottomLeft.height - 100 - 60; // 100px margin from bottom, 60px for button size LK.gui.bottomLeft.addChild(warnBtn); // Position help button at bottom right, with margin, and keep it inside visible area helpBtn.x = LK.gui.bottomRight.width - 160; helpBtn.y = LK.gui.bottomRight.height - 160; LK.gui.bottomRight.addChild(helpBtn); // Help menu overlay (hidden by default) var helpMenu = new Container(); helpMenu.visible = false; // Semi-transparent background var helpBg = LK.getAsset('cookieBtn2', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.2, scaleY: 3.2, x: 0, y: 0 }); helpBg.alpha = 0.85; helpMenu.addChild(helpBg); // Help message var helpMsg = new Text2("Oyunda bu üç şekle tıklayarak her üç saniyede bir kurabiye üretebilirsiniz ve böyle oyun devam eder. Ayrıca oyunda belirli sayıda kurabiye kazanırsan bazı ünvanlar açılır.", { size: 80, fill: "#222", align: "center", wordWrap: true, wordWrapWidth: 1200 }); helpMsg.anchor.set(0.5, 0.5); helpMsg.x = 0; helpMsg.y = -40; helpMenu.addChild(helpMsg); // Close button var closeBtn = new Container(); var closeCircle = LK.getAsset('cookieBtn1', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.35, scaleY: 0.35, x: 0, y: 0 }); closeCircle.alpha = 0.8; closeBtn.addChild(closeCircle); var closeX = new Text2('X', { size: 90, fill: "#fff" }); closeX.anchor.set(0.5, 0.5); closeBtn.addChild(closeX); closeBtn.x = 480; closeBtn.y = -320; helpMenu.addChild(closeBtn); // Center help menu in the game area helpMenu.x = 2048 / 2; helpMenu.y = 2732 / 2; game.addChild(helpMenu); // Show help menu on helpBtn down helpBtn.down = function (x, y, obj) { helpMenu.visible = true; }; // Show warning menu on warnBtn down warnBtn.down = function (x, y, obj) { warningMenu.visible = true; }; // --- WARNING MENU --- var warningMenu = new Container(); warningMenu.visible = false; // Semi-transparent circular blue background for warning menu var warnBg = LK.getAsset('cookieBtn2', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.2, scaleY: 3.2, x: 0, y: 0 }); warnBg.alpha = 0.85; warningMenu.addChild(warnBg); // Warning message var warnMsg = new Text2("Eyer aynı anda bir çok kez tıklarsanız oyun algılayamaz, sadece ilk tıkladığınızı anlar.", { size: 80, fill: "#222", align: "center", wordWrap: true, wordWrapWidth: 1200 }); warnMsg.anchor.set(0.5, 0.5); warnMsg.x = 0; warnMsg.y = -40; warningMenu.addChild(warnMsg); // Close button for warning var warnCloseBtn = new Container(); var warnCloseCircle = LK.getAsset('cookieBtn1', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.35, scaleY: 0.35, x: 0, y: 0 }); warnCloseCircle.alpha = 0.8; warnCloseBtn.addChild(warnCloseCircle); var warnCloseX = new Text2('X', { size: 90, fill: "#fff" }); warnCloseX.anchor.set(0.5, 0.5); warnCloseBtn.addChild(warnCloseX); warnCloseBtn.x = 480; warnCloseBtn.y = -320; warningMenu.addChild(warnCloseBtn); // Center warning menu in the game area warningMenu.x = 2048 / 2; warningMenu.y = 2732 / 2; game.addChild(warningMenu); // Hide warning menu on close warnCloseBtn.down = function (x, y, obj) { warningMenu.visible = false; }; // Hide help menu on closeBtn down closeBtn.down = function (x, y, obj) { helpMenu.visible = false; }; // (Optional) Reset all timers on game over (handled by LK automatically, but for safety) game.destroy = function () { for (var i = 0; i < buttons.length; i++) { buttons[i].cancelTimer(); } };
===================================================================
--- original.js
+++ change.js
@@ -360,9 +360,9 @@
});
warnBg.alpha = 0.85;
warningMenu.addChild(warnBg);
// Warning message
-var warnMsg = new Text2("Eyer aynı anda bir çok kez tıklarsanız oyun algılayamaz, sadece ilk tıkladığınızı anlar", {
+var warnMsg = new Text2("Eyer aynı anda bir çok kez tıklarsanız oyun algılayamaz, sadece ilk tıkladığınızı anlar.", {
size: 80,
fill: "#222",
align: "center",
wordWrap: true,