User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var hint = gameScreen.addChild(LK.getAsset('hint', {' Line Number: 486
User prompt
выводи ассет hint на экран anvil
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'blueSwordsText is not defined' in or related to this line: 'var blueSword = screens.recipesScreen.addChild(new CraftableItem('bluecrystalswordrecipe', 2000, 10, 1000, 'blueCrystalIngotScore', 'blueSwords', 'blueswordsclick', blueSwordsText));' Line Number: 948
User prompt
Please fix the bug: 'greenAxesText is not defined' in or related to this line: 'var greenAxe = screens.recipesScreen.addChild(new CraftableItem('axeOfGreenCrystalsRecipe', 10000, 25, 3000, 'greenCrystalIngotScore', 'greenAxes', 'greenAxeClicks', greenAxesText));' Line Number: 959
User prompt
Please fix the bug: 'blueSwordsText is not defined' in or related to this line: 'var blueSword = screens.recipesScreen.addChild(new CraftableItem('bluecrystalswordrecipe', 2000, 10, 1000, 'blueCrystalIngotScore', 'blueSwords', 'blueswordsclick', blueSwordsText));' Line Number: 948
Code edit (6 edits merged)
Please save this source code
User prompt
нужно сократить количество кода не потеряв в функционале
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
сделай окно с текстом после нажаnия на кнопку new game "This is your forge, hit the anvil and develop skills, mine crystals in the cave, melt them into ingots and craft weapons. Sell it in the city." желтого цвета. это сообщение должно исчезнуть по колику и больше не показываться
User prompt
Please fix the bug: 'Timeout.tick error: anvil is not defined' in or related to this line: 'if (anvil) {' Line Number: 517
User prompt
Please fix the bug: 'Timeout.tick error: anvil is not defined' in or related to this line: 'if (anvil) {' Line Number: 517
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of null (reading 'x')' in or related to this line: 'anvilStar.x = anvil.x;' Line Number: 518
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { forgingSkill: 0, growthRate: 0, goldScore: 0, blueCristallScore: 0, greenCristallScore: 0, redCristallScore: 0, blueCrystalIngotScore: 0, greenCrystalIngotScore: 0, redCrystalIngotScore: 0, blueSwords: 0, greenAxes: 0, redCrystalTwoHandedSwords: 0, blueswordsclick: 0, greenAxeClicks: 0, redCrystalTwoHandedSwordClicks: 0, autominebluecristallClicked: false, autominegreencristallClicked: false, automineredcristallClicked: false, autogrowthRateClicked: false, multiclickupgrade: false, theBlacksmithsApprentice: false, lastgametime: 0 }); /**** * Classes ****/ var Anvil = Container.expand(function () { var self = Container.call(this); self.attachAsset('anvil', { anchorX: 0.5, anchorY: 0.5, alpha: 0.0, interactive: true }); self.clickCounter = storage.forgingSkill; self.down = function () { self.clickCounter++; if (Math.random() < (storage.multiclickupgrade ? 0.04 : 0.02)) { self.clickCounter += 5; var multi = game.addChild(LK.getAsset('multyclick', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 })); tween(multi, { scaleX: 2, scaleY: 2 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { return multi.destroy(); } }); } storage.forgingSkill = self.clickCounter; counterText.setText('Forging skill: ' + self.clickCounter); var tints = [[1000, 0x00FF00], [2000, 0x0000FF], [15000, 0x800080], [30000, 0xcc7c04]]; for (var _i = 0, _tints = tints; _i < _tints.length; _i++) { var _tints$_i = _slicedToArray(_tints[_i], 2), threshold = _tints$_i[0], color = _tints$_i[1]; if (self.clickCounter >= threshold) { counterText.tint = color; } } }; }); var CraftableItem = Container.expand(function (recipeAsset, skillReq, ingotReq, clicksReq, ingotKey, itemKey, clicksKey, stockText) { var self = Container.call(this); self.attachAsset(recipeAsset, { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { if (storage.forgingSkill >= skillReq && storage[ingotKey] >= ingotReq) { storage[clicksKey] = (storage[clicksKey] || 0) + 100; if (storage[clicksKey] >= clicksReq) { storage[clicksKey] = 0; storage[itemKey] += 1; storage[ingotKey] -= ingotReq; stockText.setText(storage[itemKey].toString()); } } }; }); var Crystal = Container.expand(function (color, scoreKey, scoreText) { var self = Container.call(this); self.attachAsset(color + 'Cristal', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { storage[scoreKey] = (storage[scoreKey] || 0) + 1; scoreText.setText("".concat(color, " Cristall: ").concat(storage[scoreKey])); }; }); var CrystalIngot = Container.expand(function (color, crystalKey, ingotKey, growthReq, growthInc, crystalCost, scoreText) { var self = Container.call(this); self.attachAsset(color + 'CrystalIngot', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { if (storage.growthRate >= growthReq && storage[crystalKey] >= crystalCost) { storage[ingotKey] = (storage[ingotKey] || 0) + 1; storage[crystalKey] -= crystalCost; storage.growthRate += growthInc; growthRateText.setText('Growth rate: ' + storage.growthRate); scoreText.setText("".concat(color, "CrystalIngot: ").concat(storage[ingotKey])); } }; }); /**** * Initialize Game ****/ /**** * Game Setup ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var blueSwordsText = new Text2('Blue Swords: ' + (storage.blueSwords || 0), { size: 50, fill: 0xFFFFFF }); LK.gui.topRight.addChild(blueSwordsText, { x: 0, y: 150 }); function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) { return _arrayLikeToArray(r, a); } var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) { return; } f = !1; } else { for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) { return; } } finally { if (o) { throw n; } } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) { return r; } } var assets = [{ type: 'shape', name: 'Gold', width: 100, height: 100, color: 0xba3e24, shape: 'box' }, { type: 'shape', name: 'anvil', width: 480, height: 300, color: 0x90b8f4, shape: 'box' }, { type: 'shape', name: 'anvilstar', width: 100, height: 100, color: 0x9eec73, shape: 'box' }, { type: 'image', name: 'Door', width: 300, height: 300, id: '6794cd7686e5290db4ef0f61' }, { type: 'image', name: 'Map', width: 300, height: 300, id: '67960d5478a5ca831e38e79f' }, { type: 'image', name: 'Theblacksmithsapprentice', width: 250, height: 250, id: '67b872b7f35062e15c95627b' }, { type: 'image', name: 'anvilmap', width: 100, height: 100, id: '6796204778a5ca831e38e7db' }, { type: 'image', name: 'autogrowthRate', width: 360, height: 300, id: '67b4c3c752a1da49713d524a' }, { type: 'image', name: 'autominebluecristall', width: 250, height: 250, id: '67b4bd8952a1da49713d51e5' }, { type: 'image', name: 'autominegreencristall', width: 250, height: 250, id: '67b4be1152a1da49713d51fa' }, { type: 'image', name: 'automineredcristall', width: 250, height: 250, id: '67b4ba73345af481077a5a3a' }, { type: 'image', name: 'axeOfGreenCrystalsRecipe', width: 300, height: 500, id: '67991a67090093ccb7744bb4' }, { type: 'image', name: 'background', width: 2000, height: 2000, id: '67b07ea12e29576e5caf3b79' }, { type: 'image', name: 'blueCristal', width: 300, height: 300, id: '67b89f3ddacac0208c8f6e0e' }, { type: 'image', name: 'blueCrystalIngot', width: 100, height: 80, id: '67966dd1690fa8a090669322' }, { type: 'image', name: 'bluecrystalswordrecipe', width: 400, height: 400, id: '67991043090093ccb7744b1a', flipX: 1, flipY: 1, orientation: 3 }, { type: 'image', name: 'blueingotrecipe', width: 200, height: 150, id: '67bf46c527fc48d849e4e932' }, { type: 'image', name: 'citybackground', width: 2000, height: 2000, id: '67a0d50d52a2e35ca0eb5c70' }, { type: 'image', name: 'citymap', width: 150, height: 150, id: '679f607e55b87b3a41d5d55a' }, { type: 'image', name: 'continueText', width: 300, height: 370, id: '67b060fe2e29576e5caf3af2' }, { type: 'image', name: 'gameScreenBackground', width: 2000, height: 1900, id: '67b8ba062d0daaf579fc58d0' }, { type: 'image', name: 'greenCristal', width: 300, height: 300, id: '67b8a0c4dacac0208c8f6e47' }, { type: 'image', name: 'greenCrystalIngot', width: 110, height: 90, id: '67967631690fa8a090669346' }, { type: 'image', name: 'greeningotrecipe', width: 200, height: 190.48, id: '67967631690fa8a090669346' }, { type: 'image', name: 'growthRate', width: 300, height: 300, id: '67b8aa3cdacac0208c8f6ea0' }, { type: 'image', name: 'hammer', width: 150, height: 150, id: '6794cebe86e5290db4ef0f74' }, { type: 'image', name: 'magicNurseryBackground', width: 1000, height: 1000, id: '67965c40690fa8a090669227' }, { type: 'image', name: 'mapbackground', width: 1900, height: 1900, id: '67960c7078a5ca831e38e78c' }, { type: 'image', name: 'mine', width: 80, height: 100, id: '6796224378a5ca831e38e807' }, { type: 'image', name: 'mineinsidebackground', width: 1850, height: 1850, id: '679625c578a5ca831e38e821' }, { type: 'image', name: 'multiclickupgrade', width: 280, height: 280, id: '67b4d29752a1da49713d526e' }, { type: 'image', name: 'multyclick', width: 200, height: 200, id: '67a38faeec1e8c186c4e68aa' }, { type: 'image', name: 'newGameText', width: 300, height: 400, id: '67b0610c2e29576e5caf3af6' }, { type: 'image', name: 'newTools', width: 200, height: 200, id: '67a4ed1a15483cfd543c1702' }, { type: 'image', name: 'newToolsBackground', width: 2000, height: 2000, id: '679905e1090093ccb7744b04' }, { type: 'image', name: 'newToolsout', width: 300, height: 300, id: '6797a530690fa8a090669c76' }, { type: 'image', name: 'recipes', width: 350, height: 350, id: '6797a530690fa8a090669c76' }, { type: 'image', name: 'recipesbackground', width: 2000, height: 2000, id: '679905e1090093ccb7744b04' }, { type: 'image', name: 'recipesnext', width: 350, height: 350, id: '679b9f5d0f1a2ec74003f873' }, { type: 'image', name: 'recipesnextbackgr1', width: 2000, height: 2000, id: '679905e1090093ccb7744b04' }, { type: 'image', name: 'recipesout', width: 350, height: 350, id: '6797a530690fa8a090669c76' }, { type: 'image', name: 'recipesprev', width: 350, height: 350, id: '679b9f5d0f1a2ec74003f873', flipX: 1 }, { type: 'image', name: 'redCristal', width: 500, height: 600, id: '67b8a15bdacac0208c8f6e55' }, { type: 'image', name: 'redCristalIngot', width: 110, height: 90, id: '67967c31690fa8a0906693e7' }, { type: 'image', name: 'redcrystaltwo-handedswordrecipe', width: 400, height: 400, id: '67adcc78e366fb4797fc38c0' }, { type: 'image', name: 'redingotrecipe', width: 250, height: 180, id: '67bf4c3827fc48d849e4e955' }, { type: 'image', name: 'sellweapons', width: 300, height: 300, id: '67b35cb8a9534c1274453a27' }, { type: 'image', name: 'shop', width: 400, height: 400, id: '67be174fc61ffecc5503a69d' }, { type: 'image', name: 'shopbackground', width: 2000, height: 2000, id: '67a0f8b752a2e35ca0eb5fdf' }, { type: 'image', name: 'shopout', width: 300, height: 300, id: '6794cd7686e5290db4ef0f61' }, { type: 'image', name: 'star', width: 50, height: 50, id: '6794fd2986e5290db4ef104a' }, { type: 'image', name: 'title', width: 900, height: 400, id: '67b8af589837459f356f3e4b' }, { type: 'sound', name: 'booksaudio', volume: 1, start: 0, end: 1, id: '67b8a6c6dacac0208c8f6e80' }, { type: 'sound', name: 'doors', volume: 1, start: 0, end: 1, id: '67b8a3d2dacac0208c8f6e73' }, { type: 'sound', name: 'hammer', volume: 1, start: 0, end: 0.862, id: '6794fd6d86e5290db4ef1050' }, { type: 'sound', name: 'mapaudio', volume: 1, start: 0, end: 1, id: '67b8a489dacac0208c8f6e79' }, { type: 'sound', name: 'paper', volume: 1, start: 0, end: 1, id: '67b8a489dacac0208c8f6e79' }, { type: 'sound', name: 'shopin', volume: 1, start: 0, end: 0.776, id: '67b8a891dacac0208c8f6e8a' }]; assets.forEach(function (asset) { if (asset.type === 'image') {} else if (asset.type === 'shape') {} else if (asset.type === 'sound') {} }); var screens = { main: new Container(), gameScreen: new Container(), mapScreen: new Container(), shopScreen: new Container(), recipesScreen: new Container(), mineScreen: new Container(), magicNursery: new Container() }; var hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); function updateHammer(x, y) { hammer.x = x; hammer.y = y; } game.move = function (x, y) { return updateHammer(x, y); }; game.down = function (x, y) { LK.getSound('hammer').play(); tween(hammer, { rotation: -Math.PI / 2 }, { duration: 125, easing: tween.easeInOut, onFinish: function onFinish() { 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; star.update = function () { star.y -= 5; star.x += star.x < hammer.x ? 2 : -2; }; LK.setTimeout(function () { return star.destroy(); }, 250); } tween(hammer, { rotation: 0 }, { duration: 125, easing: tween.easeInOut }); } }); }; // UI Elements var counterText = new Text2('Forging skill: ' + storage.forgingSkill, { size: 50, fill: 0xFFFFFF }); LK.gui.topLeft.addChild(counterText, { x: 0, y: 0 }); var growthRateText = new Text2('Growth rate: ' + storage.growthRate, { size: 50, fill: 0xFFFFFF }); LK.gui.topLeft.addChild(growthRateText, { x: 0, y: counterText.height - 6 }); var goldScoreTxt = new Text2('Gold: ' + (storage.goldScore || 0), { size: 50, fill: 0xFFFFFF }); LK.gui.topLeft.addChild(goldScoreTxt, { x: counterText.width + 10, y: 0 }); var scoreTxt = new Text2('Blue Cristall: ' + (storage.blueCristallScore || 0), { size: 50, fill: 0xFFFFFF }); LK.gui.topLeft.addChild(scoreTxt, { x: 0, y: 100 }); var greenScoreTxt = new Text2('Green Cristall: ' + (storage.greenCristallScore || 0), { size: 50, fill: 0xFFFFFF }); LK.gui.topLeft.addChild(greenScoreTxt, { x: 0, y: 150 }); var redScoreTxt = new Text2('Red Cristall: ' + (storage.redCristallScore || 0), { size: 50, fill: 0xFFFFFF }); LK.gui.topLeft.addChild(redScoreTxt, { x: 0, y: 200 }); var blueCrystalIngotScoreTxt = new Text2('BlueCrystalIngot: ' + (storage.blueCrystalIngotScore || 0), { size: 50, fill: 0xFFFFFF }); LK.gui.topRight.addChild(blueCrystalIngotScoreTxt, { x: 0, y: 0 }); var greenCrystalIngotScoreTxt = new Text2('GreenCrystalIngot: ' + (storage.greenCrystalIngotScore || 0), { size: 50, fill: 0xFFFFFF }); LK.gui.topRight.addChild(greenCrystalIngotScoreTxt, { x: 0, y: 50 }); var redCrystalIngotScoreTxt = new Text2('RedCrystalIngot: ' + (storage.redCrystalIngotScore || 0), { size: 50, fill: 0xFFFFFF }); LK.gui.topRight.addChild(redCrystalIngotScoreTxt, { x: 0, y: 100 }); // Screen Management function switchScreen(activeScreen) { Object.values(screens).forEach(function (screen) { return screen.visible = false; }); screens[activeScreen].visible = true; } // Main Screen screens.main.attachAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); var title = screens.main.addChild(LK.getAsset('title', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 3200 / 5 })); var newGame = screens.main.addChild(new Container()); newGame.attachAsset('newGameText', { anchorX: 0.5, anchorY: 0.5, stroke: 0xFFFFFF, strokeThickness: 5 }); newGame.x = 2650 / 2 + 100; newGame.y = 2680 * 4.2 / 5; newGame.interactive = true; var continueText = screens.main.addChild(LK.getAsset('continueText', { anchorX: 0.5, anchorY: 0.5, x: newGame.x - newGame.width - 500, y: newGame.y, interactive: true })); continueText.down = function () { return startGame(); }; // Game Screen screens.gameScreen.x = 2048 / 2; screens.gameScreen.y = 2732 / 2; screens.gameScreen.attachAsset('gameScreenBackground', { anchorX: 0.5, anchorY: 0.5 }); var anvil = screens.gameScreen.addChild(new Anvil()); anvil.x = 20; anvil.y = 500; var door = screens.gameScreen.addChild(new Container()); door.attachAsset('Door', { anchorX: 0.5, anchorY: 0.5, interactive: true }); door.x = 2048 / 4; door.y = 2732 / 2.5; door.down = function () { LK.getSound('doors').play(); switchScreen('magicNursery'); }; // Magic Nursery Screen screens.magicNursery.x = 2048 / 2; screens.magicNursery.y = 2732 / 2; screens.magicNursery.attachAsset('magicNurseryBackground', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); var blueIngot = screens.magicNursery.addChild(new CrystalIngot('blue', 'blueCristallScore', 'blueCrystalIngotScore', 0, 10, 10, blueCrystalIngotScoreTxt)); blueIngot.x = 200 + blueIngot.width / 2; blueIngot.y = 2500 - blueIngot.height / 2; var greenIngot = screens.magicNursery.addChild(new CrystalIngot('green', 'greenCristallScore', 'greenCrystalIngotScore', 3000, 10, 10, greenCrystalIngotScoreTxt)); greenIngot.x = blueIngot.x + blueIngot.width + greenIngot.width / 2 + 40; greenIngot.y = blueIngot.y; var redIngot = screens.magicNursery.addChild(new CrystalIngot('red', 'redCristallScore', 'redCrystalIngotScore', 9000, 20, 10, redCrystalIngotScoreTxt)); redIngot.x = 1300 / 2; redIngot.y = 4930 / 2; var door2 = screens.magicNursery.addChild(new Container()); door2.attachAsset('Door', { anchorX: 0.5, anchorY: 0.5, interactive: true }); door2.x = 2048 * 0.75; door2.y = 2732 * 0.9; door2.down = function () { LK.getSound('doors').play(); switchScreen('gameScreen'); }; // Map Screen var map = screens.gameScreen.addChild(LK.getAsset('Map', { anchorX: 0.5, anchorY: 0.5, x: 400, y: 2450, interactive: true })); map.down = function () { LK.getSound('mapaudio').play(); switchScreen('mapScreen'); }; screens.mapScreen.x = 2048 / 2; screens.mapScreen.y = 2732 / 2; screens.mapScreen.attachAsset('mapbackground', { anchorX: 0.5, anchorY: 0.5 }); var cityMap = screens.mapScreen.attachAsset('citymap', { anchorX: 0.5, anchorY: 0.5, x: -250, y: 160, interactive: true }); cityMap.down = function () { return switchScreen('shopScreen'); }; var anvilMap = screens.mapScreen.attachAsset('anvilmap', { anchorX: 0.5, anchorY: 0.5, interactive: true }); anvilMap.down = function () { return switchScreen('gameScreen'); }; var mine = screens.mapScreen.attachAsset('mine', { anchorX: 0.5, anchorY: 0.5, x: -150, y: -150, interactive: true }); mine.down = function () { return switchScreen('mineScreen'); }; // Mine Screen screens.mineScreen.x = 2048 / 2; screens.mineScreen.y = 2732 / 2; screens.mineScreen.attachAsset('mineinsidebackground', { anchorX: 0.5, anchorY: 0.5 }); var blueCrystal = screens.mineScreen.addChild(new Crystal('blue', 'blueCristallScore', scoreTxt)); blueCrystal.x = -410; blueCrystal.y = -310; var greenCrystal = screens.mineScreen.addChild(new Crystal('green', 'greenCristallScore', greenScoreTxt)); greenCrystal.x = 510; greenCrystal.y = 10; var redCrystal = screens.mineScreen.addChild(new Crystal('red', 'redCristallScore', redScoreTxt)); redCrystal.x = -510; redCrystal.y = 490; // Shop Screen screens.shopScreen.x = 2048 / 2; screens.shopScreen.y = 2732 / 2; screens.shopScreen.attachAsset('shopbackground', { anchorX: 0.5, anchorY: 0.5 }); var newTools = screens.shopScreen.attachAsset('newTools', { anchorX: 0.5, anchorY: 0.5, x: -650, y: 1100, interactive: true }); newTools.down = function () { LK.getSound('shopin').play(); switchScreen('shopTools'); }; var sellWeapons = screens.shopScreen.attachAsset('sellweapons', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 1100, interactive: true }); sellWeapons.down = function () { storage.goldScore += storage.blueSwords * 50 + storage.greenAxes * 150 + storage.redCrystalTwoHandedSwords * 600; storage.blueSwords = storage.greenAxes = storage.redCrystalTwoHandedSwords = 0; goldScoreTxt.setText('Gold: ' + storage.goldScore); }; var shopOut = screens.shopScreen.attachAsset('shopout', { anchorX: 0.5, anchorY: 0.5, x: 650, y: 1100, interactive: true }); shopOut.down = function () { LK.getSound('doors').play(); switchScreen('mapScreen'); }; // Shop Tools Screen var shopToolsScreen = new Container(); shopToolsScreen.x = 2048 / 2; shopToolsScreen.y = 2732 / 2; shopToolsScreen.attachAsset('newToolsBackground', { anchorX: 0.5, anchorY: 0.5 }); var toolsOut = shopToolsScreen.attachAsset('newToolsout', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 1100, interactive: true }); toolsOut.down = function () { LK.getSound('booksaudio').play(); switchScreen('shopScreen'); }; screens.shopTools = shopToolsScreen; game.addChild(shopToolsScreen); // Recipes Screen var recipes = screens.gameScreen.attachAsset('recipes', { anchorX: 0.5, anchorY: 0.5, x: -1050, y: 150, interactive: true }); recipes.down = function () { LK.getSound('booksaudio').play(); switchScreen('recipesScreen'); }; screens.recipesScreen.x = 2048 / 2; screens.recipesScreen.y = 2732 / 2; screens.recipesScreen.attachAsset('recipesbackground', { anchorX: 0.5, anchorY: 0.5 }); var blueSword = screens.recipesScreen.addChild(new CraftableItem('bluecrystalswordrecipe', 2000, 10, 1000, 'blueCrystalIngotScore', 'blueSwords', 'blueswordsclick', blueSwordsText)); blueSword.x = 1248 / 2; blueSword.y = 2132 / 2; var greenAxe = screens.recipesScreen.addChild(new CraftableItem('axeOfGreenCrystalsRecipe', 10000, 25, 3000, 'greenCrystalIngotScore', 'greenAxes', 'greenAxeClicks', greenAxesText)); greenAxe.x = 2848 / 2; greenAxe.y = 2132 / 2; var recipesOut = screens.recipesScreen.attachAsset('recipesout', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 1100, interactive: true }); recipesOut.down = function () { LK.getSound('paper').play(); switchScreen('gameScreen'); }; // Game Start function startGame() { switchScreen('gameScreen'); } // Initialize switchScreen('main'); var intervals = {}; function startMiner(key, scoreKey, scoreText) { if (storage[key + 'Clicked'] && !intervals[key]) { intervals[key] = LK.setInterval(function () { storage[scoreKey] += 1; scoreText.setText("".concat(key.replace('automine', '').replace('cristall', ' Cristall'), ": ").concat(storage[scoreKey])); }, 1000); } } startMiner('automineblue', 'blueCristallScore', scoreTxt); startMiner('autominegreen', 'greenCristallScore', greenScoreTxt); startMiner('autominered', 'redCristallScore', redScoreTxt); if (storage.autogrowthRateClicked) { intervals['growth'] = LK.setInterval(function () { return storage.growthRate += 1; }, 1000); } if (storage.theBlacksmithsApprentice) { intervals['apprentice'] = LK.setInterval(function () { return storage.forgingSkill += 1; }, 1000); } LK.setInterval(function () { return storage.lastgametime = Math.floor(Date.now() / 1000); }, 1000);
===================================================================
--- original.js
+++ change.js
@@ -134,8 +134,16 @@
/****
* Game Code
****/
+var blueSwordsText = new Text2('Blue Swords: ' + (storage.blueSwords || 0), {
+ size: 50,
+ fill: 0xFFFFFF
+});
+LK.gui.topRight.addChild(blueSwordsText, {
+ x: 0,
+ y: 150
+});
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _nonIterableRest() {