User prompt
add background for total money text
User prompt
create image and references to background
User prompt
add image to backgroun
User prompt
change background
User prompt
move earning amount and upgrade button right
User prompt
can you change font
User prompt
move bussiness up
User prompt
add space between bussiness
User prompt
add space between business
User prompt
place earn button little bit above
User prompt
place tap button little bit above
User prompt
place tap button bottom
User prompt
remove button texts
User prompt
remove auto buttons
User prompt
if bussiness lvl above 1 automaticly work
User prompt
bussiness not working automatic
User prompt
auto bussiness function not working
User prompt
cant buy any business
User prompt
cant buy any upgrade
User prompt
can not interact with upgrade button
User prompt
upgrade buttons not working
User prompt
input not working
User prompt
start with 1 lemonade stand
User prompt
tap to earn not work
User prompt
Please fix the bug: 'Timeout.tick error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.businesses[id] = {' Line Number: 382
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { money: 0, businesses: {}, lastTick: 0 }); /**** * Classes ****/ // Business class: represents a single business row var Business = Container.expand(function () { var self = Container.call(this); // Properties (set after creation) self.bizId = null; self.bizData = null; self.index = 0; // UI elements var icon = null; var nameTxt = null; var levelTxt = null; var costTxt = null; var profitTxt = null; var timerBar = null; var upgradeBtn = null; var managerBtn = null; // State self.timer = 0; // ms left for current run self.running = false; // Setup method (called after creation) self.setup = function (bizId, bizData, index) { self.bizId = bizId; self.bizData = bizData; self.index = index; // Icon icon = self.attachAsset(bizData.asset, { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); // Name nameTxt = new Text2(bizData.name, { size: 48, fill: "#222", font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); nameTxt.anchor.set(0, 0.5); nameTxt.x = 140; nameTxt.y = 0; self.addChild(nameTxt); // Level levelTxt = new Text2("Lvl 0", { size: 40, fill: "#444", font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); levelTxt.anchor.set(0, 0.5); levelTxt.x = 140; levelTxt.y = 50; self.addChild(levelTxt); // Cost costTxt = new Text2("Buy: $0", { size: 36, fill: "#666", font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); costTxt.anchor.set(0, 0.5); costTxt.x = 140; costTxt.y = -50; self.addChild(costTxt); // Profit profitTxt = new Text2("+$0", { size: 36, fill: 0x008000, font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); profitTxt.anchor.set(1, 0.5); profitTxt.x = 900; profitTxt.y = 0; self.addChild(profitTxt); // Timer bar (progress) timerBar = self.attachAsset('biz_lemon', { anchorX: 0, anchorY: 0.5, x: 140, y: 80, width: 0, height: 16, color: 0x00bfff }); timerBar.alpha = 0.5; // Upgrade button upgradeBtn = self.attachAsset('upgrade_btn', { anchorX: 0.5, anchorY: 0.5, x: 1100, y: 0 }); upgradeBtn.interactive = true; upgradeBtn.down = function (x, y, obj) { if (self.down) self.down(x, y, upgradeBtn); }; // Removed upgradeTxt label // (Auto/manager button removed) // Event listeners self.down = function (x, y, obj) { // If tap on icon, start business if unlocked if (self.isUnlocked() && !self.isAuto() && self.timer <= 0) { self.startRun(); } // If tap on upgrade button if (self.isUnlocked() && obj === upgradeBtn && upgradeBtn.alpha >= 1) { self.tryUpgrade(); } // (Auto/manager button tap logic removed) // If tap anywhere on the business row and not unlocked, allow buying if (!self.isUnlocked()) { self.tryUpgrade(); } }; // Update UI self.refresh(); }; // Is business unlocked? self.isUnlocked = function () { return businesses[self.bizId].level > 0; }; // Is manager hired? self.isAuto = function () { return businesses[self.bizId].manager; }; // Start a run (manual or auto) self.startRun = function () { if (!self.isUnlocked()) return; if (self.timer > 0) return; self.timer = self.getDuration(); self.running = true; }; // Try to buy/upgrade self.tryUpgrade = function () { var cost = self.getCost(); // Only allow upgrade if enough money and upgradeBtn is enabled if (money >= cost && upgradeBtn.alpha >= 1) { money -= cost; businesses[self.bizId].level += 1; self.refresh(); updateMoneyUI(); saveGame(); } }; // Try to hire manager self.tryHireManager = function () { var mCost = self.getManagerCost(); if (money >= mCost && !self.isAuto()) { money -= mCost; businesses[self.bizId].manager = true; self.refresh(); updateMoneyUI(); saveGame(); } }; // Get current cost to buy/upgrade self.getCost = function () { var lvl = businesses[self.bizId].level; return Math.floor(self.bizData.baseCost * Math.pow(self.bizData.costMult, lvl)); }; // Get current profit self.getProfit = function () { var lvl = businesses[self.bizId].level; if (lvl === 0) return 0; return Math.floor(self.bizData.baseProfit * lvl * Math.pow(1.07, lvl - 1)); }; // Get duration (ms) self.getDuration = function () { return self.bizData.baseTime; }; // Get manager cost self.getManagerCost = function () { return self.bizData.managerCost; }; // Update UI self.refresh = function () { var lvl = businesses[self.bizId].level; var unlocked = lvl > 0; var profit = self.getProfit(); var cost = self.getCost(); var mCost = self.getManagerCost(); levelTxt.setText("Lvl " + lvl); costTxt.setText(unlocked ? "Upgrade: $" + formatNum(cost) : "Buy: $" + formatNum(cost)); profitTxt.setText("+$" + formatNum(profit)); profitTxt.alpha = unlocked ? 1 : 0.3; levelTxt.alpha = unlocked ? 1 : 0.3; icon.alpha = unlocked ? 1 : 0.3; // Timer bar timerBar.width = 320 * (self.timer > 0 ? 1 - self.timer / self.getDuration() : 0); // Upgrade button upgradeBtn.alpha = money >= cost ? 1 : 0.5; // (Auto/manager button UI refresh removed) }; // Update per tick self.update = function () { if (!self.isUnlocked()) { self.refresh(); return; } // Auto-run if manager or level > 1 if ((self.isAuto() || businesses[self.bizId].level > 1) && self.timer <= 0) { self.startRun(); // Ensure running is set so update continues ticking self.running = true; } // Progress timer if (self.timer > 0) { self.timer -= 1000 / 60; if (self.timer <= 0) { self.timer = 0; // Award profit var profit = self.getProfit(); money += profit; updateMoneyUI(); saveGame(); self.refresh(); // If auto, start again next frame } self.refresh(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb // Changed to a sky blue color }); /**** * Game Code ****/ // Business icons (simple colored boxes for MVP) // --- Game Data --- var businessList = [{ id: 'lemon', name: 'Lemonade Stand', asset: 'biz_lemon', baseCost: 4, costMult: 1.07, baseProfit: 1, baseTime: 1000, managerCost: 100 }, { id: 'newspaper', name: 'Newspaper Delivery', asset: 'biz_newspaper', baseCost: 60, costMult: 1.15, baseProfit: 8, baseTime: 3000, managerCost: 500 }, { id: 'carwash', name: 'Car Wash', asset: 'biz_carwash', baseCost: 720, costMult: 1.14, baseProfit: 64, baseTime: 6000, managerCost: 3000 }, { id: 'pizza', name: 'Pizza Delivery', asset: 'biz_pizza', baseCost: 8640, costMult: 1.13, baseProfit: 576, baseTime: 12000, managerCost: 10000 }, { id: 'movie', name: 'Movie Studio', asset: 'biz_movie', baseCost: 103680, costMult: 1.12, baseProfit: 5184, baseTime: 24000, managerCost: 100000 }, { id: 'bank', name: 'Bank', asset: 'biz_bank', baseCost: 1244160, costMult: 1.11, baseProfit: 46656, baseTime: 48000, managerCost: 500000 }, { id: 'oil', name: 'Oil Company', asset: 'biz_oil', baseCost: 14929920, costMult: 1.10, baseProfit: 419904, baseTime: 96000, managerCost: 1200000 }]; // --- State --- var money = 0; var businesses = {}; var businessObjs = []; var lastTick = 0; // --- UI Elements --- var moneyTxt = null; var tapBtn = null; var tapBtnTxt = null; // --- Utility Functions --- function formatNum(n) { if (n < 1000) return "" + n; var units = ['K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'Dc']; var u = -1; while (n >= 1000 && u < units.length - 1) { n /= 1000; u++; } return n.toFixed(2) + units[u]; } function updateMoneyUI() { moneyTxt.setText("$" + formatNum(money)); } // --- Save/Load --- function saveGame() { storage.money = money; storage.businesses = {}; for (var i = 0; i < businessList.length; ++i) { var id = businessList[i].id; storage.businesses[id + "_level"] = businesses[id].level; storage.businesses[id + "_manager"] = businesses[id].manager; } storage.lastTick = Date.now(); } function loadGame() { money = storage.money || 0; businesses = {}; for (var i = 0; i < businessList.length; ++i) { var id = businessList[i].id; // Start with 1 lemonade stand businesses[id] = { level: id === 'lemon' ? 1 : 0, manager: false }; if (storage.businesses) { if (typeof storage.businesses[id + "_level"] !== "undefined") { businesses[id].level = storage.businesses[id + "_level"]; } if (typeof storage.businesses[id + "_manager"] !== "undefined") { businesses[id].manager = !!storage.businesses[id + "_manager"]; } } } lastTick = storage.lastTick || Date.now(); } // --- Offline Progress --- function applyOfflineEarnings() { var now = Date.now(); var dt = now - lastTick; if (dt < 1000) return; var total = 0; for (var i = 0; i < businessList.length; ++i) { var biz = businessList[i]; var b = businesses[biz.id]; if (b.level > 0 && b.manager) { var cycles = Math.floor(dt / biz.baseTime); var profit = Math.floor(biz.baseProfit * b.level * Math.pow(1.07, b.level - 1)); total += cycles * profit; } } if (total > 0) { money += total; updateMoneyUI(); } } // --- Game Setup --- // Add background image behind all game elements var bgImage = LK.getAsset('bg_main', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 1, scaleY: 1 }); game.addChild(bgImage); function setupUI() { // Money display background var moneyBg = LK.getAsset('tap_btn', { anchorX: 0.5, anchorY: 0, x: 0, y: 0, scaleX: 1.2, scaleY: 0.7 }); moneyBg.x = 0; moneyBg.y = 0; LK.gui.top.addChild(moneyBg); moneyTxt = new Text2("$0", { size: 90, fill: "#222", font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" // Custom font }); moneyTxt.anchor.set(0.5, 0); LK.gui.top.addChild(moneyTxt); // Tap button (big, bottom center) tapBtn = LK.getAsset('tap_btn', { anchorX: 0.5, anchorY: 1, // bottom anchor x: 2048 / 2, y: 2732 - 320 // 320px above bottom (moved up) }); tapBtn.interactive = true; game.addChild(tapBtn); // Removed tapBtnTxt label tapBtn.down = function (x, y, obj) { if (game.down) game.down(x, y, tapBtn); }; // Business rows var startY = 500; var gapY = 260; // Further increased gap for even more space between businesses for (var i = 0; i < businessList.length; ++i) { var biz = businessList[i]; var bizObj = new Business(); bizObj.setup(biz.id, biz, i); bizObj.x = 200; bizObj.y = startY + i * gapY; game.addChild(bizObj); businessObjs.push(bizObj); } } // --- Tap Handler --- game.down = function (x, y, obj) { // Tap on tapBtn if (obj === tapBtn || obj === tapBtnTxt) { var tapVal = 1 + Math.floor(businesses['lemon'].level / 10); money += tapVal; updateMoneyUI(); saveGame(); // Animate tapBtn tween(tapBtn, { scaleX: 0.9, scaleY: 0.9 }, { duration: 80, easing: tween.easeOut, onFinish: function onFinish() { tween(tapBtn, { scaleX: 1, scaleY: 1 }, { duration: 80, easing: tween.easeIn }); } }); } }; // --- Game Update --- game.update = function () { // Update all businesses for (var i = 0; i < businessObjs.length; ++i) { businessObjs[i].update(); } }; // --- Init --- loadGame(); applyOfflineEarnings(); setupUI(); updateMoneyUI(); // --- Save every 5 seconds --- LK.setInterval(function () { saveGame(); }, 5000);
===================================================================
--- original.js
+++ change.js
@@ -394,9 +394,20 @@
scaleY: 1
});
game.addChild(bgImage);
function setupUI() {
- // Money display
+ // Money display background
+ var moneyBg = LK.getAsset('tap_btn', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: 0,
+ y: 0,
+ scaleX: 1.2,
+ scaleY: 0.7
+ });
+ moneyBg.x = 0;
+ moneyBg.y = 0;
+ LK.gui.top.addChild(moneyBg);
moneyTxt = new Text2("$0", {
size: 90,
fill: "#222",
font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" // Custom font
button when clicked earn gold. In-Game asset. 2d. High contrast. No shadows
button upgrade level of business. In-Game asset. 2d. High contrast. No shadows
lemonade stand. In-Game asset. 2d. High contrast. No shadows
newspaper delivery. In-Game asset. 2d. High contrast. No shadows
carwash bussiness. In-Game asset. 2d. High contrast. No shadows
pizza store. In-Game asset. 2d. High contrast. No shadows
movie theater. In-Game asset. 2d. High contrast. No shadows
bank. In-Game asset. 2d. High contrast. No shadows
oil company. In-Game asset. 2d. High contrast. No shadows
background for game clean minimalist. In-Game asset. 2d. High contrast. No shadows
dollar paper. In-Game asset. 2d. High contrast. No shadows