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)
// --- 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 (smaller, above and left of question mark)
var warnCircle = LK.getAsset('cookieBtn3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.22,
scaleY: 0.22,
x: -40,
y: -110
});
warnCircle.alpha = 0.95;
helpBtn.addChild(warnCircle);
var warnText = new Text2('!', {
size: 70,
fill: "#fff"
});
warnText.anchor.set(0.5, 0.5);
warnText.x = -40;
warnText.y = -110;
helpBtn.addChild(warnText);
// 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.", {
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) {
// If the user pressed on the exclamation mark, show warning instead
// Convert event coordinates to local coordinates of warnCircle
var local = warnCircle.toLocal({
x: x,
y: y
}, game);
// Check if inside warnCircle (radius 44, since scale 0.22 * 400/2)
var dx = local.x;
var dy = local.y;
var r = 44;
if (dx * dx + dy * dy < r * r) {
warningMenu.visible = true;
} else {
helpMenu.visible = true;
}
};
// --- WARNING MENU ---
var warningMenu = new Container();
warningMenu.visible = false;
// Semi-transparent background
var warnBg = LK.getAsset('cookieBtn3', {
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
@@ -206,26 +206,26 @@
fill: "#fff"
});
helpText.anchor.set(0.5, 0.5);
helpBtn.addChild(helpText);
-// Add exclamation mark icon overlay (smaller, top-right of question mark)
+// Add exclamation mark icon overlay (smaller, above and left of question mark)
var warnCircle = LK.getAsset('cookieBtn3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.22,
scaleY: 0.22,
- x: 60,
- y: -60
+ x: -40,
+ y: -110
});
warnCircle.alpha = 0.95;
helpBtn.addChild(warnCircle);
var warnText = new Text2('!', {
size: 70,
fill: "#fff"
});
warnText.anchor.set(0.5, 0.5);
-warnText.x = 60;
-warnText.y = -60;
+warnText.x = -40;
+warnText.y = -110;
helpBtn.addChild(warnText);
// 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;