User prompt
make it not green and reg color and make this better ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'self.costText.style.fill = "#ff6666";' Line Number: 177
Code edit (1 edits merged)
Please save this source code
User prompt
Hack Clicker Empire
Initial prompt
make hack clicker and i can set the image has what you are clicking
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { bits: 0, bitsPerClick: 1, autoClickerCount: 0, autoClickerCost: 10, autoClickerRate: 1, serverCount: 0, serverCost: 100, serverRate: 5, botnetCount: 0, botnetCost: 1000, botnetRate: 50, targetType: "server" }); /**** * Classes ****/ var HackingTarget = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); // Clicked effect self.click = function () { // Play clicking sound LK.getSound('click').play(); // Add bits based on current rate var bitsEarned = storage.bitsPerClick; storage.bits += bitsEarned; // Visual feedback for click LK.effects.flashObject(targetGraphics, 0xffffff, 300); // Create temporary text showing bits earned var earnText = new Text2("+" + bitsEarned, { size: 60, fill: 0x33FF33 }); earnText.anchor.set(0.5, 0.5); earnText.x = 0; earnText.y = 0; self.addChild(earnText); // Animate the text upward and fade out tween(earnText, { y: earnText.y - 100, alpha: 0 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { earnText.destroy(); } }); // Slight grow/shrink effect tween(targetGraphics, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(targetGraphics, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.elasticOut }); } }); }; // Update target appearance based on type self.updateType = function (type) { if (type === 'server') { targetGraphics.tint = 0x33ff33; // Green } else if (type === 'terminal') { targetGraphics.tint = 0x3366ff; // Blue } else if (type === 'network') { targetGraphics.tint = 0xff3366; // Red } }; // Event handlers self.down = function (x, y, obj) { self.click(); }; return self; }); var TargetTypeButton = Container.expand(function (type, title) { var self = Container.call(this); var buttonBg = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.6 }); self.type = type; // Button text var titleText = new Text2(title, { size: 35, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); self.addChild(titleText); // Event handlers self.down = function (x, y, obj) { storage.targetType = type; // Flash button to indicate selection LK.effects.flashObject(buttonBg, 0xffffff, 200); }; // Update appearance based on selection state self.update = function () { if (storage.targetType === self.type) { buttonBg.tint = 0x33aa33; } else { buttonBg.tint = 0x555555; } }; return self; }); var UpgradeButton = Container.expand(function (type, title) { var self = Container.call(this); var buttonBg = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5 }); self.type = type; // Button text self.titleText = new Text2(title, { size: 40, fill: 0xFFFFFF }); self.titleText.anchor.set(0.5, 0); self.titleText.y = -30; self.addChild(self.titleText); // Cost text self.costText = new Text2("", { size: 30, fill: 0xAAFFAA }); self.costText.anchor.set(0.5, 1); self.costText.y = 30; self.addChild(self.costText); // Update button cost display self.updateCost = function () { var cost = 0; if (self.type === 'autoClicker') { cost = storage.autoClickerCost; } else if (self.type === 'server') { cost = storage.serverCost; } else if (self.type === 'botnet') { cost = storage.botnetCost; } self.costText.setText("Cost: " + formatNumber(cost) + " bits"); // Visual indication of affordability if (storage.bits >= cost) { buttonBg.tint = 0x555555; self.costText.tint = 0xaaffaa; } else { buttonBg.tint = 0x333333; self.costText.tint = 0xff6666; } }; // Purchase the upgrade self.purchase = function () { var cost = 0; var canPurchase = false; if (self.type === 'autoClicker') { cost = storage.autoClickerCost; if (storage.bits >= cost) { storage.bits -= cost; storage.autoClickerCount++; storage.autoClickerCost = Math.floor(storage.autoClickerCost * 1.2); canPurchase = true; } } else if (self.type === 'server') { cost = storage.serverCost; if (storage.bits >= cost) { storage.bits -= cost; storage.serverCount++; storage.serverCost = Math.floor(storage.serverCost * 1.3); canPurchase = true; } } else if (self.type === 'botnet') { cost = storage.botnetCost; if (storage.bits >= cost) { storage.bits -= cost; storage.botnetCount++; storage.botnetCost = Math.floor(storage.botnetCost * 1.4); canPurchase = true; } } if (canPurchase) { LK.getSound('upgrade').play(); LK.effects.flashObject(buttonBg, 0x33ff33, 300); // Button pulse animation tween(buttonBg, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(buttonBg, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.elasticOut }); } }); } }; // Event handlers self.down = function (x, y, obj) { self.purchase(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x111111 }); /**** * Game Code ****/ // Format large numbers with K, M, B, T suffixes function formatNumber(num) { if (num < 1000) { return num.toString(); } if (num < 1000000) { return (num / 1000).toFixed(1) + "K"; } if (num < 1000000000) { return (num / 1000000).toFixed(1) + "M"; } if (num < 1000000000000) { return (num / 1000000000).toFixed(1) + "B"; } return (num / 1000000000000).toFixed(1) + "T"; } // Game variables var lastUpdate = Date.now(); var target; var bitsText; var bpsText; var clickValueText; var upgradeButtons = []; var targetTypeButtons = []; // Create hacking target target = new HackingTarget(); target.x = 2048 / 2; target.y = 800; target.updateType(storage.targetType); game.addChild(target); // Create stats display var statsBox = LK.getAsset('statsBackground', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 200, alpha: 0.8 }); game.addChild(statsBox); // Bits counter bitsText = new Text2("Bits: " + formatNumber(storage.bits), { size: 60, fill: 0x33FF33 }); bitsText.anchor.set(0.5, 0); bitsText.x = 2048 / 2; bitsText.y = 140; game.addChild(bitsText); // Bits per second display bpsText = new Text2("0 bits/sec", { size: 40, fill: 0xAAFFAA }); bpsText.anchor.set(0.5, 0); bpsText.x = 2048 / 2; bpsText.y = 210; game.addChild(bpsText); // Bits per click display clickValueText = new Text2("+" + storage.bitsPerClick + " bits/click", { size: 35, fill: 0xFFFFFF }); clickValueText.anchor.set(0.5, 0); clickValueText.x = 2048 / 2; clickValueText.y = 260; game.addChild(clickValueText); // Create target type selection buttons var targetTypes = [{ type: 'server', title: 'Server' }, { type: 'terminal', title: 'Terminal' }, { type: 'network', title: 'Network' }]; for (var i = 0; i < targetTypes.length; i++) { var typeButton = new TargetTypeButton(targetTypes[i].type, targetTypes[i].title); typeButton.x = 2048 / 2 + (i - 1) * 320; typeButton.y = 400; targetTypeButtons.push(typeButton); game.addChild(typeButton); } // Create upgrade buttons var upgradeTypes = [{ type: 'autoClicker', title: 'Auto Clicker' }, { type: 'server', title: 'Server Farm' }, { type: 'botnet', title: 'Botnet' }]; for (var i = 0; i < upgradeTypes.length; i++) { var upgradeButton = new UpgradeButton(upgradeTypes[i].type, upgradeTypes[i].title); upgradeButton.x = 2048 / 2; upgradeButton.y = 1500 + i * 150; upgradeButtons.push(upgradeButton); game.addChild(upgradeButton); } // Play background music LK.playMusic('hackerMusic'); // Game update function game.update = function () { // Calculate time since last update for idle income var now = Date.now(); var deltaTime = (now - lastUpdate) / 1000; // Convert to seconds lastUpdate = now; // Calculate automated bits per second var bitsPerSecond = storage.autoClickerCount * storage.autoClickerRate + storage.serverCount * storage.serverRate + storage.botnetCount * storage.botnetRate; // Add earned bits if (bitsPerSecond > 0) { storage.bits += bitsPerSecond * deltaTime; } // Update UI bitsText.setText("Bits: " + formatNumber(Math.floor(storage.bits))); bpsText.setText(formatNumber(bitsPerSecond) + " bits/sec"); clickValueText.setText("+" + storage.bitsPerClick + " bits/click"); // Update target appearance based on selected type target.updateType(storage.targetType); // Update target type buttons for (var i = 0; i < targetTypeButtons.length; i++) { targetTypeButtons[i].update(); } // Update upgrade button costs for (var i = 0; i < upgradeButtons.length; i++) { upgradeButtons[i].updateCost(); } // Occasional subtle pulse animation on target to attract attention if (LK.ticks % 180 === 0) { tween(target, { scaleX: 1.05, scaleY: 1.05 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(target, { scaleX: 1, scaleY: 1 }, { duration: 400, easing: tween.elasticOut }); } }); } // Check for milestone achievements if (storage.bits >= 1000000 && storage.bitsPerClick === 1) { storage.bitsPerClick = 2; LK.effects.flashScreen(0x33ff33, 500); } else if (storage.bits >= 10000000 && storage.bitsPerClick === 2) { storage.bitsPerClick = 5; LK.effects.flashScreen(0x33ff33, 500); } else if (storage.bits >= 100000000 && storage.bitsPerClick === 5) { storage.bitsPerClick = 10; LK.effects.flashScreen(0x33ff33, 500); } };
===================================================================
--- original.js
+++ change.js
@@ -159,12 +159,12 @@
self.costText.setText("Cost: " + formatNumber(cost) + " bits");
// Visual indication of affordability
if (storage.bits >= cost) {
buttonBg.tint = 0x555555;
- self.costText.style.fill = "#aaffaa";
+ self.costText.tint = 0xaaffaa;
} else {
buttonBg.tint = 0x333333;
- self.costText.style.fill = "#ff6666";
+ self.costText.tint = 0xff6666;
}
};
// Purchase the upgrade
self.purchase = function () {