/**** * 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); // Teleport button to random position on screen var buttonWidth = buttonGraphics.width; var buttonHeight = buttonGraphics.height; var randomX = Math.random() * (2048 - buttonWidth) + buttonWidth / 2; var randomY = Math.random() * (2732 - buttonHeight) + buttonHeight / 2; self.x = randomX; self.y = randomY; }; 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() { if (clickValue >= 10) { return 1500 + upgradeLevel * 580; } else { 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 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(); // Play background music LK.playMusic('bgMusic'); // 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; } };
/****
* 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);
// Teleport button to random position on screen
var buttonWidth = buttonGraphics.width;
var buttonHeight = buttonGraphics.height;
var randomX = Math.random() * (2048 - buttonWidth) + buttonWidth / 2;
var randomY = Math.random() * (2732 - buttonHeight) + buttonHeight / 2;
self.x = randomX;
self.y = randomY;
};
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() {
if (clickValue >= 10) {
return 1500 + upgradeLevel * 580;
} else {
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 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();
// Play background music
LK.playMusic('bgMusic');
// 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;
}
};