User prompt
Let the upgrade in 10 clicks be 1500
User prompt
when you click the pen, it will appear in a random place on the screen and with each click it will teleport to a random place on the screen but not leave the screen
User prompt
play music when you start the game
User prompt
remove the click fortune text at the top
User prompt
Remove the text below tap the button to earn money
User prompt
When per click is 10, increase the upgrade price by 580
User prompt
remove the click text on the button
User prompt
Every time we click on the upgrade, the price of the upgrade increases by 100.
Code edit (1 edits merged)
Please save this source code
User prompt
Click Fortune
Initial prompt
play a clicking game with me Let's click the button in the middle so that 1 money comes with each click and there is an upgrade button below and every time we press it, the money comes instead of 1 and 2, so every time we upgrade, the money increases by 1 But the price of the upgrade will also increase
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1", {
money: 0,
clickValue: 1,
upgradeLevel: 0
});
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ClickButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('clickButton', {
anchorX: 0.5,
anchorY: 0.5
});
// Button text removed - clean circular button design
self.down = function (x, y, obj) {
// Visual feedback - scale animation
tween(buttonGraphics, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
tween(buttonGraphics, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(buttonGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
// Add money
money += clickValue;
storage.money = money;
// Update displays
moneyText.setText('$' + money);
// Play click sound
LK.getSound('click').play();
// Show floating text
showFloatingText('+$' + clickValue, self.x, self.y - 100);
};
return self;
});
var UpgradeButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5
});
var upgradeText = new Text2('', {
size: 50,
fill: 0xFFFFFF
});
upgradeText.anchor.set(0.5, 0.5);
self.addChild(upgradeText);
self.updateText = function () {
var cost = getUpgradeCost();
var nextValue = clickValue + 1;
upgradeText.setText('Upgrade +$' + nextValue + ' per click\nCost: $' + cost);
// Change color based on affordability
if (money >= cost) {
buttonGraphics.tint = 0x4CAF50; // Green if affordable
} else {
buttonGraphics.tint = 0x757575; // Gray if not affordable
}
};
self.down = function (x, y, obj) {
var cost = getUpgradeCost();
if (money >= cost) {
// Purchase upgrade
money -= cost;
clickValue += 1;
upgradeLevel += 1;
// Save to storage
storage.money = money;
storage.clickValue = clickValue;
storage.upgradeLevel = upgradeLevel;
// Update displays
moneyText.setText('$' + money);
self.updateText();
// Visual feedback
tween(buttonGraphics, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100
});
tween(buttonGraphics, {
scaleX: 1.05,
scaleY: 1.05
}, {
duration: 100,
onFinish: function onFinish() {
tween(buttonGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
// Play upgrade sound
LK.getSound('upgrade').play();
// Show floating text
showFloatingText('UPGRADED!', self.x, self.y - 50);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
// Game variables
var money = storage.money || 0;
var clickValue = storage.clickValue || 1;
var upgradeLevel = storage.upgradeLevel || 0;
// Helper function to calculate upgrade cost
function getUpgradeCost() {
return 10 + upgradeLevel * 100;
}
// Helper function to show floating text
function showFloatingText(text, x, y) {
var floatText = new Text2(text, {
size: 60,
fill: 0xFFD700
});
floatText.anchor.set(0.5, 0.5);
floatText.x = x;
floatText.y = y;
game.addChild(floatText);
tween(floatText, {
y: y - 150,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
floatText.destroy();
}
});
}
// Create UI elements
var titleText = new Text2('Click Fortune', {
size: 120,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0);
titleText.x = 2048 / 2;
titleText.y = 200;
game.addChild(titleText);
var moneyText = new Text2('$' + money, {
size: 100,
fill: 0x4CAF50
});
moneyText.anchor.set(0.5, 0);
moneyText.x = 2048 / 2;
moneyText.y = 400;
game.addChild(moneyText);
// Create click button
var clickButton = new ClickButton();
clickButton.x = 2048 / 2;
clickButton.y = 1000;
game.addChild(clickButton);
// Create upgrade button
var upgradeButton = new UpgradeButton();
upgradeButton.x = 2048 / 2;
upgradeButton.y = 1500;
game.addChild(upgradeButton);
// Initialize upgrade button text
upgradeButton.updateText();
// Create info text
var infoText = new Text2('Tap the button to earn money!\nBuy upgrades to earn more per click', {
size: 40,
fill: 0xCCCCCC
});
infoText.anchor.set(0.5, 0.5);
infoText.x = 2048 / 2;
infoText.y = 1800;
game.addChild(infoText);
// Add current click value display
var clickValueText = new Text2('$' + clickValue + ' per click', {
size: 60,
fill: 0xFFB74D
});
clickValueText.anchor.set(0.5, 0.5);
clickValueText.x = 2048 / 2;
clickValueText.y = 650;
game.addChild(clickValueText);
// Game update loop
game.update = function () {
// Update click value display
clickValueText.setText('$' + clickValue + ' per click');
// Update upgrade button text periodically
if (LK.ticks % 30 == 0) {
upgradeButton.updateText();
}
// Save progress periodically
if (LK.ticks % 300 == 0) {
storage.money = money;
storage.clickValue = clickValue;
storage.upgradeLevel = upgradeLevel;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -16,14 +16,9 @@
var buttonGraphics = self.attachAsset('clickButton', {
anchorX: 0.5,
anchorY: 0.5
});
- var buttonText = new Text2('CLICK', {
- size: 80,
- fill: 0xFFFFFF
- });
- buttonText.anchor.set(0.5, 0.5);
- self.addChild(buttonText);
+ // Button text removed - clean circular button design
self.down = function (x, y, obj) {
// Visual feedback - scale animation
tween(buttonGraphics, {
scaleX: 0.9,