User prompt
make a villian and he tries to steal out money sometimes we should defend our money from him with some fighting things
User prompt
fix the plugins please
Code edit (1 edits merged)
Please save this source code
User prompt
Money Clicker Tycoon
Initial prompt
make me a money clicker simulator with objectives for mobile phone
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
money: 0,
tapValue: 1,
autoIncome: 0,
upgrades: 0,
objectives: 0
});
/****
* Classes
****/
// Automation Icon (shows if auto income is unlocked)
var AutoIcon = Container.expand(function () {
var self = Container.call(this);
var icon = self.attachAsset('autoIcon', {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2('AUTO', {
size: 32,
fill: "#fff"
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
return self;
});
// Money Button (main clickable)
var MoneyButton = Container.expand(function () {
var self = Container.call(this);
var btn = self.attachAsset('moneyBtn', {
anchorX: 0.5,
anchorY: 0.5
});
// Animate on tap
self.flash = function () {
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 80,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 120,
easing: tween.easeIn
});
}
});
};
// Touch event
self.down = function (x, y, obj) {
self.flash();
addMoney(tapValue);
};
return self;
});
// Objective Badge
var ObjectiveBadge = Container.expand(function () {
var self = Container.call(this);
var badge = self.attachAsset('objectiveBadge', {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2('', {
size: 36,
fill: "#333"
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.setLabel = function (txt) {
label.setText(txt);
};
return self;
});
// Upgrade Button
var UpgradeButton = Container.expand(function () {
var self = Container.call(this);
var btn = self.attachAsset('upgradeBtn', {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2('', {
size: 48,
fill: "#fff"
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.setLabel = function (txt) {
label.setText(txt);
};
self.setEnabled = function (enabled) {
btn.alpha = enabled ? 1 : 0.5;
self.interactive = enabled;
};
// Touch event
self.down = function (x, y, obj) {
if (canUpgrade()) {
doUpgrade();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222222
});
/****
* Game Code
****/
// Automation icon (orange, square)
// Objective badge (yellow, round)
// Upgrade button (smaller, blue, round)
// Main money button (big, green, round)
// --- Persistent State ---
var money = storage.money || 0;
var tapValue = storage.tapValue || 1;
var autoIncome = storage.autoIncome || 0;
var upgrades = storage.upgrades || 0;
var objectives = storage.objectives || 0;
// --- UI Elements ---
var moneyBtn = new MoneyButton();
var upgradeBtn = new UpgradeButton();
var autoIcon = new AutoIcon();
var objectiveBadge = new ObjectiveBadge();
// --- Text Displays ---
var moneyTxt = new Text2('', {
size: 120,
fill: "#fff"
});
moneyTxt.anchor.set(0.5, 0);
// Upgrade cost and effect
function getUpgradeCost() {
// Cost increases exponentially
return 50 * Math.pow(2, upgrades);
}
function getUpgradeEffect() {
// Every upgrade increases tap value by 1, every 3rd upgrade unlocks auto income
return 1;
}
function getAutoIncome() {
// Every 3rd upgrade gives +1 auto income per second
return Math.floor(upgrades / 3);
}
// Objective system
var objectiveList = [{
desc: "Earn $100",
check: function check() {
return money >= 100;
},
reward: function reward() {
tapValue += 1;
},
rewardText: "+1 Tap Value"
}, {
desc: "Buy 3 Upgrades",
check: function check() {
return upgrades >= 3;
},
reward: function reward() {
autoIncome += 1;
},
rewardText: "+1 Auto Income"
}, {
desc: "Earn $1000",
check: function check() {
return money >= 1000;
},
reward: function reward() {
tapValue += 2;
},
rewardText: "+2 Tap Value"
}, {
desc: "Buy 6 Upgrades",
check: function check() {
return upgrades >= 6;
},
reward: function reward() {
autoIncome += 2;
},
rewardText: "+2 Auto Income"
}, {
desc: "Earn $10000",
check: function check() {
return money >= 10000;
},
reward: function reward() {
tapValue += 5;
},
rewardText: "+5 Tap Value"
}, {
desc: "Buy 10 Upgrades",
check: function check() {
return upgrades >= 10;
},
reward: function reward() {
autoIncome += 5;
},
rewardText: "+5 Auto Income"
}
// Add more objectives as needed
];
// --- Helper Functions ---
function addMoney(amount) {
money += amount;
storage.money = money;
updateMoneyDisplay();
checkObjectives();
}
function canUpgrade() {
return money >= getUpgradeCost();
}
function doUpgrade() {
var cost = getUpgradeCost();
if (money >= cost) {
money -= cost;
upgrades += 1;
tapValue += getUpgradeEffect();
autoIncome = getAutoIncome();
storage.money = money;
storage.upgrades = upgrades;
storage.tapValue = tapValue;
storage.autoIncome = autoIncome;
updateMoneyDisplay();
updateUpgradeDisplay();
updateAutoIcon();
checkObjectives();
}
}
function updateMoneyDisplay() {
moneyTxt.setText('$' + formatMoney(money));
}
function updateUpgradeDisplay() {
var cost = getUpgradeCost();
upgradeBtn.setLabel('Upgrade\n$' + formatMoney(cost));
upgradeBtn.setEnabled(money >= cost);
}
function updateAutoIcon() {
if (autoIncome > 0) {
autoIcon.visible = true;
} else {
autoIcon.visible = false;
}
}
function updateObjectiveBadge() {
if (objectives < objectiveList.length) {
var obj = objectiveList[objectives];
objectiveBadge.setLabel(objectives + 1 + '');
objectiveBadge.visible = true;
} else {
objectiveBadge.visible = false;
}
}
function checkObjectives() {
if (objectives < objectiveList.length) {
var obj = objectiveList[objectives];
if (obj.check()) {
// Show reward flash
LK.effects.flashObject(objectiveBadge, 0x00e676, 800);
// Reward
obj.reward();
storage.tapValue = tapValue;
storage.autoIncome = autoIncome;
objectives += 1;
storage.objectives = objectives;
// Show reward text
showObjectiveReward(obj.rewardText);
updateAutoIcon();
updateUpgradeDisplay();
updateObjectiveBadge();
}
}
}
function showObjectiveReward(txt) {
var rewardTxt = new Text2(txt, {
size: 60,
fill: 0xFFD600
});
rewardTxt.anchor.set(0.5, 0.5);
rewardTxt.x = 2048 / 2;
rewardTxt.y = 900;
game.addChild(rewardTxt);
tween(rewardTxt, {
y: rewardTxt.y - 120,
alpha: 0
}, {
duration: 1200,
easing: tween.easeOut,
onFinish: function onFinish() {
rewardTxt.destroy();
}
});
}
// Format money for display
function formatMoney(val) {
if (val >= 1e9) return (val / 1e9).toFixed(2) + 'B';
if (val >= 1e6) return (val / 1e6).toFixed(2) + 'M';
if (val >= 1e3) return (val / 1e3).toFixed(2) + 'K';
return Math.floor(val);
}
// --- Layout ---
function layoutUI() {
// Money Button: center
moneyBtn.x = 2048 / 2;
moneyBtn.y = 1200;
moneyBtn.scaleX = 1;
moneyBtn.scaleY = 1;
// Money Text: above button
moneyTxt.x = 2048 / 2;
moneyTxt.y = 400;
// Upgrade Button: below button
upgradeBtn.x = 2048 / 2;
upgradeBtn.y = 1700;
// Auto Icon: right of button
autoIcon.x = 2048 / 2 + 350;
autoIcon.y = 1200;
// Objective Badge: left of button
objectiveBadge.x = 2048 / 2 - 350;
objectiveBadge.y = 1200;
}
// --- Add to Game ---
game.addChild(moneyBtn);
game.addChild(moneyTxt);
game.addChild(upgradeBtn);
game.addChild(autoIcon);
game.addChild(objectiveBadge);
// --- GUI: Title ---
var titleTxt = new Text2('Money Clicker Tycoon', {
size: 70,
fill: "#fff"
});
titleTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(titleTxt);
// --- Initial State ---
updateMoneyDisplay();
updateUpgradeDisplay();
updateAutoIcon();
updateObjectiveBadge();
layoutUI();
// --- Idle Income Timer ---
var autoTimer = LK.setInterval(function () {
if (autoIncome > 0) {
addMoney(autoIncome);
// Animate auto icon
tween(autoIcon, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 80,
onFinish: function onFinish() {
tween(autoIcon, {
scaleX: 1,
scaleY: 1
}, {
duration: 120
});
}
});
}
}, 1000);
// --- Game Update Loop ---
game.update = function () {
// Nothing needed for now; all logic is event/timer driven
};
// --- Responsive Layout on Resize ---
game.on('resize', function () {
layoutUI();
});
// --- Prevent UI in top-left 100x100 px ---
titleTxt.x = LK.gui.top.width / 2;
titleTxt.y = 0;
// --- Touchscreen: No drag, only tap ---
// --- End of File --- ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,383 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1", {
+ money: 0,
+ tapValue: 1,
+ autoIncome: 0,
+ upgrades: 0,
+ objectives: 0
+});
+
+/****
+* Classes
+****/
+// Automation Icon (shows if auto income is unlocked)
+var AutoIcon = Container.expand(function () {
+ var self = Container.call(this);
+ var icon = self.attachAsset('autoIcon', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var label = new Text2('AUTO', {
+ size: 32,
+ fill: "#fff"
+ });
+ label.anchor.set(0.5, 0.5);
+ self.addChild(label);
+ return self;
+});
+// Money Button (main clickable)
+var MoneyButton = Container.expand(function () {
+ var self = Container.call(this);
+ var btn = self.attachAsset('moneyBtn', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Animate on tap
+ self.flash = function () {
+ tween(self, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 80,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 120,
+ easing: tween.easeIn
+ });
+ }
+ });
+ };
+ // Touch event
+ self.down = function (x, y, obj) {
+ self.flash();
+ addMoney(tapValue);
+ };
+ return self;
+});
+// Objective Badge
+var ObjectiveBadge = Container.expand(function () {
+ var self = Container.call(this);
+ var badge = self.attachAsset('objectiveBadge', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var label = new Text2('', {
+ size: 36,
+ fill: "#333"
+ });
+ label.anchor.set(0.5, 0.5);
+ self.addChild(label);
+ self.setLabel = function (txt) {
+ label.setText(txt);
+ };
+ return self;
+});
+// Upgrade Button
+var UpgradeButton = Container.expand(function () {
+ var self = Container.call(this);
+ var btn = self.attachAsset('upgradeBtn', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var label = new Text2('', {
+ size: 48,
+ fill: "#fff"
+ });
+ label.anchor.set(0.5, 0.5);
+ self.addChild(label);
+ self.setLabel = function (txt) {
+ label.setText(txt);
+ };
+ self.setEnabled = function (enabled) {
+ btn.alpha = enabled ? 1 : 0.5;
+ self.interactive = enabled;
+ };
+ // Touch event
+ self.down = function (x, y, obj) {
+ if (canUpgrade()) {
+ doUpgrade();
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x222222
+});
+
+/****
+* Game Code
+****/
+// Automation icon (orange, square)
+// Objective badge (yellow, round)
+// Upgrade button (smaller, blue, round)
+// Main money button (big, green, round)
+// --- Persistent State ---
+var money = storage.money || 0;
+var tapValue = storage.tapValue || 1;
+var autoIncome = storage.autoIncome || 0;
+var upgrades = storage.upgrades || 0;
+var objectives = storage.objectives || 0;
+// --- UI Elements ---
+var moneyBtn = new MoneyButton();
+var upgradeBtn = new UpgradeButton();
+var autoIcon = new AutoIcon();
+var objectiveBadge = new ObjectiveBadge();
+// --- Text Displays ---
+var moneyTxt = new Text2('', {
+ size: 120,
+ fill: "#fff"
+});
+moneyTxt.anchor.set(0.5, 0);
+// Upgrade cost and effect
+function getUpgradeCost() {
+ // Cost increases exponentially
+ return 50 * Math.pow(2, upgrades);
+}
+function getUpgradeEffect() {
+ // Every upgrade increases tap value by 1, every 3rd upgrade unlocks auto income
+ return 1;
+}
+function getAutoIncome() {
+ // Every 3rd upgrade gives +1 auto income per second
+ return Math.floor(upgrades / 3);
+}
+// Objective system
+var objectiveList = [{
+ desc: "Earn $100",
+ check: function check() {
+ return money >= 100;
+ },
+ reward: function reward() {
+ tapValue += 1;
+ },
+ rewardText: "+1 Tap Value"
+}, {
+ desc: "Buy 3 Upgrades",
+ check: function check() {
+ return upgrades >= 3;
+ },
+ reward: function reward() {
+ autoIncome += 1;
+ },
+ rewardText: "+1 Auto Income"
+}, {
+ desc: "Earn $1000",
+ check: function check() {
+ return money >= 1000;
+ },
+ reward: function reward() {
+ tapValue += 2;
+ },
+ rewardText: "+2 Tap Value"
+}, {
+ desc: "Buy 6 Upgrades",
+ check: function check() {
+ return upgrades >= 6;
+ },
+ reward: function reward() {
+ autoIncome += 2;
+ },
+ rewardText: "+2 Auto Income"
+}, {
+ desc: "Earn $10000",
+ check: function check() {
+ return money >= 10000;
+ },
+ reward: function reward() {
+ tapValue += 5;
+ },
+ rewardText: "+5 Tap Value"
+}, {
+ desc: "Buy 10 Upgrades",
+ check: function check() {
+ return upgrades >= 10;
+ },
+ reward: function reward() {
+ autoIncome += 5;
+ },
+ rewardText: "+5 Auto Income"
+}
+// Add more objectives as needed
+];
+// --- Helper Functions ---
+function addMoney(amount) {
+ money += amount;
+ storage.money = money;
+ updateMoneyDisplay();
+ checkObjectives();
+}
+function canUpgrade() {
+ return money >= getUpgradeCost();
+}
+function doUpgrade() {
+ var cost = getUpgradeCost();
+ if (money >= cost) {
+ money -= cost;
+ upgrades += 1;
+ tapValue += getUpgradeEffect();
+ autoIncome = getAutoIncome();
+ storage.money = money;
+ storage.upgrades = upgrades;
+ storage.tapValue = tapValue;
+ storage.autoIncome = autoIncome;
+ updateMoneyDisplay();
+ updateUpgradeDisplay();
+ updateAutoIcon();
+ checkObjectives();
+ }
+}
+function updateMoneyDisplay() {
+ moneyTxt.setText('$' + formatMoney(money));
+}
+function updateUpgradeDisplay() {
+ var cost = getUpgradeCost();
+ upgradeBtn.setLabel('Upgrade\n$' + formatMoney(cost));
+ upgradeBtn.setEnabled(money >= cost);
+}
+function updateAutoIcon() {
+ if (autoIncome > 0) {
+ autoIcon.visible = true;
+ } else {
+ autoIcon.visible = false;
+ }
+}
+function updateObjectiveBadge() {
+ if (objectives < objectiveList.length) {
+ var obj = objectiveList[objectives];
+ objectiveBadge.setLabel(objectives + 1 + '');
+ objectiveBadge.visible = true;
+ } else {
+ objectiveBadge.visible = false;
+ }
+}
+function checkObjectives() {
+ if (objectives < objectiveList.length) {
+ var obj = objectiveList[objectives];
+ if (obj.check()) {
+ // Show reward flash
+ LK.effects.flashObject(objectiveBadge, 0x00e676, 800);
+ // Reward
+ obj.reward();
+ storage.tapValue = tapValue;
+ storage.autoIncome = autoIncome;
+ objectives += 1;
+ storage.objectives = objectives;
+ // Show reward text
+ showObjectiveReward(obj.rewardText);
+ updateAutoIcon();
+ updateUpgradeDisplay();
+ updateObjectiveBadge();
+ }
+ }
+}
+function showObjectiveReward(txt) {
+ var rewardTxt = new Text2(txt, {
+ size: 60,
+ fill: 0xFFD600
+ });
+ rewardTxt.anchor.set(0.5, 0.5);
+ rewardTxt.x = 2048 / 2;
+ rewardTxt.y = 900;
+ game.addChild(rewardTxt);
+ tween(rewardTxt, {
+ y: rewardTxt.y - 120,
+ alpha: 0
+ }, {
+ duration: 1200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ rewardTxt.destroy();
+ }
+ });
+}
+// Format money for display
+function formatMoney(val) {
+ if (val >= 1e9) return (val / 1e9).toFixed(2) + 'B';
+ if (val >= 1e6) return (val / 1e6).toFixed(2) + 'M';
+ if (val >= 1e3) return (val / 1e3).toFixed(2) + 'K';
+ return Math.floor(val);
+}
+// --- Layout ---
+function layoutUI() {
+ // Money Button: center
+ moneyBtn.x = 2048 / 2;
+ moneyBtn.y = 1200;
+ moneyBtn.scaleX = 1;
+ moneyBtn.scaleY = 1;
+ // Money Text: above button
+ moneyTxt.x = 2048 / 2;
+ moneyTxt.y = 400;
+ // Upgrade Button: below button
+ upgradeBtn.x = 2048 / 2;
+ upgradeBtn.y = 1700;
+ // Auto Icon: right of button
+ autoIcon.x = 2048 / 2 + 350;
+ autoIcon.y = 1200;
+ // Objective Badge: left of button
+ objectiveBadge.x = 2048 / 2 - 350;
+ objectiveBadge.y = 1200;
+}
+// --- Add to Game ---
+game.addChild(moneyBtn);
+game.addChild(moneyTxt);
+game.addChild(upgradeBtn);
+game.addChild(autoIcon);
+game.addChild(objectiveBadge);
+// --- GUI: Title ---
+var titleTxt = new Text2('Money Clicker Tycoon', {
+ size: 70,
+ fill: "#fff"
+});
+titleTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(titleTxt);
+// --- Initial State ---
+updateMoneyDisplay();
+updateUpgradeDisplay();
+updateAutoIcon();
+updateObjectiveBadge();
+layoutUI();
+// --- Idle Income Timer ---
+var autoTimer = LK.setInterval(function () {
+ if (autoIncome > 0) {
+ addMoney(autoIncome);
+ // Animate auto icon
+ tween(autoIcon, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 80,
+ onFinish: function onFinish() {
+ tween(autoIcon, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 120
+ });
+ }
+ });
+ }
+}, 1000);
+// --- Game Update Loop ---
+game.update = function () {
+ // Nothing needed for now; all logic is event/timer driven
+};
+// --- Responsive Layout on Resize ---
+game.on('resize', function () {
+ layoutUI();
+});
+// --- Prevent UI in top-left 100x100 px ---
+titleTxt.x = LK.gui.top.width / 2;
+titleTxt.y = 0;
+// --- Touchscreen: No drag, only tap ---
+// --- End of File ---
\ No newline at end of file