/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var BackgroundElements = Container.expand(function () { var self = Container.call(this); // Create gradient background for business empire theme self.backgroundGradient = LK.getAsset('box', { width: 2048, height: 2732, color: 0x1a1a2e, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); self.addChild(self.backgroundGradient); // Add subtle pattern overlay self.patternOverlay = LK.getAsset('box', { width: 2048, height: 2732, color: 0x16213e, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); self.patternOverlay.alpha = 0.3; self.addChild(self.patternOverlay); // Add golden accent elements for empire feel self.topAccent = LK.getAsset('box', { width: 2048, height: 8, color: 0xFFD700, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); self.addChild(self.topAccent); self.bottomAccent = LK.getAsset('box', { width: 2048, height: 8, color: 0xFFD700, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 2724 }); self.addChild(self.bottomAccent); return self; }); var Generator = Container.expand(function (type, baseCost, baseIncome) { var self = Container.call(this); self.type = type; self.baseCost = baseCost; self.baseIncome = baseIncome; self.level = 0; self.lastIncomeTime = Date.now(); // Create visual representation var visual = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); // Add level text self.levelText = new Text2('Lv.0', { size: 40, fill: 0xFFFFFF }); self.levelText.anchor.set(0.5, 0); self.levelText.x = 0; self.levelText.y = visual.height / 2 + 10; self.addChild(self.levelText); self.getCost = function () { return Math.floor(self.baseCost * Math.pow(1.15, self.level)); }; self.getIncome = function () { var baseIncome = self.baseIncome * self.level; if (baseIncome > 0) { // Apply global multipliers and efficiency bonuses var globalMultiplier = Math.pow(2, globalMultiplierUpgrades || 0); var efficiencyMultiplier = 1 + (efficiencyUpgrades || 0) * 0.25; var prestigeMultiplier = 1 + (prestigePoints || 0) * 0.1; return baseIncome * globalMultiplier * efficiencyMultiplier * prestigeMultiplier; } return baseIncome; }; self.upgrade = function () { if (self.level < 200) { self.level++; self.levelText.setText('Lv.' + self.level); LK.getSound('upgrade').play(); } }; self.generateIncome = function () { if (self.level > 0) { var now = Date.now(); var timeDiff = (now - self.lastIncomeTime) / 1000; // Convert to seconds var income = self.getIncome() * timeDiff; self.lastIncomeTime = now; return income; } return 0; }; return self; }); var LuxuryItem = Container.expand(function (name, assetId, cost, description) { var self = Container.call(this); self.name = name; self.assetId = assetId; self.cost = cost; self.description = description; self.owned = false; // Create visual representation self.visual = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // Add name text self.nameText = new Text2(name, { size: 30, fill: 0xFFFFFF }); self.nameText.anchor.set(0.5, 0); self.nameText.x = 0; self.nameText.y = self.visual.height / 2 + 10; self.addChild(self.nameText); // Add cost text self.costText = new Text2('$' + formatNumber(cost), { size: 25, fill: 0xFFD700 }); self.costText.anchor.set(0.5, 0); self.costText.x = 0; self.costText.y = self.visual.height / 2 + 50; self.addChild(self.costText); // Add owned indicator self.ownedText = new Text2('OWNED', { size: 20, fill: 0x00FF00 }); self.ownedText.anchor.set(0.5, 0.5); self.ownedText.x = 0; self.ownedText.y = -self.visual.height / 2 - 20; self.ownedText.visible = false; self.addChild(self.ownedText); self.purchase = function () { if (!self.owned && currency >= self.cost) { currency -= self.cost; self.owned = true; self.ownedText.visible = true; self.visual.alpha = 0.7; self.costText.visible = false; LK.getSound('purchase').play(); updateUI(); saveLuxuryItems(); // Check if all luxury items are now owned var allItemsOwned = true; for (var i = 0; i < luxuryTab.luxuryItems.length; i++) { if (!luxuryTab.luxuryItems[i].owned) { allItemsOwned = false; break; } } if (allItemsOwned) { createConfettiExplosion(); } return true; } return false; }; self.down = function (x, y, obj) { self.purchase(); }; return self; }); var LuxuryTab = Container.expand(function () { var self = Container.call(this); self.visible = false; self.luxuryItems = []; // Create background self.background = LK.getAsset('box', { width: 2048, height: 2732, color: 0x2a2a3e, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); self.addChild(self.background); // Create title self.titleText = new Text2('LUXURY ITEMS', { size: 80, fill: 0xFFD700 }); self.titleText.anchor.set(0.5, 0); self.titleText.x = 1024; self.titleText.y = 150; self.addChild(self.titleText); // Create close button self.closeButton = new Text2('CLOSE', { size: 50, fill: 0xFF0000 }); self.closeButton.anchor.set(1, 0); self.closeButton.x = 1998; self.closeButton.y = 50; self.addChild(self.closeButton); self.closeButton.down = function (x, y, obj) { self.visible = false; }; // Initialize luxury items self.initializeLuxuryItems = function () { var luxuryItemsData = [{ name: 'Small House', assetId: 'luxuryHouse', cost: 50000, description: 'A cozy starter home' }, { name: 'Sports Car', assetId: 'luxuryCar', cost: 100000, description: 'Fast and flashy' }, { name: 'Yacht', assetId: 'luxuryShip', cost: 500000, description: 'Luxury on the water' }, { name: 'Mansion', assetId: 'luxuryMansion', cost: 2000000, description: 'Ultimate luxury living' }, { name: 'Super Yacht', assetId: 'luxuryYacht', cost: 10000000, description: 'The pinnacle of maritime luxury' }, { name: 'Private Jet', assetId: 'luxuryJet', cost: 50000000, description: 'Travel in ultimate style' }]; for (var i = 0; i < luxuryItemsData.length; i++) { var data = luxuryItemsData[i]; var item = new LuxuryItem(data.name, data.assetId, data.cost, data.description); var col = i % 3; var row = Math.floor(i / 3); item.x = 300 + col * 450; item.y = 400 + row * 400; self.addChild(item); self.luxuryItems.push(item); } }; self.loadOwnedItems = function () { var ownedItems = storage.ownedLuxuryItems || {}; for (var i = 0; i < self.luxuryItems.length; i++) { var item = self.luxuryItems[i]; if (ownedItems[item.name]) { item.owned = true; item.ownedText.visible = true; item.visual.alpha = 0.7; item.costText.visible = false; } } }; return self; }); var MultiplierButtons = Container.expand(function () { var self = Container.call(this); self.multiplierButtons = []; var multiplierValues = [1, 5, 10, 100, 'All']; // Create multiplier buttons for (var i = 0; i < multiplierValues.length; i++) { var multiplier = multiplierValues[i]; var btn = new Container(); var bg = LK.getAsset('box', { width: 120, height: 60, color: multiplier === 1 ? 0x2E8B57 : 0x666666, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); btn.addChild(bg); var text = new Text2(multiplier + 'x', { size: 30, fill: 0xFFFFFF }); text.anchor.set(0.5, 0.5); btn.addChild(text); btn.x = (i - 2) * 140; // Center the buttons btn.multiplierValue = multiplier; btn.bg = bg; btn.down = function (x, y, obj) { // Reset all buttons to inactive color self.multiplierButtons.forEach(function (button) { button.bg.tint = 0x666666; }); // Set this button to active color this.bg.tint = 0x2E8B57; purchaseMultiplier = this.multiplierValue; updateUI(); }; self.addChild(btn); self.multiplierButtons.push(btn); } return self; }); var UpgradeButton = Container.expand(function (text, cost, onPurchase, isRepeatable) { var self = Container.call(this); self.cost = cost; self.onPurchase = onPurchase; self.purchased = false; self.isRepeatable = isRepeatable || false; self.baseText = text; // Background var bg = LK.getAsset('box', { width: 600, height: 120, color: 0x2E8B57, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.addChild(bg); // Text self.buttonText = new Text2(text + ' - $' + formatNumber(cost), { size: 48, fill: 0xFFFFFF }); self.buttonText.anchor.set(0.5, 0.5); self.addChild(self.buttonText); self.down = function (x, y, obj) { if (!self.purchased && currency >= self.cost) { currency -= self.cost; if (self.isRepeatable) { self.onPurchase(); } else { self.purchased = true; self.onPurchase(); self.buttonText.setText(self.baseText + ' - PURCHASED'); bg.tint = 0x666666; } LK.getSound('purchase').play(); updateUI(); } }; self.updateAffordability = function () { if (!self.purchased) { if (currency >= self.cost) { bg.tint = 0x2E8B57; // Green - affordable } else { bg.tint = 0x8B0000; // Dark red - not affordable } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1E1E1E }); /**** * Game Code ****/ // Initialize background elements // Luxury items assets var backgroundElements = new BackgroundElements(); game.addChild(backgroundElements); // Game state variables var currency = storage.currency || 0; var tapPower = storage.tapPower || 1; var totalEarned = storage.totalEarned || 0; var prestigePoints = storage.prestigePoints || 0; var tapUpgradePurchases = storage.tapUpgradePurchases || 0; var purchaseMultiplier = 1; // Generators var generators = []; var factoryGen, workerGen, machineGen; // UI elements var currencyText, tapPowerText, prestigeText; var goldCoin; var upgradeButtons = []; // Initialize main gold coin goldCoin = game.attachAsset('goldCoin', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 700 }); // Add continuous spinning animation to the gold coin function startCoinSpin() { tween(goldCoin, { rotation: goldCoin.rotation + Math.PI * 2 }, { duration: 3000, easing: tween.linear, onFinish: function onFinish() { startCoinSpin(); // Restart the spin animation } }); } startCoinSpin(); // Coin tap effect goldCoin.down = function (x, y, obj) { // Add currency with prestige multiplier (50% per prestige point) var earnAmount = tapPower * (1 + prestigePoints * 0.5); currency += earnAmount; totalEarned += earnAmount; // Visual feedback tween(goldCoin, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, onFinish: function onFinish() { tween(goldCoin, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); // Show floating text in random position around the gold coin showFloatingText('+$' + formatNumber(earnAmount), goldCoin.x, goldCoin.y); LK.getSound('coinTap').play(); updateUI(); saveGame(); }; // Initialize generators factoryGen = new Generator('factory', 100, 1); factoryGen.x = 300; factoryGen.y = 1400; game.addChild(factoryGen); generators.push(factoryGen); workerGen = new Generator('worker', 1000, 10); workerGen.x = 1024; workerGen.y = 1400; game.addChild(workerGen); generators.push(workerGen); machineGen = new Generator('machine', 10000, 100); machineGen.x = 1748; machineGen.y = 1400; game.addChild(machineGen); generators.push(machineGen); // Add new generator types var officeGen = new Generator('office', 100000, 1000); // Use unique office asset officeGen.x = 300; officeGen.y = 1700; game.addChild(officeGen); generators.push(officeGen); var labGen = new Generator('laboratory', 1000000, 10000); // Use unique laboratory asset labGen.x = 1024; labGen.y = 1700; game.addChild(labGen); generators.push(labGen); var hqGen = new Generator('headquarters', 10000000, 100000); // Use unique headquarters asset hqGen.x = 1748; hqGen.y = 1700; game.addChild(hqGen); generators.push(hqGen); // Load generator levels from storage factoryGen.level = storage.factoryLevel || 0; workerGen.level = storage.workerLevel || 0; machineGen.level = storage.machineLevel || 0; officeGen.level = storage.officeLevel || 0; labGen.level = storage.labLevel || 0; hqGen.level = storage.hqLevel || 0; // Update generator visuals generators.forEach(function (gen) { gen.levelText.setText('Lv.' + gen.level); gen.lastIncomeTime = Date.now(); }); // Generator purchase handlers factoryGen.down = function (x, y, obj) { var maxAffordable = getMaxAffordablePurchases(factoryGen.baseCost, factoryGen.level); var purchaseInfo = calculateMultiplePurchaseCost(factoryGen.baseCost, factoryGen.level, purchaseMultiplier, maxAffordable); if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && factoryGen.level < 200) { currency -= purchaseInfo.cost; for (var i = 0; i < purchaseInfo.purchases; i++) { if (factoryGen.level < 200) { factoryGen.upgrade(); } } updateUI(); saveGame(); } }; workerGen.down = function (x, y, obj) { var maxAffordable = getMaxAffordablePurchases(workerGen.baseCost, workerGen.level); var purchaseInfo = calculateMultiplePurchaseCost(workerGen.baseCost, workerGen.level, purchaseMultiplier, maxAffordable); if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && workerGen.level < 200) { currency -= purchaseInfo.cost; for (var i = 0; i < purchaseInfo.purchases; i++) { if (workerGen.level < 200) { workerGen.upgrade(); } } updateUI(); saveGame(); } }; machineGen.down = function (x, y, obj) { var maxAffordable = getMaxAffordablePurchases(machineGen.baseCost, machineGen.level); var purchaseInfo = calculateMultiplePurchaseCost(machineGen.baseCost, machineGen.level, purchaseMultiplier, maxAffordable); if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && machineGen.level < 200) { currency -= purchaseInfo.cost; for (var i = 0; i < purchaseInfo.purchases; i++) { if (machineGen.level < 200) { machineGen.upgrade(); } } updateUI(); saveGame(); } }; officeGen.down = function (x, y, obj) { var maxAffordable = getMaxAffordablePurchases(officeGen.baseCost, officeGen.level); var purchaseInfo = calculateMultiplePurchaseCost(officeGen.baseCost, officeGen.level, purchaseMultiplier, maxAffordable); if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && officeGen.level < 200) { currency -= purchaseInfo.cost; for (var i = 0; i < purchaseInfo.purchases; i++) { if (officeGen.level < 200) { officeGen.upgrade(); } } updateUI(); saveGame(); } }; labGen.down = function (x, y, obj) { var maxAffordable = getMaxAffordablePurchases(labGen.baseCost, labGen.level); var purchaseInfo = calculateMultiplePurchaseCost(labGen.baseCost, labGen.level, purchaseMultiplier, maxAffordable); if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && labGen.level < 200) { currency -= purchaseInfo.cost; for (var i = 0; i < purchaseInfo.purchases; i++) { if (labGen.level < 200) { labGen.upgrade(); } } updateUI(); saveGame(); } }; hqGen.down = function (x, y, obj) { var maxAffordable = getMaxAffordablePurchases(hqGen.baseCost, hqGen.level); var purchaseInfo = calculateMultiplePurchaseCost(hqGen.baseCost, hqGen.level, purchaseMultiplier, maxAffordable); if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && hqGen.level < 200) { currency -= purchaseInfo.cost; for (var i = 0; i < purchaseInfo.purchases; i++) { if (hqGen.level < 200) { hqGen.upgrade(); } } updateUI(); saveGame(); } }; // UI Setup currencyText = new Text2('$0', { size: 80, fill: 0xFFD700 }); currencyText.anchor.set(0.5, 0); LK.gui.top.addChild(currencyText); currencyText.y = 50; tapPowerText = new Text2('Tap Power: $1', { size: 50, fill: 0xFFFFFF }); tapPowerText.anchor.set(0, 0); tapPowerText.x = 50; tapPowerText.y = 200; game.addChild(tapPowerText); prestigeText = new Text2('Prestige Points: 0', { size: 40, fill: 0xFF69B4 }); prestigeText.anchor.set(1, 0); prestigeText.x = 1998; prestigeText.y = 200; game.addChild(prestigeText); // Passive income display var passiveIncomeText = new Text2('Passive Income: $0/s', { size: 45, fill: 0x90EE90 }); passiveIncomeText.anchor.set(0.5, 0); passiveIncomeText.x = 1024; passiveIncomeText.y = 200; game.addChild(passiveIncomeText); // Auto tap rate display var autoTapRateText = new Text2('Auto Taps: 0/s', { size: 45, fill: 0x87CEEB }); autoTapRateText.anchor.set(0.5, 0); autoTapRateText.x = 1024; autoTapRateText.y = 300; game.addChild(autoTapRateText); // Multiplier selection buttons var multiplierContainer = new MultiplierButtons(); multiplierContainer.x = 1024; multiplierContainer.y = 1100; game.addChild(multiplierContainer); var multiplierButtons = multiplierContainer.multiplierButtons; // Generator info texts var factoryInfoText = new Text2('Factory\nCost: $100\nIncome: $1/s', { size: 35, fill: 0xFFFFFF }); factoryInfoText.anchor.set(0.5, 1); factoryInfoText.x = 300; factoryInfoText.y = 1320; game.addChild(factoryInfoText); var workerInfoText = new Text2('Worker\nCost: $1K\nIncome: $10/s', { size: 35, fill: 0xFFFFFF }); workerInfoText.anchor.set(0.5, 1); workerInfoText.x = 1024; workerInfoText.y = 1320; game.addChild(workerInfoText); var machineInfoText = new Text2('Machine\nCost: $10K\nIncome: $100/s', { size: 35, fill: 0xFFFFFF }); machineInfoText.anchor.set(0.5, 1); machineInfoText.x = 1748; machineInfoText.y = 1320; game.addChild(machineInfoText); var officeInfoText = new Text2('Office\nCost: $100K\nIncome: $1K/s', { size: 35, fill: 0xFFFFFF }); officeInfoText.anchor.set(0.5, 1); officeInfoText.x = 300; officeInfoText.y = 1620; game.addChild(officeInfoText); var labInfoText = new Text2('Laboratory\nCost: $1M\nIncome: $10K/s', { size: 35, fill: 0xFFFFFF }); labInfoText.anchor.set(0.5, 1); labInfoText.x = 1024; labInfoText.y = 1620; game.addChild(labInfoText); var hqInfoText = new Text2('Headquarters\nCost: $10M\nIncome: $100K/s', { size: 35, fill: 0xFFFFFF }); hqInfoText.anchor.set(0.5, 1); hqInfoText.x = 1748; hqInfoText.y = 1620; game.addChild(hqInfoText); // Upgrade buttons function getTapUpgradeCost() { return 500 * Math.pow(1.9, tapUpgradePurchases); } var tapUpgradeBtn = new UpgradeButton('2x Tap Power', getTapUpgradeCost(), function () { tapPower *= 2; tapUpgradePurchases++; // Update button cost and text for next purchase tapUpgradeBtn.cost = getTapUpgradeCost(); tapUpgradeBtn.buttonText.setText('2x Tap Power - $' + formatNumber(tapUpgradeBtn.cost)); var bg = tapUpgradeBtn.children[0]; bg.tint = 0x2E8B57; updateUI(); saveGame(); }, true); tapUpgradeBtn.x = 1024; tapUpgradeBtn.y = 2100; game.addChild(tapUpgradeBtn); upgradeButtons.push(tapUpgradeBtn); // Auto tap upgrade tracking var autoTapUpgradePurchases = storage.autoTapUpgradePurchases || 0; var autoTapRate = storage.autoTapRate || 0; function getAutoTapUpgradeCost() { return 2000 * Math.pow(3, autoTapUpgradePurchases); } var autoTapBtn = new UpgradeButton('Auto Tap (+1/s)', getAutoTapUpgradeCost(), function () { autoTapEnabled = true; autoTapRate++; autoTapUpgradePurchases++; // Update button cost and text for next purchase autoTapBtn.cost = getAutoTapUpgradeCost(); autoTapBtn.buttonText.setText('Auto Tap (+1/s) - $' + formatNumber(autoTapBtn.cost)); var bg = autoTapBtn.children[0]; bg.tint = 0x2E8B57; updateUI(); saveGame(); }, true); autoTapBtn.x = 1024; autoTapBtn.y = 2280; game.addChild(autoTapBtn); upgradeButtons.push(autoTapBtn); // Global multiplier upgrades var globalMultiplierUpgrades = storage.globalMultiplierUpgrades || 0; function getGlobalMultiplierCost() { return 50000 * Math.pow(5, globalMultiplierUpgrades); } // Efficiency upgrades var efficiencyUpgrades = storage.efficiencyUpgrades || 0; function getEfficiencyUpgradeCost() { return 25000 * Math.pow(4, efficiencyUpgrades); } // Prestige button var prestigeBtn = new UpgradeButton('PRESTIGE (+1 PP)', 1000000, function () { prestige(); }); prestigeBtn.x = 1024; prestigeBtn.y = 2460; game.addChild(prestigeBtn); // Auto tap var autoTapEnabled = storage.autoTapEnabled || false; var autoTapTimer = 0; // Floating text system var floatingTexts = []; function showFloatingText(text, x, y) { // Generate random position around the gold coin var coinRadius = 250; // Distance from coin center var angle = Math.random() * Math.PI * 2; // Random angle var randomX = goldCoin.x + Math.cos(angle) * (coinRadius + Math.random() * 100); var randomY = goldCoin.y + Math.sin(angle) * (coinRadius + Math.random() * 100); var floatingText = new Text2(text, { size: 60, fill: 0xFFD700, stroke: 0x000000, strokeThickness: 4 }); floatingText.anchor.set(0.5, 0.5); floatingText.x = randomX; floatingText.y = randomY; floatingText.alpha = 1; game.addChild(floatingText); floatingTexts.push(floatingText); tween(floatingText, { y: randomY - 100, alpha: 0 }, { duration: 1500, onFinish: function onFinish() { floatingText.destroy(); var index = floatingTexts.indexOf(floatingText); if (index > -1) { floatingTexts.splice(index, 1); } } }); } function calculateMultiplePurchaseCost(baseCost, currentLevel, multiplier, maxAffordable) { if (multiplier === 'All') { var totalCost = 0; var level = currentLevel; var purchases = 0; while (totalCost + Math.floor(baseCost * Math.pow(1.15, level)) <= currency && purchases < maxAffordable && level < 200) { totalCost += Math.floor(baseCost * Math.pow(1.15, level)); level++; purchases++; } return { cost: totalCost, purchases: purchases }; } else { var totalCost = 0; var actualPurchases = Math.min(multiplier, maxAffordable, 200 - currentLevel); for (var i = 0; i < actualPurchases; i++) { totalCost += Math.floor(baseCost * Math.pow(1.15, currentLevel + i)); } return { cost: totalCost, purchases: actualPurchases }; } } function getMaxAffordablePurchases(baseCost, currentLevel) { var totalCost = 0; var level = currentLevel; var purchases = 0; while (totalCost + Math.floor(baseCost * Math.pow(1.15, level)) <= currency && level < 200) { totalCost += Math.floor(baseCost * Math.pow(1.15, level)); level++; purchases++; if (purchases >= 1000) break; // Prevent infinite loops } return purchases; } function formatNumber(num) { if (num < 0) return '-' + formatNumber(-num); if (num < 1000) return Math.floor(num).toString(); var abbreviations = [{ value: 1e303, suffix: 'Ce' }, // Centillion { value: 1e300, suffix: 'NeCe' }, // Novemnonagintillion { value: 1e297, suffix: 'OcNo' }, // Octooctogintillion { value: 1e294, suffix: 'SpNo' }, // Septenseptuagintillion { value: 1e291, suffix: 'SxNo' }, // Sexsexagintillion { value: 1e288, suffix: 'QiNo' }, // Quinquinquagintillion { value: 1e285, suffix: 'QaNo' }, // Quattuorquadragintillion { value: 1e282, suffix: 'TrNo' }, // Tretrigintillion { value: 1e279, suffix: 'DuNo' }, // Duovigintillion { value: 1e276, suffix: 'UnNo' }, // Unvigintillion { value: 1e273, suffix: 'No' }, // Novemvigintillion { value: 1e270, suffix: 'OcVg' }, // Octovigintillion { value: 1e267, suffix: 'SpVg' }, // Septenvigintillion { value: 1e264, suffix: 'SxVg' }, // Sexvigintillion { value: 1e261, suffix: 'QiVg' }, // Quinvigintillion { value: 1e258, suffix: 'QaVg' }, // Quattuorvigintillion { value: 1e255, suffix: 'TrVg' }, // Trevigintillion { value: 1e252, suffix: 'DuVg' }, // Duovigintillion { value: 1e249, suffix: 'UnVg' }, // Unvigintillion { value: 1e246, suffix: 'Vg' }, // Vigintillion { value: 1e243, suffix: 'NoNd' }, // Novemdeciillion { value: 1e240, suffix: 'OcNd' }, // Octodeciillion { value: 1e237, suffix: 'SpNd' }, // Septendeciillion { value: 1e234, suffix: 'SxNd' }, // Sexdeciillion { value: 1e231, suffix: 'QiNd' }, // Quindeciillion { value: 1e228, suffix: 'QaNd' }, // Quattuordeciillion { value: 1e225, suffix: 'TrNd' }, // Tredeciillion { value: 1e222, suffix: 'DuNd' }, // Duodeciillion { value: 1e219, suffix: 'UnNd' }, // Undeciillion { value: 1e216, suffix: 'Nd' }, // Deciillion { value: 1e213, suffix: 'NoOc' }, // Novemoctagintillion { value: 1e210, suffix: 'OcOc' }, // Octooctagintillion { value: 1e207, suffix: 'SpOc' }, // Septenoctagintillion { value: 1e204, suffix: 'SxOc' }, // Sexoctagintillion { value: 1e201, suffix: 'QiOc' }, // Quinoctagintillion { value: 1e198, suffix: 'QaOc' }, // Quattuoroctagintillion { value: 1e195, suffix: 'TrOc' }, // Treoctagintillion { value: 1e192, suffix: 'DuOc' }, // Duooctagintillion { value: 1e189, suffix: 'UnOc' }, // Unoctagintillion { value: 1e186, suffix: 'Oc' }, // Octagintillion { value: 1e183, suffix: 'NoSp' }, // Novemseptuagintillion { value: 1e180, suffix: 'OcSp' }, // Octoseptuagintillion { value: 1e177, suffix: 'SpSp' }, // Septenseptuagintillion { value: 1e174, suffix: 'SxSp' }, // Sexseptuagintillion { value: 1e171, suffix: 'QiSp' }, // Quinseptuagintillion { value: 1e168, suffix: 'QaSp' }, // Quattuorseptuagintillion { value: 1e165, suffix: 'TrSp' }, // Treseptuagintillion { value: 1e162, suffix: 'DuSp' }, // Duoseptuagintillion { value: 1e159, suffix: 'UnSp' }, // Unseptuagintillion { value: 1e156, suffix: 'Sp' }, // Septuagintillion { value: 1e153, suffix: 'NoSx' }, // Novemsexagintillion { value: 1e150, suffix: 'OcSx' }, // Octosexagintillion { value: 1e147, suffix: 'SpSx' }, // Septensexagintillion { value: 1e144, suffix: 'SxSx' }, // Sexsexagintillion { value: 1e141, suffix: 'QiSx' }, // Quinsexagintillion { value: 1e138, suffix: 'QaSx' }, // Quattuorsexagintillion { value: 1e135, suffix: 'TrSx' }, // Tresexagintillion { value: 1e132, suffix: 'DuSx' }, // Duosexagintillion { value: 1e129, suffix: 'UnSx' }, // Unsexagintillion { value: 1e126, suffix: 'Sx' }, // Sexagintillion { value: 1e123, suffix: 'NoQi' }, // Novemquinquagintillion { value: 1e120, suffix: 'OcQi' }, // Octoquinquagintillion { value: 1e117, suffix: 'SpQi' }, // Septenquinquagintillion { value: 1e114, suffix: 'SxQi' }, // Sexquinquagintillion { value: 1e111, suffix: 'QiQi' }, // Quinquinquagintillion { value: 1e108, suffix: 'QaQi' }, // Quattuorquinquagintillion { value: 1e105, suffix: 'TrQi' }, // Trequinquagintillion { value: 1e102, suffix: 'DuQi' }, // Duoquinquagintillion { value: 1e99, suffix: 'UnQi' }, // Unquinquagintillion { value: 1e96, suffix: 'Qi' }, // Quinquagintillion { value: 1e93, suffix: 'NoQa' }, // Novemquadragintillion { value: 1e90, suffix: 'OcQa' }, // Octoquadragintillion { value: 1e87, suffix: 'SpQa' }, // Septenquadragintillion { value: 1e84, suffix: 'SxQa' }, // Sexquadragintillion { value: 1e81, suffix: 'QiQa' }, // Quinquadragintillion { value: 1e78, suffix: 'QaQa' }, // Quattuorquadragintillion { value: 1e75, suffix: 'TrQa' }, // Trequadragintillion { value: 1e72, suffix: 'DuQa' }, // Duoquadragintillion { value: 1e69, suffix: 'UnQa' }, // Unquadragintillion { value: 1e66, suffix: 'Qa' }, // Quadragintillion { value: 1e63, suffix: 'Vg' }, // Vigintillion { value: 1e60, suffix: 'Nd' }, // Novemdecillion { value: 1e57, suffix: 'Od' }, // Octodecillion { value: 1e54, suffix: 'Sd' }, // Septendecillion { value: 1e51, suffix: 'Sxd' }, // Sexdecillion { value: 1e48, suffix: 'Qid' }, // Quindecillion { value: 1e45, suffix: 'Qad' }, // Quattuordecillion { value: 1e42, suffix: 'Td' }, // Tredecillion { value: 1e39, suffix: 'Dd' }, // Duodecillion { value: 1e36, suffix: 'Ud' }, // Undecillion { value: 1e33, suffix: 'Dc' }, // Decillion { value: 1e30, suffix: 'No' }, // Nonillion { value: 1e27, suffix: 'Oc' }, // Octillion { value: 1e24, suffix: 'Sp' }, // Septillion { value: 1e21, suffix: 'Sx' }, // Sextillion { value: 1e18, suffix: 'Qi' }, // Quintillion { value: 1e15, suffix: 'Qa' }, // Quadrillion { value: 1e12, suffix: 'T' }, // Trillion { value: 1e9, suffix: 'B' }, // Billion { value: 1e6, suffix: 'M' }, // Million { value: 1e3, suffix: 'K' } // Thousand ]; for (var i = 0; i < abbreviations.length; i++) { if (num >= abbreviations[i].value) { var result = num / abbreviations[i].value; if (result >= 100) { return Math.floor(result).toString() + abbreviations[i].suffix; } else if (result >= 10) { return result.toFixed(1) + abbreviations[i].suffix; } else { return result.toFixed(2) + abbreviations[i].suffix; } } } return Math.floor(num).toString(); } function updateUI() { currencyText.setText('$' + formatNumber(currency)); tapPowerText.setText('Tap Power: $' + formatNumber(tapPower)); prestigeText.setText('Prestige Points: ' + prestigePoints); // Calculate total passive income from all generators var totalPassiveIncome = 0; generators.forEach(function (gen) { totalPassiveIncome += gen.getIncome(); }); passiveIncomeText.setText('Passive Income: $' + formatNumber(totalPassiveIncome) + '/s'); autoTapRateText.setText('Auto Taps: ' + (autoTapRate || 0) + '/s'); // Update generator info with multiplier costs var factoryMaxAffordable = getMaxAffordablePurchases(factoryGen.baseCost, factoryGen.level); var factoryPurchaseInfo = calculateMultiplePurchaseCost(factoryGen.baseCost, factoryGen.level, purchaseMultiplier, factoryMaxAffordable); factoryInfoText.setText('Factory (Lv.' + factoryGen.level + ')\nCost: $' + formatNumber(factoryPurchaseInfo.cost) + ' (' + factoryPurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(factoryGen.getIncome()) + '/s'); factoryInfoText.tint = currency >= factoryPurchaseInfo.cost && factoryPurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B; var workerMaxAffordable = getMaxAffordablePurchases(workerGen.baseCost, workerGen.level); var workerPurchaseInfo = calculateMultiplePurchaseCost(workerGen.baseCost, workerGen.level, purchaseMultiplier, workerMaxAffordable); workerInfoText.setText('Worker (Lv.' + workerGen.level + ')\nCost: $' + formatNumber(workerPurchaseInfo.cost) + ' (' + workerPurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(workerGen.getIncome()) + '/s'); workerInfoText.tint = currency >= workerPurchaseInfo.cost && workerPurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B; var machineMaxAffordable = getMaxAffordablePurchases(machineGen.baseCost, machineGen.level); var machinePurchaseInfo = calculateMultiplePurchaseCost(machineGen.baseCost, machineGen.level, purchaseMultiplier, machineMaxAffordable); machineInfoText.setText('Machine (Lv.' + machineGen.level + ')\nCost: $' + formatNumber(machinePurchaseInfo.cost) + ' (' + machinePurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(machineGen.getIncome()) + '/s'); machineInfoText.tint = currency >= machinePurchaseInfo.cost && machinePurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B; var officeMaxAffordable = getMaxAffordablePurchases(officeGen.baseCost, officeGen.level); var officePurchaseInfo = calculateMultiplePurchaseCost(officeGen.baseCost, officeGen.level, purchaseMultiplier, officeMaxAffordable); officeInfoText.setText('Office (Lv.' + officeGen.level + ')\nCost: $' + formatNumber(officePurchaseInfo.cost) + ' (' + officePurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(officeGen.getIncome()) + '/s'); officeInfoText.tint = currency >= officePurchaseInfo.cost && officePurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B; var labMaxAffordable = getMaxAffordablePurchases(labGen.baseCost, labGen.level); var labPurchaseInfo = calculateMultiplePurchaseCost(labGen.baseCost, labGen.level, purchaseMultiplier, labMaxAffordable); labInfoText.setText('Laboratory (Lv.' + labGen.level + ')\nCost: $' + formatNumber(labPurchaseInfo.cost) + ' (' + labPurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(labGen.getIncome()) + '/s'); labInfoText.tint = currency >= labPurchaseInfo.cost && labPurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B; var hqMaxAffordable = getMaxAffordablePurchases(hqGen.baseCost, hqGen.level); var hqPurchaseInfo = calculateMultiplePurchaseCost(hqGen.baseCost, hqGen.level, purchaseMultiplier, hqMaxAffordable); hqInfoText.setText('Headquarters (Lv.' + hqGen.level + ')\nCost: $' + formatNumber(hqPurchaseInfo.cost) + ' (' + hqPurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(hqGen.getIncome()) + '/s'); hqInfoText.tint = currency >= hqPurchaseInfo.cost && hqPurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B; // Update upgrade button affordability upgradeButtons.forEach(function (btn) { btn.updateAffordability(); }); // Update prestige button if (totalEarned >= 1000000) { prestigeBtn.updateAffordability(); } } function saveGame() { storage.currency = currency; storage.tapPower = tapPower; storage.totalEarned = totalEarned; storage.prestigePoints = prestigePoints; storage.factoryLevel = factoryGen.level; storage.workerLevel = workerGen.level; storage.machineLevel = machineGen.level; storage.officeLevel = officeGen.level; storage.labLevel = labGen.level; storage.hqLevel = hqGen.level; storage.autoTapEnabled = autoTapEnabled; storage.tapUpgradePurchases = tapUpgradePurchases; storage.autoTapUpgradePurchases = autoTapUpgradePurchases; storage.autoTapRate = autoTapRate; storage.globalMultiplierUpgrades = globalMultiplierUpgrades; storage.efficiencyUpgrades = efficiencyUpgrades; saveLuxuryItems(); } function prestige() { if (totalEarned >= 1000000) { prestigePoints++; currency = 0; tapPower = 1; totalEarned = 0; tapUpgradePurchases = 0; autoTapUpgradePurchases = 0; autoTapRate = 0; globalMultiplierUpgrades = 0; efficiencyUpgrades = 0; // Reset generators generators.forEach(function (gen) { gen.level = 0; gen.levelText.setText('Lv.0'); }); // Reset upgrades upgradeButtons.forEach(function (btn) { btn.purchased = false; if (btn === tapUpgradeBtn) { btn.cost = getTapUpgradeCost(); btn.buttonText.setText('2x Tap Power - $' + formatNumber(btn.cost)); } else if (btn === autoTapBtn) { btn.cost = getAutoTapUpgradeCost(); btn.buttonText.setText('Auto Tap (+1/s) - $' + formatNumber(btn.cost)); } else if (!btn.isRepeatable) { btn.buttonText.setText(btn.baseText + ' - $' + formatNumber(btn.cost)); } }); autoTapEnabled = false; updateUI(); saveGame(); showFloatingText('PRESTIGE! +1 PP', 1024, 1366); } } // Handle offline earnings var lastSaveTime = storage.lastSaveTime || Date.now(); var offlineTime = (Date.now() - lastSaveTime) / 1000; // seconds if (offlineTime > 60) { // Only if offline for more than 1 minute var offlineEarnings = 0; generators.forEach(function (gen) { offlineEarnings += gen.getIncome() * Math.min(offlineTime, 3600); // Cap at 1 hour }); if (offlineEarnings > 0) { currency += offlineEarnings; totalEarned += offlineEarnings; showFloatingText('Offline Earnings: +$' + formatNumber(offlineEarnings), 1024, 600); } } // Add click handler for instant coin calculation game.down = function (x, y, obj) { // Check if click is in the right side of screen, under prestige text if (x > 1500 && y > 250 && y < 800) { // Calculate total coins earned instantly var instantEarnings = totalEarned; showFloatingText('Total Earned: $' + formatNumber(instantEarnings), x, y); } }; // Create luxury tab var luxuryTab = new LuxuryTab(); luxuryTab.initializeLuxuryItems(); luxuryTab.loadOwnedItems(); game.addChild(luxuryTab); // Create luxury tab button var luxuryTabButton = LK.getAsset('box', { width: 200, height: 80, color: 0xFFD700, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); luxuryTabButton.x = 200; luxuryTabButton.y = 320; game.addChild(luxuryTabButton); var luxuryButtonText = new Text2('LUXURY', { size: 60, fill: 0x000000 }); luxuryButtonText.anchor.set(0.5, 0.5); luxuryButtonText.x = 200; luxuryButtonText.y = 320; game.addChild(luxuryButtonText); luxuryTabButton.down = function (x, y, obj) { luxuryTab.visible = true; }; // Save luxury items function function saveLuxuryItems() { var ownedItems = {}; for (var i = 0; i < luxuryTab.luxuryItems.length; i++) { var item = luxuryTab.luxuryItems[i]; if (item.owned) { ownedItems[item.name] = true; } } storage.ownedLuxuryItems = ownedItems; } // Confetti explosion function function createConfettiExplosion() { var confettiPieces = []; var centerX = 1024; var centerY = 1366; for (var i = 0; i < 30; i++) { var confetti = LK.getAsset('box', { width: 20, height: 20, color: Math.random() > 0.5 ? 0xFFD700 : Math.random() > 0.5 ? 0xFF69B4 : 0x00FF00, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); confetti.x = centerX; confetti.y = centerY; confetti.rotation = Math.random() * Math.PI * 2; game.addChild(confetti); confettiPieces.push(confetti); // Random direction and distance var angle = Math.random() * Math.PI * 2; var distance = 200 + Math.random() * 300; var targetX = centerX + Math.cos(angle) * distance; var targetY = centerY + Math.sin(angle) * distance; // Animate confetti piece tween(confetti, { x: targetX, y: targetY, rotation: confetti.rotation + Math.PI * 4, alpha: 0 }, { duration: 2000 + Math.random() * 1000, easing: tween.easeOut, onFinish: function onFinish() { confetti.destroy(); } }); } } // Initial UI update updateUI(); // Game loop game.update = function () { // Generate passive income generators.forEach(function (gen) { var income = gen.generateIncome(); if (income > 0) { // Apply global multipliers and efficiency bonuses var globalMultiplier = Math.pow(2, globalMultiplierUpgrades); var efficiencyMultiplier = 1 + efficiencyUpgrades * 0.25; var prestigeMultiplier = 1 + prestigePoints * 0.1; var finalIncome = income * globalMultiplier * efficiencyMultiplier * prestigeMultiplier; currency += finalIncome; totalEarned += finalIncome; } }); // Auto tap if (autoTapEnabled && autoTapRate > 0) { autoTapTimer++; if (autoTapTimer >= Math.floor(60 / autoTapRate)) { // Frequency based on auto tap rate var earnAmount = tapPower * (1 + prestigePoints * 0.5); currency += earnAmount; totalEarned += earnAmount; autoTapTimer = 0; } } // Update UI every 30 frames (twice per second) if (LK.ticks % 30 === 0) { updateUI(); } // Save game every 5 seconds if (LK.ticks % 300 === 0) { storage.lastSaveTime = Date.now(); saveGame(); } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BackgroundElements = Container.expand(function () {
var self = Container.call(this);
// Create gradient background for business empire theme
self.backgroundGradient = LK.getAsset('box', {
width: 2048,
height: 2732,
color: 0x1a1a2e,
shape: 'box',
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
self.addChild(self.backgroundGradient);
// Add subtle pattern overlay
self.patternOverlay = LK.getAsset('box', {
width: 2048,
height: 2732,
color: 0x16213e,
shape: 'box',
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
self.patternOverlay.alpha = 0.3;
self.addChild(self.patternOverlay);
// Add golden accent elements for empire feel
self.topAccent = LK.getAsset('box', {
width: 2048,
height: 8,
color: 0xFFD700,
shape: 'box',
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
self.addChild(self.topAccent);
self.bottomAccent = LK.getAsset('box', {
width: 2048,
height: 8,
color: 0xFFD700,
shape: 'box',
anchorX: 0,
anchorY: 0,
x: 0,
y: 2724
});
self.addChild(self.bottomAccent);
return self;
});
var Generator = Container.expand(function (type, baseCost, baseIncome) {
var self = Container.call(this);
self.type = type;
self.baseCost = baseCost;
self.baseIncome = baseIncome;
self.level = 0;
self.lastIncomeTime = Date.now();
// Create visual representation
var visual = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
// Add level text
self.levelText = new Text2('Lv.0', {
size: 40,
fill: 0xFFFFFF
});
self.levelText.anchor.set(0.5, 0);
self.levelText.x = 0;
self.levelText.y = visual.height / 2 + 10;
self.addChild(self.levelText);
self.getCost = function () {
return Math.floor(self.baseCost * Math.pow(1.15, self.level));
};
self.getIncome = function () {
var baseIncome = self.baseIncome * self.level;
if (baseIncome > 0) {
// Apply global multipliers and efficiency bonuses
var globalMultiplier = Math.pow(2, globalMultiplierUpgrades || 0);
var efficiencyMultiplier = 1 + (efficiencyUpgrades || 0) * 0.25;
var prestigeMultiplier = 1 + (prestigePoints || 0) * 0.1;
return baseIncome * globalMultiplier * efficiencyMultiplier * prestigeMultiplier;
}
return baseIncome;
};
self.upgrade = function () {
if (self.level < 200) {
self.level++;
self.levelText.setText('Lv.' + self.level);
LK.getSound('upgrade').play();
}
};
self.generateIncome = function () {
if (self.level > 0) {
var now = Date.now();
var timeDiff = (now - self.lastIncomeTime) / 1000; // Convert to seconds
var income = self.getIncome() * timeDiff;
self.lastIncomeTime = now;
return income;
}
return 0;
};
return self;
});
var LuxuryItem = Container.expand(function (name, assetId, cost, description) {
var self = Container.call(this);
self.name = name;
self.assetId = assetId;
self.cost = cost;
self.description = description;
self.owned = false;
// Create visual representation
self.visual = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
// Add name text
self.nameText = new Text2(name, {
size: 30,
fill: 0xFFFFFF
});
self.nameText.anchor.set(0.5, 0);
self.nameText.x = 0;
self.nameText.y = self.visual.height / 2 + 10;
self.addChild(self.nameText);
// Add cost text
self.costText = new Text2('$' + formatNumber(cost), {
size: 25,
fill: 0xFFD700
});
self.costText.anchor.set(0.5, 0);
self.costText.x = 0;
self.costText.y = self.visual.height / 2 + 50;
self.addChild(self.costText);
// Add owned indicator
self.ownedText = new Text2('OWNED', {
size: 20,
fill: 0x00FF00
});
self.ownedText.anchor.set(0.5, 0.5);
self.ownedText.x = 0;
self.ownedText.y = -self.visual.height / 2 - 20;
self.ownedText.visible = false;
self.addChild(self.ownedText);
self.purchase = function () {
if (!self.owned && currency >= self.cost) {
currency -= self.cost;
self.owned = true;
self.ownedText.visible = true;
self.visual.alpha = 0.7;
self.costText.visible = false;
LK.getSound('purchase').play();
updateUI();
saveLuxuryItems();
// Check if all luxury items are now owned
var allItemsOwned = true;
for (var i = 0; i < luxuryTab.luxuryItems.length; i++) {
if (!luxuryTab.luxuryItems[i].owned) {
allItemsOwned = false;
break;
}
}
if (allItemsOwned) {
createConfettiExplosion();
}
return true;
}
return false;
};
self.down = function (x, y, obj) {
self.purchase();
};
return self;
});
var LuxuryTab = Container.expand(function () {
var self = Container.call(this);
self.visible = false;
self.luxuryItems = [];
// Create background
self.background = LK.getAsset('box', {
width: 2048,
height: 2732,
color: 0x2a2a3e,
shape: 'box',
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
self.addChild(self.background);
// Create title
self.titleText = new Text2('LUXURY ITEMS', {
size: 80,
fill: 0xFFD700
});
self.titleText.anchor.set(0.5, 0);
self.titleText.x = 1024;
self.titleText.y = 150;
self.addChild(self.titleText);
// Create close button
self.closeButton = new Text2('CLOSE', {
size: 50,
fill: 0xFF0000
});
self.closeButton.anchor.set(1, 0);
self.closeButton.x = 1998;
self.closeButton.y = 50;
self.addChild(self.closeButton);
self.closeButton.down = function (x, y, obj) {
self.visible = false;
};
// Initialize luxury items
self.initializeLuxuryItems = function () {
var luxuryItemsData = [{
name: 'Small House',
assetId: 'luxuryHouse',
cost: 50000,
description: 'A cozy starter home'
}, {
name: 'Sports Car',
assetId: 'luxuryCar',
cost: 100000,
description: 'Fast and flashy'
}, {
name: 'Yacht',
assetId: 'luxuryShip',
cost: 500000,
description: 'Luxury on the water'
}, {
name: 'Mansion',
assetId: 'luxuryMansion',
cost: 2000000,
description: 'Ultimate luxury living'
}, {
name: 'Super Yacht',
assetId: 'luxuryYacht',
cost: 10000000,
description: 'The pinnacle of maritime luxury'
}, {
name: 'Private Jet',
assetId: 'luxuryJet',
cost: 50000000,
description: 'Travel in ultimate style'
}];
for (var i = 0; i < luxuryItemsData.length; i++) {
var data = luxuryItemsData[i];
var item = new LuxuryItem(data.name, data.assetId, data.cost, data.description);
var col = i % 3;
var row = Math.floor(i / 3);
item.x = 300 + col * 450;
item.y = 400 + row * 400;
self.addChild(item);
self.luxuryItems.push(item);
}
};
self.loadOwnedItems = function () {
var ownedItems = storage.ownedLuxuryItems || {};
for (var i = 0; i < self.luxuryItems.length; i++) {
var item = self.luxuryItems[i];
if (ownedItems[item.name]) {
item.owned = true;
item.ownedText.visible = true;
item.visual.alpha = 0.7;
item.costText.visible = false;
}
}
};
return self;
});
var MultiplierButtons = Container.expand(function () {
var self = Container.call(this);
self.multiplierButtons = [];
var multiplierValues = [1, 5, 10, 100, 'All'];
// Create multiplier buttons
for (var i = 0; i < multiplierValues.length; i++) {
var multiplier = multiplierValues[i];
var btn = new Container();
var bg = LK.getAsset('box', {
width: 120,
height: 60,
color: multiplier === 1 ? 0x2E8B57 : 0x666666,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
btn.addChild(bg);
var text = new Text2(multiplier + 'x', {
size: 30,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
btn.addChild(text);
btn.x = (i - 2) * 140; // Center the buttons
btn.multiplierValue = multiplier;
btn.bg = bg;
btn.down = function (x, y, obj) {
// Reset all buttons to inactive color
self.multiplierButtons.forEach(function (button) {
button.bg.tint = 0x666666;
});
// Set this button to active color
this.bg.tint = 0x2E8B57;
purchaseMultiplier = this.multiplierValue;
updateUI();
};
self.addChild(btn);
self.multiplierButtons.push(btn);
}
return self;
});
var UpgradeButton = Container.expand(function (text, cost, onPurchase, isRepeatable) {
var self = Container.call(this);
self.cost = cost;
self.onPurchase = onPurchase;
self.purchased = false;
self.isRepeatable = isRepeatable || false;
self.baseText = text;
// Background
var bg = LK.getAsset('box', {
width: 600,
height: 120,
color: 0x2E8B57,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(bg);
// Text
self.buttonText = new Text2(text + ' - $' + formatNumber(cost), {
size: 48,
fill: 0xFFFFFF
});
self.buttonText.anchor.set(0.5, 0.5);
self.addChild(self.buttonText);
self.down = function (x, y, obj) {
if (!self.purchased && currency >= self.cost) {
currency -= self.cost;
if (self.isRepeatable) {
self.onPurchase();
} else {
self.purchased = true;
self.onPurchase();
self.buttonText.setText(self.baseText + ' - PURCHASED');
bg.tint = 0x666666;
}
LK.getSound('purchase').play();
updateUI();
}
};
self.updateAffordability = function () {
if (!self.purchased) {
if (currency >= self.cost) {
bg.tint = 0x2E8B57; // Green - affordable
} else {
bg.tint = 0x8B0000; // Dark red - not affordable
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1E1E1E
});
/****
* Game Code
****/
// Initialize background elements
// Luxury items assets
var backgroundElements = new BackgroundElements();
game.addChild(backgroundElements);
// Game state variables
var currency = storage.currency || 0;
var tapPower = storage.tapPower || 1;
var totalEarned = storage.totalEarned || 0;
var prestigePoints = storage.prestigePoints || 0;
var tapUpgradePurchases = storage.tapUpgradePurchases || 0;
var purchaseMultiplier = 1;
// Generators
var generators = [];
var factoryGen, workerGen, machineGen;
// UI elements
var currencyText, tapPowerText, prestigeText;
var goldCoin;
var upgradeButtons = [];
// Initialize main gold coin
goldCoin = game.attachAsset('goldCoin', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 700
});
// Add continuous spinning animation to the gold coin
function startCoinSpin() {
tween(goldCoin, {
rotation: goldCoin.rotation + Math.PI * 2
}, {
duration: 3000,
easing: tween.linear,
onFinish: function onFinish() {
startCoinSpin(); // Restart the spin animation
}
});
}
startCoinSpin();
// Coin tap effect
goldCoin.down = function (x, y, obj) {
// Add currency with prestige multiplier (50% per prestige point)
var earnAmount = tapPower * (1 + prestigePoints * 0.5);
currency += earnAmount;
totalEarned += earnAmount;
// Visual feedback
tween(goldCoin, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
onFinish: function onFinish() {
tween(goldCoin, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
// Show floating text in random position around the gold coin
showFloatingText('+$' + formatNumber(earnAmount), goldCoin.x, goldCoin.y);
LK.getSound('coinTap').play();
updateUI();
saveGame();
};
// Initialize generators
factoryGen = new Generator('factory', 100, 1);
factoryGen.x = 300;
factoryGen.y = 1400;
game.addChild(factoryGen);
generators.push(factoryGen);
workerGen = new Generator('worker', 1000, 10);
workerGen.x = 1024;
workerGen.y = 1400;
game.addChild(workerGen);
generators.push(workerGen);
machineGen = new Generator('machine', 10000, 100);
machineGen.x = 1748;
machineGen.y = 1400;
game.addChild(machineGen);
generators.push(machineGen);
// Add new generator types
var officeGen = new Generator('office', 100000, 1000); // Use unique office asset
officeGen.x = 300;
officeGen.y = 1700;
game.addChild(officeGen);
generators.push(officeGen);
var labGen = new Generator('laboratory', 1000000, 10000); // Use unique laboratory asset
labGen.x = 1024;
labGen.y = 1700;
game.addChild(labGen);
generators.push(labGen);
var hqGen = new Generator('headquarters', 10000000, 100000); // Use unique headquarters asset
hqGen.x = 1748;
hqGen.y = 1700;
game.addChild(hqGen);
generators.push(hqGen);
// Load generator levels from storage
factoryGen.level = storage.factoryLevel || 0;
workerGen.level = storage.workerLevel || 0;
machineGen.level = storage.machineLevel || 0;
officeGen.level = storage.officeLevel || 0;
labGen.level = storage.labLevel || 0;
hqGen.level = storage.hqLevel || 0;
// Update generator visuals
generators.forEach(function (gen) {
gen.levelText.setText('Lv.' + gen.level);
gen.lastIncomeTime = Date.now();
});
// Generator purchase handlers
factoryGen.down = function (x, y, obj) {
var maxAffordable = getMaxAffordablePurchases(factoryGen.baseCost, factoryGen.level);
var purchaseInfo = calculateMultiplePurchaseCost(factoryGen.baseCost, factoryGen.level, purchaseMultiplier, maxAffordable);
if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && factoryGen.level < 200) {
currency -= purchaseInfo.cost;
for (var i = 0; i < purchaseInfo.purchases; i++) {
if (factoryGen.level < 200) {
factoryGen.upgrade();
}
}
updateUI();
saveGame();
}
};
workerGen.down = function (x, y, obj) {
var maxAffordable = getMaxAffordablePurchases(workerGen.baseCost, workerGen.level);
var purchaseInfo = calculateMultiplePurchaseCost(workerGen.baseCost, workerGen.level, purchaseMultiplier, maxAffordable);
if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && workerGen.level < 200) {
currency -= purchaseInfo.cost;
for (var i = 0; i < purchaseInfo.purchases; i++) {
if (workerGen.level < 200) {
workerGen.upgrade();
}
}
updateUI();
saveGame();
}
};
machineGen.down = function (x, y, obj) {
var maxAffordable = getMaxAffordablePurchases(machineGen.baseCost, machineGen.level);
var purchaseInfo = calculateMultiplePurchaseCost(machineGen.baseCost, machineGen.level, purchaseMultiplier, maxAffordable);
if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && machineGen.level < 200) {
currency -= purchaseInfo.cost;
for (var i = 0; i < purchaseInfo.purchases; i++) {
if (machineGen.level < 200) {
machineGen.upgrade();
}
}
updateUI();
saveGame();
}
};
officeGen.down = function (x, y, obj) {
var maxAffordable = getMaxAffordablePurchases(officeGen.baseCost, officeGen.level);
var purchaseInfo = calculateMultiplePurchaseCost(officeGen.baseCost, officeGen.level, purchaseMultiplier, maxAffordable);
if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && officeGen.level < 200) {
currency -= purchaseInfo.cost;
for (var i = 0; i < purchaseInfo.purchases; i++) {
if (officeGen.level < 200) {
officeGen.upgrade();
}
}
updateUI();
saveGame();
}
};
labGen.down = function (x, y, obj) {
var maxAffordable = getMaxAffordablePurchases(labGen.baseCost, labGen.level);
var purchaseInfo = calculateMultiplePurchaseCost(labGen.baseCost, labGen.level, purchaseMultiplier, maxAffordable);
if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && labGen.level < 200) {
currency -= purchaseInfo.cost;
for (var i = 0; i < purchaseInfo.purchases; i++) {
if (labGen.level < 200) {
labGen.upgrade();
}
}
updateUI();
saveGame();
}
};
hqGen.down = function (x, y, obj) {
var maxAffordable = getMaxAffordablePurchases(hqGen.baseCost, hqGen.level);
var purchaseInfo = calculateMultiplePurchaseCost(hqGen.baseCost, hqGen.level, purchaseMultiplier, maxAffordable);
if (currency >= purchaseInfo.cost && purchaseInfo.purchases > 0 && hqGen.level < 200) {
currency -= purchaseInfo.cost;
for (var i = 0; i < purchaseInfo.purchases; i++) {
if (hqGen.level < 200) {
hqGen.upgrade();
}
}
updateUI();
saveGame();
}
};
// UI Setup
currencyText = new Text2('$0', {
size: 80,
fill: 0xFFD700
});
currencyText.anchor.set(0.5, 0);
LK.gui.top.addChild(currencyText);
currencyText.y = 50;
tapPowerText = new Text2('Tap Power: $1', {
size: 50,
fill: 0xFFFFFF
});
tapPowerText.anchor.set(0, 0);
tapPowerText.x = 50;
tapPowerText.y = 200;
game.addChild(tapPowerText);
prestigeText = new Text2('Prestige Points: 0', {
size: 40,
fill: 0xFF69B4
});
prestigeText.anchor.set(1, 0);
prestigeText.x = 1998;
prestigeText.y = 200;
game.addChild(prestigeText);
// Passive income display
var passiveIncomeText = new Text2('Passive Income: $0/s', {
size: 45,
fill: 0x90EE90
});
passiveIncomeText.anchor.set(0.5, 0);
passiveIncomeText.x = 1024;
passiveIncomeText.y = 200;
game.addChild(passiveIncomeText);
// Auto tap rate display
var autoTapRateText = new Text2('Auto Taps: 0/s', {
size: 45,
fill: 0x87CEEB
});
autoTapRateText.anchor.set(0.5, 0);
autoTapRateText.x = 1024;
autoTapRateText.y = 300;
game.addChild(autoTapRateText);
// Multiplier selection buttons
var multiplierContainer = new MultiplierButtons();
multiplierContainer.x = 1024;
multiplierContainer.y = 1100;
game.addChild(multiplierContainer);
var multiplierButtons = multiplierContainer.multiplierButtons;
// Generator info texts
var factoryInfoText = new Text2('Factory\nCost: $100\nIncome: $1/s', {
size: 35,
fill: 0xFFFFFF
});
factoryInfoText.anchor.set(0.5, 1);
factoryInfoText.x = 300;
factoryInfoText.y = 1320;
game.addChild(factoryInfoText);
var workerInfoText = new Text2('Worker\nCost: $1K\nIncome: $10/s', {
size: 35,
fill: 0xFFFFFF
});
workerInfoText.anchor.set(0.5, 1);
workerInfoText.x = 1024;
workerInfoText.y = 1320;
game.addChild(workerInfoText);
var machineInfoText = new Text2('Machine\nCost: $10K\nIncome: $100/s', {
size: 35,
fill: 0xFFFFFF
});
machineInfoText.anchor.set(0.5, 1);
machineInfoText.x = 1748;
machineInfoText.y = 1320;
game.addChild(machineInfoText);
var officeInfoText = new Text2('Office\nCost: $100K\nIncome: $1K/s', {
size: 35,
fill: 0xFFFFFF
});
officeInfoText.anchor.set(0.5, 1);
officeInfoText.x = 300;
officeInfoText.y = 1620;
game.addChild(officeInfoText);
var labInfoText = new Text2('Laboratory\nCost: $1M\nIncome: $10K/s', {
size: 35,
fill: 0xFFFFFF
});
labInfoText.anchor.set(0.5, 1);
labInfoText.x = 1024;
labInfoText.y = 1620;
game.addChild(labInfoText);
var hqInfoText = new Text2('Headquarters\nCost: $10M\nIncome: $100K/s', {
size: 35,
fill: 0xFFFFFF
});
hqInfoText.anchor.set(0.5, 1);
hqInfoText.x = 1748;
hqInfoText.y = 1620;
game.addChild(hqInfoText);
// Upgrade buttons
function getTapUpgradeCost() {
return 500 * Math.pow(1.9, tapUpgradePurchases);
}
var tapUpgradeBtn = new UpgradeButton('2x Tap Power', getTapUpgradeCost(), function () {
tapPower *= 2;
tapUpgradePurchases++;
// Update button cost and text for next purchase
tapUpgradeBtn.cost = getTapUpgradeCost();
tapUpgradeBtn.buttonText.setText('2x Tap Power - $' + formatNumber(tapUpgradeBtn.cost));
var bg = tapUpgradeBtn.children[0];
bg.tint = 0x2E8B57;
updateUI();
saveGame();
}, true);
tapUpgradeBtn.x = 1024;
tapUpgradeBtn.y = 2100;
game.addChild(tapUpgradeBtn);
upgradeButtons.push(tapUpgradeBtn);
// Auto tap upgrade tracking
var autoTapUpgradePurchases = storage.autoTapUpgradePurchases || 0;
var autoTapRate = storage.autoTapRate || 0;
function getAutoTapUpgradeCost() {
return 2000 * Math.pow(3, autoTapUpgradePurchases);
}
var autoTapBtn = new UpgradeButton('Auto Tap (+1/s)', getAutoTapUpgradeCost(), function () {
autoTapEnabled = true;
autoTapRate++;
autoTapUpgradePurchases++;
// Update button cost and text for next purchase
autoTapBtn.cost = getAutoTapUpgradeCost();
autoTapBtn.buttonText.setText('Auto Tap (+1/s) - $' + formatNumber(autoTapBtn.cost));
var bg = autoTapBtn.children[0];
bg.tint = 0x2E8B57;
updateUI();
saveGame();
}, true);
autoTapBtn.x = 1024;
autoTapBtn.y = 2280;
game.addChild(autoTapBtn);
upgradeButtons.push(autoTapBtn);
// Global multiplier upgrades
var globalMultiplierUpgrades = storage.globalMultiplierUpgrades || 0;
function getGlobalMultiplierCost() {
return 50000 * Math.pow(5, globalMultiplierUpgrades);
}
// Efficiency upgrades
var efficiencyUpgrades = storage.efficiencyUpgrades || 0;
function getEfficiencyUpgradeCost() {
return 25000 * Math.pow(4, efficiencyUpgrades);
}
// Prestige button
var prestigeBtn = new UpgradeButton('PRESTIGE (+1 PP)', 1000000, function () {
prestige();
});
prestigeBtn.x = 1024;
prestigeBtn.y = 2460;
game.addChild(prestigeBtn);
// Auto tap
var autoTapEnabled = storage.autoTapEnabled || false;
var autoTapTimer = 0;
// Floating text system
var floatingTexts = [];
function showFloatingText(text, x, y) {
// Generate random position around the gold coin
var coinRadius = 250; // Distance from coin center
var angle = Math.random() * Math.PI * 2; // Random angle
var randomX = goldCoin.x + Math.cos(angle) * (coinRadius + Math.random() * 100);
var randomY = goldCoin.y + Math.sin(angle) * (coinRadius + Math.random() * 100);
var floatingText = new Text2(text, {
size: 60,
fill: 0xFFD700,
stroke: 0x000000,
strokeThickness: 4
});
floatingText.anchor.set(0.5, 0.5);
floatingText.x = randomX;
floatingText.y = randomY;
floatingText.alpha = 1;
game.addChild(floatingText);
floatingTexts.push(floatingText);
tween(floatingText, {
y: randomY - 100,
alpha: 0
}, {
duration: 1500,
onFinish: function onFinish() {
floatingText.destroy();
var index = floatingTexts.indexOf(floatingText);
if (index > -1) {
floatingTexts.splice(index, 1);
}
}
});
}
function calculateMultiplePurchaseCost(baseCost, currentLevel, multiplier, maxAffordable) {
if (multiplier === 'All') {
var totalCost = 0;
var level = currentLevel;
var purchases = 0;
while (totalCost + Math.floor(baseCost * Math.pow(1.15, level)) <= currency && purchases < maxAffordable && level < 200) {
totalCost += Math.floor(baseCost * Math.pow(1.15, level));
level++;
purchases++;
}
return {
cost: totalCost,
purchases: purchases
};
} else {
var totalCost = 0;
var actualPurchases = Math.min(multiplier, maxAffordable, 200 - currentLevel);
for (var i = 0; i < actualPurchases; i++) {
totalCost += Math.floor(baseCost * Math.pow(1.15, currentLevel + i));
}
return {
cost: totalCost,
purchases: actualPurchases
};
}
}
function getMaxAffordablePurchases(baseCost, currentLevel) {
var totalCost = 0;
var level = currentLevel;
var purchases = 0;
while (totalCost + Math.floor(baseCost * Math.pow(1.15, level)) <= currency && level < 200) {
totalCost += Math.floor(baseCost * Math.pow(1.15, level));
level++;
purchases++;
if (purchases >= 1000) break; // Prevent infinite loops
}
return purchases;
}
function formatNumber(num) {
if (num < 0) return '-' + formatNumber(-num);
if (num < 1000) return Math.floor(num).toString();
var abbreviations = [{
value: 1e303,
suffix: 'Ce'
},
// Centillion
{
value: 1e300,
suffix: 'NeCe'
},
// Novemnonagintillion
{
value: 1e297,
suffix: 'OcNo'
},
// Octooctogintillion
{
value: 1e294,
suffix: 'SpNo'
},
// Septenseptuagintillion
{
value: 1e291,
suffix: 'SxNo'
},
// Sexsexagintillion
{
value: 1e288,
suffix: 'QiNo'
},
// Quinquinquagintillion
{
value: 1e285,
suffix: 'QaNo'
},
// Quattuorquadragintillion
{
value: 1e282,
suffix: 'TrNo'
},
// Tretrigintillion
{
value: 1e279,
suffix: 'DuNo'
},
// Duovigintillion
{
value: 1e276,
suffix: 'UnNo'
},
// Unvigintillion
{
value: 1e273,
suffix: 'No'
},
// Novemvigintillion
{
value: 1e270,
suffix: 'OcVg'
},
// Octovigintillion
{
value: 1e267,
suffix: 'SpVg'
},
// Septenvigintillion
{
value: 1e264,
suffix: 'SxVg'
},
// Sexvigintillion
{
value: 1e261,
suffix: 'QiVg'
},
// Quinvigintillion
{
value: 1e258,
suffix: 'QaVg'
},
// Quattuorvigintillion
{
value: 1e255,
suffix: 'TrVg'
},
// Trevigintillion
{
value: 1e252,
suffix: 'DuVg'
},
// Duovigintillion
{
value: 1e249,
suffix: 'UnVg'
},
// Unvigintillion
{
value: 1e246,
suffix: 'Vg'
},
// Vigintillion
{
value: 1e243,
suffix: 'NoNd'
},
// Novemdeciillion
{
value: 1e240,
suffix: 'OcNd'
},
// Octodeciillion
{
value: 1e237,
suffix: 'SpNd'
},
// Septendeciillion
{
value: 1e234,
suffix: 'SxNd'
},
// Sexdeciillion
{
value: 1e231,
suffix: 'QiNd'
},
// Quindeciillion
{
value: 1e228,
suffix: 'QaNd'
},
// Quattuordeciillion
{
value: 1e225,
suffix: 'TrNd'
},
// Tredeciillion
{
value: 1e222,
suffix: 'DuNd'
},
// Duodeciillion
{
value: 1e219,
suffix: 'UnNd'
},
// Undeciillion
{
value: 1e216,
suffix: 'Nd'
},
// Deciillion
{
value: 1e213,
suffix: 'NoOc'
},
// Novemoctagintillion
{
value: 1e210,
suffix: 'OcOc'
},
// Octooctagintillion
{
value: 1e207,
suffix: 'SpOc'
},
// Septenoctagintillion
{
value: 1e204,
suffix: 'SxOc'
},
// Sexoctagintillion
{
value: 1e201,
suffix: 'QiOc'
},
// Quinoctagintillion
{
value: 1e198,
suffix: 'QaOc'
},
// Quattuoroctagintillion
{
value: 1e195,
suffix: 'TrOc'
},
// Treoctagintillion
{
value: 1e192,
suffix: 'DuOc'
},
// Duooctagintillion
{
value: 1e189,
suffix: 'UnOc'
},
// Unoctagintillion
{
value: 1e186,
suffix: 'Oc'
},
// Octagintillion
{
value: 1e183,
suffix: 'NoSp'
},
// Novemseptuagintillion
{
value: 1e180,
suffix: 'OcSp'
},
// Octoseptuagintillion
{
value: 1e177,
suffix: 'SpSp'
},
// Septenseptuagintillion
{
value: 1e174,
suffix: 'SxSp'
},
// Sexseptuagintillion
{
value: 1e171,
suffix: 'QiSp'
},
// Quinseptuagintillion
{
value: 1e168,
suffix: 'QaSp'
},
// Quattuorseptuagintillion
{
value: 1e165,
suffix: 'TrSp'
},
// Treseptuagintillion
{
value: 1e162,
suffix: 'DuSp'
},
// Duoseptuagintillion
{
value: 1e159,
suffix: 'UnSp'
},
// Unseptuagintillion
{
value: 1e156,
suffix: 'Sp'
},
// Septuagintillion
{
value: 1e153,
suffix: 'NoSx'
},
// Novemsexagintillion
{
value: 1e150,
suffix: 'OcSx'
},
// Octosexagintillion
{
value: 1e147,
suffix: 'SpSx'
},
// Septensexagintillion
{
value: 1e144,
suffix: 'SxSx'
},
// Sexsexagintillion
{
value: 1e141,
suffix: 'QiSx'
},
// Quinsexagintillion
{
value: 1e138,
suffix: 'QaSx'
},
// Quattuorsexagintillion
{
value: 1e135,
suffix: 'TrSx'
},
// Tresexagintillion
{
value: 1e132,
suffix: 'DuSx'
},
// Duosexagintillion
{
value: 1e129,
suffix: 'UnSx'
},
// Unsexagintillion
{
value: 1e126,
suffix: 'Sx'
},
// Sexagintillion
{
value: 1e123,
suffix: 'NoQi'
},
// Novemquinquagintillion
{
value: 1e120,
suffix: 'OcQi'
},
// Octoquinquagintillion
{
value: 1e117,
suffix: 'SpQi'
},
// Septenquinquagintillion
{
value: 1e114,
suffix: 'SxQi'
},
// Sexquinquagintillion
{
value: 1e111,
suffix: 'QiQi'
},
// Quinquinquagintillion
{
value: 1e108,
suffix: 'QaQi'
},
// Quattuorquinquagintillion
{
value: 1e105,
suffix: 'TrQi'
},
// Trequinquagintillion
{
value: 1e102,
suffix: 'DuQi'
},
// Duoquinquagintillion
{
value: 1e99,
suffix: 'UnQi'
},
// Unquinquagintillion
{
value: 1e96,
suffix: 'Qi'
},
// Quinquagintillion
{
value: 1e93,
suffix: 'NoQa'
},
// Novemquadragintillion
{
value: 1e90,
suffix: 'OcQa'
},
// Octoquadragintillion
{
value: 1e87,
suffix: 'SpQa'
},
// Septenquadragintillion
{
value: 1e84,
suffix: 'SxQa'
},
// Sexquadragintillion
{
value: 1e81,
suffix: 'QiQa'
},
// Quinquadragintillion
{
value: 1e78,
suffix: 'QaQa'
},
// Quattuorquadragintillion
{
value: 1e75,
suffix: 'TrQa'
},
// Trequadragintillion
{
value: 1e72,
suffix: 'DuQa'
},
// Duoquadragintillion
{
value: 1e69,
suffix: 'UnQa'
},
// Unquadragintillion
{
value: 1e66,
suffix: 'Qa'
},
// Quadragintillion
{
value: 1e63,
suffix: 'Vg'
},
// Vigintillion
{
value: 1e60,
suffix: 'Nd'
},
// Novemdecillion
{
value: 1e57,
suffix: 'Od'
},
// Octodecillion
{
value: 1e54,
suffix: 'Sd'
},
// Septendecillion
{
value: 1e51,
suffix: 'Sxd'
},
// Sexdecillion
{
value: 1e48,
suffix: 'Qid'
},
// Quindecillion
{
value: 1e45,
suffix: 'Qad'
},
// Quattuordecillion
{
value: 1e42,
suffix: 'Td'
},
// Tredecillion
{
value: 1e39,
suffix: 'Dd'
},
// Duodecillion
{
value: 1e36,
suffix: 'Ud'
},
// Undecillion
{
value: 1e33,
suffix: 'Dc'
},
// Decillion
{
value: 1e30,
suffix: 'No'
},
// Nonillion
{
value: 1e27,
suffix: 'Oc'
},
// Octillion
{
value: 1e24,
suffix: 'Sp'
},
// Septillion
{
value: 1e21,
suffix: 'Sx'
},
// Sextillion
{
value: 1e18,
suffix: 'Qi'
},
// Quintillion
{
value: 1e15,
suffix: 'Qa'
},
// Quadrillion
{
value: 1e12,
suffix: 'T'
},
// Trillion
{
value: 1e9,
suffix: 'B'
},
// Billion
{
value: 1e6,
suffix: 'M'
},
// Million
{
value: 1e3,
suffix: 'K'
} // Thousand
];
for (var i = 0; i < abbreviations.length; i++) {
if (num >= abbreviations[i].value) {
var result = num / abbreviations[i].value;
if (result >= 100) {
return Math.floor(result).toString() + abbreviations[i].suffix;
} else if (result >= 10) {
return result.toFixed(1) + abbreviations[i].suffix;
} else {
return result.toFixed(2) + abbreviations[i].suffix;
}
}
}
return Math.floor(num).toString();
}
function updateUI() {
currencyText.setText('$' + formatNumber(currency));
tapPowerText.setText('Tap Power: $' + formatNumber(tapPower));
prestigeText.setText('Prestige Points: ' + prestigePoints);
// Calculate total passive income from all generators
var totalPassiveIncome = 0;
generators.forEach(function (gen) {
totalPassiveIncome += gen.getIncome();
});
passiveIncomeText.setText('Passive Income: $' + formatNumber(totalPassiveIncome) + '/s');
autoTapRateText.setText('Auto Taps: ' + (autoTapRate || 0) + '/s');
// Update generator info with multiplier costs
var factoryMaxAffordable = getMaxAffordablePurchases(factoryGen.baseCost, factoryGen.level);
var factoryPurchaseInfo = calculateMultiplePurchaseCost(factoryGen.baseCost, factoryGen.level, purchaseMultiplier, factoryMaxAffordable);
factoryInfoText.setText('Factory (Lv.' + factoryGen.level + ')\nCost: $' + formatNumber(factoryPurchaseInfo.cost) + ' (' + factoryPurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(factoryGen.getIncome()) + '/s');
factoryInfoText.tint = currency >= factoryPurchaseInfo.cost && factoryPurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B;
var workerMaxAffordable = getMaxAffordablePurchases(workerGen.baseCost, workerGen.level);
var workerPurchaseInfo = calculateMultiplePurchaseCost(workerGen.baseCost, workerGen.level, purchaseMultiplier, workerMaxAffordable);
workerInfoText.setText('Worker (Lv.' + workerGen.level + ')\nCost: $' + formatNumber(workerPurchaseInfo.cost) + ' (' + workerPurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(workerGen.getIncome()) + '/s');
workerInfoText.tint = currency >= workerPurchaseInfo.cost && workerPurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B;
var machineMaxAffordable = getMaxAffordablePurchases(machineGen.baseCost, machineGen.level);
var machinePurchaseInfo = calculateMultiplePurchaseCost(machineGen.baseCost, machineGen.level, purchaseMultiplier, machineMaxAffordable);
machineInfoText.setText('Machine (Lv.' + machineGen.level + ')\nCost: $' + formatNumber(machinePurchaseInfo.cost) + ' (' + machinePurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(machineGen.getIncome()) + '/s');
machineInfoText.tint = currency >= machinePurchaseInfo.cost && machinePurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B;
var officeMaxAffordable = getMaxAffordablePurchases(officeGen.baseCost, officeGen.level);
var officePurchaseInfo = calculateMultiplePurchaseCost(officeGen.baseCost, officeGen.level, purchaseMultiplier, officeMaxAffordable);
officeInfoText.setText('Office (Lv.' + officeGen.level + ')\nCost: $' + formatNumber(officePurchaseInfo.cost) + ' (' + officePurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(officeGen.getIncome()) + '/s');
officeInfoText.tint = currency >= officePurchaseInfo.cost && officePurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B;
var labMaxAffordable = getMaxAffordablePurchases(labGen.baseCost, labGen.level);
var labPurchaseInfo = calculateMultiplePurchaseCost(labGen.baseCost, labGen.level, purchaseMultiplier, labMaxAffordable);
labInfoText.setText('Laboratory (Lv.' + labGen.level + ')\nCost: $' + formatNumber(labPurchaseInfo.cost) + ' (' + labPurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(labGen.getIncome()) + '/s');
labInfoText.tint = currency >= labPurchaseInfo.cost && labPurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B;
var hqMaxAffordable = getMaxAffordablePurchases(hqGen.baseCost, hqGen.level);
var hqPurchaseInfo = calculateMultiplePurchaseCost(hqGen.baseCost, hqGen.level, purchaseMultiplier, hqMaxAffordable);
hqInfoText.setText('Headquarters (Lv.' + hqGen.level + ')\nCost: $' + formatNumber(hqPurchaseInfo.cost) + ' (' + hqPurchaseInfo.purchases + 'x)\nIncome: $' + formatNumber(hqGen.getIncome()) + '/s');
hqInfoText.tint = currency >= hqPurchaseInfo.cost && hqPurchaseInfo.purchases > 0 ? 0xFFFFFF : 0xFF6B6B;
// Update upgrade button affordability
upgradeButtons.forEach(function (btn) {
btn.updateAffordability();
});
// Update prestige button
if (totalEarned >= 1000000) {
prestigeBtn.updateAffordability();
}
}
function saveGame() {
storage.currency = currency;
storage.tapPower = tapPower;
storage.totalEarned = totalEarned;
storage.prestigePoints = prestigePoints;
storage.factoryLevel = factoryGen.level;
storage.workerLevel = workerGen.level;
storage.machineLevel = machineGen.level;
storage.officeLevel = officeGen.level;
storage.labLevel = labGen.level;
storage.hqLevel = hqGen.level;
storage.autoTapEnabled = autoTapEnabled;
storage.tapUpgradePurchases = tapUpgradePurchases;
storage.autoTapUpgradePurchases = autoTapUpgradePurchases;
storage.autoTapRate = autoTapRate;
storage.globalMultiplierUpgrades = globalMultiplierUpgrades;
storage.efficiencyUpgrades = efficiencyUpgrades;
saveLuxuryItems();
}
function prestige() {
if (totalEarned >= 1000000) {
prestigePoints++;
currency = 0;
tapPower = 1;
totalEarned = 0;
tapUpgradePurchases = 0;
autoTapUpgradePurchases = 0;
autoTapRate = 0;
globalMultiplierUpgrades = 0;
efficiencyUpgrades = 0;
// Reset generators
generators.forEach(function (gen) {
gen.level = 0;
gen.levelText.setText('Lv.0');
});
// Reset upgrades
upgradeButtons.forEach(function (btn) {
btn.purchased = false;
if (btn === tapUpgradeBtn) {
btn.cost = getTapUpgradeCost();
btn.buttonText.setText('2x Tap Power - $' + formatNumber(btn.cost));
} else if (btn === autoTapBtn) {
btn.cost = getAutoTapUpgradeCost();
btn.buttonText.setText('Auto Tap (+1/s) - $' + formatNumber(btn.cost));
} else if (!btn.isRepeatable) {
btn.buttonText.setText(btn.baseText + ' - $' + formatNumber(btn.cost));
}
});
autoTapEnabled = false;
updateUI();
saveGame();
showFloatingText('PRESTIGE! +1 PP', 1024, 1366);
}
}
// Handle offline earnings
var lastSaveTime = storage.lastSaveTime || Date.now();
var offlineTime = (Date.now() - lastSaveTime) / 1000; // seconds
if (offlineTime > 60) {
// Only if offline for more than 1 minute
var offlineEarnings = 0;
generators.forEach(function (gen) {
offlineEarnings += gen.getIncome() * Math.min(offlineTime, 3600); // Cap at 1 hour
});
if (offlineEarnings > 0) {
currency += offlineEarnings;
totalEarned += offlineEarnings;
showFloatingText('Offline Earnings: +$' + formatNumber(offlineEarnings), 1024, 600);
}
}
// Add click handler for instant coin calculation
game.down = function (x, y, obj) {
// Check if click is in the right side of screen, under prestige text
if (x > 1500 && y > 250 && y < 800) {
// Calculate total coins earned instantly
var instantEarnings = totalEarned;
showFloatingText('Total Earned: $' + formatNumber(instantEarnings), x, y);
}
};
// Create luxury tab
var luxuryTab = new LuxuryTab();
luxuryTab.initializeLuxuryItems();
luxuryTab.loadOwnedItems();
game.addChild(luxuryTab);
// Create luxury tab button
var luxuryTabButton = LK.getAsset('box', {
width: 200,
height: 80,
color: 0xFFD700,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
luxuryTabButton.x = 200;
luxuryTabButton.y = 320;
game.addChild(luxuryTabButton);
var luxuryButtonText = new Text2('LUXURY', {
size: 60,
fill: 0x000000
});
luxuryButtonText.anchor.set(0.5, 0.5);
luxuryButtonText.x = 200;
luxuryButtonText.y = 320;
game.addChild(luxuryButtonText);
luxuryTabButton.down = function (x, y, obj) {
luxuryTab.visible = true;
};
// Save luxury items function
function saveLuxuryItems() {
var ownedItems = {};
for (var i = 0; i < luxuryTab.luxuryItems.length; i++) {
var item = luxuryTab.luxuryItems[i];
if (item.owned) {
ownedItems[item.name] = true;
}
}
storage.ownedLuxuryItems = ownedItems;
}
// Confetti explosion function
function createConfettiExplosion() {
var confettiPieces = [];
var centerX = 1024;
var centerY = 1366;
for (var i = 0; i < 30; i++) {
var confetti = LK.getAsset('box', {
width: 20,
height: 20,
color: Math.random() > 0.5 ? 0xFFD700 : Math.random() > 0.5 ? 0xFF69B4 : 0x00FF00,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
confetti.x = centerX;
confetti.y = centerY;
confetti.rotation = Math.random() * Math.PI * 2;
game.addChild(confetti);
confettiPieces.push(confetti);
// Random direction and distance
var angle = Math.random() * Math.PI * 2;
var distance = 200 + Math.random() * 300;
var targetX = centerX + Math.cos(angle) * distance;
var targetY = centerY + Math.sin(angle) * distance;
// Animate confetti piece
tween(confetti, {
x: targetX,
y: targetY,
rotation: confetti.rotation + Math.PI * 4,
alpha: 0
}, {
duration: 2000 + Math.random() * 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
confetti.destroy();
}
});
}
}
// Initial UI update
updateUI();
// Game loop
game.update = function () {
// Generate passive income
generators.forEach(function (gen) {
var income = gen.generateIncome();
if (income > 0) {
// Apply global multipliers and efficiency bonuses
var globalMultiplier = Math.pow(2, globalMultiplierUpgrades);
var efficiencyMultiplier = 1 + efficiencyUpgrades * 0.25;
var prestigeMultiplier = 1 + prestigePoints * 0.1;
var finalIncome = income * globalMultiplier * efficiencyMultiplier * prestigeMultiplier;
currency += finalIncome;
totalEarned += finalIncome;
}
});
// Auto tap
if (autoTapEnabled && autoTapRate > 0) {
autoTapTimer++;
if (autoTapTimer >= Math.floor(60 / autoTapRate)) {
// Frequency based on auto tap rate
var earnAmount = tapPower * (1 + prestigePoints * 0.5);
currency += earnAmount;
totalEarned += earnAmount;
autoTapTimer = 0;
}
}
// Update UI every 30 frames (twice per second)
if (LK.ticks % 30 === 0) {
updateUI();
}
// Save game every 5 seconds
if (LK.ticks % 300 === 0) {
storage.lastSaveTime = Date.now();
saveGame();
}
};
Coin. In-Game asset. 2d. High contrast. No shadows
Factory. In-Game asset. 2d. High contrast. No shadows
Worker. In-Game asset. 2d. High contrast. No shadows
Machine. In-Game asset. 2d. High contrast. No shadows
Headquarters. In-Game asset. 2d. High contrast. No shadows
Laboratuvar. In-Game asset. 2d. High contrast. No shadows
Ofis. In-Game asset. 2d. High contrast. No shadows
Luxury car. In-Game asset. 2d. High contrast. No shadows