User prompt
добавь ассет к боксу ForgeOfMatter, прорисовывай его в последнюю очередь
User prompt
добавь ассет к босу ForgeOfMatter
User prompt
увеличь бокс ForgeOfMatter в 2 раза
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'setText')' in or related to this line: 'blueSwordsText.setText(storage.blueSwords.toString());' Line Number: 651
User prompt
Please fix the bug: 'Uncaught ReferenceError: blueSwordsText is not defined' in or related to this line: 'blueSwordsText.setText(storage.blueSwords.toString());' Line Number: 650
Code edit (9 edits merged)
Please save this source code
User prompt
сдедай так что бы при клике sellweapon счетчик 'Swords in stock'. обнулялся, а за каждую единицу в нем добавлялось +100 в счетчик голд
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'width')' in or related to this line: 'goldScoreTxt.x = counterText.width + 10; // Position to the right of the Forging skill counter' Line Number: 480
User prompt
добавь счетчик к ассету Gold с таким же названием, выводи его на в верхней части экрана игры справа от счетчика Forging skill сразу после старнта игры
User prompt
не вижу отображение счетчика голд в верхней части экрана исправь ошибку
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'width')' in or related to this line: 'goldText.x = counterText.width + 20; // Position the Gold counter to the right of the forging skill counter' Line Number: 561
User prompt
показывай счетчик голд справа от счетчика forging skill
User prompt
выводи счетчик горд сразу после старта игры
User prompt
добавь счетчик к ассету Gold, выводи его в верхней части экрана текстом "Gold"
User prompt
добавь новый ассет Gold, выводи его сразу в начале иглы в верхней части экрана по центру
User prompt
отображай ассет Gold сразу после старта игры
User prompt
давай добавим новую переменную Gold с ассетом сверху экрана по центру
User prompt
добавь к ассету sellweapons возможность клика о нему
User prompt
переименуй ассет newBuildings в sellweapons
User prompt
опусти счетчик ниже
Code edit (1 edits merged)
Please save this source code
User prompt
надпись Redcrystaltwo-\n handedswordrecipe"\n Forging Skill 20k.\n 1000 red crystal ingots +\n 10000 clicks on the anvil дублируется, удали лишнюю
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'redCrystalTwoHandedSwordDescription.anchor.set(0.5, 0.5);' Line Number: 1012
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { forgingSkill: 0, growthRate: 0, blueCristallScore: 0, greenCrystalIngotScore: 0, blueSwords: 0, greenAxes: 0, redCrystalTwoHandedSwords: 0 }); /**** * Classes ****/ // Create a new class for the anvil object var Anvil = Container.expand(function () { var self = Container.call(this); // Attach 'anvil' asset to the 'Anvil' object var anvilGraphics = self.attachAsset('anvil', { anchorX: 0.5, anchorY: 0.5, alpha: 0.0 // Make the anvil fully transparent }); // Initialize the click counter self.clickCounter = storage.forgingSkill; // Make the 'Anvil' object interactive self.interactive = true; // Define the 'down' event handler self.down = function (x, y, obj) { // Increment the click counter self.clickCounter++; // Add a 5% chance for a multi-click event to increase forging skill by 5 if (Math.random() < 0.02) { self.clickCounter += 5; // Create a new asset at the center of the screen var newAsset = game.addChild(LK.getAsset('multyclick', { anchorX: 0.5, anchorY: 0.5 })); // Position the new asset at the center of the screen newAsset.x = 2048 / 2; newAsset.y = 2732 / 2; // Animate the scaling of the new asset tween(newAsset, { scaleX: 2, scaleY: 2 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { newAsset.destroy(); // Remove the asset after the animation } }); } // Update the text object with the click counter and label counterText.setText('Forging skill: ' + self.clickCounter); // Persist the click counter storage.forgingSkill = self.clickCounter; // Change the color of the counter text based on the click counter if (self.clickCounter >= 100 && self.clickCounter < 200) { counterText.tint = 0x00FF00; // Green } else if (self.clickCounter >= 200 && self.clickCounter < 300) { counterText.tint = 0x0000FF; // Blue } else if (self.clickCounter >= 300) { counterText.tint = 0x800080; // Purple } }; }); // Create a new class for the BlueCristal object var BlueCristal = Container.expand(function () { var self = Container.call(this); // Attach 'blueCristal' asset to the 'BlueCristal' object var blueCristalGraphics = self.attachAsset('blueCristal', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the blueCristal interactive }); // Define the 'down' event handler for blueCristal self.down = function (x, y, obj) { // Increment the score by 1 blueCristallScore += 1; LK.setScore(blueCristallScore); storage.blueCristallScore = blueCristallScore; // Update the score text scoreTxt.setText('Blue Cristall: ' + LK.getScore()); scoreTxt.visible = true; // Ensure the score text remains visible }; }); // Create a new class for the BlueCrystalIngot object var BlueCrystalIngot = Container.expand(function () { var self = Container.call(this); // Attach 'blueCrystalIngot' asset to the 'BlueCrystalIngot' object var blueCrystalIngotGraphics = self.attachAsset('blueCrystalIngot', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the blueCrystalIngot interactive }); // Define the 'down' event handler for blueCrystalIngot self.down = function (x, y, obj) { // Logic for what happens when the blueCrystalIngot is clicked if (blueCristallScore >= 100) { blueCrystalIngotScore += 1; //{y.1} storage.forgingSkill += 100; // Increment forging skill by 100 counterText.setText('Forging skill: ' + storage.forgingSkill); // Update the forging skill display blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + blueCrystalIngotScore); //{y.2} storage.blueCrystalIngotScore = blueCrystalIngotScore; blueCristallScore -= 100; if (blueCristallScore < 0) { blueCristallScore = 0; } storage.blueCristallScore = blueCristallScore; // Persist the decrement LK.setScore(blueCristallScore); scoreTxt.setText('Blue Cristall: ' + LK.getScore()); } }; }); // Create a new class for the Door object var Door = Container.expand(function () { var self = Container.call(this); // Attach 'Door' asset to the 'Door' object var doorGraphics = self.attachAsset('Door', { anchorX: 0.5, anchorY: 0.5 }); // Make the 'Door' object interactive self.interactive = true; // Define the 'down' event handler self.down = function (x, y, obj) { // Remove the existing hammer hammer.destroy(); // Create a new screen game.magicNursery = game.addChild(new Container()); // Attach 'magicNurseryBackground' asset to the 'magicNursery' object var magicNurseryBackground = game.magicNursery.attachAsset('magicNurseryBackground', { anchorX: 0.5, anchorY: 0.5, interactive: false, // Disable interactivity to prevent blurring on click scaleX: 2, // Double the size horizontally scaleY: 2 // Double the size vertically }); // Recreate the hammer asset magicNurseryBackground.x = 2048 / 2; magicNurseryBackground.y = 2732 / 2; // Attach 'ForgeOfMatter' asset to the 'magicNursery' object var forgeOfMatter = game.magicNursery.attachAsset('ForgeOfMatter', { anchorX: 0.5, anchorY: 0.5, interactive: true, scaleX: 1, scaleY: 1 }); // Create and add a new instance of the BlueCrystalIngot class var blueCrystalIngot = game.magicNursery.addChild(new BlueCrystalIngot()); //{P.1} // Position the blueCrystalIngot asset in the bottom-left corner blueCrystalIngot.x = 200 + blueCrystalIngot.width / 2; blueCrystalIngot.y = 2500 - blueCrystalIngot.height / 2; // Create and add a new instance of the RedCrystalIngot class var redCrystalIngot = game.magicNursery.addChild(new RedCrystalIngot()); // Center the redCrystalIngot asset in the magicNursery screen redCrystalIngot.x = 1300 / 2; redCrystalIngot.y = 4930 / 2; // Create and add a new instance of the GreenCristalIngot class var greenCristalIngot = game.magicNursery.addChild(LK.getAsset('greenCristalIngot', { anchorX: 0.5, anchorY: 0.5 })); // Position the greenCristalIngot asset to the right of the blueCrystalIngot asset greenCristalIngot.x = blueCrystalIngot.x + blueCrystalIngot.width + greenCristalIngot.width / 2 + 40; //{Y.1} greenCristalIngot.y = blueCrystalIngot.y; // Create and add a new instance of the GreenCrystalIngot class var greenCrystalIngotInstance = game.magicNursery.addChild(new GreenCrystalIngot()); // Position the greenCrystalIngotInstance asset to the right of the blueCrystalIngot asset greenCrystalIngotInstance.x = blueCrystalIngot.x + blueCrystalIngot.width + greenCrystalIngotInstance.width / 2 + 40; greenCrystalIngotInstance.y = blueCrystalIngot.y; // Initialize the click counter for ForgeOfMatter forgeOfMatter.clickCounter = 0; // Initialize the growth rate click counter from the global growthRateCounter forgeOfMatter.clickCounter = growthRateCounter; growthRateText.setText('Growth rate: ' + forgeOfMatter.clickCounter); // Center the growthRate asset in the magicNursery screen var growthRate = game.magicNursery.addChild(LK.getAsset('growthRate', { anchorX: 0.5, anchorY: 0.5 })); growthRate.x = 2048 / 2 - 100; growthRate.y = 2732 / 2; // Define the 'down' event handler for ForgeOfMatter forgeOfMatter.down = function (x, y, obj) { // Increment the click counter forgeOfMatter.clickCounter++; // Update the text object with the click counter and label growthRateText.setText('Growth rate: ' + forgeOfMatter.clickCounter); // Persist the click counter to the global growthRateCounter growthRateCounter = forgeOfMatter.clickCounter; storage.growthRate = growthRateCounter; }; forgeOfMatter.x = 1100 / 1.5; forgeOfMatter.y = 2000 / 1.5; // Add a new counter to the ForgeOfMatter object growthRateText.setText('Growth rate: ' + forgeOfMatter.clickCounter); growthRateText.visible = true; // Hide the game screen gameScreen.visible = false; // Show the forging skill counter when transitioning to magicNursery counterText.visible = true; // Hide the map when switching to the magic nursery screen map.visible = false; // Add a new object 'Door2' var door2 = game.magicNursery.addChild(new Door2()); // Position 'Door2' to the right, between the center and the edge of the screen door2.x = 2048 * 0.75; door2.y = 2732 * 0.9; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; }); // Create a new class for the Door2 object var Door2 = Container.expand(function () { var self = Container.call(this); // Attach 'Door' asset to the 'Door2' object var doorGraphics = self.attachAsset('Door', { anchorX: 0.5, anchorY: 0.5 }); // Make the 'Door2' object interactive self.interactive = true; // Define the 'down' event handler self.down = function (x, y, obj) { // Remove the existing hammer hammer.destroy(); // Show the Anvil screen gameScreen.visible = true; // Show the map only on the anvil screen map.visible = true; // Show the counter display counterText.visible = true; // Hide the Magic Nursery screen game.magicNursery.visible = false; // Show the Growth rate counter when transitioning to anvil growthRateText.visible = true; // Recreate the hammer asset hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; }); // Create a new class for the GreenAxe object var GreenAxe = Container.expand(function () { var self = Container.call(this); // Attach 'axeOfGreenCrystalsRecipe' asset to the 'GreenAxe' object var greenAxeGraphics = self.attachAsset('axeOfGreenCrystalsRecipe', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the greenAxe interactive }); // Define the 'down' event handler for greenAxe self.down = function (x, y, obj) { if (storage.forgingSkill >= 10000 && storage.greenCrystalIngotScore >= 500) { greenAxeClicks += 1000; } if (greenAxeClicks >= 3000) { greenAxeClicks = 0; storage.greenAxes += 1; // Increment the green axes count in storage greenAxesText.setText(storage.greenAxes.toString()); } greenAxeClicksText.setText('(current ' + greenAxeClicks + ')'); }; }); // Create a new class for the GreenCristal object var GreenCristal = Container.expand(function () { var self = Container.call(this); // Attach 'greenCristal' asset to the 'GreenCristal' object var greenCristalGraphics = self.attachAsset('greenCristal', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the greenCristal interactive }); // Define the 'down' event handler for greenCristal self.down = function (x, y, obj) { // Increment the score by 1 greenCristallScore += 1; LK.setScore(greenCristallScore); storage.greenCristallScore = greenCristallScore; // Update the score text greenScoreTxt.setText('Green Cristall: ' + greenCristallScore); greenScoreTxt.visible = true; // Ensure the score text remains visible }; }); // Create a new class for the GreenCrystalIngot object var GreenCrystalIngot = Container.expand(function () { var self = Container.call(this); // Attach 'greenCrystalIngot' asset to the 'GreenCrystalIngot' object var greenCrystalIngotGraphics = self.attachAsset('greenCrystalIngot', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the greenCrystalIngot interactive }); // Define the 'down' event handler for greenCrystalIngot self.down = function (x, y, obj) { if (greenCristallScore >= 100) { // Increment the GreenCrystalIngot score by 1 greenCrystalIngotScore += 1; greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + greenCrystalIngotScore); storage.greenCrystalIngotScore = greenCrystalIngotScore; // Decrement the GreenCristal score by 100 greenCristallScore -= 100; if (greenCristallScore < 0) { greenCristallScore = 0; } storage.greenCristallScore = greenCristallScore; // Persist the decrement greenScoreTxt.setText('Green Cristall: ' + greenCristallScore); } }; }); // Create a new class for the RecipesScreen object var RecipesScreen = Container.expand(function () { var self = Container.call(this); // Attach 'recipesout' asset to the 'RecipesScreen' object var recipesOutGraphics = self.attachAsset('recipesout', { anchorX: 0.5, anchorY: 0.5 }); // Center the 'recipesout' asset on the screen recipesOutGraphics.x = 2048 / 2; recipesOutGraphics.y = 2732 / 2 + 1100; // Make the 'recipesout' asset interactive recipesOutGraphics.interactive = true; // Define the 'down' event handler for recipesOutGraphics recipesOutGraphics.down = function (x, y, obj) { // Hide the 'recipesout' asset recipesOutGraphics.visible = false; // Transition to the 'gameScreen' gameScreen.visible = true; // Make the map visible after transitioning to the recipesout screen map.visible = true; // Hide the current recipes screen self.visible = false; }; }); // Create a new class for the RedCristal object var RedCristal = Container.expand(function () { var self = Container.call(this); // Attach 'redCristal' asset to the 'RedCristal' object var redCristalGraphics = self.attachAsset('redCristal', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the redCristal interactive }); // Define the 'down' event handler for redCristal self.down = function (x, y, obj) { // Increment the score by 1 redCristallScore += 1; LK.setScore(redCristallScore); storage.redCristallScore = redCristallScore; // Update the score text redScoreTxt.setText('Red Cristall: ' + redCristallScore); redScoreTxt.visible = true; // Ensure the score text remains visible }; }); // Create a new class for the RedCrystalIngot object var RedCrystalIngot = Container.expand(function () { var self = Container.call(this); // Attach 'redCristalIngot' asset to the 'RedCrystalIngot' object var redCrystalIngotGraphics = self.attachAsset('redCristalIngot', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the redCrystalIngot interactive }); // Define the 'down' event handler for redCrystalIngot self.down = function (x, y, obj) { // Decrement the RedCristal score by 100 if (redCristallScore >= 100) { // Increment the RedCrystalIngot score by 1 redCrystalIngotScore += 1; redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + redCrystalIngotScore); storage.redCrystalIngotScore = redCrystalIngotScore; redCristallScore -= 100; storage.redCristallScore = redCristallScore; // Persist the decrement redScoreTxt.setText('Red Cristall: ' + redCristallScore); } }; }); var RedCrystalTwoHandedSword = Container.expand(function () { var self = Container.call(this); // Attach 'redcrystaltwo-handedswordrecipe' asset to the 'RedCrystalTwoHandedSword' object var redCrystalTwoHandedSwordGraphics = self.attachAsset('redcrystaltwo-handedswordrecipe', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the redCrystalTwoHandedSword interactive }); // Define the 'down' event handler for redCrystalTwoHandedSword self.down = function (x, y, obj) { if (storage.forgingSkill >= 20000 && storage.redCrystalIngotScore >= 1000) { redCrystalTwoHandedSwordClicks += 1; } if (redCrystalTwoHandedSwordClicks >= 10000) { redCrystalTwoHandedSwordClicks = 0; storage.redCrystalTwoHandedSwords += 1; // Increment the red crystal two-handed swords count in storage redCrystalTwoHandedSwordsText.setText(storage.redCrystalTwoHandedSwords.toString()); } redCrystalTwoHandedSwordClicksText.setText('(current ' + redCrystalTwoHandedSwordClicks + ')'); }; }); /**** * Initialize Game ****/ // Create a new text object to display the click counter var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var redCrystalIngotScore = storage.redCrystalIngotScore || 0; var redCrystalIngotScoreTxt = new Text2('RedCrystalIngot: ' + redCrystalIngotScore, { size: 50, fill: 0xFFFFFF }); redCrystalIngotScoreTxt.anchor.set(1, 0); redCrystalIngotScoreTxt.y = 100; // Position below the GreenCrystalIngot score LK.gui.topRight.addChild(redCrystalIngotScoreTxt); //{0.1} var mineInsideBackground; var blueCristallScore = storage.blueCristallScore || 0; var scoreTxt = new Text2('Blue Cristall: ' + blueCristallScore, { size: 50, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); scoreTxt.y = 100; // Move the score text 100 pixels down LK.gui.topLeft.addChild(scoreTxt); var greenCristallScore = storage.greenCristallScore || 0; var greenScoreTxt = new Text2('Green Cristall: ' + greenCristallScore, { size: 50, fill: 0xFFFFFF }); greenScoreTxt.anchor.set(0, 0); greenScoreTxt.y = 150; // Position below the Blue Cristall score LK.gui.topLeft.addChild(greenScoreTxt); var greenCrystalIngotScore = storage.greenCrystalIngotScore || 0; var greenCrystalIngotScoreTxt = new Text2('GreenCrystalIngot: ' + greenCrystalIngotScore, { size: 50, fill: 0xFFFFFF }); greenCrystalIngotScoreTxt.anchor.set(1, 0); greenCrystalIngotScoreTxt.y = 50; // Position below the BlueCrystalIngot score LK.gui.topRight.addChild(greenCrystalIngotScoreTxt); var blueCristal; // Define blueCristal in the global scope to fix the reference error var greenCristal; // Define greenCristal in the global scope to fix the reference error var redCristal; // Define redCristal in the global scope to fix the reference error var blueCrystalIngotScore = storage.blueCrystalIngotScore || 0; //{1Z.1} var redCristallScore = storage.redCristallScore || 0; var blueCrystalIngotScoreTxt = new Text2('BlueCrystalIngot: ' + blueCrystalIngotScore, { size: 50, fill: 0xFFFFFF }); blueCrystalIngotScoreTxt.anchor.set(1, 0); blueCrystalIngotScoreTxt.y = 0; LK.gui.topRight.addChild(blueCrystalIngotScoreTxt); var redScoreTxt = new Text2('Red Cristall: ' + redCristallScore, { size: 50, fill: 0xFFFFFF }); redScoreTxt.anchor.set(0, 0); redScoreTxt.y = 200; // Position below the Green Cristall score LK.gui.topLeft.addChild(redScoreTxt); var map = game.addChild(LK.getAsset('Map', { anchorX: 0.5, anchorY: 0.5 })); map.x = 400; map.y = 2450; map.visible = false; // Initialize the map as invisible // Make the map interactive map.interactive = true; // Define the 'down' event handler for the map map.down = function (x, y, obj) { // Hide the map asset when transitioning to the map screen map.visible = false; // Hide the mineInsideBackground if it exists if (mineInsideBackground) { mineInsideBackground.visible = false; mineInsideBackground.destroy(); // Ensure it is completely removed } if (redCristal) { redCristal.visible = false; //{1Z.1} redCristal.destroy(); // Ensure it is completely removed } //{1Z.3} if (blueCristal) { blueCristal.visible = false; //{1X.1} blueCristal.destroy(); // Ensure it is completely removed } //{1X.3} if (greenCristal) { greenCristal.visible = false; //{1Y.1} greenCristal.destroy(); // Ensure it is completely removed } //{1Y.3} var mapScreen = game.addChild(new Container()); // Attach 'mapbackground' asset to the mapScreen var mapBackground = mapScreen.attachAsset('mapbackground', { anchorX: 0.5, //{1h.1} anchorY: 0.5, //{1h.2} interactive: false // Ensure mapbackground does not block cursor interaction }); //{1h.3} // Add 'citymap' asset to the center of the screen var cityMap = mapScreen.attachAsset('citymap', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the 'citymap' asset interactive }); cityMap.x = -250; cityMap.y = 160; // Define the 'down' event handler for cityMap cityMap.down = function (x, y, obj) { // Create a new screen without background var isolatedScreen = game.addChild(new Container()); // Hide the current map screen mapScreen.visible = false; // Add 'citybackground' asset to the center of the isolatedScreen var cityBackground = isolatedScreen.attachAsset('citybackground', { anchorX: 0.5, anchorY: 0.5 }); cityBackground.x = 0; cityBackground.y = 0; // Add 'map' asset to the isolatedScreen var mapAsset = isolatedScreen.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the 'map' asset interactive }); mapAsset.x = -650; mapAsset.y = 1100; // Define the 'down' event handler for mapAsset mapAsset.down = function (x, y, obj) { // Transition back to the citymap screen isolatedScreen.visible = false; // Hide the current isolated screen mapScreen.visible = true; // Show the citymap screen cityBackground.visible = false; // Ensure citybackground is hidden }; // Add 'shop' asset to the center of the isolatedScreen var shop = isolatedScreen.attachAsset('shop', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the 'shop' asset interactive }); shop.x = 490; shop.y = -100; // Define the 'down' event handler for shop shop.down = function (x, y, obj) { // Create a new screen without background var shopScreen = game.addChild(new Container()); // Hide the current isolated screen isolatedScreen.visible = false; // Position the shopScreen at the center shopScreen.x = 2048 / 2; shopScreen.y = 2732 / 2; // Add 'new tools' asset to the center of the shopScreen var newTools = shopScreen.attachAsset('newTools', { anchorX: 0.5, anchorY: 0.5 }); newTools.x = -650; newTools.y = 1100; // Add 'new buildings' asset to the center of the shopScreen var newBuildings = shopScreen.attachAsset('newBuildings', { anchorX: 0.5, anchorY: 0.5 }); newBuildings.x = 0; newBuildings.y = 1100; // Add 'shopout' asset to the shopScreen var shopBackground = shopScreen.attachAsset('shopbackground', { anchorX: 0.5, anchorY: 0.5 }); shopBackground.x = 0; shopBackground.y = 0; // Add 'shopout' asset to the shopScreen var shopOut = shopScreen.attachAsset('shopout', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the 'shopout' asset interactive }); shopOut.x = 650; shopOut.y = 1100; // Define the 'down' event handler for shopOut shopOut.down = function (x, y, obj) { shopScreen.visible = false; // Hide the current shop screen mapBackground.visible = false; // Ensure the mapbackground asset is hidden mapScreen.visible = true; // Show the citymap screen isolatedScreen.visible = true; // Ensure the isolated screen is visible }; }; // Position the isolatedScreen at the center isolatedScreen.x = 2048 / 2; isolatedScreen.y = 2732 / 2; }; // Attach 'anvilmap' asset to the mapScreen on the top layer var anvilMap = mapScreen.attachAsset('anvilmap', { anchorX: 0.5, anchorY: 0.5, interactive: true }); // Attach 'mine' asset to the mapScreen on the top layer var mine = mapScreen.attachAsset('mine', { anchorX: 0.5, anchorY: 0.5, interactive: true }); mine.x -= 150; // Move the mine asset 150 pixels to the left mine.y -= 150; // Move the mine asset 150 pixels higher // Make mine interactive and define the 'down' event handler mine.down = function (x, y, obj) { // Create a new screen for the mine var mineScreen = game.addChild(new Container()); // Make the map visible after transitioning to the mine screen map.visible = true; // Hide the current map screen mapScreen.visible = false; // Disable the active background background.visible = false; // Attach 'mineinsidebackground' asset to the mineScreen on the bottom layer mineInsideBackground = mineScreen.attachAsset('mineinsidebackground', { anchorX: 0.5, anchorY: 0.5, interactive: false, zIndex: -1 // Ensure it is on the bottom layer }); // Create and add a new instance of the RedCristal class redCristal = mineScreen.addChild(new RedCristal()); // Position the redCristal asset redCristal.x -= 510; // Move 100 pixels to the left redCristal.y += 490; // Move 100 pixels lower // Create and add a new instance of the GreenCristal class greenCristal = mineScreen.addChild(new GreenCristal()); // Position the greenCristal asset greenCristal.x -= 510; // Move 100 pixels to the left greenCristal.y += 90; // Move 100 pixels lower // Create and add a new instance of the BlueCristal class blueCristal = mineScreen.addChild(new BlueCristal()); // Position the blueCristal asset blueCristal.x += -40; // Move 100 pixels to the right blueCristal.y += 150; // Move 100 pixels lower // Position the blueCristal asset blueCristal.x -= 410; // Move 100 pixels to the left blueCristal.y -= 310; // Move 100 pixels lower // Position the mineScreen at the center mineScreen.x = 2048 / 2; //{1E.1} mineScreen.y = 2732 / 2; //{1E.2} }; // Make anvilMap interactive and define the 'down' event handler anvilMap.down = function (x, y, obj) { // Show the Anvil screen gameScreen.visible = true; // Make the map visible after transitioning to the anvil map map.visible = true; // Attach 'gameScreenBackground' asset to the 'gameScreen' object gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', { anchorX: 0.5, anchorY: 0.5 }); // Attach 'recipes' asset to the 'gameScreenBackground' object var recipes = gameScreenBackground.attachAsset('recipes', { anchorX: 0.5, anchorY: 0.5 }); // Center the 'recipes' asset on the gameScreenBackground recipes.x = gameScreenBackground.width / 2 - 1050; //{3u.1} recipes.y = gameScreenBackground.height / 2 + 150; //{3v.1} // Hide the mineinsidebackground when exiting the mine screen if (mineInsideBackground) { mineInsideBackground.visible = false; mineInsideBackground.destroy(); // Ensure it is completely removed } if (mineInsideBackground) { mineInsideBackground.visible = false; mineInsideBackground.destroy(); // Ensure it is completely removed } if (blueCristal) { blueCristal.visible = false; //{1X.1} blueCristal.destroy(); // Ensure it is completely removed } //{1X.3} if (greenCristal) { greenCristal.visible = false; //{1Y.1} greenCristal.destroy(); // Ensure it is completely removed } //{1Y.3} if (redCristal) { redCristal.visible = false; //{1Z.1} redCristal.destroy(); // Ensure it is completely removed } //{1Z.3} // Hide the map screen mapScreen.visible = false; // Show the counter display counterText.visible = true; // Show the Growth rate counter when transitioning to anvilmap growthRateText.visible = true; }; // Hide the current game screen gameScreen.visible = false; // Disable the active background background.visible = false; // Attach a new background or asset to the mapScreen if needed // Example: mapScreen.attachAsset('newBackground', { anchorX: 0.5, anchorY: 0.5 }); // Position the mapScreen at the center mapScreen.x = 2048 / 2; mapScreen.y = 2732 / 2; }; var growthRateText; var growthRateCounter = storage.growthRate; // Initialize growth rate counter from storage var background = game.addChild(new Container()); background.width = 2048; background.height = 2732; background.x = 2048 / 2; background.y = 2732 / 2; var backgroundGraphics = background.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); var gameScreen = new Container(); //{1h.1} var newGame = game.addChild(new Container()); newGame.x = 2048 / 2; newGame.y = 2680 * 4.2 / 5; //{3d.1} // Attach 'newGameText' asset to the 'New Game' object var newGameText = newGame.attachAsset('newGameText', { anchorX: 0.5, anchorY: 0.5, stroke: 0xFFFFFF, // White color strokeThickness: 5 // 5px thickness }); // Attach 'continueText' asset to the game object var continueText = game.addChild(LK.getAsset('continueText', { anchorX: 0.5, anchorY: 0.5 })); continueText.x = newGame.x - newGame.width - 150; // Position continueText 150 pixels to the left of newGame continueText.y = newGame.y; // Align vertically with newGame continueText.interactive = true; continueText.down = function (x, y, obj) { startgame(); }; var blueswordsclick = 0; var greenAxeClicks = 0; // Initialize greenAxeClicks variable var redCrystalTwoHandedSwordClicks = 0; // Initialize redCrystalTwoHandedSwordClicks variable function startgame() { hammer.destroy(); // Create a new game screen gameScreen = game.addChild(new Container()); gameScreen.x = 2048 / 2; gameScreen.y = 2732 / 2; // Attach 'gameScreenBackground' asset to the 'gameScreen' object gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', { anchorX: 0.5, anchorY: 0.5 }); // Attach 'recipes' asset to the 'gameScreenBackground' object var recipes = gameScreenBackground.attachAsset('recipes', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the recipes asset interactive }); // Remove 'continueText' asset when transitioning to new game // Define the 'down' event handler for recipes recipes.down = function (x, y, obj) { // Create a new screen for the recipes var recipesScreen = game.addChild(new RecipesScreen()); map.visible = false; // Hide the map asset after transitioning to the recipes screen // Add 'recipesbackground' asset to the center of the screen var recipesBackground = recipesScreen.attachAsset('recipesbackground', { anchorX: 0.5, anchorY: 0.5 }); recipesBackground.x = 2048 / 2; recipesBackground.y = 2932 / 2; // Add 'bluecrystalswordrecipe' asset to the center of the screen var bluecrystalswordrecipe = recipesScreen.attachAsset('bluecrystalswordrecipe', { anchorX: 0.5, anchorY: 0.5 }); bluecrystalswordrecipe.x = 1248 / 2; bluecrystalswordrecipe.y = 2132 / 2; bluecrystalswordrecipe.down = function () { if (storage.forgingSkill >= 2000 && storage.blueCrystalIngotScore >= 100) { blueswordsclick += 1; } if (blueswordsclick >= 1000) { blueswordsclick = 0; storage.blueSwords += 1; // Increment the blue swords count in storage blueSwordsText.setText(storage.blueSwords.toString()); } blueCrystalSwordClicks.setText('(current ' + blueswordsclick + ')'); }; // Add 'Swords in stock' text asset to the center of the screen var swordsInStockText = new Text2('Swords in stock', { size: 50, fill: 0x000000 // Black color }); swordsInStockText.anchor.set(0.5, 0.5); swordsInStockText.x = 1248 / 2; swordsInStockText.y = 2732 / 2 + 400; recipesScreen.addChild(swordsInStockText); // Display the number of blue swords in stock var blueSwordsText = new Text2(storage.blueSwords.toString(), { size: 50, fill: 0x000000 // Black color }); blueSwordsText.anchor.set(0.5, 0.5); blueSwordsText.x = 1248 / 2; blueSwordsText.y = swordsInStockText.y + 50; // Position below the 'Swords in stock' text recipesScreen.addChild(blueSwordsText); // Add 'Axe of Green Crystals recipe' asset to the center of the screen var axeOfGreenCrystalsRecipe = recipesScreen.attachAsset('axeOfGreenCrystalsRecipe', { anchorX: 0.5, anchorY: 0.5 }); axeOfGreenCrystalsRecipe.x = 2848 / 2; axeOfGreenCrystalsRecipe.y = 2132 / 2; axeOfGreenCrystalsRecipe.down = function () { if (storage.forgingSkill >= 10000 && storage.greenCrystalIngotScore >= 500) { greenAxeClicks += 1; } if (greenAxeClicks >= 3000) { greenAxeClicks = 0; storage.greenAxes += 1; // Increment the green axes count in storage greenAxesText.setText(storage.greenAxes.toString()); } greenAxeClicksText.setText('(current ' + greenAxeClicks + ')'); }; // Add 'Axe in stock' text asset to the center of the screen var axeInStockText = new Text2('Axe in stock', { size: 50, fill: 0x000000 // Black color }); axeInStockText.anchor.set(0.5, 0.5); axeInStockText.x = 2848 / 2; axeInStockText.y = swordsInStockText.y + 50; // Position below the 'Swords in stock' text recipesScreen.addChild(axeInStockText); // Display the number of green axes in stock var greenAxesText = new Text2(storage.greenAxes.toString(), { size: 50, fill: 0x000000 // Black color }); greenAxesText.anchor.set(0.5, 0.5); greenAxesText.x = 2848 / 2; greenAxesText.y = swordsInStockText.y + 100; // Position below the 'Swords in stock' text recipesScreen.addChild(greenAxesText); // Add 'Green Axe clicks' text asset to the center of the screen var greenAxeClicksText = new Text2('(current ' + greenAxeClicks + ')', { size: 50, fill: 0x000000, alpha: 0.5 // Set transparency }); greenAxeClicksText.anchor.set(0.5, 0.5); greenAxeClicksText.x = 2848 / 2 - 150; greenAxeClicksText.y = 2732 / 2 + 330; recipesScreen.addChild(greenAxeClicksText); // Add 'Blue crystal sword description' text asset to the center of the screen var blueCrystalSwordDescription = new Text2('"Blue Crystal Sword"\n Forging Skill 2k.\n 100 blue crystal ingots +\n 1000 clicks on the recipe', { size: 50, fill: 0x000000, alpha: 0.5 // Set transparency }); blueCrystalSwordDescription.anchor.set(0.5, 0.5); blueCrystalSwordDescription.x = 1248 / 2; blueCrystalSwordDescription.y = 2732 / 2 + 200; recipesScreen.addChild(blueCrystalSwordDescription); var blueCrystalSwordClicks = new Text2('(current ' + blueswordsclick + ')', { size: 50, fill: 0x000000, alpha: 0.5 // Set transparency }); blueCrystalSwordClicks.anchor.set(0.5, 0.5); blueCrystalSwordClicks.x = 1248 / 2 - 150; blueCrystalSwordClicks.y = 2732 / 2 + 330; recipesScreen.addChild(blueCrystalSwordClicks); // Add 'axeOfGreenCrystals description' text asset to the center of the screen var axeOfGreenCrystalsDescription = new Text2('"Axe of Green Crystals"\n Forging Skill 10k.\n 500 green crystal ingots +\n 3000 clicks on the anvil', { size: 50, fill: 0x000000, alpha: 0.5 // Set transparency }); axeOfGreenCrystalsDescription.anchor.set(0.5, 0.5); axeOfGreenCrystalsDescription.x = 2890 / 2; axeOfGreenCrystalsDescription.y = 2732 / 2 + 200; recipesScreen.addChild(axeOfGreenCrystalsDescription); // Add 'recipesnext' asset to the center of the screen var recipesNext = recipesScreen.attachAsset('recipesnext', { anchorX: 0.5, anchorY: 0.5 //{4F.1} }); //{4G.1} recipesNext.x = 3248 / 2; recipesNext.y = 5000 / 2; // Make the 'recipesnext' asset interactive recipesNext.interactive = true; // Define the 'down' event handler for recipesNext recipesNext.down = function (x, y, obj) { // Create a new screen for the next section var nextScreen = game.addChild(new Container()); // Remove the current background recipesScreen.visible = false; // Add 'recipesnextbackgr1' asset to the center of the screen var recipesNextBackgr1 = nextScreen.attachAsset('recipesnextbackgr1', { anchorX: 0.5, anchorY: 0.5 }); recipesNextBackgr1.x = 2048 / 2; recipesNextBackgr1.y = 2732 / 2; // Add 'recipesprev' asset to the center of the screen var recipesPrev = nextScreen.attachAsset('recipesprev', { anchorX: 0.5, anchorY: 0.5, interactive: true // Make the 'recipesprev' asset interactive }); recipesPrev.x = 888 / 2; recipesPrev.y = 5000 / 2; // Define the 'down' event handler for recipesPrev recipesPrev.down = function (x, y, obj) { // Transition back to the recipes screen nextScreen.visible = false; // Hide the current screen recipesScreen.visible = true; // Show the recipes screen }; // Add 'recipesnext2' asset to the center of the screen var recipesNext2 = nextScreen.attachAsset('recipesnext2', { anchorX: 0.5, anchorY: 0.5 }); recipesNext2.x = 3248 / 2; recipesNext2.y = 5000 / 2; // Add 'redcrystaltwo-handedswordrecipe' asset to the center of the screen var redCrystalTwoHandedSwordRecipe = nextScreen.attachAsset('redcrystaltwo-handedswordrecipe', { anchorX: 0.5, anchorY: 0.5 }); redCrystalTwoHandedSwordRecipe.x = 1248 / 2; redCrystalTwoHandedSwordRecipe.y = 2132 / 2; redCrystalTwoHandedSwordRecipe.down = function () { if (storage.forgingSkill >= 20000 && storage.redCrystalIngotScore >= 1000) { redCrystalTwoHandedSwordClicks += 1; } if (redCrystalTwoHandedSwordClicks >= 10000) { redCrystalTwoHandedSwordClicks = 0; storage.redCrystalTwoHandedSwords += 1; // Increment the red crystal two-handed swords count in storage redCrystalTwoHandedSwordsText.setText(storage.redCrystalTwoHandedSwords.toString()); } redCrystalTwoHandedSwordClicksText.setText('(current ' + redCrystalTwoHandedSwordClicks + ')'); }; // Add 'Red Crystal Two-Handed Sword in stock' text asset to the center of the screen var redCrystalTwoHandedSwordsText = new Text2(storage.redCrystalTwoHandedSwords.toString(), { size: 50, fill: 0x000000 // Black color }); redCrystalTwoHandedSwordDescription.anchor.set(0.5, 0.5); redCrystalTwoHandedSwordDescription.x = 1248 / 2; redCrystalTwoHandedSwordDescription.y = 2732 / 2 + 100; nextScreen.addChild(redCrystalTwoHandedSwordDescription); // Add 'Two-hand Swords in stock' text asset to the center of the screen var twoHandSwordsInStockText = new Text2('Two-hand Swords in stock', { size: 50, fill: 0x000000 // Black color }); twoHandSwordsInStockText.anchor.set(0.5, 0.5); twoHandSwordsInStockText.x = 1248 / 2; twoHandSwordsInStockText.y = redCrystalTwoHandedSwordDescription.y + 50; // Position below the description nextScreen.addChild(twoHandSwordsInStockText); redCrystalTwoHandedSwordsText.y = redCrystalTwoHandedSwordDescription.y + 200; // Position further below the description nextScreen.addChild(redCrystalTwoHandedSwordsText); // Add a new text box with black text under the 'redcrystaltwo-handedswordrecipe' asset var redCrystalTwoHandedSwordDescription = new Text2('"Redcrystaltwo-\n handedswordrecipe"\n Forging Skill 20k.\n 1000 red crystal ingots +\n 10000 clicks on the anvil', { size: 50, fill: 0x000000 // Black color }); redCrystalTwoHandedSwordDescription.anchor.set(0.5, 0.5); redCrystalTwoHandedSwordDescription.x = 1248 / 2; redCrystalTwoHandedSwordDescription.y = 2732 / 2 + 200; nextScreen.addChild(redCrystalTwoHandedSwordDescription); }; // Hide the current game screen gameScreen.visible = false; }; // Center the 'recipes' asset on the gameScreenBackground recipes.x = gameScreenBackground.width / 2 - 1050; //{3u.1} recipes.y = gameScreenBackground.height / 2 + 150; //{3v.1} // Make the map visible when 'New Game' is clicked map.visible = true; // Hide the main menu newGame.visible = false; continueText.visible = false; // Disable the background background.visible = false; // Create a new instance of the Anvil class var anvil = gameScreen.addChild(new Anvil()); // Initialize the anvil click counter from storage anvil.clickCounter = storage.forgingSkill; counterText.setText('Forging skill: ' + anvil.clickCounter); // Position 'The anvil' at the location of the anvil on the gameScreenBackground anvil.x = gameScreenBackground.x - -20; // Adjust x-coordinate based on the anvil's position on the background anvil.y = gameScreenBackground.y + 500; // Adjust y-coordinate based on the anvil's position on the background // Add a new object 'Magic Nursery' var magicNursery = gameScreen.addChild(new Door()); // Position 'Magic Nursery' to the left and up magicNursery.x = 2048 / 4; magicNursery.y = 2732 / 2.5; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); } // Make the 'New Game' object clickable newGame.interactive = true; newGame.down = function (x, y, obj) { // Reset all saved data storage.forgingSkill = 0; storage.growthRate = 0; storage.blueCrystalIngotScore = 0; storage.greenCrystalIngotScore = 0; storage.redCristallScore = 0; storage.redCrystalIngotScore = 0; storage.greenCristallScore = 0; storage.greenCrystalIngotScore = 0; storage.blueSwords = 0; // Reset current variables redCrystalIngotScore = 0; blueCristallScore = 0; greenCristallScore = 0; greenCrystalIngotScore = 0; blueCrystalIngotScore = 0; redCristallScore = 0; growthRateCounter = 0; growthRateText.setText('Growth rate: ' + storage.growthRate); counterText.setText('Forging skill: ' + storage.forgingSkill); scoreTxt.setText('Blue Cristall: ' + blueCristallScore); greenScoreTxt.setText('Green Cristall: ' + greenCristallScore); redScoreTxt.setText('Red Cristall: ' + redCristallScore); blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + storage.blueCrystalIngotScore); greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + storage.greenCrystalIngotScore); redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + storage.redCristallScore); startgame(); }; // Create a new text object to display the click counter var counterText = new Text2('Forging skill: ' + storage.forgingSkill, { size: 50, fill: 0xFFFFFF }); // Position the text object at the top right corner of the screen counterText.anchor.set(0, 0); LK.gui.topLeft.addChild(counterText); counterText.y = 0; counterText.x = 0; growthRateText = new Text2('Growth rate: ' + growthRateCounter, { size: 50, fill: 0xFFFFFF }); growthRateText.anchor.set(0, 0); LK.gui.topLeft.addChild(growthRateText); growthRateText.y = counterText.height; growthRateText.x = 0; // Initialize hammer asset var hammer; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); // Function to make the hammer follow the mouse/touch position function updateHammerPosition(x, y) { if (hammer) { hammer.x = x; hammer.y = y; } } // Make the cursor follow the mouse/touch position game.move = function (x, y, obj) { updateHammerPosition(x, y); }; // Animate cursor rotation on click game.down = function (x, y, obj) { LK.getSound('hammer').play(); tween(hammer, { rotation: -Math.PI / 2 }, { duration: 125, easing: tween.easeInOut, onFinish: function onFinish() { // Create stars around the hammer for 0.25 seconds for (var i = 0; i < 5; i++) { var star = game.addChild(LK.getAsset('star', { anchorX: 0.5, anchorY: 0.5 })); star.x = hammer.x - hammer.width / 2 + Math.random() * 100 - 25; star.y = hammer.y + hammer.height / 2 + Math.random() * 100 - 25; (function (star) { // Make the star move upwards star.update = function () { star.y -= 5; // Move the star upwards by 5 pixels per frame if (star.x < hammer.x) { star.x += 2; // Move the star slightly to the right if on the left side of the hammer } else { star.x -= 2; // Move the star slightly to the left if on the right side of the hammer } }; LK.setTimeout(function () { star.destroy(); }, 250); })(star); } tween(hammer, { rotation: 0 }, { duration: 125, easing: tween.easeInOut }); } }); };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
forgingSkill: 0,
growthRate: 0,
blueCristallScore: 0,
greenCrystalIngotScore: 0,
blueSwords: 0,
greenAxes: 0,
redCrystalTwoHandedSwords: 0
});
/****
* Classes
****/
// Create a new class for the anvil object
var Anvil = Container.expand(function () {
var self = Container.call(this);
// Attach 'anvil' asset to the 'Anvil' object
var anvilGraphics = self.attachAsset('anvil', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.0 // Make the anvil fully transparent
});
// Initialize the click counter
self.clickCounter = storage.forgingSkill;
// Make the 'Anvil' object interactive
self.interactive = true;
// Define the 'down' event handler
self.down = function (x, y, obj) {
// Increment the click counter
self.clickCounter++;
// Add a 5% chance for a multi-click event to increase forging skill by 5
if (Math.random() < 0.02) {
self.clickCounter += 5;
// Create a new asset at the center of the screen
var newAsset = game.addChild(LK.getAsset('multyclick', {
anchorX: 0.5,
anchorY: 0.5
}));
// Position the new asset at the center of the screen
newAsset.x = 2048 / 2;
newAsset.y = 2732 / 2;
// Animate the scaling of the new asset
tween(newAsset, {
scaleX: 2,
scaleY: 2
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
newAsset.destroy(); // Remove the asset after the animation
}
});
}
// Update the text object with the click counter and label
counterText.setText('Forging skill: ' + self.clickCounter);
// Persist the click counter
storage.forgingSkill = self.clickCounter;
// Change the color of the counter text based on the click counter
if (self.clickCounter >= 100 && self.clickCounter < 200) {
counterText.tint = 0x00FF00; // Green
} else if (self.clickCounter >= 200 && self.clickCounter < 300) {
counterText.tint = 0x0000FF; // Blue
} else if (self.clickCounter >= 300) {
counterText.tint = 0x800080; // Purple
}
};
});
// Create a new class for the BlueCristal object
var BlueCristal = Container.expand(function () {
var self = Container.call(this);
// Attach 'blueCristal' asset to the 'BlueCristal' object
var blueCristalGraphics = self.attachAsset('blueCristal', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the blueCristal interactive
});
// Define the 'down' event handler for blueCristal
self.down = function (x, y, obj) {
// Increment the score by 1
blueCristallScore += 1;
LK.setScore(blueCristallScore);
storage.blueCristallScore = blueCristallScore;
// Update the score text
scoreTxt.setText('Blue Cristall: ' + LK.getScore());
scoreTxt.visible = true; // Ensure the score text remains visible
};
});
// Create a new class for the BlueCrystalIngot object
var BlueCrystalIngot = Container.expand(function () {
var self = Container.call(this);
// Attach 'blueCrystalIngot' asset to the 'BlueCrystalIngot' object
var blueCrystalIngotGraphics = self.attachAsset('blueCrystalIngot', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the blueCrystalIngot interactive
});
// Define the 'down' event handler for blueCrystalIngot
self.down = function (x, y, obj) {
// Logic for what happens when the blueCrystalIngot is clicked
if (blueCristallScore >= 100) {
blueCrystalIngotScore += 1; //{y.1}
storage.forgingSkill += 100; // Increment forging skill by 100
counterText.setText('Forging skill: ' + storage.forgingSkill); // Update the forging skill display
blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + blueCrystalIngotScore); //{y.2}
storage.blueCrystalIngotScore = blueCrystalIngotScore;
blueCristallScore -= 100;
if (blueCristallScore < 0) {
blueCristallScore = 0;
}
storage.blueCristallScore = blueCristallScore; // Persist the decrement
LK.setScore(blueCristallScore);
scoreTxt.setText('Blue Cristall: ' + LK.getScore());
}
};
});
// Create a new class for the Door object
var Door = Container.expand(function () {
var self = Container.call(this);
// Attach 'Door' asset to the 'Door' object
var doorGraphics = self.attachAsset('Door', {
anchorX: 0.5,
anchorY: 0.5
});
// Make the 'Door' object interactive
self.interactive = true;
// Define the 'down' event handler
self.down = function (x, y, obj) {
// Remove the existing hammer
hammer.destroy();
// Create a new screen
game.magicNursery = game.addChild(new Container());
// Attach 'magicNurseryBackground' asset to the 'magicNursery' object
var magicNurseryBackground = game.magicNursery.attachAsset('magicNurseryBackground', {
anchorX: 0.5,
anchorY: 0.5,
interactive: false,
// Disable interactivity to prevent blurring on click
scaleX: 2,
// Double the size horizontally
scaleY: 2 // Double the size vertically
});
// Recreate the hammer asset
magicNurseryBackground.x = 2048 / 2;
magicNurseryBackground.y = 2732 / 2;
// Attach 'ForgeOfMatter' asset to the 'magicNursery' object
var forgeOfMatter = game.magicNursery.attachAsset('ForgeOfMatter', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true,
scaleX: 1,
scaleY: 1
});
// Create and add a new instance of the BlueCrystalIngot class
var blueCrystalIngot = game.magicNursery.addChild(new BlueCrystalIngot()); //{P.1}
// Position the blueCrystalIngot asset in the bottom-left corner
blueCrystalIngot.x = 200 + blueCrystalIngot.width / 2;
blueCrystalIngot.y = 2500 - blueCrystalIngot.height / 2;
// Create and add a new instance of the RedCrystalIngot class
var redCrystalIngot = game.magicNursery.addChild(new RedCrystalIngot());
// Center the redCrystalIngot asset in the magicNursery screen
redCrystalIngot.x = 1300 / 2;
redCrystalIngot.y = 4930 / 2;
// Create and add a new instance of the GreenCristalIngot class
var greenCristalIngot = game.magicNursery.addChild(LK.getAsset('greenCristalIngot', {
anchorX: 0.5,
anchorY: 0.5
}));
// Position the greenCristalIngot asset to the right of the blueCrystalIngot asset
greenCristalIngot.x = blueCrystalIngot.x + blueCrystalIngot.width + greenCristalIngot.width / 2 + 40; //{Y.1}
greenCristalIngot.y = blueCrystalIngot.y;
// Create and add a new instance of the GreenCrystalIngot class
var greenCrystalIngotInstance = game.magicNursery.addChild(new GreenCrystalIngot());
// Position the greenCrystalIngotInstance asset to the right of the blueCrystalIngot asset
greenCrystalIngotInstance.x = blueCrystalIngot.x + blueCrystalIngot.width + greenCrystalIngotInstance.width / 2 + 40;
greenCrystalIngotInstance.y = blueCrystalIngot.y;
// Initialize the click counter for ForgeOfMatter
forgeOfMatter.clickCounter = 0;
// Initialize the growth rate click counter from the global growthRateCounter
forgeOfMatter.clickCounter = growthRateCounter;
growthRateText.setText('Growth rate: ' + forgeOfMatter.clickCounter);
// Center the growthRate asset in the magicNursery screen
var growthRate = game.magicNursery.addChild(LK.getAsset('growthRate', {
anchorX: 0.5,
anchorY: 0.5
}));
growthRate.x = 2048 / 2 - 100;
growthRate.y = 2732 / 2;
// Define the 'down' event handler for ForgeOfMatter
forgeOfMatter.down = function (x, y, obj) {
// Increment the click counter
forgeOfMatter.clickCounter++;
// Update the text object with the click counter and label
growthRateText.setText('Growth rate: ' + forgeOfMatter.clickCounter);
// Persist the click counter to the global growthRateCounter
growthRateCounter = forgeOfMatter.clickCounter;
storage.growthRate = growthRateCounter;
};
forgeOfMatter.x = 1100 / 1.5;
forgeOfMatter.y = 2000 / 1.5;
// Add a new counter to the ForgeOfMatter object
growthRateText.setText('Growth rate: ' + forgeOfMatter.clickCounter);
growthRateText.visible = true;
// Hide the game screen
gameScreen.visible = false;
// Show the forging skill counter when transitioning to magicNursery
counterText.visible = true;
// Hide the map when switching to the magic nursery screen
map.visible = false;
// Add a new object 'Door2'
var door2 = game.magicNursery.addChild(new Door2());
// Position 'Door2' to the right, between the center and the edge of the screen
door2.x = 2048 * 0.75;
door2.y = 2732 * 0.9;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
});
// Create a new class for the Door2 object
var Door2 = Container.expand(function () {
var self = Container.call(this);
// Attach 'Door' asset to the 'Door2' object
var doorGraphics = self.attachAsset('Door', {
anchorX: 0.5,
anchorY: 0.5
});
// Make the 'Door2' object interactive
self.interactive = true;
// Define the 'down' event handler
self.down = function (x, y, obj) {
// Remove the existing hammer
hammer.destroy();
// Show the Anvil screen
gameScreen.visible = true;
// Show the map only on the anvil screen
map.visible = true;
// Show the counter display
counterText.visible = true;
// Hide the Magic Nursery screen
game.magicNursery.visible = false;
// Show the Growth rate counter when transitioning to anvil
growthRateText.visible = true;
// Recreate the hammer asset
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
});
// Create a new class for the GreenAxe object
var GreenAxe = Container.expand(function () {
var self = Container.call(this);
// Attach 'axeOfGreenCrystalsRecipe' asset to the 'GreenAxe' object
var greenAxeGraphics = self.attachAsset('axeOfGreenCrystalsRecipe', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the greenAxe interactive
});
// Define the 'down' event handler for greenAxe
self.down = function (x, y, obj) {
if (storage.forgingSkill >= 10000 && storage.greenCrystalIngotScore >= 500) {
greenAxeClicks += 1000;
}
if (greenAxeClicks >= 3000) {
greenAxeClicks = 0;
storage.greenAxes += 1; // Increment the green axes count in storage
greenAxesText.setText(storage.greenAxes.toString());
}
greenAxeClicksText.setText('(current ' + greenAxeClicks + ')');
};
});
// Create a new class for the GreenCristal object
var GreenCristal = Container.expand(function () {
var self = Container.call(this);
// Attach 'greenCristal' asset to the 'GreenCristal' object
var greenCristalGraphics = self.attachAsset('greenCristal', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the greenCristal interactive
});
// Define the 'down' event handler for greenCristal
self.down = function (x, y, obj) {
// Increment the score by 1
greenCristallScore += 1;
LK.setScore(greenCristallScore);
storage.greenCristallScore = greenCristallScore;
// Update the score text
greenScoreTxt.setText('Green Cristall: ' + greenCristallScore);
greenScoreTxt.visible = true; // Ensure the score text remains visible
};
});
// Create a new class for the GreenCrystalIngot object
var GreenCrystalIngot = Container.expand(function () {
var self = Container.call(this);
// Attach 'greenCrystalIngot' asset to the 'GreenCrystalIngot' object
var greenCrystalIngotGraphics = self.attachAsset('greenCrystalIngot', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the greenCrystalIngot interactive
});
// Define the 'down' event handler for greenCrystalIngot
self.down = function (x, y, obj) {
if (greenCristallScore >= 100) {
// Increment the GreenCrystalIngot score by 1
greenCrystalIngotScore += 1;
greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + greenCrystalIngotScore);
storage.greenCrystalIngotScore = greenCrystalIngotScore;
// Decrement the GreenCristal score by 100
greenCristallScore -= 100;
if (greenCristallScore < 0) {
greenCristallScore = 0;
}
storage.greenCristallScore = greenCristallScore; // Persist the decrement
greenScoreTxt.setText('Green Cristall: ' + greenCristallScore);
}
};
});
// Create a new class for the RecipesScreen object
var RecipesScreen = Container.expand(function () {
var self = Container.call(this);
// Attach 'recipesout' asset to the 'RecipesScreen' object
var recipesOutGraphics = self.attachAsset('recipesout', {
anchorX: 0.5,
anchorY: 0.5
});
// Center the 'recipesout' asset on the screen
recipesOutGraphics.x = 2048 / 2;
recipesOutGraphics.y = 2732 / 2 + 1100;
// Make the 'recipesout' asset interactive
recipesOutGraphics.interactive = true;
// Define the 'down' event handler for recipesOutGraphics
recipesOutGraphics.down = function (x, y, obj) {
// Hide the 'recipesout' asset
recipesOutGraphics.visible = false;
// Transition to the 'gameScreen'
gameScreen.visible = true;
// Make the map visible after transitioning to the recipesout screen
map.visible = true;
// Hide the current recipes screen
self.visible = false;
};
});
// Create a new class for the RedCristal object
var RedCristal = Container.expand(function () {
var self = Container.call(this);
// Attach 'redCristal' asset to the 'RedCristal' object
var redCristalGraphics = self.attachAsset('redCristal', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the redCristal interactive
});
// Define the 'down' event handler for redCristal
self.down = function (x, y, obj) {
// Increment the score by 1
redCristallScore += 1;
LK.setScore(redCristallScore);
storage.redCristallScore = redCristallScore;
// Update the score text
redScoreTxt.setText('Red Cristall: ' + redCristallScore);
redScoreTxt.visible = true; // Ensure the score text remains visible
};
});
// Create a new class for the RedCrystalIngot object
var RedCrystalIngot = Container.expand(function () {
var self = Container.call(this);
// Attach 'redCristalIngot' asset to the 'RedCrystalIngot' object
var redCrystalIngotGraphics = self.attachAsset('redCristalIngot', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the redCrystalIngot interactive
});
// Define the 'down' event handler for redCrystalIngot
self.down = function (x, y, obj) {
// Decrement the RedCristal score by 100
if (redCristallScore >= 100) {
// Increment the RedCrystalIngot score by 1
redCrystalIngotScore += 1;
redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + redCrystalIngotScore);
storage.redCrystalIngotScore = redCrystalIngotScore;
redCristallScore -= 100;
storage.redCristallScore = redCristallScore; // Persist the decrement
redScoreTxt.setText('Red Cristall: ' + redCristallScore);
}
};
});
var RedCrystalTwoHandedSword = Container.expand(function () {
var self = Container.call(this);
// Attach 'redcrystaltwo-handedswordrecipe' asset to the 'RedCrystalTwoHandedSword' object
var redCrystalTwoHandedSwordGraphics = self.attachAsset('redcrystaltwo-handedswordrecipe', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the redCrystalTwoHandedSword interactive
});
// Define the 'down' event handler for redCrystalTwoHandedSword
self.down = function (x, y, obj) {
if (storage.forgingSkill >= 20000 && storage.redCrystalIngotScore >= 1000) {
redCrystalTwoHandedSwordClicks += 1;
}
if (redCrystalTwoHandedSwordClicks >= 10000) {
redCrystalTwoHandedSwordClicks = 0;
storage.redCrystalTwoHandedSwords += 1; // Increment the red crystal two-handed swords count in storage
redCrystalTwoHandedSwordsText.setText(storage.redCrystalTwoHandedSwords.toString());
}
redCrystalTwoHandedSwordClicksText.setText('(current ' + redCrystalTwoHandedSwordClicks + ')');
};
});
/****
* Initialize Game
****/
// Create a new text object to display the click counter
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var redCrystalIngotScore = storage.redCrystalIngotScore || 0;
var redCrystalIngotScoreTxt = new Text2('RedCrystalIngot: ' + redCrystalIngotScore, {
size: 50,
fill: 0xFFFFFF
});
redCrystalIngotScoreTxt.anchor.set(1, 0);
redCrystalIngotScoreTxt.y = 100; // Position below the GreenCrystalIngot score
LK.gui.topRight.addChild(redCrystalIngotScoreTxt);
//{0.1}
var mineInsideBackground;
var blueCristallScore = storage.blueCristallScore || 0;
var scoreTxt = new Text2('Blue Cristall: ' + blueCristallScore, {
size: 50,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
scoreTxt.y = 100; // Move the score text 100 pixels down
LK.gui.topLeft.addChild(scoreTxt);
var greenCristallScore = storage.greenCristallScore || 0;
var greenScoreTxt = new Text2('Green Cristall: ' + greenCristallScore, {
size: 50,
fill: 0xFFFFFF
});
greenScoreTxt.anchor.set(0, 0);
greenScoreTxt.y = 150; // Position below the Blue Cristall score
LK.gui.topLeft.addChild(greenScoreTxt);
var greenCrystalIngotScore = storage.greenCrystalIngotScore || 0;
var greenCrystalIngotScoreTxt = new Text2('GreenCrystalIngot: ' + greenCrystalIngotScore, {
size: 50,
fill: 0xFFFFFF
});
greenCrystalIngotScoreTxt.anchor.set(1, 0);
greenCrystalIngotScoreTxt.y = 50; // Position below the BlueCrystalIngot score
LK.gui.topRight.addChild(greenCrystalIngotScoreTxt);
var blueCristal; // Define blueCristal in the global scope to fix the reference error
var greenCristal; // Define greenCristal in the global scope to fix the reference error
var redCristal; // Define redCristal in the global scope to fix the reference error
var blueCrystalIngotScore = storage.blueCrystalIngotScore || 0; //{1Z.1}
var redCristallScore = storage.redCristallScore || 0;
var blueCrystalIngotScoreTxt = new Text2('BlueCrystalIngot: ' + blueCrystalIngotScore, {
size: 50,
fill: 0xFFFFFF
});
blueCrystalIngotScoreTxt.anchor.set(1, 0);
blueCrystalIngotScoreTxt.y = 0;
LK.gui.topRight.addChild(blueCrystalIngotScoreTxt);
var redScoreTxt = new Text2('Red Cristall: ' + redCristallScore, {
size: 50,
fill: 0xFFFFFF
});
redScoreTxt.anchor.set(0, 0);
redScoreTxt.y = 200; // Position below the Green Cristall score
LK.gui.topLeft.addChild(redScoreTxt);
var map = game.addChild(LK.getAsset('Map', {
anchorX: 0.5,
anchorY: 0.5
}));
map.x = 400;
map.y = 2450;
map.visible = false; // Initialize the map as invisible
// Make the map interactive
map.interactive = true;
// Define the 'down' event handler for the map
map.down = function (x, y, obj) {
// Hide the map asset when transitioning to the map screen
map.visible = false;
// Hide the mineInsideBackground if it exists
if (mineInsideBackground) {
mineInsideBackground.visible = false;
mineInsideBackground.destroy(); // Ensure it is completely removed
}
if (redCristal) {
redCristal.visible = false; //{1Z.1}
redCristal.destroy(); // Ensure it is completely removed
} //{1Z.3}
if (blueCristal) {
blueCristal.visible = false; //{1X.1}
blueCristal.destroy(); // Ensure it is completely removed
} //{1X.3}
if (greenCristal) {
greenCristal.visible = false; //{1Y.1}
greenCristal.destroy(); // Ensure it is completely removed
} //{1Y.3}
var mapScreen = game.addChild(new Container());
// Attach 'mapbackground' asset to the mapScreen
var mapBackground = mapScreen.attachAsset('mapbackground', {
anchorX: 0.5,
//{1h.1}
anchorY: 0.5,
//{1h.2}
interactive: false // Ensure mapbackground does not block cursor interaction
}); //{1h.3}
// Add 'citymap' asset to the center of the screen
var cityMap = mapScreen.attachAsset('citymap', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'citymap' asset interactive
});
cityMap.x = -250;
cityMap.y = 160;
// Define the 'down' event handler for cityMap
cityMap.down = function (x, y, obj) {
// Create a new screen without background
var isolatedScreen = game.addChild(new Container());
// Hide the current map screen
mapScreen.visible = false;
// Add 'citybackground' asset to the center of the isolatedScreen
var cityBackground = isolatedScreen.attachAsset('citybackground', {
anchorX: 0.5,
anchorY: 0.5
});
cityBackground.x = 0;
cityBackground.y = 0;
// Add 'map' asset to the isolatedScreen
var mapAsset = isolatedScreen.attachAsset('Map', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'map' asset interactive
});
mapAsset.x = -650;
mapAsset.y = 1100;
// Define the 'down' event handler for mapAsset
mapAsset.down = function (x, y, obj) {
// Transition back to the citymap screen
isolatedScreen.visible = false; // Hide the current isolated screen
mapScreen.visible = true; // Show the citymap screen
cityBackground.visible = false; // Ensure citybackground is hidden
};
// Add 'shop' asset to the center of the isolatedScreen
var shop = isolatedScreen.attachAsset('shop', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'shop' asset interactive
});
shop.x = 490;
shop.y = -100;
// Define the 'down' event handler for shop
shop.down = function (x, y, obj) {
// Create a new screen without background
var shopScreen = game.addChild(new Container());
// Hide the current isolated screen
isolatedScreen.visible = false;
// Position the shopScreen at the center
shopScreen.x = 2048 / 2;
shopScreen.y = 2732 / 2;
// Add 'new tools' asset to the center of the shopScreen
var newTools = shopScreen.attachAsset('newTools', {
anchorX: 0.5,
anchorY: 0.5
});
newTools.x = -650;
newTools.y = 1100;
// Add 'new buildings' asset to the center of the shopScreen
var newBuildings = shopScreen.attachAsset('newBuildings', {
anchorX: 0.5,
anchorY: 0.5
});
newBuildings.x = 0;
newBuildings.y = 1100;
// Add 'shopout' asset to the shopScreen
var shopBackground = shopScreen.attachAsset('shopbackground', {
anchorX: 0.5,
anchorY: 0.5
});
shopBackground.x = 0;
shopBackground.y = 0;
// Add 'shopout' asset to the shopScreen
var shopOut = shopScreen.attachAsset('shopout', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'shopout' asset interactive
});
shopOut.x = 650;
shopOut.y = 1100;
// Define the 'down' event handler for shopOut
shopOut.down = function (x, y, obj) {
shopScreen.visible = false; // Hide the current shop screen
mapBackground.visible = false; // Ensure the mapbackground asset is hidden
mapScreen.visible = true; // Show the citymap screen
isolatedScreen.visible = true; // Ensure the isolated screen is visible
};
};
// Position the isolatedScreen at the center
isolatedScreen.x = 2048 / 2;
isolatedScreen.y = 2732 / 2;
};
// Attach 'anvilmap' asset to the mapScreen on the top layer
var anvilMap = mapScreen.attachAsset('anvilmap', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true
});
// Attach 'mine' asset to the mapScreen on the top layer
var mine = mapScreen.attachAsset('mine', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true
});
mine.x -= 150; // Move the mine asset 150 pixels to the left
mine.y -= 150; // Move the mine asset 150 pixels higher
// Make mine interactive and define the 'down' event handler
mine.down = function (x, y, obj) {
// Create a new screen for the mine
var mineScreen = game.addChild(new Container());
// Make the map visible after transitioning to the mine screen
map.visible = true;
// Hide the current map screen
mapScreen.visible = false;
// Disable the active background
background.visible = false;
// Attach 'mineinsidebackground' asset to the mineScreen on the bottom layer
mineInsideBackground = mineScreen.attachAsset('mineinsidebackground', {
anchorX: 0.5,
anchorY: 0.5,
interactive: false,
zIndex: -1 // Ensure it is on the bottom layer
});
// Create and add a new instance of the RedCristal class
redCristal = mineScreen.addChild(new RedCristal());
// Position the redCristal asset
redCristal.x -= 510; // Move 100 pixels to the left
redCristal.y += 490; // Move 100 pixels lower
// Create and add a new instance of the GreenCristal class
greenCristal = mineScreen.addChild(new GreenCristal());
// Position the greenCristal asset
greenCristal.x -= 510; // Move 100 pixels to the left
greenCristal.y += 90; // Move 100 pixels lower
// Create and add a new instance of the BlueCristal class
blueCristal = mineScreen.addChild(new BlueCristal());
// Position the blueCristal asset
blueCristal.x += -40; // Move 100 pixels to the right
blueCristal.y += 150; // Move 100 pixels lower
// Position the blueCristal asset
blueCristal.x -= 410; // Move 100 pixels to the left
blueCristal.y -= 310; // Move 100 pixels lower
// Position the mineScreen at the center
mineScreen.x = 2048 / 2; //{1E.1}
mineScreen.y = 2732 / 2; //{1E.2}
};
// Make anvilMap interactive and define the 'down' event handler
anvilMap.down = function (x, y, obj) {
// Show the Anvil screen
gameScreen.visible = true;
// Make the map visible after transitioning to the anvil map
map.visible = true;
// Attach 'gameScreenBackground' asset to the 'gameScreen' object
gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', {
anchorX: 0.5,
anchorY: 0.5
});
// Attach 'recipes' asset to the 'gameScreenBackground' object
var recipes = gameScreenBackground.attachAsset('recipes', {
anchorX: 0.5,
anchorY: 0.5
});
// Center the 'recipes' asset on the gameScreenBackground
recipes.x = gameScreenBackground.width / 2 - 1050; //{3u.1}
recipes.y = gameScreenBackground.height / 2 + 150; //{3v.1}
// Hide the mineinsidebackground when exiting the mine screen
if (mineInsideBackground) {
mineInsideBackground.visible = false;
mineInsideBackground.destroy(); // Ensure it is completely removed
}
if (mineInsideBackground) {
mineInsideBackground.visible = false;
mineInsideBackground.destroy(); // Ensure it is completely removed
}
if (blueCristal) {
blueCristal.visible = false; //{1X.1}
blueCristal.destroy(); // Ensure it is completely removed
} //{1X.3}
if (greenCristal) {
greenCristal.visible = false; //{1Y.1}
greenCristal.destroy(); // Ensure it is completely removed
} //{1Y.3}
if (redCristal) {
redCristal.visible = false; //{1Z.1}
redCristal.destroy(); // Ensure it is completely removed
} //{1Z.3}
// Hide the map screen
mapScreen.visible = false;
// Show the counter display
counterText.visible = true;
// Show the Growth rate counter when transitioning to anvilmap
growthRateText.visible = true;
};
// Hide the current game screen
gameScreen.visible = false;
// Disable the active background
background.visible = false;
// Attach a new background or asset to the mapScreen if needed
// Example: mapScreen.attachAsset('newBackground', { anchorX: 0.5, anchorY: 0.5 });
// Position the mapScreen at the center
mapScreen.x = 2048 / 2;
mapScreen.y = 2732 / 2;
};
var growthRateText;
var growthRateCounter = storage.growthRate; // Initialize growth rate counter from storage
var background = game.addChild(new Container());
background.width = 2048;
background.height = 2732;
background.x = 2048 / 2;
background.y = 2732 / 2;
var backgroundGraphics = background.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
var gameScreen = new Container(); //{1h.1}
var newGame = game.addChild(new Container());
newGame.x = 2048 / 2;
newGame.y = 2680 * 4.2 / 5; //{3d.1}
// Attach 'newGameText' asset to the 'New Game' object
var newGameText = newGame.attachAsset('newGameText', {
anchorX: 0.5,
anchorY: 0.5,
stroke: 0xFFFFFF,
// White color
strokeThickness: 5 // 5px thickness
});
// Attach 'continueText' asset to the game object
var continueText = game.addChild(LK.getAsset('continueText', {
anchorX: 0.5,
anchorY: 0.5
}));
continueText.x = newGame.x - newGame.width - 150; // Position continueText 150 pixels to the left of newGame
continueText.y = newGame.y; // Align vertically with newGame
continueText.interactive = true;
continueText.down = function (x, y, obj) {
startgame();
};
var blueswordsclick = 0;
var greenAxeClicks = 0; // Initialize greenAxeClicks variable
var redCrystalTwoHandedSwordClicks = 0; // Initialize redCrystalTwoHandedSwordClicks variable
function startgame() {
hammer.destroy();
// Create a new game screen
gameScreen = game.addChild(new Container());
gameScreen.x = 2048 / 2;
gameScreen.y = 2732 / 2;
// Attach 'gameScreenBackground' asset to the 'gameScreen' object
gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', {
anchorX: 0.5,
anchorY: 0.5
});
// Attach 'recipes' asset to the 'gameScreenBackground' object
var recipes = gameScreenBackground.attachAsset('recipes', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the recipes asset interactive
});
// Remove 'continueText' asset when transitioning to new game
// Define the 'down' event handler for recipes
recipes.down = function (x, y, obj) {
// Create a new screen for the recipes
var recipesScreen = game.addChild(new RecipesScreen());
map.visible = false; // Hide the map asset after transitioning to the recipes screen
// Add 'recipesbackground' asset to the center of the screen
var recipesBackground = recipesScreen.attachAsset('recipesbackground', {
anchorX: 0.5,
anchorY: 0.5
});
recipesBackground.x = 2048 / 2;
recipesBackground.y = 2932 / 2;
// Add 'bluecrystalswordrecipe' asset to the center of the screen
var bluecrystalswordrecipe = recipesScreen.attachAsset('bluecrystalswordrecipe', {
anchorX: 0.5,
anchorY: 0.5
});
bluecrystalswordrecipe.x = 1248 / 2;
bluecrystalswordrecipe.y = 2132 / 2;
bluecrystalswordrecipe.down = function () {
if (storage.forgingSkill >= 2000 && storage.blueCrystalIngotScore >= 100) {
blueswordsclick += 1;
}
if (blueswordsclick >= 1000) {
blueswordsclick = 0;
storage.blueSwords += 1; // Increment the blue swords count in storage
blueSwordsText.setText(storage.blueSwords.toString());
}
blueCrystalSwordClicks.setText('(current ' + blueswordsclick + ')');
};
// Add 'Swords in stock' text asset to the center of the screen
var swordsInStockText = new Text2('Swords in stock', {
size: 50,
fill: 0x000000 // Black color
});
swordsInStockText.anchor.set(0.5, 0.5);
swordsInStockText.x = 1248 / 2;
swordsInStockText.y = 2732 / 2 + 400;
recipesScreen.addChild(swordsInStockText);
// Display the number of blue swords in stock
var blueSwordsText = new Text2(storage.blueSwords.toString(), {
size: 50,
fill: 0x000000 // Black color
});
blueSwordsText.anchor.set(0.5, 0.5);
blueSwordsText.x = 1248 / 2;
blueSwordsText.y = swordsInStockText.y + 50; // Position below the 'Swords in stock' text
recipesScreen.addChild(blueSwordsText);
// Add 'Axe of Green Crystals recipe' asset to the center of the screen
var axeOfGreenCrystalsRecipe = recipesScreen.attachAsset('axeOfGreenCrystalsRecipe', {
anchorX: 0.5,
anchorY: 0.5
});
axeOfGreenCrystalsRecipe.x = 2848 / 2;
axeOfGreenCrystalsRecipe.y = 2132 / 2;
axeOfGreenCrystalsRecipe.down = function () {
if (storage.forgingSkill >= 10000 && storage.greenCrystalIngotScore >= 500) {
greenAxeClicks += 1;
}
if (greenAxeClicks >= 3000) {
greenAxeClicks = 0;
storage.greenAxes += 1; // Increment the green axes count in storage
greenAxesText.setText(storage.greenAxes.toString());
}
greenAxeClicksText.setText('(current ' + greenAxeClicks + ')');
};
// Add 'Axe in stock' text asset to the center of the screen
var axeInStockText = new Text2('Axe in stock', {
size: 50,
fill: 0x000000 // Black color
});
axeInStockText.anchor.set(0.5, 0.5);
axeInStockText.x = 2848 / 2;
axeInStockText.y = swordsInStockText.y + 50; // Position below the 'Swords in stock' text
recipesScreen.addChild(axeInStockText);
// Display the number of green axes in stock
var greenAxesText = new Text2(storage.greenAxes.toString(), {
size: 50,
fill: 0x000000 // Black color
});
greenAxesText.anchor.set(0.5, 0.5);
greenAxesText.x = 2848 / 2;
greenAxesText.y = swordsInStockText.y + 100; // Position below the 'Swords in stock' text
recipesScreen.addChild(greenAxesText);
// Add 'Green Axe clicks' text asset to the center of the screen
var greenAxeClicksText = new Text2('(current ' + greenAxeClicks + ')', {
size: 50,
fill: 0x000000,
alpha: 0.5 // Set transparency
});
greenAxeClicksText.anchor.set(0.5, 0.5);
greenAxeClicksText.x = 2848 / 2 - 150;
greenAxeClicksText.y = 2732 / 2 + 330;
recipesScreen.addChild(greenAxeClicksText);
// Add 'Blue crystal sword description' text asset to the center of the screen
var blueCrystalSwordDescription = new Text2('"Blue Crystal Sword"\n Forging Skill 2k.\n 100 blue crystal ingots +\n 1000 clicks on the recipe', {
size: 50,
fill: 0x000000,
alpha: 0.5 // Set transparency
});
blueCrystalSwordDescription.anchor.set(0.5, 0.5);
blueCrystalSwordDescription.x = 1248 / 2;
blueCrystalSwordDescription.y = 2732 / 2 + 200;
recipesScreen.addChild(blueCrystalSwordDescription);
var blueCrystalSwordClicks = new Text2('(current ' + blueswordsclick + ')', {
size: 50,
fill: 0x000000,
alpha: 0.5 // Set transparency
});
blueCrystalSwordClicks.anchor.set(0.5, 0.5);
blueCrystalSwordClicks.x = 1248 / 2 - 150;
blueCrystalSwordClicks.y = 2732 / 2 + 330;
recipesScreen.addChild(blueCrystalSwordClicks);
// Add 'axeOfGreenCrystals description' text asset to the center of the screen
var axeOfGreenCrystalsDescription = new Text2('"Axe of Green Crystals"\n Forging Skill 10k.\n 500 green crystal ingots +\n 3000 clicks on the anvil', {
size: 50,
fill: 0x000000,
alpha: 0.5 // Set transparency
});
axeOfGreenCrystalsDescription.anchor.set(0.5, 0.5);
axeOfGreenCrystalsDescription.x = 2890 / 2;
axeOfGreenCrystalsDescription.y = 2732 / 2 + 200;
recipesScreen.addChild(axeOfGreenCrystalsDescription);
// Add 'recipesnext' asset to the center of the screen
var recipesNext = recipesScreen.attachAsset('recipesnext', {
anchorX: 0.5,
anchorY: 0.5 //{4F.1}
}); //{4G.1}
recipesNext.x = 3248 / 2;
recipesNext.y = 5000 / 2;
// Make the 'recipesnext' asset interactive
recipesNext.interactive = true;
// Define the 'down' event handler for recipesNext
recipesNext.down = function (x, y, obj) {
// Create a new screen for the next section
var nextScreen = game.addChild(new Container());
// Remove the current background
recipesScreen.visible = false;
// Add 'recipesnextbackgr1' asset to the center of the screen
var recipesNextBackgr1 = nextScreen.attachAsset('recipesnextbackgr1', {
anchorX: 0.5,
anchorY: 0.5
});
recipesNextBackgr1.x = 2048 / 2;
recipesNextBackgr1.y = 2732 / 2;
// Add 'recipesprev' asset to the center of the screen
var recipesPrev = nextScreen.attachAsset('recipesprev', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'recipesprev' asset interactive
});
recipesPrev.x = 888 / 2;
recipesPrev.y = 5000 / 2;
// Define the 'down' event handler for recipesPrev
recipesPrev.down = function (x, y, obj) {
// Transition back to the recipes screen
nextScreen.visible = false; // Hide the current screen
recipesScreen.visible = true; // Show the recipes screen
};
// Add 'recipesnext2' asset to the center of the screen
var recipesNext2 = nextScreen.attachAsset('recipesnext2', {
anchorX: 0.5,
anchorY: 0.5
});
recipesNext2.x = 3248 / 2;
recipesNext2.y = 5000 / 2;
// Add 'redcrystaltwo-handedswordrecipe' asset to the center of the screen
var redCrystalTwoHandedSwordRecipe = nextScreen.attachAsset('redcrystaltwo-handedswordrecipe', {
anchorX: 0.5,
anchorY: 0.5
});
redCrystalTwoHandedSwordRecipe.x = 1248 / 2;
redCrystalTwoHandedSwordRecipe.y = 2132 / 2;
redCrystalTwoHandedSwordRecipe.down = function () {
if (storage.forgingSkill >= 20000 && storage.redCrystalIngotScore >= 1000) {
redCrystalTwoHandedSwordClicks += 1;
}
if (redCrystalTwoHandedSwordClicks >= 10000) {
redCrystalTwoHandedSwordClicks = 0;
storage.redCrystalTwoHandedSwords += 1; // Increment the red crystal two-handed swords count in storage
redCrystalTwoHandedSwordsText.setText(storage.redCrystalTwoHandedSwords.toString());
}
redCrystalTwoHandedSwordClicksText.setText('(current ' + redCrystalTwoHandedSwordClicks + ')');
};
// Add 'Red Crystal Two-Handed Sword in stock' text asset to the center of the screen
var redCrystalTwoHandedSwordsText = new Text2(storage.redCrystalTwoHandedSwords.toString(), {
size: 50,
fill: 0x000000 // Black color
});
redCrystalTwoHandedSwordDescription.anchor.set(0.5, 0.5);
redCrystalTwoHandedSwordDescription.x = 1248 / 2;
redCrystalTwoHandedSwordDescription.y = 2732 / 2 + 100;
nextScreen.addChild(redCrystalTwoHandedSwordDescription);
// Add 'Two-hand Swords in stock' text asset to the center of the screen
var twoHandSwordsInStockText = new Text2('Two-hand Swords in stock', {
size: 50,
fill: 0x000000 // Black color
});
twoHandSwordsInStockText.anchor.set(0.5, 0.5);
twoHandSwordsInStockText.x = 1248 / 2;
twoHandSwordsInStockText.y = redCrystalTwoHandedSwordDescription.y + 50; // Position below the description
nextScreen.addChild(twoHandSwordsInStockText);
redCrystalTwoHandedSwordsText.y = redCrystalTwoHandedSwordDescription.y + 200; // Position further below the description
nextScreen.addChild(redCrystalTwoHandedSwordsText);
// Add a new text box with black text under the 'redcrystaltwo-handedswordrecipe' asset
var redCrystalTwoHandedSwordDescription = new Text2('"Redcrystaltwo-\n handedswordrecipe"\n Forging Skill 20k.\n 1000 red crystal ingots +\n 10000 clicks on the anvil', {
size: 50,
fill: 0x000000 // Black color
});
redCrystalTwoHandedSwordDescription.anchor.set(0.5, 0.5);
redCrystalTwoHandedSwordDescription.x = 1248 / 2;
redCrystalTwoHandedSwordDescription.y = 2732 / 2 + 200;
nextScreen.addChild(redCrystalTwoHandedSwordDescription);
};
// Hide the current game screen
gameScreen.visible = false;
};
// Center the 'recipes' asset on the gameScreenBackground
recipes.x = gameScreenBackground.width / 2 - 1050; //{3u.1}
recipes.y = gameScreenBackground.height / 2 + 150; //{3v.1}
// Make the map visible when 'New Game' is clicked
map.visible = true;
// Hide the main menu
newGame.visible = false;
continueText.visible = false;
// Disable the background
background.visible = false;
// Create a new instance of the Anvil class
var anvil = gameScreen.addChild(new Anvil());
// Initialize the anvil click counter from storage
anvil.clickCounter = storage.forgingSkill;
counterText.setText('Forging skill: ' + anvil.clickCounter);
// Position 'The anvil' at the location of the anvil on the gameScreenBackground
anvil.x = gameScreenBackground.x - -20; // Adjust x-coordinate based on the anvil's position on the background
anvil.y = gameScreenBackground.y + 500; // Adjust y-coordinate based on the anvil's position on the background
// Add a new object 'Magic Nursery'
var magicNursery = gameScreen.addChild(new Door());
// Position 'Magic Nursery' to the left and up
magicNursery.x = 2048 / 4;
magicNursery.y = 2732 / 2.5;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
}
// Make the 'New Game' object clickable
newGame.interactive = true;
newGame.down = function (x, y, obj) {
// Reset all saved data
storage.forgingSkill = 0;
storage.growthRate = 0;
storage.blueCrystalIngotScore = 0;
storage.greenCrystalIngotScore = 0;
storage.redCristallScore = 0;
storage.redCrystalIngotScore = 0;
storage.greenCristallScore = 0;
storage.greenCrystalIngotScore = 0;
storage.blueSwords = 0;
// Reset current variables
redCrystalIngotScore = 0;
blueCristallScore = 0;
greenCristallScore = 0;
greenCrystalIngotScore = 0;
blueCrystalIngotScore = 0;
redCristallScore = 0;
growthRateCounter = 0;
growthRateText.setText('Growth rate: ' + storage.growthRate);
counterText.setText('Forging skill: ' + storage.forgingSkill);
scoreTxt.setText('Blue Cristall: ' + blueCristallScore);
greenScoreTxt.setText('Green Cristall: ' + greenCristallScore);
redScoreTxt.setText('Red Cristall: ' + redCristallScore);
blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + storage.blueCrystalIngotScore);
greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + storage.greenCrystalIngotScore);
redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + storage.redCristallScore);
startgame();
};
// Create a new text object to display the click counter
var counterText = new Text2('Forging skill: ' + storage.forgingSkill, {
size: 50,
fill: 0xFFFFFF
});
// Position the text object at the top right corner of the screen
counterText.anchor.set(0, 0);
LK.gui.topLeft.addChild(counterText);
counterText.y = 0;
counterText.x = 0;
growthRateText = new Text2('Growth rate: ' + growthRateCounter, {
size: 50,
fill: 0xFFFFFF
});
growthRateText.anchor.set(0, 0);
LK.gui.topLeft.addChild(growthRateText);
growthRateText.y = counterText.height;
growthRateText.x = 0;
// Initialize hammer asset
var hammer;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
// Function to make the hammer follow the mouse/touch position
function updateHammerPosition(x, y) {
if (hammer) {
hammer.x = x;
hammer.y = y;
}
}
// Make the cursor follow the mouse/touch position
game.move = function (x, y, obj) {
updateHammerPosition(x, y);
};
// Animate cursor rotation on click
game.down = function (x, y, obj) {
LK.getSound('hammer').play();
tween(hammer, {
rotation: -Math.PI / 2
}, {
duration: 125,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Create stars around the hammer for 0.25 seconds
for (var i = 0; i < 5; i++) {
var star = game.addChild(LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5
}));
star.x = hammer.x - hammer.width / 2 + Math.random() * 100 - 25;
star.y = hammer.y + hammer.height / 2 + Math.random() * 100 - 25;
(function (star) {
// Make the star move upwards
star.update = function () {
star.y -= 5; // Move the star upwards by 5 pixels per frame
if (star.x < hammer.x) {
star.x += 2; // Move the star slightly to the right if on the left side of the hammer
} else {
star.x -= 2; // Move the star slightly to the left if on the right side of the hammer
}
};
LK.setTimeout(function () {
star.destroy();
}, 250);
})(star);
}
tween(hammer, {
rotation: 0
}, {
duration: 125,
easing: tween.easeInOut
});
}
});
};