Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'initialSpawn is not defined' in or related to this line: 'initialSpawn();' Line Number: 778
User prompt
Please fix the bug: 'ReferenceError: quantumSelectionActive is not defined' in or related to this line: 'if (quantumSelectionActive) {' Line Number: 746
User prompt
Please fix the bug: 'ReferenceError: upgradeMenu is not defined' in or related to this line: 'if (upgradeMenu.parent) {' Line Number: 733
User prompt
Please fix the bug: 'ReferenceError: droneObjects is not defined' in or related to this line: 'for (var i = 0; i < droneObjects.length; i++) {' Line Number: 715
User prompt
Please fix the bug: 'ReferenceError: clusters is not defined' in or related to this line: 'clusters.forEach(function (c) {' Line Number: 167
User prompt
Please fix the bug: 'updateUI is not defined' in or related to this line: 'updateUI();' Line Number: 783
User prompt
Please fix the bug: 'initialSpawn is not defined' in or related to this line: 'initialSpawn();' Line Number: 778
Code edit (5 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: 262
User prompt
var Drone = Container.expand(function () { var self = Container.call(this); // Attach the drone sprite self.droneSprite = LK.getAsset('drone_asset', { anchorX: 0.5, anchorY: 0.5 }); self.addChild(self.droneSprite); // Movement self.vx = (Math.random() - 0.5) * 6; // random velocity x self.vy = (Math.random() - 0.5) * 6; // random velocity y self.speed = 3; self.changeDirCounter = 0; // how many frames until we pick new direction // AoE stats self.AOE_RANGE = 100; self.droneDamage = 2; // how much damage each zap deals (tweak as needed) self.cooldown = 0; // frames self.COOLDOWN_MAX = 60; // 1 second if your game is ~60fps self.updateDrone = function () { // 1) Movement if (self.changeDirCounter <= 0) { // pick new random direction occasionally self.vx = (Math.random() - 0.5) * self.speed; self.vy = (Math.random() - 0.5) * self.speed; self.changeDirCounter = 120; // every 2s } else { self.changeDirCounter--; } // update position self.x += self.vx; self.y += self.vy; // bounce off edges (assuming 2048x2732 stage) if (self.x < 50 || self.x > 2000) self.vx *= -1; if (self.y < 50 || self.y > 2682) self.vy *= -1; // 2) AoE Zap if cooldown is ready if (self.cooldown > 0) { self.cooldown--; } else { self.tryZap(); } }; self.tryZap = function () { // Find any ore within AOE_RANGE // We'll gather a list of clusters or single ores within range var anyHit = false; clusters.forEach(function (cluster) { cluster.oreList.forEach(function (ore) { if (ore.health > 0) { var oreGlobalX = cluster.x + ore.x; var oreGlobalY = cluster.y + ore.y; var dx = self.x - oreGlobalX; var dy = self.y - oreGlobalY; var dist = Math.sqrt(dx*dx + dy*dy); if (dist < self.AOE_RANGE) { // deal damage ore.health -= self.droneDamage; anyHit = true; if (ore.health <= 0) { var baseValue = ore.getValue(); gameState.money += baseValue; updateUI(); ore.cluster.notifyOreDestroyed(ore); spawnMiningParticles(ore, 5); } } } }); }); // If we zapped anything, apply cooldown if (anyHit) { self.cooldown = self.COOLDOWN_MAX; } }; return self; }); game.update = function () { // existing miner update if (miner) miner.update(); // your other logic (clusters, etc.) // update each drone for (var i = 0; i < droneObjects.length; i++) { droneObjects[i].updateDrone(); } }; { id: 'drone_level_1', name: 'Buy Drones (Lv +1)', cost: 5000, effect: 'Each level adds another drone that roams & AoE zaps', purchased: false, multi: true, level: 0, action: function () { if (!gameState.droneLevel) gameState.droneLevel = 0; gameState.droneLevel++; this.level++; this.cost = Math.floor(this.cost * 1.5); updateDroneObjects(); } } var droneObjects = []; // A function to create new drones up to gameState.droneLevel function updateDroneObjects() { // If we want exactly gameState.droneLevel drones: while (droneObjects.length < gameState.droneLevel) { var d = new Drone(); // position them randomly d.x = 200 + Math.random() * (2048 - 400); d.y = 200 + Math.random() * (2732 - 400); droneObjects.push(d); game.addChild(d); } }
User prompt
// Make sure to call updateDroneSprites() after you buy or increase drone level: { // inside the 'drone_level_1' upgrade or anywhere you increment droneLevel: action: function () { gameState.droneLevel++; this.level++; this.cost = Math.floor(this.cost * 1.5); updateDroneSprites(); } }
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: 'if (LK.time.elapsed % 60 === 0) {' Line Number: 1332
Code edit (1 edits merged)
Please save this source code
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: 336
Code edit (1 edits merged)
Please save this source code
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: 294
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
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ /** * Cluster spawns multiple Ore objects of a given type. */ var Cluster = Container.expand(function (type) { var self = Container.call(this); self.type = type; self.oreList = []; // Random center var centerX = 100 + Math.random() * (2048 - 200); var centerY = 100 + Math.random() * (2732 - 200); self.x = centerX; self.y = centerY; // Decide how many ore in this cluster var cc = gameState.clusterConfig; var count = randomInt(cc.min, cc.max); // Create ore for (var i = 0; i < count; i++) { var ore = new Ore(type, self); ore.x = (Math.random() - 0.5) * 120; ore.y = (Math.random() - 0.5) * 120; self.oreList.push(ore); self.addChild(ore); } self.notifyOreDestroyed = function (ore) { var idx = self.oreList.indexOf(ore); if (idx >= 0) { self.oreList.splice(idx, 1); } ore.destroy(); // If all gone => remove cluster if (self.oreList.length === 0) { if (self.parent) { self.parent.removeChild(self); } var cidx = clusters.indexOf(self); if (cidx >= 0) { clusters.splice(cidx, 1); } gameState.clusterCount[type]--; // Wait respawnTime, then spawn new cluster var finalDelay = gameState.respawnTime; if (type === 'coal') { finalDelay *= 2; // slow for coal } LK.setTimeout(function () { maybeSpawnCluster(type); }, finalDelay); } }; return self; }); /** * Miner moves to the closest valid ore and mines it. */ 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; // frames per "hit" self.miningDamage = 1; // For the Chronostone speed boost self.speedBoostMultiplier = 1; // accumulative if multiple boosts occur self.speedBoostTimer = 0; // frames left // For the Soul Ember 500% value boost (for next 10 ores) self.soulEmberStacks = 0; // how many empowered hits remain // For the Quantum Shard pathing system self.quantumPathActive = false; self.quantumPath = []; self.quantumShardValueBonus = false; // 50% bonus if path completed self.findNewTarget = function () { if (self.quantumPathActive && self.quantumPath.length > 0) { // If quantum path is active and we have a queued path, pick the next ore self.currentTarget = self.quantumPath[0]; // If that ore is destroyed or invalid, remove it and find again if (!self.currentTarget || self.currentTarget.health <= 0) { self.quantumPath.shift(); if (self.quantumPath.length === 0) { // finished the path if (self.quantumShardValueBonus) { // maybe notify user or something self.quantumShardValueBonus = false; } self.quantumPathActive = false; self.currentTarget = null; } return; } return; } // Normal search var validOre = []; clusters.forEach(function (c) { c.oreList.forEach(function (ore) { if (ore.health > 0 && ore.tier <= gameState.currentTier) { validOre.push(ore); } }); }); if (validOre.length === 0) { self.currentTarget = null; return; } // Sort by distance self.currentTarget = validOre.sort(function (a, b) { var aX = a.parent.x + a.x; var aY = a.parent.y + a.y; var bX = b.parent.x + b.x; var bY = b.parent.y + b.y; var distA = Math.hypot(aX - self.x, aY - self.y); var distB = Math.hypot(bX - self.x, bY - self.y); return distA - distB; })[0]; }; self.update = function () { // Decay speed boost if active if (self.speedBoostTimer > 0) { self.speedBoostTimer--; if (self.speedBoostTimer <= 0) { // reset self.speedBoostMultiplier = 1; } } self.findNewTarget(); if (self.currentTarget) { var tx = self.currentTarget.parent.x + self.currentTarget.x; var ty = self.currentTarget.parent.y + self.currentTarget.y; var dx = tx - self.x; var dy = ty - self.y; var dist = Math.sqrt(dx * dx + dy * dy); var finalSpeed = self.speed * self.speedBoostMultiplier; if (dist > self.miningRange) { self.x += dx / dist * finalSpeed; self.y += dy / dist * finalSpeed; } else { self.mineOre(self.currentTarget); } } else { // idle float self.y += Math.sin(LK.time.elapsed / 250) * 0.5; } }; self.mineOre = function (ore) { if (self.miningCooldown > 0) { self.miningCooldown--; return; } // If quantum path is in effect, once we mine this target, remove it from path if (self.quantumPathActive && self.quantumPath.length > 0 && self.quantumPath[0] === ore) { self.quantumPath.shift(); if (self.quantumPath.length === 0) { // done if (self.quantumShardValueBonus) { // 50% extra money for the chain. // We'll just handle that by applying the multiplier below } self.quantumPathActive = false; } } var damageDealt = self.miningDamage * gameState.pickaxeLevel; ore.health -= damageDealt; self.miningCooldown = self.miningRate; // reset cooldown if (ore.health <= 0) { var baseValue = ore.getValue(); var finalValue = baseValue; // If soul ember effect is active, 500% value if (self.soulEmberStacks > 0) { finalValue *= 5; // 500% self.soulEmberStacks--; } // If quantum shard chain is active and we want a 50% bonus if (self.quantumShardValueBonus) { finalValue *= 1.5; } gameState.money += finalValue; updateUI(); ore.cluster.notifyOreDestroyed(ore); spawnMiningParticles(ore, 5); } else { spawnMiningParticles(ore, 2); } }; // Chronostone speed boost self.applyChronostoneBoost = function () { self.speedBoostMultiplier *= 3; // +200% on top of current (300% total speed) self.speedBoostTimer = 30 * 60; // 30 seconds at 60fps }; // Soul Ember effect self.applySoulEmberBoost = function () { // Drains 10% money, then next 10 ores are 500% value // only if money >= 1e6 if (gameState.money >= 1e6) { var drain = gameState.money * 0.10; gameState.money -= drain; self.soulEmberStacks = 10; updateUI(); } // else do nothing (auto-decline) }; // Quantum Shard effect self.triggerQuantumShardMode = function () { // Pause game? We can temporarily set a global var to freeze updates except for UI. // But we'll do a simpler approach: set quantumPathActive = true, then let player choose 5 ores. // Darken screen, highlight ores, let user pick up to 5. // We'll store them in self.quantumPath. // Implementation detail: We'll just simulate. self.quantumShardValueBonus = true; // 50% bonus if completed chain self.quantumPathActive = true; self.quantumPath = []; game.pauseForQuantumSelection(); }; return self; }); /** * A single ore object (7 possible types + new prestige ores). */ var Ore = Container.expand(function (type, cluster) { var self = Container.call(this); self.type = type; self.cluster = cluster; // Determine tier based on order. We'll handle special prestige ores differently. var typeList = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby']; if (typeList.indexOf(type) >= 0) { self.tier = typeList.indexOf(type) + 1; } else { // For new special ores, we'll set tier super high so they appear only if we specifically spawn them. self.tier = 999; } self.baseValue = oreData[type].baseValue; self.maxHealth = oreData[type].baseHealth; self.health = self.maxHealth; // Attach sprite self.attachAsset(oreData[type].assetId, { anchorX: 0.5, anchorY: 0.5 }); // Health bar self.healthBar = LK.getAsset('rectangle', { width: 120, height: 20, fill: 0x00FF00, anchorX: 0.5, anchorY: 0.5 }); self.healthBar.x = 0; self.healthBar.y = -70; self.addChild(self.healthBar); self.getValue = function () { return self.baseValue * gameState.oreMultipliers[self.type]; }; return self; }); /**** * Initialize Game ****/ /**** * HELPER FUNCTIONS ****/ /**** * The Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ /**** * HELPER FUNCTIONS ****/ // Additional new special ores // New backgrounds for deeper layers // Image for the Prestige Shop // New images for upgraded pickaxes // Original assets // upgraded pickaxes, a prestige shop, and a separate drone system tab in the buy menu. // Below is the updated code for your Idle Mining game with the requested Prestige system, new ore mechanics, background transitions, // We'll track two backgrounds at a time for transitions function randomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function spawnMiningParticles(ore, num) { for (var i = 0; i < num; i++) { var p = LK.getAsset('mining_particle', { anchorX: 0.5, anchorY: 0.5 }); if (ore.parent) { p.x = ore.parent.x + ore.x; p.y = ore.parent.y + ore.y; } else { 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() { p.destroy(); } }); game.addChild(p); } } function interpolateColor(c1, c2, f) { var r1 = c1 >> 16 & 0xFF, g1 = c1 >> 8 & 0xFF, b1 = c1 & 0xFF; var r2 = c2 >> 16 & 0xFF, g2 = c2 >> 8 & 0xFF, b2 = c2 & 0xFF; var r = Math.round(r1 + f * (r2 - r1)); var g = Math.round(g1 + f * (g2 - g1)); var b = Math.round(b1 + f * (b2 - b1)); return r << 16 | g << 8 | b; } function maybeSpawnCluster(type) { var typeList = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby']; // If these special ores are requested, handle separately. // We'll do normal cluster spawns for standard ore, with a chance to spawn special ores if conditions are met. if (typeList.indexOf(type) >= 0) { var tIndex = typeList.indexOf(type) + 1; if (tIndex > gameState.currentTier) { return; } } if (gameState.clusterCount[type] >= gameState.maxClustersPerType) { return; } var cluster = new Cluster(type); game.addChild(cluster); clusters.push(cluster); gameState.clusterCount[type]++; } // Attempt to spawn special ores if prestige level is high enough function maybeSpawnSpecialOres() { // Chronostone => Prestige >= 3 => 3-5% chance per cluster // Soul Ember => Prestige >= 5 => 1.5-2.5% chance // Quantum Shard => Prestige >= 8 => 0.8-1.2% var spawnChances = []; if (gameState.prestigeCount >= 3) { spawnChances.push({ type: 'chronostone', min: 3, max: 5 }); } if (gameState.prestigeCount >= 5) { spawnChances.push({ type: 'soulember', min: 1.5, max: 2.5 }); } if (gameState.prestigeCount >= 8) { spawnChances.push({ type: 'quantumshard', min: 0.8, max: 1.2 }); } if (spawnChances.length === 0) { return; } // For each standard spawn, we have a chance to replace it with a special ore cluster var standardTypes = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby']; standardTypes.forEach(function (type) { if (gameState.clusterCount[type] < gameState.maxClustersPerType) { // roll chance for each special ore type for (var i = 0; i < spawnChances.length; i++) { var chanceObj = spawnChances[i]; var chance = randomInt(chanceObj.min * 10, chanceObj.max * 10) / 10; // e.g. 3.1% var roll = Math.random() * 100; if (roll < chance) { // spawn that special ore cluster if (gameState.clusterCount[chanceObj.type] < gameState.maxClustersPerType) { maybeSpawnCluster(chanceObj.type); } } } } }); } var currentBackground = null; var nextBackground = null; // miner instance var miner = null; // Keep references to each cluster container var clusters = []; /**** * ORE DATA ****/ var oreData = { coal: { baseValue: 5, baseHealth: 10, assetId: 'coal_ore' }, iron: { baseValue: 500, baseHealth: 100, assetId: 'iron_ore' }, gold: { baseValue: 10000, baseHealth: 500, assetId: 'gold_ore' }, diamond: { baseValue: 25000, baseHealth: 1000, assetId: 'diamond_ore' }, sapphire: { baseValue: 100000, baseHealth: 2000, assetId: 'sapphire_ore' }, emerald: { baseValue: 500000, baseHealth: 5000, assetId: 'emerald_ore' }, ruby: { baseValue: 1000000, baseHealth: 10000, assetId: 'ruby_ore' }, chronostone: { baseValue: 2000000, baseHealth: 2000, assetId: 'chronostone_ore' }, soulember: { baseValue: 5000000, baseHealth: 5000, assetId: 'soulember_ore' }, quantumshard: { baseValue: 10000000, baseHealth: 10000, assetId: 'quantumshard_ore' } }; /**** * GAME STATE ****/ var gameState = { money: 0, pickaxeLevel: 1, currentTier: 1, oreMultipliers: { coal: 1, iron: 1, gold: 1, diamond: 1, sapphire: 1, emerald: 1, ruby: 1, chronostone: 1, soulember: 1, quantumshard: 1 }, respawnTime: 3000, maxClustersPerType: 3, clusterCount: { coal: 0, iron: 0, gold: 0, diamond: 0, sapphire: 0, emerald: 0, ruby: 0, chronostone: 0, soulember: 0, quantumshard: 0 }, clusterConfigLevels: [{ min: 2, max: 3 }, { min: 2, max: 4 }, { min: 3, max: 5 }, { min: 5, max: 10 }], clusterUpgradeTier: 0, get clusterConfig() { return this.clusterConfigLevels[this.clusterUpgradeTier] || { min: 2, max: 3 }; }, // Prestige prestigeCount: 0, prestigeCurrency: 0 }; /**** * HELPER FUNCTIONS FOR PRESTIGE ****/ function getPrestigeRequirement() { // Example: Next prestige requires 1e12 * (10^(2*prestigeCount)) etc. // We'll just do a simpler approach for demonstration. var base = 1e12; // 1 trillion var multiplier = Math.pow(1000, gameState.prestigeCount); // scale by 1000 each time return base * multiplier; } function canPrestige() { return gameState.money >= getPrestigeRequirement(); } function calculatePrestigeShards() { // example: 1 shard per 10x over threshold var threshold = getPrestigeRequirement(); if (gameState.money < threshold) { return 0; } var ratio = gameState.money / threshold; var shards = Math.floor(Math.log10(ratio) * 2); // scale return Math.max(shards, 1); } function doPrestige() { // Clear all clusters from screen for (var i = clusters.length - 1; i >= 0; i--) { var c = clusters[i]; c.removeChildren(); if (c.parent) { c.parent.removeChild(c); } clusters.splice(i, 1); } // Calculate shards, increment prestige count var shards = calculatePrestigeShards(); gameState.prestigeCurrency += shards; gameState.prestigeCount++; // Reset progression but keep prestige shop items (pickaxe upgrades can remain partial or we can reset them if you want) gameState.money = 0; gameState.currentTier = 1; // reset cluster counts for (var key in gameState.clusterCount) { gameState.clusterCount[key] = 0; } // background transition handleBackgroundTransition(); // Re-initialize spawns initialSpawn(); updateUI(); } /**** * BACKGROUND TRANSITION ****/ function handleBackgroundTransition() { // If we have a next background that was in transition, remove it. if (nextBackground && nextBackground.parent) { nextBackground.parent.removeChild(nextBackground); } // We'll pick a background based on prestige tiers: 3,5,8 var newBg = null; if (gameState.prestigeCount >= 8) { newBg = LK.getAsset('background_tier8', { anchorX: 0.5, anchorY: 0.5 }); } else if (gameState.prestigeCount >= 5) { newBg = LK.getAsset('background_tier5', { anchorX: 0.5, anchorY: 0.5 }); } else if (gameState.prestigeCount >= 3) { newBg = LK.getAsset('background_tier3', { anchorX: 0.5, anchorY: 0.5 }); } else { newBg = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5 }); } newBg.x = 2048 / 2; newBg.y = 2732 + 2732 / 2; // start off-screen bottom game.addChild(newBg); nextBackground = newBg; var oldBg = currentBackground; if (!oldBg) { // If none, the old background is just the normal background. oldBg = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5 }); oldBg.x = 2048 / 2; oldBg.y = 2732 / 2; game.addChildAt(oldBg, 0); } // If oldBg is the same as newBg, skip. if (oldBg === newBg) { currentBackground = newBg; return; } // Move them upwards for 3 seconds to simulate descending var dur = 3000; tween(oldBg, { y: oldBg.y - 2732 }, { duration: dur, onFinish: function onFinish() { if (oldBg && oldBg.parent) { oldBg.parent.removeChild(oldBg); } } }); tween(newBg, { y: 2732 / 2 }, { duration: dur, onFinish: function onFinish() { currentBackground = newBg; } }); } /**** * DRONES ****/ // We'll add a new tab in the main buy menu for drones. // For simplicity, let's store a droneLevel in gameState and each level adds some base DPS. var droneDPS = 0; // We'll accumulate from drone upgrades. function getDroneDPS() { // formula: each level adds some base DPS. // e.g. 10 * droneLevel. return 10 * gameState.droneLevel; } function droneDamageTick() { // Let the drones deal damage over time. // We'll do a simplified approach: find random valid ores and deal damage. var dps = getDroneDPS(); if (dps <= 0) { return; } // pick random ore or distribute among them. var totalOreCount = 0; var allValidOres = []; clusters.forEach(function (c) { c.oreList.forEach(function (ore) { if (ore.health > 0 && ore.tier <= gameState.currentTier) { allValidOres.push(ore); } }); }); if (allValidOres.length === 0) { return; } // We'll just do total dps as damage distributed among some random ore. var damageRemaining = dps; while (damageRemaining > 0 && allValidOres.length > 0) { var randomIndex = Math.floor(Math.random() * allValidOres.length); var ore = allValidOres[randomIndex]; var chunk = Math.min(damageRemaining, 10); // deal in chunks ore.health -= chunk; damageRemaining -= chunk; if (ore.health <= 0) { // kill ore var baseValue = ore.getValue(); gameState.money += baseValue; updateUI(); ore.cluster.notifyOreDestroyed(ore); spawnMiningParticles(ore, 5); allValidOres.splice(randomIndex, 1); } } } /**** * UPGRADE DATA ****/ // We'll add a tab for drones in main menu, with upgrades. // We'll also add a new prestige shop with artifacts. var oreUpgrades = { coal: [{ id: 'double_coal', name: 'Double Coal Value', cost: 100, multi: true, level: 0, effect: 'Doubles Coal Value each purchase', action: function action() { this.level++; gameState.oreMultipliers.coal *= 2; this.cost *= 2; } }], iron: [{ id: 'unlock_iron', name: 'Unlock Iron Mining', cost: 500, effect: 'Allows iron ore clusters to spawn', purchased: false, action: function action() { // Increase currentTier if needed if (gameState.currentTier < 2) { gameState.currentTier = 2; } // Immediately spawn some iron for (var i = 0; i < gameState.maxClustersPerType; i++) { maybeSpawnCluster('iron'); } } }, { id: 'double_iron', name: 'Double Iron Value', cost: 1000, multi: true, level: 0, effect: 'Doubles Iron Value each purchase', action: function action() { this.level++; gameState.oreMultipliers.iron *= 2; this.cost *= 2; } }], gold: [{ id: 'unlock_gold', name: 'Unlock Gold Mining', cost: 5000, effect: 'Allows gold ore clusters to spawn', purchased: false, action: function action() { if (gameState.currentTier < 3) { gameState.currentTier = 3; } for (var i = 0; i < gameState.maxClustersPerType; i++) { maybeSpawnCluster('gold'); } } }, { id: 'double_gold', name: 'Double Gold Value', cost: 20000, multi: true, level: 0, effect: 'Doubles Gold Value each purchase', action: function action() { this.level++; gameState.oreMultipliers.gold *= 2; this.cost *= 2; } }], diamond: [{ id: 'unlock_diamond', name: 'Unlock Diamond Mining', cost: 20000, effect: 'Allows diamond ore clusters to spawn', purchased: false, action: function action() { if (gameState.currentTier < 4) { gameState.currentTier = 4; } for (var i = 0; i < gameState.maxClustersPerType; i++) { maybeSpawnCluster('diamond'); } } }, { id: 'double_diamond', name: 'Double Diamond Value', cost: 50000, multi: true, level: 0, effect: 'Doubles Diamond Value each purchase', action: function action() { this.level++; gameState.oreMultipliers.diamond *= 2; this.cost *= 2; } }], sapphire: [{ id: 'unlock_sapphire', name: 'Unlock Sapphire Mining', cost: 100000, effect: 'Allows sapphire ore clusters to spawn', purchased: false, action: function action() { if (gameState.currentTier < 5) { gameState.currentTier = 5; } for (var i = 0; i < gameState.maxClustersPerType; i++) { maybeSpawnCluster('sapphire'); } } }, { id: 'double_sapphire', name: 'Double Sapphire Value', cost: 200000, multi: true, level: 0, effect: 'Doubles Sapphire Value each purchase', action: function action() { this.level++; gameState.oreMultipliers.sapphire *= 2; this.cost *= 2; } }], emerald: [{ id: 'unlock_emerald', name: 'Unlock Emerald Mining', cost: 500000, effect: 'Allows emerald ore clusters to spawn', purchased: false, action: function action() { if (gameState.currentTier < 6) { gameState.currentTier = 6; } for (var i = 0; i < gameState.maxClustersPerType; i++) { maybeSpawnCluster('emerald'); } } }, { id: 'double_emerald', name: 'Double Emerald Value', cost: 1000000, multi: true, level: 0, effect: 'Doubles Emerald Value each purchase', action: function action() { this.level++; gameState.oreMultipliers.emerald *= 2; this.cost *= 2; } }], ruby: [{ id: 'unlock_ruby', name: 'Unlock Ruby Mining', cost: 1000000, effect: 'Allows ruby ore clusters to spawn', purchased: false, action: function action() { if (gameState.currentTier < 7) { gameState.currentTier = 7; } for (var i = 0; i < gameState.maxClustersPerType; i++) { maybeSpawnCluster('ruby'); } } }, { id: 'double_ruby', name: 'Double Ruby Value', cost: 2000000, multi: true, level: 0, effect: 'Doubles Ruby Value each purchase', action: function action() { this.level++; gameState.oreMultipliers.ruby *= 2; this.cost *= 2; } }] }; var generalUpgrades = [{ id: 'faster_respawn', name: 'Quicker Respawn', cost: 8000, effect: 'Halves respawn time (min 500 ms)', purchased: false, action: function action() { gameState.respawnTime = Math.max(500, gameState.respawnTime / 2); } }, { id: 'cluster_up', name: 'Cluster Growth', cost: 1000, effect: 'Increases cluster size range', purchased: false, action: function action() { if (gameState.clusterUpgradeTier < gameState.clusterConfigLevels.length - 1) { gameState.clusterUpgradeTier++; } this.cost += 2000; } }]; // new pickaxe upgrades (artifact axes) in the Prestige shop var prestigeUpgrades = [{ id: 'pickaxe_plus_1', name: 'Pickaxe Level +1', cost: 5, effect: 'Increases pickaxe damage by 1', purchased: false, action: function action() { gameState.pickaxeLevel++; } }, { id: 'pickaxe_plus_2', name: 'Pickaxe Speed +10%', cost: 8, effect: 'Reduces mining cooldown by 10%', purchased: false, action: function action() { miner.miningRate = Math.floor(miner.miningRate * 0.90); if (miner.miningRate < 1) { miner.miningRate = 1; } } }, { id: 'pickaxe_plus_3', name: 'Pickaxe Bonus DMG +2', cost: 10, effect: 'Increases pickaxe damage by an additional 2', purchased: false, action: function action() { gameState.pickaxeLevel += 2; } } // you can add more ]; // a separate list for artifact drones in prestige shop var prestigeDrones = [{ id: 'drone_speedup', name: 'Drone Technology +1', cost: 10, effect: 'Increases Drone DPS by 50', purchased: false, action: function action() { if (!gameState.droneLevel) { gameState.droneLevel = 0; } // each purchase +5 levels? gameState.droneLevel += 5; } }]; // standard drone upgrades in the normal buy menu var droneUpgrades = [{ id: 'drone_level_1', name: 'Buy Drones (Lv +1)', cost: 5000, effect: 'Each level adds +10 DPS', purchased: false, multi: true, level: 0, action: function action() { if (!gameState.droneLevel) { gameState.droneLevel = 0; } gameState.droneLevel++; this.level++; this.cost = Math.floor(this.cost * 1.5); } }]; /**** * UI ****/ var upgradeMenu = new Container(); var tooltip = new Text2('', { size: 40, fill: 0xFFFFFF }); game.addChild(tooltip); 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; game.addChild(moneyDisplay); // Add a text display for Prestige info var prestigeDisplay = new Text2('Prestige: 0', { size: 50, fill: 0xFFFFFF, fontWeight: 'bold', stroke: 0x000000, strokeThickness: 4 }); prestigeDisplay.x = 50; prestigeDisplay.y = 50; game.addChild(prestigeDisplay); // Shop icon var shopOpenButton = LK.getAsset('shop_icon', { anchorX: 0.5, anchorY: 0.5 }); shopOpenButton.x = 2048 - 150; shopOpenButton.y = 2732 - 150; shopOpenButton.down = function () { createMainUpgradeMenu(); game.addChild(upgradeMenu); }; game.addChild(shopOpenButton); // Prestige shop icon var prestigeShopButton = LK.getAsset('prestige_shop_icon', { anchorX: 0.5, anchorY: 0.5 }); prestigeShopButton.x = 150; prestigeShopButton.y = 2732 - 150; prestigeShopButton.down = function () { if (canPrestige()) { doPrestige(); } else { createPrestigeShopMenu(); game.addChild(upgradeMenu); } }; game.addChild(prestigeShopButton); // Debug: Add money button var addMoneyButton = LK.getAsset('buy_button', { anchorX: 0.5, anchorY: 0.5 }); addMoneyButton.x = 200; addMoneyButton.y = 2732 - 300; addMoneyButton.down = function () { gameState.money += 5000000000; // 5B updateUI(); }; game.addChild(addMoneyButton); // create main upgrade menu with an additional tab for drones function createMainUpgradeMenu() { upgradeMenu.removeChildren(); subUpgradeItemRefs = []; var menuBg = LK.getAsset('rectangle', { width: 1800, height: 2200, color: 0x2a2a2a, anchorX: 0.5, anchorY: 0.5 }); menuBg.x = 2048 / 2; menuBg.y = 2732 / 2 + 50; upgradeMenu.addChild(menuBg); // 8 categories + 1 drones var categories = [{ name: 'Coal Upgrades', yOff: -800, type: 'coal' }, { name: 'Iron Upgrades', yOff: -600, type: 'iron' }, { name: 'Gold Upgrades', yOff: -400, type: 'gold' }, { name: 'Diamond Upgrades', yOff: -200, type: 'diamond' }, { name: 'Sapphire Upgrades', yOff: 0, type: 'sapphire' }, { name: 'Emerald Upgrades', yOff: 200, type: 'emerald' }, { name: 'Ruby Upgrades', yOff: 400, type: 'ruby' }, { name: 'General Upgrades', yOff: 600, type: 'general' }, { name: 'Drones', yOff: 800, type: 'drones' }]; categories.forEach(function (cat) { var btn = LK.getAsset('buy_button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = menuBg.x; btn.y = menuBg.y + cat.yOff; upgradeMenu.addChild(btn); var txt = new Text2(cat.name, { size: 50, fill: 0x000000, align: 'center' }); txt.anchor.set(0.5); txt.x = btn.x; txt.y = btn.y; upgradeMenu.addChild(txt); btn.down = function () { if (cat.type === 'general') { createSubUpgradeMenu('General Upgrades', generalUpgrades); } else if (cat.type === 'drones') { createSubUpgradeMenu('Drone Upgrades', droneUpgrades); } else { createSubUpgradeMenu(cat.name, oreUpgrades[cat.type]); } }; }); // Close button var closeBtn = LK.getAsset('cancelButton', { anchorX: 0.5, anchorY: 0.5 }); closeBtn.x = menuBg.x + 700; closeBtn.y = menuBg.y - 900; closeBtn.down = function () { game.removeChild(upgradeMenu); }; upgradeMenu.addChild(closeBtn); } var subUpgradeItemRefs = []; function createSubUpgradeMenu(title, upgList) { upgradeMenu.removeChildren(); subUpgradeItemRefs = []; var menuBg = LK.getAsset('rectangle', { width: 1800, height: 2200, color: 0x2a2a2a, anchorX: 0.5, anchorY: 0.5 }); menuBg.x = 2048 / 2; menuBg.y = 2732 / 2 + 50; upgradeMenu.addChild(menuBg); var titleText = new Text2(title, { size: 60, fill: 0xFFFFFF, align: 'center' }); titleText.anchor.set(0.5); titleText.x = menuBg.x; titleText.y = menuBg.y - 1000; upgradeMenu.addChild(titleText); var startY = menuBg.y - 800; upgList.forEach(function (upg, i) { var itemContainer = new Container(); upgradeMenu.addChild(itemContainer); var btn = LK.getAsset('buy_button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = menuBg.x; btn.y = startY + i * 250; itemContainer.addChild(btn); var displayName = upg.name; if (typeof upg.level === 'number' && upg.level > 0) { displayName += " (Lv " + upg.level + ")"; } var costStr = upg.multi ? "$" + upg.cost : "$" + upg.cost; var txtStr = displayName + "\n" + upg.effect + "\n" + costStr; var txt = new Text2(txtStr, { size: 40, fill: 0x666666, align: 'center' }); txt.anchor.set(0.5); txt.x = btn.x; txt.y = btn.y; itemContainer.addChild(txt); btn.down = function () { if (canPurchaseUpgrade(upgList, upg)) { gameState.money -= upg.cost; upg.purchased = true; upg.action(); updateUI(); createSubUpgradeMenu(title, upgList); } }; subUpgradeItemRefs.push({ upgList: upgList, upgrade: upg, textObj: txt }); }); var backBtn = LK.getAsset('cancelButton', { anchorX: 0.5, anchorY: 0.5 }); backBtn.x = menuBg.x + 700; backBtn.y = menuBg.y - 1000; backBtn.down = function () { createMainUpgradeMenu(); }; upgradeMenu.addChild(backBtn); } function canPurchaseUpgrade(upgList, upg) { if (upg.requires) { var needed = upgList.find(function (u) { return u.id === upg.requires; }); if (!needed || !needed.purchased) { return false; } } if (!upg.multi && upg.purchased) { return false; } if (gameState.money < upg.cost) { return false; } return true; } // Prestige Shop Menu function createPrestigeShopMenu() { upgradeMenu.removeChildren(); var menuBg = LK.getAsset('rectangle', { width: 1800, height: 2200, color: 0x2a2a2a, anchorX: 0.5, anchorY: 0.5 }); menuBg.x = 2048 / 2; menuBg.y = 2732 / 2 + 50; upgradeMenu.addChild(menuBg); var titleText = new Text2('Prestige Shop', { size: 60, fill: 0xFFFFFF, align: 'center' }); titleText.anchor.set(0.5); titleText.x = menuBg.x; titleText.y = menuBg.y - 1000; upgradeMenu.addChild(titleText); var shardText = new Text2('Prestige Shards: ' + gameState.prestigeCurrency, { size: 50, fill: 0xFFFF00, align: 'center' }); shardText.anchor.set(0.5); shardText.x = menuBg.x; shardText.y = menuBg.y - 900; upgradeMenu.addChild(shardText); // We'll list pickaxe artifact upgrades and drone artifact upgrades var combinedUpgrades = prestigeUpgrades.concat(prestigeDrones); var startY = menuBg.y - 700; combinedUpgrades.forEach(function (upg, i) { var itemContainer = new Container(); upgradeMenu.addChild(itemContainer); var btn = LK.getAsset('buy_button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = menuBg.x; btn.y = startY + i * 250; itemContainer.addChild(btn); var txtStr = upg.name + "\n" + upg.effect + "\nCost: " + upg.cost + " Shards"; var txt = new Text2(txtStr, { size: 40, fill: 0x666666, align: 'center' }); txt.anchor.set(0.5); txt.x = btn.x; txt.y = btn.y; itemContainer.addChild(txt); btn.down = function () { if (gameState.prestigeCurrency >= upg.cost) { gameState.prestigeCurrency -= upg.cost; upg.action(); updateUI(); createPrestigeShopMenu(); } }; }); var backBtn = LK.getAsset('cancelButton', { anchorX: 0.5, anchorY: 0.5 }); backBtn.x = menuBg.x + 700; backBtn.y = menuBg.y - 1000; backBtn.down = function () { game.removeChild(upgradeMenu); }; upgradeMenu.addChild(backBtn); } /**** * GAME LOOP ****/ var quantumSelectTimer = 0; var quantumSelectionActive = false; game.update = function () { if (miner) { miner.update(); } // Drone DPS tick (maybe once per second) if (LK.time.elapsed % 60 === 0) { droneDamageTick(); } // Update ore visuals clusters.forEach(function (cluster) { cluster.oreList.forEach(function (ore) { if (ore.health > 0) { var fraction = ore.health / ore.maxHealth; ore.healthBar.width = 120 * fraction; ore.healthBar.fill = interpolateColor(0xFF0000, 0x00FF00, fraction); ore.alpha = fraction; } }); }); // Update sub-menu color if open if (upgradeMenu.parent) { subUpgradeItemRefs.forEach(function (ref) { var upg = ref.upgrade; var canBuy = canPurchaseUpgrade(ref.upgList, upg); if (ref.textObj && ref.textObj.style) { ref.textObj.style.fill = canBuy ? 0xFFFFFF : 0x666666; } }); } // If quantum selection is active, track timer if (quantumSelectionActive) { quantumSelectTimer++; if (quantumSelectTimer > 15 * 60) { // 15s passed, unpause quantumSelectionActive = false; miner.quantumPathActive = false; } } }; /**** * UI REFRESH ****/ function updateUI() { moneyDisplay.setText("$" + Math.floor(gameState.money).toLocaleString()); moneyDisplay.x = 2048 / 2 - moneyDisplay.width / 2; prestigeDisplay.setText("Prestige: " + gameState.prestigeCount); } /**** * SAVE & LOAD ****/ LK.saveGame = function () { return gameState; }; LK.loadGame = function (data) { gameState = data; updateUI(); }; /**** * INITIAL SPAWN ****/ function initialSpawn() { var allTypes = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby']; allTypes.forEach(function (type, idx) { var t = idx + 1; if (t <= gameState.currentTier) { for (var i = 0; i < gameState.maxClustersPerType; i++) { maybeSpawnCluster(type); } } }); // also attempt special ore spawns maybeSpawnSpecialOres(); } /**** * START ****/ function startGame() { // spawn backgrounds currentBackground = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5 }); currentBackground.x = 2048 / 2; currentBackground.y = 2732 / 2; game.addChildAt(currentBackground, 0); // create miner miner = new Miner(); miner.x = 2048 / 2; miner.y = 2732 / 2; game.addChild(miner); initialSpawn(); updateUI(); } startGame(); // quantum selection function // This is a stub for the advanced effect. We won't fully implement the UI. game.pauseForQuantumSelection = function () { quantumSelectionActive = true; quantumSelectTimer = 0; // darken screen, highlight ores, etc. };
===================================================================
--- original.js
+++ change.js
@@ -5,11 +5,8 @@
/****
* Classes
****/
-/****
-* CLASSES
-****/
/**
* Cluster spawns multiple Ore objects of a given type.
*/
var Cluster = Container.expand(function (type) {
@@ -74,9 +71,38 @@
self.miningRange = 25;
self.miningCooldown = 0;
self.miningRate = 30; // frames per "hit"
self.miningDamage = 1;
+ // For the Chronostone speed boost
+ self.speedBoostMultiplier = 1; // accumulative if multiple boosts occur
+ self.speedBoostTimer = 0; // frames left
+ // For the Soul Ember 500% value boost (for next 10 ores)
+ self.soulEmberStacks = 0; // how many empowered hits remain
+ // For the Quantum Shard pathing system
+ self.quantumPathActive = false;
+ self.quantumPath = [];
+ self.quantumShardValueBonus = false; // 50% bonus if path completed
self.findNewTarget = function () {
+ if (self.quantumPathActive && self.quantumPath.length > 0) {
+ // If quantum path is active and we have a queued path, pick the next ore
+ self.currentTarget = self.quantumPath[0];
+ // If that ore is destroyed or invalid, remove it and find again
+ if (!self.currentTarget || self.currentTarget.health <= 0) {
+ self.quantumPath.shift();
+ if (self.quantumPath.length === 0) {
+ // finished the path
+ if (self.quantumShardValueBonus) {
+ // maybe notify user or something
+ self.quantumShardValueBonus = false;
+ }
+ self.quantumPathActive = false;
+ self.currentTarget = null;
+ }
+ return;
+ }
+ return;
+ }
+ // Normal search
var validOre = [];
clusters.forEach(function (c) {
c.oreList.forEach(function (ore) {
if (ore.health > 0 && ore.tier <= gameState.currentTier) {
@@ -99,18 +125,27 @@
return distA - distB;
})[0];
};
self.update = function () {
+ // Decay speed boost if active
+ if (self.speedBoostTimer > 0) {
+ self.speedBoostTimer--;
+ if (self.speedBoostTimer <= 0) {
+ // reset
+ self.speedBoostMultiplier = 1;
+ }
+ }
self.findNewTarget();
if (self.currentTarget) {
var tx = self.currentTarget.parent.x + self.currentTarget.x;
var ty = self.currentTarget.parent.y + self.currentTarget.y;
var dx = tx - self.x;
var dy = ty - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
+ var finalSpeed = self.speed * self.speedBoostMultiplier;
if (dist > self.miningRange) {
- self.x += dx / dist * self.speed;
- self.y += dy / dist * self.speed;
+ self.x += dx / dist * finalSpeed;
+ self.y += dy / dist * finalSpeed;
} else {
self.mineOre(self.currentTarget);
}
} else {
@@ -122,38 +157,93 @@
if (self.miningCooldown > 0) {
self.miningCooldown--;
return;
}
- ore.health -= self.miningDamage * gameState.pickaxeLevel;
- self.miningCooldown = self.miningRate;
+ // If quantum path is in effect, once we mine this target, remove it from path
+ if (self.quantumPathActive && self.quantumPath.length > 0 && self.quantumPath[0] === ore) {
+ self.quantumPath.shift();
+ if (self.quantumPath.length === 0) {
+ // done
+ if (self.quantumShardValueBonus) {
+ // 50% extra money for the chain.
+ // We'll just handle that by applying the multiplier below
+ }
+ self.quantumPathActive = false;
+ }
+ }
+ var damageDealt = self.miningDamage * gameState.pickaxeLevel;
+ ore.health -= damageDealt;
+ self.miningCooldown = self.miningRate; // reset cooldown
if (ore.health <= 0) {
- // Add money
- gameState.money += ore.getValue();
+ var baseValue = ore.getValue();
+ var finalValue = baseValue;
+ // If soul ember effect is active, 500% value
+ if (self.soulEmberStacks > 0) {
+ finalValue *= 5; // 500%
+ self.soulEmberStacks--;
+ }
+ // If quantum shard chain is active and we want a 50% bonus
+ if (self.quantumShardValueBonus) {
+ finalValue *= 1.5;
+ }
+ gameState.money += finalValue;
updateUI();
ore.cluster.notifyOreDestroyed(ore);
spawnMiningParticles(ore, 5);
} else {
spawnMiningParticles(ore, 2);
}
};
+ // Chronostone speed boost
+ self.applyChronostoneBoost = function () {
+ self.speedBoostMultiplier *= 3; // +200% on top of current (300% total speed)
+ self.speedBoostTimer = 30 * 60; // 30 seconds at 60fps
+ };
+ // Soul Ember effect
+ self.applySoulEmberBoost = function () {
+ // Drains 10% money, then next 10 ores are 500% value
+ // only if money >= 1e6
+ if (gameState.money >= 1e6) {
+ var drain = gameState.money * 0.10;
+ gameState.money -= drain;
+ self.soulEmberStacks = 10;
+ updateUI();
+ } // else do nothing (auto-decline)
+ };
+ // Quantum Shard effect
+ self.triggerQuantumShardMode = function () {
+ // Pause game? We can temporarily set a global var to freeze updates except for UI.
+ // But we'll do a simpler approach: set quantumPathActive = true, then let player choose 5 ores.
+ // Darken screen, highlight ores, let user pick up to 5.
+ // We'll store them in self.quantumPath.
+ // Implementation detail: We'll just simulate.
+ self.quantumShardValueBonus = true; // 50% bonus if completed chain
+ self.quantumPathActive = true;
+ self.quantumPath = [];
+ game.pauseForQuantumSelection();
+ };
return self;
});
/**
-* A single ore object (7 possible types).
+* A single ore object (7 possible types + new prestige ores).
*/
var Ore = Container.expand(function (type, cluster) {
var self = Container.call(this);
self.type = type;
self.cluster = cluster;
- // Determine tier based on order in this array:
- // [coal, iron, gold, diamond, sapphire, emerald, ruby]
+ // Determine tier based on order. We'll handle special prestige ores differently.
var typeList = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby'];
- self.tier = typeList.indexOf(type) + 1;
+ if (typeList.indexOf(type) >= 0) {
+ self.tier = typeList.indexOf(type) + 1;
+ } else {
+ // For new special ores, we'll set tier super high so they appear only if we specifically spawn them.
+ self.tier = 999;
+ }
self.baseValue = oreData[type].baseValue;
self.maxHealth = oreData[type].baseHealth;
self.health = self.maxHealth;
// Attach sprite
- self.attachAsset(type + '_ore', {
+ self.attachAsset(oreData[type].assetId, {
anchorX: 0.5,
anchorY: 0.5
});
// Health bar
@@ -179,62 +269,197 @@
/****
* HELPER FUNCTIONS
****/
/****
-* THE GAME
+* The Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
-// We'll keep references to each cluster container
/****
-* GLOBAL ARRAYS & STATE
+* HELPER FUNCTIONS
****/
-/****
-* PLUGINS
-****/
-// NEW asset for shop icon
-// NEW assets for additional ores:
-/****
-* ASSETS
-****/
-// Create Miner
+// Additional new special ores
+// New backgrounds for deeper layers
+// Image for the Prestige Shop
+// New images for upgraded pickaxes
+// Original assets
+// upgraded pickaxes, a prestige shop, and a separate drone system tab in the buy menu.
+// Below is the updated code for your Idle Mining game with the requested Prestige system, new ore mechanics, background transitions,
+// We'll track two backgrounds at a time for transitions
+function randomInt(min, max) {
+ return Math.floor(Math.random() * (max - min + 1)) + min;
+}
+function spawnMiningParticles(ore, num) {
+ for (var i = 0; i < num; i++) {
+ var p = LK.getAsset('mining_particle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ if (ore.parent) {
+ p.x = ore.parent.x + ore.x;
+ p.y = ore.parent.y + ore.y;
+ } else {
+ 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() {
+ p.destroy();
+ }
+ });
+ game.addChild(p);
+ }
+}
+function interpolateColor(c1, c2, f) {
+ var r1 = c1 >> 16 & 0xFF,
+ g1 = c1 >> 8 & 0xFF,
+ b1 = c1 & 0xFF;
+ var r2 = c2 >> 16 & 0xFF,
+ g2 = c2 >> 8 & 0xFF,
+ b2 = c2 & 0xFF;
+ var r = Math.round(r1 + f * (r2 - r1));
+ var g = Math.round(g1 + f * (g2 - g1));
+ var b = Math.round(b1 + f * (b2 - b1));
+ return r << 16 | g << 8 | b;
+}
+function maybeSpawnCluster(type) {
+ var typeList = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby'];
+ // If these special ores are requested, handle separately.
+ // We'll do normal cluster spawns for standard ore, with a chance to spawn special ores if conditions are met.
+ if (typeList.indexOf(type) >= 0) {
+ var tIndex = typeList.indexOf(type) + 1;
+ if (tIndex > gameState.currentTier) {
+ return;
+ }
+ }
+ if (gameState.clusterCount[type] >= gameState.maxClustersPerType) {
+ return;
+ }
+ var cluster = new Cluster(type);
+ game.addChild(cluster);
+ clusters.push(cluster);
+ gameState.clusterCount[type]++;
+}
+// Attempt to spawn special ores if prestige level is high enough
+function maybeSpawnSpecialOres() {
+ // Chronostone => Prestige >= 3 => 3-5% chance per cluster
+ // Soul Ember => Prestige >= 5 => 1.5-2.5% chance
+ // Quantum Shard => Prestige >= 8 => 0.8-1.2%
+ var spawnChances = [];
+ if (gameState.prestigeCount >= 3) {
+ spawnChances.push({
+ type: 'chronostone',
+ min: 3,
+ max: 5
+ });
+ }
+ if (gameState.prestigeCount >= 5) {
+ spawnChances.push({
+ type: 'soulember',
+ min: 1.5,
+ max: 2.5
+ });
+ }
+ if (gameState.prestigeCount >= 8) {
+ spawnChances.push({
+ type: 'quantumshard',
+ min: 0.8,
+ max: 1.2
+ });
+ }
+ if (spawnChances.length === 0) {
+ return;
+ }
+ // For each standard spawn, we have a chance to replace it with a special ore cluster
+ var standardTypes = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby'];
+ standardTypes.forEach(function (type) {
+ if (gameState.clusterCount[type] < gameState.maxClustersPerType) {
+ // roll chance for each special ore type
+ for (var i = 0; i < spawnChances.length; i++) {
+ var chanceObj = spawnChances[i];
+ var chance = randomInt(chanceObj.min * 10, chanceObj.max * 10) / 10; // e.g. 3.1%
+ var roll = Math.random() * 100;
+ if (roll < chance) {
+ // spawn that special ore cluster
+ if (gameState.clusterCount[chanceObj.type] < gameState.maxClustersPerType) {
+ maybeSpawnCluster(chanceObj.type);
+ }
+ }
+ }
+ }
+ });
+}
+var currentBackground = null;
+var nextBackground = null;
+// miner instance
+var miner = null;
+// Keep references to each cluster container
var clusters = [];
/****
* ORE DATA
****/
var oreData = {
coal: {
baseValue: 5,
- baseHealth: 10
+ baseHealth: 10,
+ assetId: 'coal_ore'
},
iron: {
baseValue: 500,
- baseHealth: 100
+ baseHealth: 100,
+ assetId: 'iron_ore'
},
gold: {
baseValue: 10000,
- baseHealth: 500
+ baseHealth: 500,
+ assetId: 'gold_ore'
},
diamond: {
baseValue: 25000,
- baseHealth: 1000
+ baseHealth: 1000,
+ assetId: 'diamond_ore'
},
sapphire: {
baseValue: 100000,
- baseHealth: 2000
+ baseHealth: 2000,
+ assetId: 'sapphire_ore'
},
emerald: {
baseValue: 500000,
- baseHealth: 5000
+ baseHealth: 5000,
+ assetId: 'emerald_ore'
},
ruby: {
baseValue: 1000000,
- baseHealth: 10000
+ baseHealth: 10000,
+ assetId: 'ruby_ore'
+ },
+ chronostone: {
+ baseValue: 2000000,
+ baseHealth: 2000,
+ assetId: 'chronostone_ore'
+ },
+ soulember: {
+ baseValue: 5000000,
+ baseHealth: 5000,
+ assetId: 'soulember_ore'
+ },
+ quantumshard: {
+ baseValue: 10000000,
+ baseHealth: 10000,
+ assetId: 'quantumshard_ore'
}
};
/****
* GAME STATE
@@ -249,29 +474,31 @@
gold: 1,
diamond: 1,
sapphire: 1,
emerald: 1,
- ruby: 1
+ ruby: 1,
+ chronostone: 1,
+ soulember: 1,
+ quantumshard: 1
},
- // For controlling cluster spawns & respawns
respawnTime: 3000,
- // base
maxClustersPerType: 3,
clusterCount: {
coal: 0,
iron: 0,
gold: 0,
diamond: 0,
sapphire: 0,
emerald: 0,
- ruby: 0
+ ruby: 0,
+ chronostone: 0,
+ soulember: 0,
+ quantumshard: 0
},
clusterConfigLevels: [{
min: 2,
max: 3
- },
- // default
- {
+ }, {
min: 2,
max: 4
}, {
min: 3,
@@ -285,130 +512,190 @@
return this.clusterConfigLevels[this.clusterUpgradeTier] || {
min: 2,
max: 3
};
- }
+ },
+ // Prestige
+ prestigeCount: 0,
+ prestigeCurrency: 0
};
/****
-* HELPER FUNCTIONS
+* HELPER FUNCTIONS FOR PRESTIGE
****/
-function maybeSpawnCluster(type) {
- var typeList = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby'];
- var tIndex = typeList.indexOf(type) + 1;
- if (tIndex > gameState.currentTier) {
- return;
+function getPrestigeRequirement() {
+ // Example: Next prestige requires 1e12 * (10^(2*prestigeCount)) etc.
+ // We'll just do a simpler approach for demonstration.
+ var base = 1e12; // 1 trillion
+ var multiplier = Math.pow(1000, gameState.prestigeCount); // scale by 1000 each time
+ return base * multiplier;
+}
+function canPrestige() {
+ return gameState.money >= getPrestigeRequirement();
+}
+function calculatePrestigeShards() {
+ // example: 1 shard per 10x over threshold
+ var threshold = getPrestigeRequirement();
+ if (gameState.money < threshold) {
+ return 0;
}
- if (gameState.clusterCount[type] >= gameState.maxClustersPerType) {
- return;
+ var ratio = gameState.money / threshold;
+ var shards = Math.floor(Math.log10(ratio) * 2); // scale
+ return Math.max(shards, 1);
+}
+function doPrestige() {
+ // Clear all clusters from screen
+ for (var i = clusters.length - 1; i >= 0; i--) {
+ var c = clusters[i];
+ c.removeChildren();
+ if (c.parent) {
+ c.parent.removeChild(c);
+ }
+ clusters.splice(i, 1);
}
- var cluster = new Cluster(type);
- game.addChild(cluster);
- clusters.push(cluster);
- gameState.clusterCount[type]++;
+ // Calculate shards, increment prestige count
+ var shards = calculatePrestigeShards();
+ gameState.prestigeCurrency += shards;
+ gameState.prestigeCount++;
+ // Reset progression but keep prestige shop items (pickaxe upgrades can remain partial or we can reset them if you want)
+ gameState.money = 0;
+ gameState.currentTier = 1;
+ // reset cluster counts
+ for (var key in gameState.clusterCount) {
+ gameState.clusterCount[key] = 0;
+ }
+ // background transition
+ handleBackgroundTransition();
+ // Re-initialize spawns
+ initialSpawn();
+ updateUI();
}
-function randomInt(min, max) {
- return Math.floor(Math.random() * (max - min + 1)) + min;
-}
-function spawnMiningParticles(ore, num) {
- for (var i = 0; i < num; i++) {
- var p = LK.getAsset('mining_particle', {
+/****
+* BACKGROUND TRANSITION
+****/
+function handleBackgroundTransition() {
+ // If we have a next background that was in transition, remove it.
+ if (nextBackground && nextBackground.parent) {
+ nextBackground.parent.removeChild(nextBackground);
+ }
+ // We'll pick a background based on prestige tiers: 3,5,8
+ var newBg = null;
+ if (gameState.prestigeCount >= 8) {
+ newBg = LK.getAsset('background_tier8', {
anchorX: 0.5,
anchorY: 0.5
});
- if (ore.parent) {
- p.x = ore.parent.x + ore.x;
- p.y = ore.parent.y + ore.y;
- } else {
- p.x = ore.x;
- p.y = ore.y;
+ } else if (gameState.prestigeCount >= 5) {
+ newBg = LK.getAsset('background_tier5', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ } else if (gameState.prestigeCount >= 3) {
+ newBg = LK.getAsset('background_tier3', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ } else {
+ newBg = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ }
+ newBg.x = 2048 / 2;
+ newBg.y = 2732 + 2732 / 2; // start off-screen bottom
+ game.addChild(newBg);
+ nextBackground = newBg;
+ var oldBg = currentBackground;
+ if (!oldBg) {
+ // If none, the old background is just the normal background.
+ oldBg = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ oldBg.x = 2048 / 2;
+ oldBg.y = 2732 / 2;
+ game.addChildAt(oldBg, 0);
+ }
+ // If oldBg is the same as newBg, skip.
+ if (oldBg === newBg) {
+ currentBackground = newBg;
+ return;
+ }
+ // Move them upwards for 3 seconds to simulate descending
+ var dur = 3000;
+ tween(oldBg, {
+ y: oldBg.y - 2732
+ }, {
+ duration: dur,
+ onFinish: function onFinish() {
+ if (oldBg && oldBg.parent) {
+ oldBg.parent.removeChild(oldBg);
+ }
}
- 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() {
- p.destroy();
+ });
+ tween(newBg, {
+ y: 2732 / 2
+ }, {
+ duration: dur,
+ onFinish: function onFinish() {
+ currentBackground = newBg;
+ }
+ });
+}
+/****
+* DRONES
+****/
+// We'll add a new tab in the main buy menu for drones.
+// For simplicity, let's store a droneLevel in gameState and each level adds some base DPS.
+var droneDPS = 0; // We'll accumulate from drone upgrades.
+function getDroneDPS() {
+ // formula: each level adds some base DPS.
+ // e.g. 10 * droneLevel.
+ return 10 * gameState.droneLevel;
+}
+function droneDamageTick() {
+ // Let the drones deal damage over time.
+ // We'll do a simplified approach: find random valid ores and deal damage.
+ var dps = getDroneDPS();
+ if (dps <= 0) {
+ return;
+ }
+ // pick random ore or distribute among them.
+ var totalOreCount = 0;
+ var allValidOres = [];
+ clusters.forEach(function (c) {
+ c.oreList.forEach(function (ore) {
+ if (ore.health > 0 && ore.tier <= gameState.currentTier) {
+ allValidOres.push(ore);
}
});
- game.addChild(p);
+ });
+ if (allValidOres.length === 0) {
+ return;
}
+ // We'll just do total dps as damage distributed among some random ore.
+ var damageRemaining = dps;
+ while (damageRemaining > 0 && allValidOres.length > 0) {
+ var randomIndex = Math.floor(Math.random() * allValidOres.length);
+ var ore = allValidOres[randomIndex];
+ var chunk = Math.min(damageRemaining, 10); // deal in chunks
+ ore.health -= chunk;
+ damageRemaining -= chunk;
+ if (ore.health <= 0) {
+ // kill ore
+ var baseValue = ore.getValue();
+ gameState.money += baseValue;
+ updateUI();
+ ore.cluster.notifyOreDestroyed(ore);
+ spawnMiningParticles(ore, 5);
+ allValidOres.splice(randomIndex, 1);
+ }
+ }
}
-function interpolateColor(c1, c2, f) {
- var r1 = c1 >> 16 & 0xFF,
- g1 = c1 >> 8 & 0xFF,
- b1 = c1 & 0xFF;
- var r2 = c2 >> 16 & 0xFF,
- g2 = c2 >> 8 & 0xFF,
- b2 = c2 & 0xFF;
- var r = Math.round(r1 + f * (r2 - r1));
- var g = Math.round(g1 + f * (g2 - g1));
- var b = Math.round(b1 + f * (b2 - b1));
- return r << 16 | g << 8 | b;
-}
-var miner = game.addChild(new Miner());
-miner.x = 2048 / 2;
-miner.y = 2732 / 2;
-// 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
+* UPGRADE DATA
****/
-var upgradeMenu = new Container();
-var tooltip = new Text2('', {
- size: 40,
- fill: 0xFFFFFF
-});
-game.addChild(tooltip);
-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;
-game.addChild(moneyDisplay);
-// Shop icon (replacing the old buy_button for opening menu)
-var shopOpenButton = LK.getAsset('shop_icon', {
- anchorX: 0.5,
- anchorY: 0.5
-});
-shopOpenButton.x = 2048 - 150;
-shopOpenButton.y = 2732 - 150;
-shopOpenButton.down = function () {
- createMainUpgradeMenu();
- game.addChild(upgradeMenu);
-};
-game.addChild(shopOpenButton);
-// Debug: Add money button
-var addMoneyButton = LK.getAsset('buy_button', {
- anchorX: 0.5,
- anchorY: 0.5
-});
-addMoneyButton.x = 200;
-addMoneyButton.y = 2732 - 150;
-addMoneyButton.down = function () {
- gameState.money += 50000;
- updateUI();
-};
-game.addChild(addMoneyButton);
-/****
-* UPGRADE DEFINITIONS
-****/
-// Each ore has (1) an unlock (except coal) and (2) a double-value multi upgrade.
-var typeList = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby'];
-// “Unlock” costs + “Double Value” costs are arbitrary examples. Tweak if desired.
+// We'll add a tab for drones in main menu, with upgrades.
+// We'll also add a new prestige shop with artifacts.
var oreUpgrades = {
coal: [{
id: 'double_coal',
name: 'Double Coal Value',
@@ -586,9 +873,8 @@
this.cost *= 2;
}
}]
};
-// General Upgrades
var generalUpgrades = [{
id: 'faster_respawn',
name: 'Quicker Respawn',
cost: 8000,
@@ -609,58 +895,196 @@
}
this.cost += 2000;
}
}];
+// new pickaxe upgrades (artifact axes) in the Prestige shop
+var prestigeUpgrades = [{
+ id: 'pickaxe_plus_1',
+ name: 'Pickaxe Level +1',
+ cost: 5,
+ effect: 'Increases pickaxe damage by 1',
+ purchased: false,
+ action: function action() {
+ gameState.pickaxeLevel++;
+ }
+}, {
+ id: 'pickaxe_plus_2',
+ name: 'Pickaxe Speed +10%',
+ cost: 8,
+ effect: 'Reduces mining cooldown by 10%',
+ purchased: false,
+ action: function action() {
+ miner.miningRate = Math.floor(miner.miningRate * 0.90);
+ if (miner.miningRate < 1) {
+ miner.miningRate = 1;
+ }
+ }
+}, {
+ id: 'pickaxe_plus_3',
+ name: 'Pickaxe Bonus DMG +2',
+ cost: 10,
+ effect: 'Increases pickaxe damage by an additional 2',
+ purchased: false,
+ action: function action() {
+ gameState.pickaxeLevel += 2;
+ }
+}
+// you can add more
+];
+// a separate list for artifact drones in prestige shop
+var prestigeDrones = [{
+ id: 'drone_speedup',
+ name: 'Drone Technology +1',
+ cost: 10,
+ effect: 'Increases Drone DPS by 50',
+ purchased: false,
+ action: function action() {
+ if (!gameState.droneLevel) {
+ gameState.droneLevel = 0;
+ }
+ // each purchase +5 levels?
+ gameState.droneLevel += 5;
+ }
+}];
+// standard drone upgrades in the normal buy menu
+var droneUpgrades = [{
+ id: 'drone_level_1',
+ name: 'Buy Drones (Lv +1)',
+ cost: 5000,
+ effect: 'Each level adds +10 DPS',
+ purchased: false,
+ multi: true,
+ level: 0,
+ action: function action() {
+ if (!gameState.droneLevel) {
+ gameState.droneLevel = 0;
+ }
+ gameState.droneLevel++;
+ this.level++;
+ this.cost = Math.floor(this.cost * 1.5);
+ }
+}];
/****
-* MAIN MENU
+* UI
****/
+var upgradeMenu = new Container();
+var tooltip = new Text2('', {
+ size: 40,
+ fill: 0xFFFFFF
+});
+game.addChild(tooltip);
+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;
+game.addChild(moneyDisplay);
+// Add a text display for Prestige info
+var prestigeDisplay = new Text2('Prestige: 0', {
+ size: 50,
+ fill: 0xFFFFFF,
+ fontWeight: 'bold',
+ stroke: 0x000000,
+ strokeThickness: 4
+});
+prestigeDisplay.x = 50;
+prestigeDisplay.y = 50;
+game.addChild(prestigeDisplay);
+// Shop icon
+var shopOpenButton = LK.getAsset('shop_icon', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+shopOpenButton.x = 2048 - 150;
+shopOpenButton.y = 2732 - 150;
+shopOpenButton.down = function () {
+ createMainUpgradeMenu();
+ game.addChild(upgradeMenu);
+};
+game.addChild(shopOpenButton);
+// Prestige shop icon
+var prestigeShopButton = LK.getAsset('prestige_shop_icon', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+prestigeShopButton.x = 150;
+prestigeShopButton.y = 2732 - 150;
+prestigeShopButton.down = function () {
+ if (canPrestige()) {
+ doPrestige();
+ } else {
+ createPrestigeShopMenu();
+ game.addChild(upgradeMenu);
+ }
+};
+game.addChild(prestigeShopButton);
+// Debug: Add money button
+var addMoneyButton = LK.getAsset('buy_button', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+addMoneyButton.x = 200;
+addMoneyButton.y = 2732 - 300;
+addMoneyButton.down = function () {
+ gameState.money += 5000000000; // 5B
+ updateUI();
+};
+game.addChild(addMoneyButton);
+// create main upgrade menu with an additional tab for drones
function createMainUpgradeMenu() {
upgradeMenu.removeChildren();
- subUpgradeItemRefs = []; // reset
- // Big background
+ subUpgradeItemRefs = [];
var menuBg = LK.getAsset('rectangle', {
width: 1800,
- height: 2000,
+ height: 2200,
color: 0x2a2a2a,
anchorX: 0.5,
anchorY: 0.5
});
menuBg.x = 2048 / 2;
menuBg.y = 2732 / 2 + 50;
upgradeMenu.addChild(menuBg);
- // We'll define 8 “categories”: 7 Ores + 1 “General”
+ // 8 categories + 1 drones
var categories = [{
name: 'Coal Upgrades',
- yOff: -700,
+ yOff: -800,
type: 'coal'
}, {
name: 'Iron Upgrades',
- yOff: -500,
+ yOff: -600,
type: 'iron'
}, {
name: 'Gold Upgrades',
- yOff: -300,
+ yOff: -400,
type: 'gold'
}, {
name: 'Diamond Upgrades',
- yOff: -100,
+ yOff: -200,
type: 'diamond'
}, {
name: 'Sapphire Upgrades',
- yOff: 100,
+ yOff: 0,
type: 'sapphire'
}, {
name: 'Emerald Upgrades',
- yOff: 300,
+ yOff: 200,
type: 'emerald'
}, {
name: 'Ruby Upgrades',
- yOff: 500,
+ yOff: 400,
type: 'ruby'
}, {
name: 'General Upgrades',
- yOff: 700,
+ yOff: 600,
type: 'general'
+ }, {
+ name: 'Drones',
+ yOff: 800,
+ type: 'drones'
}];
categories.forEach(function (cat) {
var btn = LK.getAsset('buy_button', {
anchorX: 0.5,
@@ -668,13 +1092,11 @@
});
btn.x = menuBg.x;
btn.y = menuBg.y + cat.yOff;
upgradeMenu.addChild(btn);
- // Then text on top
var txt = new Text2(cat.name, {
size: 50,
fill: 0x000000,
- // black text for contrast
align: 'center'
});
txt.anchor.set(0.5);
txt.x = btn.x;
@@ -682,10 +1104,11 @@
upgradeMenu.addChild(txt);
btn.down = function () {
if (cat.type === 'general') {
createSubUpgradeMenu('General Upgrades', generalUpgrades);
+ } else if (cat.type === 'drones') {
+ createSubUpgradeMenu('Drone Upgrades', droneUpgrades);
} else {
- // show sub-menu for that specific ore
createSubUpgradeMenu(cat.name, oreUpgrades[cat.type]);
}
};
});
@@ -694,43 +1117,38 @@
anchorX: 0.5,
anchorY: 0.5
});
closeBtn.x = menuBg.x + 700;
- closeBtn.y = menuBg.y - 800;
+ closeBtn.y = menuBg.y - 900;
closeBtn.down = function () {
game.removeChild(upgradeMenu);
};
upgradeMenu.addChild(closeBtn);
}
-/****
-* SUB-MENU
-****/
var subUpgradeItemRefs = [];
function createSubUpgradeMenu(title, upgList) {
upgradeMenu.removeChildren();
subUpgradeItemRefs = [];
var menuBg = LK.getAsset('rectangle', {
width: 1800,
- height: 2000,
+ height: 2200,
color: 0x2a2a2a,
anchorX: 0.5,
anchorY: 0.5
});
menuBg.x = 2048 / 2;
menuBg.y = 2732 / 2 + 50;
upgradeMenu.addChild(menuBg);
- // Title
var titleText = new Text2(title, {
size: 60,
fill: 0xFFFFFF,
align: 'center'
});
titleText.anchor.set(0.5);
titleText.x = menuBg.x;
- titleText.y = menuBg.y - 850;
+ titleText.y = menuBg.y - 1000;
upgradeMenu.addChild(titleText);
- // Spacing out each upgrade by ~250 px
- var startY = menuBg.y - 600;
+ var startY = menuBg.y - 800;
upgList.forEach(function (upg, i) {
var itemContainer = new Container();
upgradeMenu.addChild(itemContainer);
var btn = LK.getAsset('buy_button', {
@@ -739,14 +1157,14 @@
});
btn.x = menuBg.x;
btn.y = startY + i * 250;
itemContainer.addChild(btn);
- // If multi with a "level" property
var displayName = upg.name;
if (typeof upg.level === 'number' && upg.level > 0) {
displayName += " (Lv " + upg.level + ")";
}
- var txtStr = displayName + "\n" + upg.effect + "\n$" + upg.cost;
+ var costStr = upg.multi ? "$" + upg.cost : "$" + upg.cost;
+ var txtStr = displayName + "\n" + upg.effect + "\n" + costStr;
var txt = new Text2(txtStr, {
size: 40,
fill: 0x666666,
align: 'center'
@@ -769,47 +1187,124 @@
upgrade: upg,
textObj: txt
});
});
- // Back button
var backBtn = LK.getAsset('cancelButton', {
anchorX: 0.5,
anchorY: 0.5
});
backBtn.x = menuBg.x + 700;
- backBtn.y = menuBg.y - 800;
+ backBtn.y = menuBg.y - 1000;
backBtn.down = function () {
createMainUpgradeMenu();
};
upgradeMenu.addChild(backBtn);
}
function canPurchaseUpgrade(upgList, upg) {
- // If there's a 'requires' property, check that upgrade is purchased first
if (upg.requires) {
var needed = upgList.find(function (u) {
return u.id === upg.requires;
});
if (!needed || !needed.purchased) {
return false;
}
}
- // If not multi and already purchased => can't buy again
if (!upg.multi && upg.purchased) {
return false;
}
- // Check money
if (gameState.money < upg.cost) {
return false;
}
return true;
}
+// Prestige Shop Menu
+function createPrestigeShopMenu() {
+ upgradeMenu.removeChildren();
+ var menuBg = LK.getAsset('rectangle', {
+ width: 1800,
+ height: 2200,
+ color: 0x2a2a2a,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ menuBg.x = 2048 / 2;
+ menuBg.y = 2732 / 2 + 50;
+ upgradeMenu.addChild(menuBg);
+ var titleText = new Text2('Prestige Shop', {
+ size: 60,
+ fill: 0xFFFFFF,
+ align: 'center'
+ });
+ titleText.anchor.set(0.5);
+ titleText.x = menuBg.x;
+ titleText.y = menuBg.y - 1000;
+ upgradeMenu.addChild(titleText);
+ var shardText = new Text2('Prestige Shards: ' + gameState.prestigeCurrency, {
+ size: 50,
+ fill: 0xFFFF00,
+ align: 'center'
+ });
+ shardText.anchor.set(0.5);
+ shardText.x = menuBg.x;
+ shardText.y = menuBg.y - 900;
+ upgradeMenu.addChild(shardText);
+ // We'll list pickaxe artifact upgrades and drone artifact upgrades
+ var combinedUpgrades = prestigeUpgrades.concat(prestigeDrones);
+ var startY = menuBg.y - 700;
+ combinedUpgrades.forEach(function (upg, i) {
+ var itemContainer = new Container();
+ upgradeMenu.addChild(itemContainer);
+ var btn = LK.getAsset('buy_button', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ btn.x = menuBg.x;
+ btn.y = startY + i * 250;
+ itemContainer.addChild(btn);
+ var txtStr = upg.name + "\n" + upg.effect + "\nCost: " + upg.cost + " Shards";
+ var txt = new Text2(txtStr, {
+ size: 40,
+ fill: 0x666666,
+ align: 'center'
+ });
+ txt.anchor.set(0.5);
+ txt.x = btn.x;
+ txt.y = btn.y;
+ itemContainer.addChild(txt);
+ btn.down = function () {
+ if (gameState.prestigeCurrency >= upg.cost) {
+ gameState.prestigeCurrency -= upg.cost;
+ upg.action();
+ updateUI();
+ createPrestigeShopMenu();
+ }
+ };
+ });
+ var backBtn = LK.getAsset('cancelButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ backBtn.x = menuBg.x + 700;
+ backBtn.y = menuBg.y - 1000;
+ backBtn.down = function () {
+ game.removeChild(upgradeMenu);
+ };
+ upgradeMenu.addChild(backBtn);
+}
/****
* GAME LOOP
****/
+var quantumSelectTimer = 0;
+var quantumSelectionActive = false;
game.update = function () {
- // 1) Miner
- miner.update();
- // 2) Update ore visuals
+ if (miner) {
+ miner.update();
+ }
+ // Drone DPS tick (maybe once per second)
+ if (LK.time.elapsed % 60 === 0) {
+ droneDamageTick();
+ }
+ // Update ore visuals
clusters.forEach(function (cluster) {
cluster.oreList.forEach(function (ore) {
if (ore.health > 0) {
var fraction = ore.health / ore.maxHealth;
@@ -818,9 +1313,9 @@
ore.alpha = fraction;
}
});
});
- // 3) Sub-menu color updates
+ // Update sub-menu color if open
if (upgradeMenu.parent) {
subUpgradeItemRefs.forEach(function (ref) {
var upg = ref.upgrade;
var canBuy = canPurchaseUpgrade(ref.upgList, upg);
@@ -828,15 +1323,25 @@
ref.textObj.style.fill = canBuy ? 0xFFFFFF : 0x666666;
}
});
}
+ // If quantum selection is active, track timer
+ if (quantumSelectionActive) {
+ quantumSelectTimer++;
+ if (quantumSelectTimer > 15 * 60) {
+ // 15s passed, unpause
+ quantumSelectionActive = false;
+ miner.quantumPathActive = false;
+ }
+ }
};
/****
* UI REFRESH
****/
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 " + "S" + gameState.oreMultipliers.sapphire + "x " + "E" + gameState.oreMultipliers.emerald + "x " + "R" + gameState.oreMultipliers.ruby + "x");
+ moneyDisplay.setText("$" + Math.floor(gameState.money).toLocaleString());
moneyDisplay.x = 2048 / 2 - moneyDisplay.width / 2;
+ prestigeDisplay.setText("Prestige: " + gameState.prestigeCount);
}
/****
* SAVE & LOAD
****/
@@ -850,10 +1355,8 @@
/****
* INITIAL SPAWN
****/
function initialSpawn() {
- // We'll spawn clusters for any ore type up to currentTier
- // Tiers: 1=Coal,2=Iron,3=Gold,4=Diamond,5=Sapphire,6=Emerald,7=Ruby
var allTypes = ['coal', 'iron', 'gold', 'diamond', 'sapphire', 'emerald', 'ruby'];
allTypes.forEach(function (type, idx) {
var t = idx + 1;
if (t <= gameState.currentTier) {
@@ -861,7 +1364,35 @@
maybeSpawnCluster(type);
}
}
});
+ // also attempt special ore spawns
+ maybeSpawnSpecialOres();
}
-initialSpawn();
-updateUI();
\ No newline at end of file
+/****
+* START
+****/
+function startGame() {
+ // spawn backgrounds
+ currentBackground = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ currentBackground.x = 2048 / 2;
+ currentBackground.y = 2732 / 2;
+ game.addChildAt(currentBackground, 0);
+ // create miner
+ miner = new Miner();
+ miner.x = 2048 / 2;
+ miner.y = 2732 / 2;
+ game.addChild(miner);
+ initialSpawn();
+ updateUI();
+}
+startGame();
+// quantum selection function
+// This is a stub for the advanced effect. We won't fully implement the UI.
+game.pauseForQuantumSelection = function () {
+ quantumSelectionActive = true;
+ quantumSelectTimer = 0;
+ // darken screen, highlight ores, etc.
+};
\ No newline at end of file
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