Code edit (1 edits merged)
Please save this source code
User prompt
Fix it
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'ref.textObj.style.fill = 0x666666;' Line Number: 638
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'ref.textObj.style.fill = 0x666666;' Line Number: 637
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 75
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'p.lastX = ore.parent.x + ore.x;' Line Number: 317
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'p.x = ore.parent.x + ore.x;' Line Number: 317
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 75
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'y')' in or related to this line: 'p.y = ore.y + ore.parent.y;' Line Number: 325
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'p.x = ore.x + ore.parent.x; // because ore is offset in the cluster' Line Number: 324
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'p.x = ore.x + ore.parent.x; // because ore is offset in the cluster' Line Number: 320
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'ref.textObj.style.fill = 0x666666;' Line Number: 650
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'p.x = ore.x + ore.parent.x; // because ore is offset in the cluster' Line Number: 316
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'p.x = ore.x + ore.parent.x; // because ore is offset in the cluster' Line Number: 310
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'elapsed')' in or related to this line: 'self.y += Math.sin(LK.time.elapsed / 250) * 0.5;' Line Number: 70
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 151
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'elapsed')' in or related to this line: 'self.y += Math.sin(LK.time.elapsed / 250) * 0.5;' Line Number: 69
Code edit (1 edits merged)
Please save this source code
User prompt
Make the buy buttons be behind each text in the buy menu
User prompt
Make the text inside of buy menu Black and Bold with a Black outline
User prompt
Move the cancel button to the left and down 200 pixels
User prompt
Move the cancel button to the upper right of menu background
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Miner class var Miner = Container.expand(function () { var self = Container.call(this); self.attachAsset('miner', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.currentTarget = null; self.miningRange = 25; self.miningCooldown = 0; self.miningRate = 30; self.miningDamage = 1; // ------------------ // 1) Miner picks the *closest* valid ore (rather than the highest tier): // We simply sort valid ores by distance ascending. // ------------------ self.findNewTarget = function () { var validOres = ores.filter(function (ore) { return ore.health > 0 && ore.tier <= gameState.currentTier; }); if (validOres.length === 0) { self.currentTarget = null; return; } // Sort by distance ascending self.currentTarget = validOres.sort(function (a, b) { var distA = Math.hypot(a.x - self.x, a.y - self.y); var distB = Math.hypot(b.x - self.x, b.y - self.y); return distA - distB; })[0]; }; self.update = function () { self.findNewTarget(); if (self.currentTarget) { var dx = self.currentTarget.x - self.x; var dy = self.currentTarget.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > self.miningRange) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } else { self.mineOre(self.currentTarget); } } else { self.y += Math.sin(LK.time.elapsed / 250) * 0.5; } }; self.mineOre = function (ore) { if (self.miningCooldown > 0) { self.miningCooldown--; return; } // Deal damage ore.health -= self.miningDamage * gameState.pickaxeLevel; self.miningCooldown = self.miningRate; // If ore is destroyed, add money & respawn with delay if (ore.health <= 0) { gameState.money += ore.getValue(); updateUI(); ore.respawn(); // Immediately find new target self.findNewTarget(); } // Mining particle effect for (var i = 0; i < 5; i++) { var p = LK.getAsset('mining_particle', { anchorX: 0.5, anchorY: 0.5 }); p.x = ore.x; p.y = ore.y; p.vx = (Math.random() - 0.5) * 10; p.vy = (Math.random() - 0.5) * 10; p.alpha = 1; tween(p, { alpha: 0, y: p.y - 50 }, { duration: 1000, onFinish: function onFinish() { return p.destroy(); } }); game.addChild(p); } }; return self; }); // Ore class var Ore = Container.expand(function (type) { var self = Container.call(this); self.type = type; self.tier = ['coal', 'iron', 'gold', 'diamond'].indexOf(type) + 1; // Value depends on tier (5 * tier base) plus multipliers self.baseValue = 5 * self.tier; self.attachAsset(type + '_ore', { anchorX: 0.5, anchorY: 0.5 }); // Returns final value (this ensures higher ores give more) self.getValue = function () { return self.baseValue * gameState.oreMultipliers[self.type]; }; // ------------------ // 2) Add a respawn timer. We now hide the ore, wait, then put it back. // The timer is controlled by gameState.respawnTime, which can be upgraded. // ------------------ self.respawn = function () { // Hide & "remove" ore self.visible = false; self.health = 0; self.x = -9999; self.y = -9999; // Use tween with 0 property changes, just to use onFinish after the delay tween(self, {}, { duration: gameState.respawnTime, onFinish: function onFinish() { // Restore ore self.health = 10; self.x = 100 + Math.random() * (2048 - 200); self.y = 100 + Math.random() * (2732 - 200); self.visible = true; // Glowing indicator var indicator = LK.getAsset('glowing_line_asset', { width: 100, height: 100 }); indicator.x = self.x; indicator.y = self.y; game.addChild(indicator); tween(indicator, { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { return indicator.destroy(); } }); } }); }; // Health bar self.healthBar = LK.getAsset('rectangle', { width: 60, height: 5, fill: 0x00FF00 }); self.healthBar.y = -40; self.addChild(self.healthBar); // Place ore randomly at start // (Call respawn directly to set position, etc.) // Because we want it visible at first, we set a tiny delay of 1 so it spawns immediately tween(self, {}, { duration: 1, onFinish: function onFinish() { self.health = 10; self.x = 100 + Math.random() * (2048 - 200); self.y = 100 + Math.random() * (2732 - 200); } }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ // This container is for the upgrade menu var upgradeMenu = new Container(); var tooltip = new Text2('', { size: 40, fill: 0xFFFFFF }); // ------------------ // 3) Add an upgrade that lowers the respawn time. // We also keep existing upgrades. // The "faster_respawn" upgrade will cut the time in half (down to a minimum). // ------------------ var upgrades = [{ id: 'coal_expert', name: "Coal Expertise", cost: 100, effect: "Double coal value", tier: 1, action: function action() { gameState.oreMultipliers.coal *= 2; } }, { id: 'unlock_iron', name: "Iron Mining", cost: 500, effect: "Unlock iron mining", tier: 2, action: function action() { gameState.currentTier = 2; } }, { id: 'iron_expert', name: "Iron Expertise", cost: 2000, effect: "Triple iron value", tier: 2, requires: 'unlock_iron', action: function action() { gameState.oreMultipliers.iron *= 3; } }, { id: 'unlock_gold', name: "Gold Mining", cost: 5000, effect: "Unlock gold mining", tier: 3, action: function action() { gameState.currentTier = 3; } }, { id: 'gold_expert', name: "Gold Expertise", cost: 10000, effect: "Quadruple gold value", tier: 3, requires: 'unlock_gold', action: function action() { gameState.oreMultipliers.gold *= 4; } }, { id: 'unlock_diamond', name: "Diamond Mining", cost: 20000, effect: "Unlock diamond mining", tier: 4, action: function action() { gameState.currentTier = 4; } }, // New upgrade to lower respawn time { id: 'faster_respawn', name: "Quicker Respawn", cost: 8000, effect: "Halves ore respawn time", tier: 2, action: function action() { // Halve the respawn time, but don't let it go below 500 ms gameState.respawnTime = Math.max(500, gameState.respawnTime / 2); } }]; // ------------------ // 4) Added a new property: respawnTime, controlling how long // each ore waits before reappearing. Default is 3000 ms. // ------------------ var gameState = { money: 0, pickaxeLevel: 1, currentTier: 1, oreMultipliers: { coal: 1, iron: 1, gold: 1, diamond: 1 }, respawnTime: 3000 // 3 seconds by default }; // Create the miner var miner = game.addChild(new Miner()); miner.x = 2048 / 2; miner.y = 2732 / 2; // Create ores var ores = ['coal', 'iron', 'gold', 'diamond'].map(function (type) { var ore = new Ore(type); game.addChild(ore); return ore; }); // Background var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5 }); background.x = 2048 / 2; background.y = 2732 / 2; game.addChildAt(background, 0); // UI Elements var moneyDisplay = new Text2('$0', { size: 80, fill: 0xFFFFFF, fontWeight: 'bold', stroke: 0x000000, strokeThickness: 5 }); moneyDisplay.x = 2048 / 2 - moneyDisplay.width / 2; moneyDisplay.y = 50; var shopButton = LK.getAsset('buy_button', { anchorX: 0.5, anchorY: 0.5 }); shopButton.x = 2048 - 150; shopButton.y = 2732 - 150; shopButton.down = function () { createUpgradeMenu(); game.addChild(upgradeMenu); }; game.addChild(moneyDisplay); game.addChild(shopButton); game.addChild(tooltip); function createUpgradeMenu() { // Clear old menu upgradeMenu.removeChildren(); // Menu background var menuBg = LK.getAsset('rectangle', { width: 1600, height: 1800, color: 0x2a2a2a, anchorX: 0.5, anchorY: 0.5 }); menuBg.x = 2048 / 2; menuBg.y = 2732 / 2; upgradeMenu.addChild(menuBg); // ------------------ // 5) Put the buy button behind the text: // - We'll first add the button, then add the text on top in the upgradeMenu. // ------------------ upgrades.forEach(function (upgrade, i) { var requirement = null; if (upgrade.requires) { requirement = upgrades.find(function (u) { return u.id === upgrade.requires; }); } var y = 2732 / 2 - 500 + i * 200; // The buy button var btn = LK.getAsset('buy_button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = 2048 / 2; btn.y = y; upgradeMenu.addChild(btn); // Decide if we can buy var canBuy = !upgrade.purchased && gameState.money >= upgrade.cost && (!requirement || requirement.purchased); // Text on top of button var text = new Text2(upgrade.name + "\n" + upgrade.effect + "\n$" + upgrade.cost, { size: 40, fill: canBuy ? 0xFFFFFF : 0x666666, align: 'center' }); text.anchor.set(0.5, 0.5); text.x = btn.x; text.y = btn.y; upgradeMenu.addChild(text); // Button action btn.down = function () { if (canBuy) { gameState.money -= upgrade.cost; upgrade.purchased = true; upgrade.action(); createUpgradeMenu(); updateUI(); } }; }); // Close button var closeBtn = LK.getAsset('cancelButton', { anchorX: 0.5, anchorY: 0.5 }); closeBtn.x = 2048 / 2 + 600; closeBtn.y = 2732 / 2 - 700; closeBtn.down = function () { return game.removeChild(upgradeMenu); }; upgradeMenu.addChild(closeBtn); } function updateUI() { moneyDisplay.setText("$" + gameState.money.toLocaleString() + "\n" + "Multipliers: " + "C" + gameState.oreMultipliers.coal + "x " + "I" + gameState.oreMultipliers.iron + "x " + "G" + gameState.oreMultipliers.gold + "x " + "D" + gameState.oreMultipliers.diamond + "x"); moneyDisplay.x = 2048 / 2 - moneyDisplay.width / 2; } // Main game update game.update = function () { miner.update(); ores.forEach(function (ore) { if (ore.health > 0) { ore.healthBar.width = 60 * (ore.health / 10); ore.healthBar.fill = interpolateColor(0xFF0000, 0x00FF00, ore.health / 10); } }); }; // Helper for color interpolation function interpolateColor(color1, color2, factor) { var r1 = color1 >> 16 & 0xff; var g1 = color1 >> 8 & 0xff; var b1 = color1 & 0xff; var r2 = color2 >> 16 & 0xff; var g2 = color2 >> 8 & 0xff; var b2 = color2 & 0xff; var r = Math.round(r1 + factor * (r2 - r1)); var g = Math.round(g1 + factor * (g2 - g1)); var b = Math.round(b1 + factor * (b2 - b1)); return r << 16 | g << 8 | b; } // Save & Load LK.saveGame = function () { return gameState; }; LK.loadGame = function (data) { gameState = data; updateUI(); }; // Initial setup updateUI();
===================================================================
--- original.js
+++ change.js
@@ -18,8 +18,27 @@
self.miningRange = 25;
self.miningCooldown = 0;
self.miningRate = 30;
self.miningDamage = 1;
+ // ------------------
+ // 1) Miner picks the *closest* valid ore (rather than the highest tier):
+ // We simply sort valid ores by distance ascending.
+ // ------------------
+ self.findNewTarget = function () {
+ var validOres = ores.filter(function (ore) {
+ return ore.health > 0 && ore.tier <= gameState.currentTier;
+ });
+ if (validOres.length === 0) {
+ self.currentTarget = null;
+ return;
+ }
+ // Sort by distance ascending
+ self.currentTarget = validOres.sort(function (a, b) {
+ var distA = Math.hypot(a.x - self.x, a.y - self.y);
+ var distB = Math.hypot(b.x - self.x, b.y - self.y);
+ return distA - distB;
+ })[0];
+ };
self.update = function () {
self.findNewTarget();
if (self.currentTarget) {
var dx = self.currentTarget.x - self.x;
@@ -34,35 +53,25 @@
} else {
self.y += Math.sin(LK.time.elapsed / 250) * 0.5;
}
};
- self.findNewTarget = function () {
- var validOres = ores.filter(function (ore) {
- return ore.health > 0 && ore.tier <= gameState.currentTier;
- });
- if (validOres.length === 0) {
- return;
- }
- self.currentTarget = validOres.sort(function (a, b) {
- if (a.tier !== b.tier) {
- return b.tier - a.tier;
- }
- return Math.hypot(a.x - self.x, a.y - self.y) - Math.hypot(b.x - self.x, b.y - self.y);
- })[0];
- };
self.mineOre = function (ore) {
if (self.miningCooldown > 0) {
self.miningCooldown--;
return;
}
+ // Deal damage
ore.health -= self.miningDamage * gameState.pickaxeLevel;
self.miningCooldown = self.miningRate;
+ // If ore is destroyed, add money & respawn with delay
if (ore.health <= 0) {
gameState.money += ore.getValue();
- ore.respawn();
updateUI();
+ ore.respawn();
+ // Immediately find new target
self.findNewTarget();
}
+ // Mining particle effect
for (var i = 0; i < 5; i++) {
var p = LK.getAsset('mining_particle', {
anchorX: 0.5,
anchorY: 0.5
@@ -90,45 +99,75 @@
var Ore = Container.expand(function (type) {
var self = Container.call(this);
self.type = type;
self.tier = ['coal', 'iron', 'gold', 'diamond'].indexOf(type) + 1;
+ // Value depends on tier (5 * tier base) plus multipliers
self.baseValue = 5 * self.tier;
self.attachAsset(type + '_ore', {
anchorX: 0.5,
anchorY: 0.5
});
+ // Returns final value (this ensures higher ores give more)
self.getValue = function () {
- return self.baseValue * gameState.oreMultipliers[type];
+ return self.baseValue * gameState.oreMultipliers[self.type];
};
+ // ------------------
+ // 2) Add a respawn timer. We now hide the ore, wait, then put it back.
+ // The timer is controlled by gameState.respawnTime, which can be upgraded.
+ // ------------------
self.respawn = function () {
- self.health = 10;
- self.visible = true;
- self.x = 100 + Math.random() * (2048 - 200);
- self.y = 100 + Math.random() * (2732 - 200);
- var indicator = LK.getAsset('glowing_line_asset', {
- width: 100,
- height: 100
- });
- indicator.x = self.x;
- indicator.y = self.y;
- game.addChild(indicator);
- tween(indicator, {
- alpha: 0
- }, {
- duration: 1000,
+ // Hide & "remove" ore
+ self.visible = false;
+ self.health = 0;
+ self.x = -9999;
+ self.y = -9999;
+ // Use tween with 0 property changes, just to use onFinish after the delay
+ tween(self, {}, {
+ duration: gameState.respawnTime,
onFinish: function onFinish() {
- return indicator.destroy();
+ // Restore ore
+ self.health = 10;
+ self.x = 100 + Math.random() * (2048 - 200);
+ self.y = 100 + Math.random() * (2732 - 200);
+ self.visible = true;
+ // Glowing indicator
+ var indicator = LK.getAsset('glowing_line_asset', {
+ width: 100,
+ height: 100
+ });
+ indicator.x = self.x;
+ indicator.y = self.y;
+ game.addChild(indicator);
+ tween(indicator, {
+ alpha: 0
+ }, {
+ duration: 1000,
+ onFinish: function onFinish() {
+ return indicator.destroy();
+ }
+ });
}
});
};
+ // Health bar
self.healthBar = LK.getAsset('rectangle', {
width: 60,
height: 5,
fill: 0x00FF00
});
self.healthBar.y = -40;
self.addChild(self.healthBar);
- self.respawn();
+ // Place ore randomly at start
+ // (Call respawn directly to set position, etc.)
+ // Because we want it visible at first, we set a tiny delay of 1 so it spawns immediately
+ tween(self, {}, {
+ duration: 1,
+ onFinish: function onFinish() {
+ self.health = 10;
+ self.x = 100 + Math.random() * (2048 - 200);
+ self.y = 100 + Math.random() * (2732 - 200);
+ }
+ });
return self;
});
/****
@@ -140,30 +179,36 @@
/****
* Game Code
****/
+// This container is for the upgrade menu
var upgradeMenu = new Container();
var tooltip = new Text2('', {
size: 40,
fill: 0xFFFFFF
});
+// ------------------
+// 3) Add an upgrade that lowers the respawn time.
+// We also keep existing upgrades.
+// The "faster_respawn" upgrade will cut the time in half (down to a minimum).
+// ------------------
var upgrades = [{
id: 'coal_expert',
name: "Coal Expertise",
cost: 100,
effect: "Double coal value",
tier: 1,
action: function action() {
- return gameState.oreMultipliers.coal *= 2;
+ gameState.oreMultipliers.coal *= 2;
}
}, {
id: 'unlock_iron',
name: "Iron Mining",
cost: 500,
effect: "Unlock iron mining",
tier: 2,
action: function action() {
- return gameState.currentTier = 2;
+ gameState.currentTier = 2;
}
}, {
id: 'iron_expert',
name: "Iron Expertise",
@@ -171,18 +216,18 @@
effect: "Triple iron value",
tier: 2,
requires: 'unlock_iron',
action: function action() {
- return gameState.oreMultipliers.iron *= 3;
+ gameState.oreMultipliers.iron *= 3;
}
}, {
id: 'unlock_gold',
name: "Gold Mining",
cost: 5000,
effect: "Unlock gold mining",
tier: 3,
action: function action() {
- return gameState.currentTier = 3;
+ gameState.currentTier = 3;
}
}, {
id: 'gold_expert',
name: "Gold Expertise",
@@ -190,20 +235,36 @@
effect: "Quadruple gold value",
tier: 3,
requires: 'unlock_gold',
action: function action() {
- return gameState.oreMultipliers.gold *= 4;
+ gameState.oreMultipliers.gold *= 4;
}
}, {
id: 'unlock_diamond',
name: "Diamond Mining",
cost: 20000,
effect: "Unlock diamond mining",
tier: 4,
action: function action() {
- return gameState.currentTier = 4;
+ gameState.currentTier = 4;
}
+},
+// New upgrade to lower respawn time
+{
+ id: 'faster_respawn',
+ name: "Quicker Respawn",
+ cost: 8000,
+ effect: "Halves ore respawn time",
+ tier: 2,
+ action: function action() {
+ // Halve the respawn time, but don't let it go below 500 ms
+ gameState.respawnTime = Math.max(500, gameState.respawnTime / 2);
+ }
}];
+// ------------------
+// 4) Added a new property: respawnTime, controlling how long
+// each ore waits before reappearing. Default is 3000 ms.
+// ------------------
var gameState = {
money: 0,
pickaxeLevel: 1,
currentTier: 1,
@@ -211,10 +272,12 @@
coal: 1,
iron: 1,
gold: 1,
diamond: 1
- }
+ },
+ respawnTime: 3000 // 3 seconds by default
};
+// Create the miner
var miner = game.addChild(new Miner());
miner.x = 2048 / 2;
miner.y = 2732 / 2;
// Create ores
@@ -254,8 +317,9 @@
game.addChild(moneyDisplay);
game.addChild(shopButton);
game.addChild(tooltip);
function createUpgradeMenu() {
+ // Clear old menu
upgradeMenu.removeChildren();
// Menu background
var menuBg = LK.getAsset('rectangle', {
width: 1600,
@@ -266,34 +330,41 @@
});
menuBg.x = 2048 / 2;
menuBg.y = 2732 / 2;
upgradeMenu.addChild(menuBg);
- // Upgrades
+ // ------------------
+ // 5) Put the buy button behind the text:
+ // - We'll first add the button, then add the text on top in the upgradeMenu.
+ // ------------------
upgrades.forEach(function (upgrade, i) {
- var _upgrades$find;
+ var requirement = null;
+ if (upgrade.requires) {
+ requirement = upgrades.find(function (u) {
+ return u.id === upgrade.requires;
+ });
+ }
var y = 2732 / 2 - 500 + i * 200;
+ // The buy button
var btn = LK.getAsset('buy_button', {
anchorX: 0.5,
anchorY: 0.5
});
btn.x = 2048 / 2;
btn.y = y;
- var canBuy = !upgrade.purchased && gameState.money >= upgrade.cost && (!upgrade.requires || ((_upgrades$find = upgrades.find(function (u) {
- return u.id === upgrade.requires;
- })) === null || _upgrades$find === void 0 ? void 0 : _upgrades$find.purchased));
- var text = new Text2("".concat(upgrade.name, "\n").concat(upgrade.effect, "\n$").concat(upgrade.cost), {
+ upgradeMenu.addChild(btn);
+ // Decide if we can buy
+ var canBuy = !upgrade.purchased && gameState.money >= upgrade.cost && (!requirement || requirement.purchased);
+ // Text on top of button
+ var text = new Text2(upgrade.name + "\n" + upgrade.effect + "\n$" + upgrade.cost, {
size: 40,
- fill: 0x000000,
- // Always black text
- fontWeight: 'bold',
- // Make text bold
- stroke: 0x000000,
- // Add black outline
- strokeThickness: 3 // Thickness of the outline
+ fill: canBuy ? 0xFFFFFF : 0x666666,
+ align: 'center'
});
- text.anchor.set(0.5);
- upgradeMenu.addChild(btn);
- btn.addChild(text);
+ text.anchor.set(0.5, 0.5);
+ text.x = btn.x;
+ text.y = btn.y;
+ upgradeMenu.addChild(text);
+ // Button action
btn.down = function () {
if (canBuy) {
gameState.money -= upgrade.cost;
upgrade.purchased = true;
@@ -301,9 +372,8 @@
createUpgradeMenu();
updateUI();
}
};
- upgradeMenu.addChild(btn);
});
// Close button
var closeBtn = LK.getAsset('cancelButton', {
anchorX: 0.5,
@@ -316,11 +386,12 @@
};
upgradeMenu.addChild(closeBtn);
}
function updateUI() {
- moneyDisplay.setText("$".concat(gameState.money.toLocaleString(), "\n") + "Multipliers: C".concat(gameState.oreMultipliers.coal, "x ") + "I".concat(gameState.oreMultipliers.iron, "x ") + "G".concat(gameState.oreMultipliers.gold, "x ") + "D".concat(gameState.oreMultipliers.diamond, "x"));
+ moneyDisplay.setText("$" + gameState.money.toLocaleString() + "\n" + "Multipliers: " + "C" + gameState.oreMultipliers.coal + "x " + "I" + gameState.oreMultipliers.iron + "x " + "G" + gameState.oreMultipliers.gold + "x " + "D" + gameState.oreMultipliers.diamond + "x");
moneyDisplay.x = 2048 / 2 - moneyDisplay.width / 2;
}
+// Main game update
game.update = function () {
miner.update();
ores.forEach(function (ore) {
if (ore.health > 0) {
@@ -328,19 +399,22 @@
ore.healthBar.fill = interpolateColor(0xFF0000, 0x00FF00, ore.health / 10);
}
});
};
-// Helper functions
+// Helper for color interpolation
function interpolateColor(color1, color2, factor) {
var r1 = color1 >> 16 & 0xff;
var g1 = color1 >> 8 & 0xff;
var b1 = color1 & 0xff;
var r2 = color2 >> 16 & 0xff;
var g2 = color2 >> 8 & 0xff;
var b2 = color2 & 0xff;
- return Math.round(r1 + factor * (r2 - r1)) << 16 | Math.round(g1 + factor * (g2 - g1)) << 8 | Math.round(b1 + factor * (b2 - b1));
+ var r = Math.round(r1 + factor * (r2 - r1));
+ var g = Math.round(g1 + factor * (g2 - g1));
+ var b = Math.round(b1 + factor * (b2 - b1));
+ return r << 16 | g << 8 | b;
}
-// Save system
+// Save & Load
LK.saveGame = function () {
return gameState;
};
LK.loadGame = function (data) {
drone_shot
Sound effect
mine_coal
Sound effect
mine_iron
Sound effect
mine_gold
Sound effect
mine_diamond
Sound effect
mine_sapphire
Sound effect
mine_emerald
Sound effect
mine_ruby
Sound effect
mine_chronostone
Sound effect
mine_quantumshard
Sound effect
ore_destroy_coal
Sound effect
ore_destroy_iron
Sound effect
ore_destroy_gold
Sound effect
ore_destroy_diamond
Sound effect
ore_destroy_sapphire
Sound effect
ore_destroy_emerald
Sound effect
ore_destroy_ruby
Sound effect
mine_coal_1
Sound effect
mine_coal_2
Sound effect
mine_coal_3
Sound effect
mine_diamond1
Sound effect
mine_diamond2
Sound effect
mine_diamond3
Sound effect
mine_emerald1
Sound effect
mine_emerald2
Sound effect
mine_emerald3
Sound effect
mine_gold1
Sound effect
mine_gold2
Sound effect
mine_gold3
Sound effect
mine_iron1
Sound effect
mine_iron2
Sound effect
mine_iron3
Sound effect
mine_ruby1
Sound effect
mine_ruby2
Sound effect
mine_ruby3
Sound effect
mine_sapphire1
Sound effect
mine_sapphire2
Sound effect
mine_sapphire3
Sound effect
song1
Music
song2
Music
song3
Music
song4
Music
song5
Music
song6
Music
song7
Music
song8
Music
song9
Music
song10
Music
song11
Music
song12
Music
song1a
Music
song1b
Music
song2a
Music
song2b
Music
song3a
Music
song3b
Music
song4a
Music
song4b
Music
song5a
Music
song5b
Music
song6a
Music
song6b
Music
song7a
Music
song7b
Music
song8a
Music
song8b
Music
song9a
Music
song9b
Music
song10a
Music
song10b
Music
song11a
Music
song11b
Music
song12a
Music
song12b
Music