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; } // 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) // No need for update loop, as all logic is event/timer based // (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
@@ -1,6 +1,197 @@
-/****
+/****
+* 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: 0x000000
-});
\ No newline at end of file
+ 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;
+}
+// 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)
+// No need for update loop, as all logic is event/timer based
+// (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();
+ }
+};
\ No newline at end of file