Code edit (1 edits merged)
Please save this source code
User prompt
remove la caracteristica de camiar de background
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'foregroundContainer.addChild(loadingBar);' Line Number: 1585
User prompt
Please fix the bug: 'ReferenceError: loadingBar is not defined' in or related to this line: 'loadingBar.scaleX = Math.min(money / 20000000, 1); // Scale from 0 to 1' Line Number: 2091
Code edit (2 edits merged)
Please save this source code
User prompt
Add rotation effect for player around world ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Hazlo en bucle
User prompt
Agrégale a player un efecto de rotación sobre world con un plugin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (10 edits merged)
Please save this source code
User prompt
crea un boton que lleve a la pagina pet
User prompt
crea un boton en pagina inicial para llevar a la tienda pet
User prompt
Aplica a king la función handleItemInteraction
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: loadingBar is not defined' in or related to this line: 'loadingBar.scaleX = Math.min(money / 20000000, 1); // Scale from 0 to 1' Line Number: 2028
User prompt
elimina barra de carga
User prompt
remplaza todos los backgroud child por backgroundone
User prompt
Please fix the bug: 'backgroundContainer is not defined' in or related to this line: 'backgroundContainer.addChild(Rock);' Line Number: 1853
User prompt
remplaza todos los foregroud child por foregroundone
User prompt
Please fix the bug: 'foregroundContainer is not defined' in or related to this line: 'foregroundContainer.addChild(loadingBar);' Line Number: 1840
User prompt
Please fix the bug: 'foregroundContainer is not defined' in or related to this line: 'foregroundContainer.addChild(loadingBar);' Line Number: 1835
User prompt
Please fix the bug: 'GuiforegroundContainer is not defined' in or related to this line: 'var guiforegroundContainer = new GuiforegroundContainer();' Line Number: 1805
User prompt
Please fix the bug: 'GuimidgroundContainer is not defined' in or related to this line: 'var guimidgroundContainer = new GuimidgroundContainer();' Line Number: 1799
User prompt
Please fix the bug: 'GuibackgroundContainer is not defined' in or related to this line: 'var guibackgroundContainer = new GuibackgroundContainer();' Line Number: 1793
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1", { meters: 0, money: 0, spin: 0, timePlayed: 0, doggy: 0, currentRockIndex: 0, monkey: 0, villager: 0, BestTime: 0, complete: 0 }); var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Create a BackgroundOneContainer class var BackgroundOneContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create a BackgroundTwoContainer class var BackgroundTwoContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create a Coin class var Coin = Container.expand(function () { var self = Container.call(this); // Attach the coin asset var coinSpriteId = 'coin'; // Default to bronze coin if (CoinUpgrade === 2) { coinSpriteId = 'coin1'; // Silver coin } else if (CoinUpgrade === 3) { coinSpriteId = 'coin2'; // Golden coin } else if (CoinUpgrade === 4) { coinSpriteId = 'coin3'; // Diamond coin } var coinGraphics = self.attachAsset(coinSpriteId, { anchorX: 0.5, anchorY: 0.5 }); // Set initial position and speed self.x = 2048 + coinGraphics.width / 2; // Start off-screen to the right self.y = player.y - 400; // Position above the player self.speed = -12; // Further increase speed to move left faster // Add spinning effect to the coin in the opposite direction tween(coinGraphics, { rotation: -Math.PI * 2 }, { duration: 800, easing: tween.linear, onFinish: function onFinish() { coinGraphics.rotation = 0; // Reset rotation after a full spin tween(coinGraphics, { rotation: -Math.PI * 2 }, { duration: 800, easing: tween.linear, onFinish: arguments.callee }); } }); // Update method to move the coin self.update = function () { self.x += self.speed; // Check if the coin is off-screen or collected by the player if (self.x < -coinGraphics.width / 2) { self.destroy(); } else if (self.intersects(player)) { if (CoinUpgrade === 4) { money += moneyPerSecond * 10; // Diamond coin value } else if (CoinUpgrade === 3 && Math.random() < 0.1) { money += moneyPerSecond * 5; // Golden coin value } else if (CoinUpgrade === 2 && Math.random() < 0.3) { money += moneyPerSecond * 2.5; // Silver coin value } else { money += moneyPerSecond * 0.5; // Regular coin value } LK.getSound('clutchedCoin').play(); // Play sound when coin is collected self.destroy(); } }; return self; }); // Create a CosmeticPage class var CosmeticPage = Container.expand(function () { var self = Container.call(this); // Add a background for the cosmetic page var cosmeticBackground = self.attachAsset('menuCosmetic', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add a title text for the cosmetic page var titleText = new Text2('Cosmetic Page', { size: 200, fill: 0xFFFFFF, font: "Medieval" }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 200; self.addChild(titleText); // Add a button to return to the main menu var backButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 - 200 }); self.addChild(backButton); var backText = new Text2('Back', { size: 150, fill: 0x000000, font: "Medieval" }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; self.addChild(backText); // Add interaction to the back button backButton.down = function () { backButton.isPressed = true; backButton.scaleX *= 0.9; backButton.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; backButton.up = function () { if (backButton.isPressed) { backButton.scaleX /= 0.9; backButton.scaleY /= 0.9; backButton.isPressed = false; // Logic to return to the main menu game.showMainMenu(); } }; // Add a cosmetic changer for rocks var rockIndex = 0; // Start with the first rock var Rock = ['Rock0', 'Rock1', 'Rock2', 'Rock3', 'Rock4', 'Rock5', 'Rock6', 'Rock7', 'Rock8', 'Rock9', 'Rock10', 'Rock11', 'Rock12', 'Rock13', 'Rock14', 'Rock15', 'Rock16', 'Rock17', 'Rock18', 'Rock19', 'Rock20', 'Rock21', 'Rock22', 'Rock23']; var cosmeticDisplay = self.attachAsset('Rock' + rockIndex, { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 600 //{X} // Moved 100 pixels lower to avoid collision with bottom }); self.addChild(cosmeticDisplay); // Add left arrow button to change the rock cosmetic var leftArrowButton = LK.getAsset('arrowleft', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 - 450, y: 2732 / 2 - 300 }); self.addChild(leftArrowButton); leftArrowButton.down = function () { leftArrowButton.isPressed = true; leftArrowButton.scaleX *= 0.9; leftArrowButton.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; leftArrowButton.up = function () { if (leftArrowButton.isPressed) { leftArrowButton.scaleX /= 0.9; leftArrowButton.scaleY /= 0.9; leftArrowButton.isPressed = false; // Change the rock cosmetic to the previous one rockIndex = (rockIndex - 1 + Rock.length) % Rock.length; // Dynamically accommodate rock assets self.removeChild(cosmeticDisplay); cosmeticDisplay = self.attachAsset('Rock' + rockIndex, { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 600 }); self.addChild(cosmeticDisplay); } }; // Add a 'Select' button between the left and right arrow buttons var selectButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 300 }); self.addChild(selectButton); var selectText = new Text2('Select', { size: 150, fill: 0x000000, font: "Medieval" }); selectText.anchor.set(0.5, 0.5); selectText.x = selectButton.x; selectText.y = selectButton.y; self.addChild(selectText); // Add interaction to the select button selectButton.down = function () { selectButton.isPressed = true; selectButton.scaleX *= 0.9; selectButton.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; selectButton.up = function () { if (selectButton.isPressed) { selectButton.scaleX /= 0.9; selectButton.scaleY /= 0.9; selectButton.isPressed = false; // Change the rock to the selected cosmetic // Ensure cosmeticDisplay is not removed when 'Select' is pressed player.removeChild(player.playerGraphics); player.playerGraphics = player.attachAsset('Rock' + rockIndex, { anchorX: 0.5, anchorY: 0.5 }); player.addChild(player.playerGraphics); storage.currentRockIndex = rockIndex; // Save the selected player skin index } }; // Add right arrow button to change the rock cosmetic var rightArrowButton = LK.getAsset('arrowright', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + 450, y: 2732 / 2 - 300 }); self.addChild(rightArrowButton); rightArrowButton.down = function () { rightArrowButton.isPressed = true; rightArrowButton.scaleX *= 0.9; rightArrowButton.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; rightArrowButton.up = function () { if (rightArrowButton.isPressed) { rightArrowButton.scaleX /= 0.9; rightArrowButton.scaleY /= 0.9; rightArrowButton.isPressed = false; // Change the rock cosmetic to the next one rockIndex = (rockIndex + 1) % Rock.length; // Dynamically accommodate rock assets self.removeChild(cosmeticDisplay); cosmeticDisplay = self.attachAsset('Rock' + rockIndex, { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 600 }); self.addChild(cosmeticDisplay); } }; return self; }); // Create a CreditsPage class var CreditsPage = Container.expand(function () { var self = Container.call(this); // Add the Slimy asset to the credits page var slimyAsset = self.attachAsset('Slimy', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add interaction to the Slimy asset slimyAsset.down = function () { // Logic to return to the extras page game.showExtrasPage(); }; return self; }); // Create an ExtrasPage class var ExtrasPage = Container.expand(function () { var self = Container.call(this); // Add a background for the extras page var extrasBackground = self.attachAsset('menuExtras', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add a title text for the extras page var titleText = new Text2('Extras Page', { size: 200, fill: 0xFFFFFF, font: "Medieval" }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 200; self.addChild(titleText); // Add a button to return to the main menu var backButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 - 200 }); self.addChild(backButton); var backText = new Text2('Back', { size: 150, fill: 0x000000, font: "Medieval" }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; self.addChild(backText); // Add interaction to the back button backButton.down = function () { backButton.isPressed = true; backButton.scaleX *= 1.1; backButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; backButton.up = function () { if (backButton.isPressed) { backButton.scaleX /= 1.1; backButton.scaleY /= 1.1; backButton.isPressed = false; // Logic to return to the main menu game.showMainMenu(); } }; // Add a reset progress button var resetButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 200 }); self.addChild(resetButton); var resetText = new Text2('Reset Progress', { size: 100, fill: 0xFF0000, font: "Medieval" }); resetText.anchor.set(0.5, 0.5); resetText.x = resetButton.x; resetText.y = resetButton.y; self.addChild(resetText); // Add interaction to the reset button resetButton.down = function () { resetButton.isPressed = true; resetButton.scaleX *= 1.1; resetButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; resetButton.up = function () { if (resetButton.isPressed) { resetButton.scaleX /= 1.1; resetButton.scaleY /= 1.1; resetButton.isPressed = false; // Custom confirmation dialog var confirmResetBackground = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 1.5, scaleY: 1.5 }); self.addChild(confirmResetBackground); var confirmReset = new Text2('Are you sure you want to\nreset your progress?', { size: 70, //{3n} // Reduced size to fit better fill: 0xFFFFFF, font: "Medieval" }); confirmReset.anchor.set(0.5, 0.5); confirmReset.x = 2048 / 2; confirmReset.y = 2732 / 2 - 100; // Adjusted position to avoid collision self.addChild(confirmReset); var yesButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 - 200, y: 2732 / 2 + 150, scaleX: 0.6, // Further decrease size scaleY: 0.6 // Further decrease size }); self.addChild(yesButton); var noButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + 200, y: 2732 / 2 + 150, scaleX: 0.6, // Further decrease size scaleY: 0.6 // Further decrease size }); self.addChild(noButton); var yesText = new Text2('Yes', { size: 100, fill: 0x000000, font: "Medieval" }); yesText.anchor.set(0.5, 0.5); yesText.x = yesButton.x; yesText.y = yesButton.y; self.addChild(yesText); var noText = new Text2('No', { size: 100, fill: 0x000000, font: "Medieval" }); noText.anchor.set(0.5, 0.5); noText.x = noButton.x; noText.y = noButton.y; self.addChild(noText); yesButton.down = function () { yesButton.isPressed = true; yesButton.scaleX *= 1.1; yesButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; yesButton.up = function () { if (yesButton.isPressed) { yesButton.scaleX /= 1.1; yesButton.scaleY /= 1.1; yesButton.isPressed = false; // Logic to reset progress storage.meters = 0; storage.money = 0; meters = 0; money = 0; moneyPerSecond = 0; // Stop money increment during reset currentRockIndex = 0; timeGame = 0; // Reset time played storage.timePlayed = 0; // Reset time played in storage // Reset all pet counts and storage littleMouse = 0; storage.littleMouse = 0; monkey = 0; storage.monkey = 0; doggy = 0; storage.doggy = 0; peasant = 0; storage.peasant = 0; warrior = 0; storage.warrior = 0; bourgeois = 0; storage.bourgeois = 0; king = 0; storage.king = 0; CoinUpgrade = 0; // Reset CoinUpgrade storage.CoinUpgrade = 0; // Reset CoinUpgrade in storage villager = 0; storage.villager = 0; console.log("Progress reset"); background.removeChild(background.playerGraphics); background.playerGraphics = background.attachAsset('Background0', { anchorX: 0.5, anchorY: 0.5 }); backgroundClone.removeChild(backgroundClone.playerGraphics); backgroundClone.playerGraphics = backgroundClone.attachAsset('Background0', { anchorX: 0.5, anchorY: 0.5 }); backgroundClone2.removeChild(backgroundClone2.playerGraphics); backgroundClone2.playerGraphics = backgroundClone2.attachAsset('Background0', { anchorX: 0.5, anchorY: 0.5 }); self.removeChild(confirmReset); self.removeChild(yesButton); self.removeChild(noButton); self.removeChild(yesText); self.removeChild(noText); self.removeChild(confirmResetBackground); // Wait 1 second and then end the game LK.setTimeout(function () { LK.showGameOver(); }, 1000); } }; noButton.down = function () { noButton.isPressed = true; noButton.scaleX *= 1.1; noButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; noButton.up = function () { if (noButton.isPressed) { noButton.scaleX /= 1.1; noButton.scaleY /= 1.1; noButton.isPressed = false; console.log("Reset canceled"); self.removeChild(confirmReset); self.removeChild(yesButton); self.removeChild(noButton); self.removeChild(yesText); self.removeChild(noText); self.removeChild(confirmResetBackground); } }; } }; // Add a credits button var creditsButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 550 }); self.addChild(creditsButton); var creditsText = new Text2('Credits', { size: 150, fill: 0x000000, font: "Medieval" }); creditsText.anchor.set(0.5, 0.5); creditsText.x = creditsButton.x; creditsText.y = creditsButton.y; self.addChild(creditsText); // Add interaction to the credits button creditsButton.down = function () { creditsButton.isPressed = true; creditsButton.scaleX *= 1.1; creditsButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; creditsButton.up = function () { if (creditsButton.isPressed) { creditsButton.scaleX /= 1.1; creditsButton.scaleY /= 1.1; creditsButton.isPressed = false; // Logic to show credits game.showCreditsPage(); } }; // Add a text display for the time played var timePlayedText = new Text2('Time Played: 0s', { size: 100, fill: 0xFFFFFF, font: "Medieval" }); timePlayedText.anchor.set(0.5, 0.5); timePlayedText.x = 2048 / 2; timePlayedText.y = 2732 / 2 - 200; self.addChild(timePlayedText); // Update the time played text every second LK.setInterval(function () { var hours = Math.floor(timeGame / 3600); var minutes = Math.floor(timeGame % 3600 / 60); var seconds = timeGame % 60; timePlayedText.setText('Time Played: ' + hours + 'h ' + minutes + 'm ' + seconds + 's'); }, 1000); // Add a text display for the best time var bestTimeText = new Text2('Best Time: ' + BestTime + 's', { size: 100, fill: 0xFFFFFF, font: "Medieval" }); bestTimeText.anchor.set(0.5, 0.5); bestTimeText.x = 2048 / 2; bestTimeText.y = 2732 / 2 - 100; self.addChild(bestTimeText); // Add a text display for the completion count var completionText = new Text2('Completion: ' + complete, { size: 100, fill: 0xFFFFFF, font: "Medieval" }); completionText.anchor.set(0.5, 0.5); completionText.x = 2048 / 2; completionText.y = 2732 / 2; self.addChild(completionText); return self; }); // Create a ForegroundOneContainer class var ForegroundOneContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create a ForegroundTwoContainer class var ForegroundTwoContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create an IntroductionPage class var IntroductionPage = Container.expand(function () { var self = Container.call(this); // Add a background for the introduction page var introductionBackground = self.attachAsset('Introduction', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add a title text for the introduction page var titleText = new Text2('Introduction Page', { size: 200, fill: 0xFFFFFF, font: "Medieval" }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 200; self.addChild(titleText); // Add a button to return to the main menu var backButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 - 200 }); self.addChild(backButton); var backText = new Text2('Back', { size: 150, fill: 0x000000, font: "Medieval" }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; self.addChild(backText); // Add interaction to the back button backButton.down = function () { backButton.isPressed = true; backButton.scaleX *= 1.1; backButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; backButton.up = function () { if (backButton.isPressed) { backButton.scaleX /= 1.1; backButton.scaleY /= 1.1; backButton.isPressed = false; // Logic to return to the main menu game.showMainMenu(); } }; return self; }); // Create a MidgroundContainer class var MidgroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create a Player class var Player = Container.expand(function () { var self = Container.call(this); // Create a list named 'rock' and add the 'Rock0' asset to it var player = ['Rock0', 'Rock1', 'Rock2', 'Rock3', 'Rock4', 'Rock5', 'Rock6', 'Rock7', 'Rock8', 'Rock9', 'Rock10', 'Rock11', 'Rock12', 'Rock13', 'Rock14']; self.playerGraphics = self.attachAsset(player[0], { anchorX: 0.5, anchorY: 0.5 }); // Set player speed self.speed = 5; // This is automatically called every game tick, if the player is attached! self.update = function () { self.y += self.speed; // Add gravity to the player if (self.y < 2732 / 2 - self.height / 2 + 50) { self.speed += 0.5; } else { self.speed = 0; self.y = 2732 / 2 - self.height / 2 + 50; // Ensure player lands correctly jump = 2; // Reset jump count when player lands } // Add rotation to the player self.rotation += 0.03; // Play or pause rockmovement sound based on rock's position if (self.y < 2732 / 2 - self.height / 2 + 50) { LK.getSound('rockmovement').stop(); // Stop sound when rock is in the air self.lastWasOnGround = false; // Track if the rock was on the ground } else { if (!self.lastWasOnGround) { LK.getSound('rockFall').play(); // Play rockfall sound when rock lands LK.setTimeout(function () { LK.getSound('rockmovement').play({ loop: true }); // Play sound when rock is on the ground after rockfall }, 100); // Delay rockmovement sound by 100ms after rockfall } else { LK.getSound('rockmovement').play({ loop: true }); // Ensure rockmovement sound loops continuously } self.lastWasOnGround = true; // Update the state to indicate rock is on the ground } }; }); // Create a RockPage class var RockPage = Container.expand(function () { var self = Container.call(this); // Add a background for the rock page var rockBackground = self.attachAsset('menuRock', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); return self; }); // Create a ShopPage class var ShopPage = Container.expand(function () { var self = Container.call(this); // Add a background for the shop page var shopBackground = self.attachAsset('menuShop', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add a title text for the shop page var titleText = new Text2('Shop Page', { size: 200, fill: 0xFFFFFF, font: "Medieval" }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 200; self.addChild(titleText); // Add a button to return to the main menu var backButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 - 200 }); self.addChild(backButton); var backText = new Text2('Back', { size: 150, fill: 0x000000, font: "Medieval" }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; self.addChild(backText); // Add interaction to the back button backButton.down = function () { backButton.isPressed = true; backButton.scaleX *= 1.1; backButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; backButton.up = function () { if (backButton.isPressed) { backButton.scaleX /= 1.1; backButton.scaleY /= 1.1; backButton.isPressed = false; // Logic to return to the main menu game.showMainMenu(); } }; // Add item asset display self.itemBackground = {}; // Add a buyable item 'Coin Upgrade' to the shop page self.coinUpgradeBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.coinUpgradeBackground); // Add 'Coin Upgrade' item title var coinUpgradeTitle = new Text2('', { size: 60, fill: 0xFFFFFF, font: "Medieval" }); coinUpgradeTitle.anchor.set(0.5, 0.5); coinUpgradeTitle.x = self.coinUpgradeBackground.x; coinUpgradeTitle.y = self.coinUpgradeBackground.y - 100; self.addChild(coinUpgradeTitle); var coinUpgradeDescription = new Text2('', { size: 50, fill: 0xFFFFFF, font: "Medieval" }); coinUpgradeDescription.anchor.set(0.5, 0.5); coinUpgradeDescription.x = self.coinUpgradeBackground.x; coinUpgradeDescription.y = self.coinUpgradeBackground.y; self.addChild(coinUpgradeDescription); // Set initial text based on CoinUpgrade level if (CoinUpgrade === 0) { coinUpgradeTitle.setText('Coin Upgrade'); coinUpgradeDescription.setText('Increases Coin Upgrade by 1.'); } else if (CoinUpgrade === 1) { coinUpgradeTitle.setText('Bronze Coin'); coinUpgradeDescription.setText('You have upgraded to a Bronze Coin.'); } else if (CoinUpgrade === 2) { coinUpgradeTitle.setText('Silver Coin'); coinUpgradeDescription.setText('You have upgraded to a Silver Coin.'); } else if (CoinUpgrade === 3) { coinUpgradeTitle.setText('Golden Coin'); coinUpgradeDescription.setText('You have upgraded to a Golden Coin.'); } else if (CoinUpgrade === 4) { coinUpgradeTitle.setText('Diamond'); coinUpgradeDescription.setText('You have upgraded to a Diamond.'); } var coinUpgradePrice = CoinUpgrade === 0 ? 25 : CoinUpgrade === 1 ? 2500 : CoinUpgrade === 2 ? 25000 : 250000; // Set prices for each Coin Upgrade level var coinUpgradePriceText = new Text2('Price: ' + coinUpgradePrice, { size: 70, fill: 0xFFD700, font: "Medieval" }); coinUpgradePriceText.anchor.set(0.5, 0.5); coinUpgradePriceText.x = self.coinUpgradeBackground.x; coinUpgradePriceText.y = self.coinUpgradeBackground.y + 100; self.addChild(coinUpgradePriceText); // Add interaction to the 'Coin Upgrade' item background self.coinUpgradeBackground.down = function () { self.coinUpgradeBackground.isPressed = true; self.coinUpgradeBackground.scaleX *= 0.9; self.coinUpgradeBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.coinUpgradeBackground.up = function () { if (self.coinUpgradeBackground.isPressed) { self.coinUpgradeBackground.scaleX /= 0.9; self.coinUpgradeBackground.scaleY /= 0.9; self.coinUpgradeBackground.isPressed = false; // Check if the Coin Upgrade can be purchased if (money >= coinUpgradePrice) { money -= coinUpgradePrice; if (CoinUpgrade < 4) { CoinUpgrade += 1; // Increase CoinUpgrade by 1 coinUpgradeQuantityText.setText('Quantity: ' + CoinUpgrade); // Update the quantity display if (CoinUpgrade === 1) { coinUpgradeTitle.setText('Bronze Coin'); coinUpgradeDescription.setText('You have upgraded to a Bronze Coin.'); coinUpgradePrice = 2500; // Set price for Silver Coin } else if (CoinUpgrade === 2) { coinUpgradeTitle.setText('Silver Coin'); coinUpgradeDescription.setText('You have upgraded to a Silver Coin.'); coinUpgradePrice = 25000; // Set price for Golden Coin } else if (CoinUpgrade === 3) { coinUpgradeTitle.setText('Golden Coin'); coinUpgradeDescription.setText('You have upgraded to a Golden Coin.'); coinUpgradePrice = 250000; // Set price for Diamond } else if (CoinUpgrade === 4) { coinUpgradeTitle.setText('Diamond'); coinUpgradeDescription.setText('You have upgraded to a Diamond.'); } coinUpgradePriceText.setText('Purchased'); coinUpgradePriceText.fill = 0x00FF00; // Set text color to green LK.setTimeout(function () { if (CoinUpgrade < 4) { coinUpgradePriceText.setText('Price: ' + coinUpgradePrice); coinUpgradePriceText.fill = 0xFFD700; // Revert text color to gold } else { coinUpgradePriceText.setText('Max Upgrades Reached'); coinUpgradePriceText.fill = 0xFF0000; // Set text color to red } }, 2000); // Display 'Purchased' for 2 seconds } else { coinUpgradePriceText.setText('Max Upgrades Reached'); coinUpgradePriceText.fill = 0xFF0000; // Set text color to red } } else { coinUpgradePriceText.setText('Insufficient Money'); coinUpgradePriceText.fill = 0xFF0000; // Set text color to red LK.setTimeout(function () { coinUpgradePriceText.setText('Price: ' + coinUpgradePrice); coinUpgradePriceText.fill = 0xFFD700; // Revert text color to gold }, 2000); // Display for 2 seconds } if (CoinUpgrade >= 4) { coinUpgradePriceText.setText('Max Upgrades Reached'); coinUpgradePriceText.fill = 0xFF0000; // Set text color to red self.coinUpgradeBackground.down = null; // Disable button interaction self.coinUpgradeBackground.up = null; // Disable button interaction } } }; // Add a text display for the quantity of CoinUpgrade in the top-right corner var coinUpgradeQuantityText = new Text2('Quantity: ' + CoinUpgrade, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); coinUpgradeQuantityText.anchor.set(1, 0); // Anchor to the top-right corner coinUpgradeQuantityText.x = self.coinUpgradeBackground.x + self.coinUpgradeBackground.width / 2 - coinUpgradeQuantityText.width - 10; coinUpgradeQuantityText.y = self.coinUpgradeBackground.y - self.coinUpgradeBackground.height / 2 + 10; self.addChild(coinUpgradeQuantityText); return self; }); // Create an UpgradePage class var UpgradePage = Container.expand(function () { var self = Container.call(this); // Add a background for the upgrade page var upgradeBackground = self.attachAsset('menuUpgrade', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add a title text for the upgrade page var titleText = new Text2('Pets Page', { size: 200, fill: 0xFFFFFF, font: "Medieval" }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 200; self.addChild(titleText); // Add a button to return to the main menu var backButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 - 200 }); self.addChild(backButton); var backText = new Text2('Back', { size: 150, fill: 0x000000, font: "Medieval" }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; self.addChild(backText); // Add interaction to the back button backButton.down = function () { backButton.isPressed = true; backButton.scaleX *= 1.1; backButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; backButton.up = function () { if (backButton.isPressed) { backButton.scaleX /= 1.1; backButton.scaleY /= 1.1; backButton.isPressed = false; // Logic to return to the main menu game.showMainMenu(); littleMousePrice = littleMouse === 0 ? 0 : littleMouse; littleMousePriceText.setText('Price: ' + littleMousePrice.toLocaleString()); // Update the price display } }; // Add a buyable item 'Little Mouse' to the upgrade page self.littleMouseBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 4 + 100, //{9C} // Adjusted for two-column layout y: 2732 / 2 - 500, //{9D} // Adjusted for three-row layout scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.littleMouseBackground); // Add 'Little Mouse' item title function createPetText(text, size, fill, x, y) { var textObj = new Text2(text, { size: size, fill: fill, font: "Medieval" }); textObj.anchor.set(0.5, 0.5); textObj.x = x; textObj.y = y; return textObj; } var littleMouseTitle = createPetText('Little Mouse', 60, 0xFFFFFF, self.littleMouseBackground.x, self.littleMouseBackground.y - 100); self.addChild(littleMouseTitle); var littleMouseDescription = createPetText('A small and nimble mouse.\nIncreases money by 0.02 per second.', 50, 0xFFFFFF, self.littleMouseBackground.x, self.littleMouseBackground.y); self.addChild(littleMouseDescription); var littleMousePriceText = createPetText('Price: ' + littleMousePrice, 70, 0xFFD700, self.littleMouseBackground.x, self.littleMouseBackground.y + 100); self.addChild(littleMousePriceText); // Add interaction to the 'Little Mouse' item background self.littleMouseBackground.down = function () { self.littleMouseBackground.isPressed = true; self.littleMouseBackground.scaleX *= 0.9; self.littleMouseBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.littleMouseBackground.up = function () { if (self.littleMouseBackground.isPressed) { self.littleMouseBackground.scaleX /= 0.9; self.littleMouseBackground.scaleY /= 0.9; self.littleMouseBackground.isPressed = false; // Check if the Little Mouse has already been purchased var price = littleMousePrice; if (money >= price) { money -= price; littleMouse += 1; // Increase littleMouse count by 1 updateMoneyPerSecond(); // Update moneyPerSecond littleMouseQuantityText.setText('Quantity: ' + littleMouse); // Update the quantity display littleMousePrice = littleMouse * 1; // Update the price littleMousePriceText.setText('Price: ' + littleMousePrice); // Update the price display } else if (littleMousePriceText.text !== 'Insufficient Money') { littleMousePriceText.setText('Insufficient Money'); // Show insufficient money message littleMousePriceText.fill = 0xFF0000; // Set text color to red LK.setTimeout(function () { littleMousePriceText.setText('Price: ' + littleMousePrice); // Revert to original price text littleMousePriceText.fill = 0xFFD700; // Revert text color to gold }, 2000); // Display for 2 seconds } } }; // Add a text display for the quantity of littleMouse in the top-right corner var littleMouseQuantityText = new Text2('Quantity: ' + littleMouse, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); littleMouseQuantityText.anchor.set(1, 0); // Anchor to the top-right corner littleMouseQuantityText.x = self.littleMouseBackground.x + self.littleMouseBackground.width / 2 - littleMouseQuantityText.width - 10; littleMouseQuantityText.y = self.littleMouseBackground.y - self.littleMouseBackground.height / 2 + 10; self.addChild(littleMouseQuantityText); // Add a buyable item 'Doggy' to the upgrade page self.doggyBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 3 * 2048 / 4 - 100, //{a7} // Adjusted for two-column layout y: 2732 / 2 - 500, //{a8} // Adjusted for three-row layout scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.doggyBackground); // Add 'Doggy' item title var doggyTitle = createPetText('Doggy', 60, 0xFFFFFF, self.doggyBackground.x, self.doggyBackground.y - 100); self.addChild(doggyTitle); var doggyDescription = createPetText('A loyal companion.\nIncreases money by 0.2 per second.', 50, 0xFFFFFF, self.doggyBackground.x, self.doggyBackground.y); self.addChild(doggyDescription); var doggyPriceText = createPetText('Price: ' + (10 + doggy * 10), 70, 0xFFD700, self.doggyBackground.x, self.doggyBackground.y + 100); self.addChild(doggyPriceText); // Add interaction to the 'Doggy' item background self.doggyBackground.down = function () { self.doggyBackground.isPressed = true; self.doggyBackground.scaleX *= 0.9; self.doggyBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.doggyBackground.up = function () { if (self.doggyBackground.isPressed) { self.doggyBackground.scaleX /= 0.9; self.doggyBackground.scaleY /= 0.9; self.doggyBackground.isPressed = false; // Check if the Doggy can be purchased var price = 10 + doggy * 10; if (money >= price && littleMouse >= 15) { money -= price; doggy += 1; // Increase doggy count by 1 doggyPriceText.setText('Price: ' + (10 + doggy * 10).toLocaleString()); // Update the price display doggyPriceText.fill = 0xFFD700; // Set text color to gold doggyQuantityText.setText('Quantity: ' + doggy); // Update the quantity display updateMoneyPerSecond(); // Update moneyPerSecond } else if (littleMouse < 15) { doggyPriceText.setText('Need 15 Little Mice'); // Show requirement doggyPriceText.fill = 0xFF0000; // Set text color to red tween(doggyPriceText, { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { doggyPriceText.setText('Price: ' + (10 + doggy * 10)); // Revert to original price text doggyPriceText.fill = 0xFFD700; // Revert text color to gold doggyPriceText.alpha = 1; // Reset alpha } }); } else { doggyPriceText.setText('Insufficient Money'); // Show insufficient money message doggyPriceText.fill = 0xFF0000; // Set text color to red LK.setTimeout(function () { doggyPriceText.setText('Price: ' + (10 + doggy * 10)); // Revert to original price text doggyPriceText.fill = 0xFFD700; // Revert text color to gold }, 2000); // Display for 2 seconds } } }; // Add a text display for the quantity of doggy in the top-right corner var doggyQuantityText = new Text2('Quantity: ' + doggy, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); doggyQuantityText.anchor.set(1, 0); // Anchor to the top-right corner doggyQuantityText.x = self.doggyBackground.x + self.doggyBackground.width / 2 - doggyQuantityText.width - 10; doggyQuantityText.y = self.doggyBackground.y - self.doggyBackground.height / 2 + 10; self.addChild(doggyQuantityText); // Add a buyable item 'Monkey' to the upgrade page self.monkeyBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 4 + 100, //{aB} // Adjusted for two-column layout y: 2732 / 2 - 100, //{aC} // Adjusted for three-row layout scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.monkeyBackground); // Add 'Monkey' item title var monkeyTitle = createPetText('Monkey', 60, 0xFFFFFF, self.monkeyBackground.x, self.monkeyBackground.y - 100); self.addChild(monkeyTitle); var monkeyDescription = createPetText('A playful monkey.\nIncreases money by 2 per second.', 50, 0xFFFFFF, self.monkeyBackground.x, self.monkeyBackground.y); self.addChild(monkeyDescription); var monkeyPriceText = createPetText('Price: ' + (100 + monkey * 100), 70, 0xFFD700, self.monkeyBackground.x, self.monkeyBackground.y + 100); self.addChild(monkeyPriceText); // Add interaction to the 'Monkey' item background self.monkeyBackground.down = function () { self.monkeyBackground.isPressed = true; self.monkeyBackground.scaleX *= 0.9; self.monkeyBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.monkeyBackground.up = function () { if (self.monkeyBackground.isPressed) { self.monkeyBackground.scaleX /= 0.9; self.monkeyBackground.scaleY /= 0.9; self.monkeyBackground.isPressed = false; // Check if the Monkey can be purchased var price = 100 + monkey * 100; if (money >= price && doggy >= 15) { money -= price; monkey += 1; // Increase monkey count by 1 monkeyPriceText.setText('Price: ' + (100 + monkey * 100).toLocaleString()); // Update the price display monkeyPriceText.fill = 0xFFD700; // Set text color to gold monkeyQuantityText.setText('Quantity: ' + monkey); // Update the quantity display updateMoneyPerSecond(); // Update moneyPerSecond } else if (doggy < 15) { monkeyPriceText.setText('Need 15 Doggies'); // Show requirement monkeyPriceText.fill = 0xFF0000; // Set text color to red tween(monkeyPriceText, { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { monkeyPriceText.setText('Price: ' + (100 + monkey * 100)); // Revert to original price text monkeyPriceText.fill = 0xFFD700; // Revert text color to gold monkeyPriceText.alpha = 1; // Reset alpha } }); } else { monkeyPriceText.setText('Insufficient Money'); // Show insufficient money message monkeyPriceText.fill = 0xFF0000; // Set text color to red LK.setTimeout(function () { monkeyPriceText.setText('Price: ' + (100 + monkey * 100)); // Revert to original price text monkeyPriceText.fill = 0xFFD700; // Revert text color to gold }, 2000); // Display for 2 seconds } } }; // Add a text display for the quantity of monkey in the top-right corner var monkeyQuantityText = new Text2('Quantity: ' + monkey, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); monkeyQuantityText.anchor.set(1, 0); // Anchor to the top-right corner monkeyQuantityText.x = self.monkeyBackground.x + self.monkeyBackground.width / 2 - monkeyQuantityText.width - 10; monkeyQuantityText.y = self.monkeyBackground.y - self.monkeyBackground.height / 2 + 10; self.addChild(monkeyQuantityText); // Add a buyable item 'Villager' to the upgrade page self.villagerBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 3 * 2048 / 4 - 100, y: 2732 / 2 - 100, scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.villagerBackground); // Add 'Villager' item title var villagerTitle = createPetText('Villager', 60, 0xFFFFFF, self.villagerBackground.x, self.villagerBackground.y - 100); self.addChild(villagerTitle); var villagerDescription = createPetText('A helpful villager.\nIncreases money by 10 per second.', 50, 0xFFFFFF, self.villagerBackground.x, self.villagerBackground.y); self.addChild(villagerDescription); var villagerPriceText = createPetText('Price: ' + (1000 + villager * 1000), 70, 0xFFD700, self.villagerBackground.x, self.villagerBackground.y + 100); self.addChild(villagerPriceText); // Add interaction to the 'Villager' item background self.villagerBackground.down = function () { self.villagerBackground.isPressed = true; self.villagerBackground.scaleX *= 0.9; self.villagerBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.villagerBackground.up = function () { if (self.villagerBackground.isPressed) { self.villagerBackground.scaleX /= 0.9; self.villagerBackground.scaleY /= 0.9; self.villagerBackground.isPressed = false; // Check if the Villager can be purchased var price = 1000 + villager * 1000; if (money >= price && monkey >= 15) { money -= price; villager += 1; // Increase villager count by 1 villagerPriceText.setText('Price: ' + (1000 + villager * 1000).toLocaleString()); // Update the price display villagerPriceText.fill = 0xFFD700; // Set text color to gold villagerQuantityText.setText('Quantity: ' + villager); // Update the quantity display updateMoneyPerSecond(); // Update moneyPerSecond } else if (monkey < 15) { villagerPriceText.setText('Need 15 Monkeys'); // Show requirement villagerPriceText.fill = 0xFF0000; // Set text color to red tween(villagerPriceText, { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { villagerPriceText.setText('Price: ' + (1000 + villager * 1000)); // Revert to original price text villagerPriceText.fill = 0xFFD700; // Revert text color to gold villagerPriceText.alpha = 1; // Reset alpha } }); } else { villagerPriceText.setText('Insufficient Money'); // Show insufficient money message villagerPriceText.fill = 0xFF0000; // Set text color to red LK.setTimeout(function () { villagerPriceText.setText('Price: ' + (1000 + villager * 1000)); // Revert to original price text villagerPriceText.fill = 0xFFD700; // Revert text color to gold }, 2000); // Display for 2 seconds } } }; // Add a text display for the quantity of villager in the top-right corner var villagerQuantityText = new Text2('Quantity: ' + villager, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); villagerQuantityText.anchor.set(1, 0); // Anchor to the top-right corner villagerQuantityText.x = self.villagerBackground.x + self.villagerBackground.width / 2 - villagerQuantityText.width - 10; villagerQuantityText.y = self.villagerBackground.y - self.villagerBackground.height / 2 + 10; self.addChild(villagerQuantityText); // Add a buyable item 'Peasant' to the upgrade page self.peasantBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 4 + 100, y: 2732 / 2 + 300, scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.peasantBackground); // Add 'Peasant' item title var peasantTitle = createPetText('Peasant', 60, 0xFFFFFF, self.peasantBackground.x, self.peasantBackground.y - 100); self.addChild(peasantTitle); var peasantDescription = createPetText('A hardworking peasant.\nIncreases money by 20 per second.', 50, 0xFFFFFF, self.peasantBackground.x, self.peasantBackground.y); self.addChild(peasantDescription); var peasantPriceText = createPetText('Price: ' + (5000 + peasant * 5000), 70, 0xFFD700, self.peasantBackground.x, self.peasantBackground.y + 100); self.addChild(peasantPriceText); // Add interaction to the 'Peasant' item background self.peasantBackground.down = function () { self.peasantBackground.isPressed = true; self.peasantBackground.scaleX *= 0.9; self.peasantBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.peasantBackground.up = function () { if (self.peasantBackground.isPressed) { self.peasantBackground.scaleX /= 0.9; self.peasantBackground.scaleY /= 0.9; self.peasantBackground.isPressed = false; // Check if the Peasant can be purchased var price = 5000 + peasant * 5000; if (money >= price && villager >= 15) { money -= price; peasant += 1; peasantPriceText.setText('Price: ' + (5000 + peasant * 5000).toLocaleString()); peasantPriceText.fill = 0xFFD700; peasantQuantityText.setText('Quantity: ' + peasant); updateMoneyPerSecond(); } else if (villager < 15) { peasantPriceText.setText('Need 15 Villagers'); // Show requirement peasantPriceText.fill = 0xFF0000; // Set text color to red tween(peasantPriceText, { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { peasantPriceText.setText('Price: ' + (5000 + peasant * 5000)); // Revert to original price text peasantPriceText.fill = 0xFFD700; // Revert text color to gold peasantPriceText.alpha = 1; // Reset alpha } }); } else { peasantPriceText.setText('Insufficient Money'); peasantPriceText.fill = 0xFF0000; LK.setTimeout(function () { peasantPriceText.setText('Price: ' + (5000 + peasant * 5000)); peasantPriceText.fill = 0xFFD700; }, 2000); } } }; // Add a text display for the quantity of peasant in the top-right corner var peasantQuantityText = new Text2('Quantity: ' + peasant, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); peasantQuantityText.anchor.set(1, 0); peasantQuantityText.x = self.peasantBackground.x + self.peasantBackground.width / 2 - peasantQuantityText.width - 10; peasantQuantityText.y = self.peasantBackground.y - self.peasantBackground.height / 2 + 10; self.addChild(peasantQuantityText); // Add a buyable item 'Warrior' to the upgrade page self.warriorBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 3 * 2048 / 4 - 100, y: 2732 / 2 + 300, scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.warriorBackground); // Add 'Warrior' item title var warriorTitle = createPetText('Warrior', 60, 0xFFFFFF, self.warriorBackground.x, self.warriorBackground.y - 100); self.addChild(warriorTitle); var warriorDescription = createPetText('A brave warrior.\nIncreases money by 50 per second.', 50, 0xFFFFFF, self.warriorBackground.x, self.warriorBackground.y); self.addChild(warriorDescription); var warriorPriceText = createPetText('Price: ' + (20000 + warrior * 20000), 70, 0xFFD700, self.warriorBackground.x, self.warriorBackground.y + 100); self.addChild(warriorPriceText); // Add interaction to the 'Warrior' item background self.warriorBackground.down = function () { self.warriorBackground.isPressed = true; self.warriorBackground.scaleX *= 0.9; self.warriorBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.warriorBackground.up = function () { if (self.warriorBackground.isPressed) { self.warriorBackground.scaleX /= 0.9; self.warriorBackground.scaleY /= 0.9; self.warriorBackground.isPressed = false; // Check if the Warrior can be purchased var price = 20000 + warrior * 20000; if (money >= price && peasant >= 15) { money -= price; warrior += 1; warriorPriceText.setText('Price: ' + (20000 + warrior * 20000).toLocaleString()); warriorPriceText.fill = 0xFFD700; warriorQuantityText.setText('Quantity: ' + warrior); updateMoneyPerSecond(); } else if (peasant < 15) { warriorPriceText.setText('Need 15 Peasants'); // Show requirement warriorPriceText.fill = 0xFF0000; // Set text color to red tween(warriorPriceText, { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { warriorPriceText.setText('Price: ' + (20000 + warrior * 20000)); // Revert to original price text warriorPriceText.fill = 0xFFD700; // Revert text color to gold warriorPriceText.alpha = 1; // Reset alpha } }); } else { warriorPriceText.setText('Insufficient Money'); warriorPriceText.fill = 0xFF0000; LK.setTimeout(function () { warriorPriceText.setText('Price: ' + (20000 + warrior * 20000)); warriorPriceText.fill = 0xFFD700; }, 2000); } } }; // Add a text display for the quantity of warrior in the top-right corner var warriorQuantityText = new Text2('Quantity: ' + warrior, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); warriorQuantityText.anchor.set(1, 0); warriorQuantityText.x = self.warriorBackground.x + self.warriorBackground.width / 2 - warriorQuantityText.width - 10; warriorQuantityText.y = self.warriorBackground.y - self.warriorBackground.height / 2 + 10; self.addChild(warriorQuantityText); // Add a buyable item 'Bourgeois' to the upgrade page self.bourgeoisBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 4 + 100, y: 2732 / 2 + 700, scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.bourgeoisBackground); // Add 'Bourgeois' item title var bourgeoisTitle = createPetText('Bourgeois', 60, 0xFFFFFF, self.bourgeoisBackground.x, self.bourgeoisBackground.y - 100); self.addChild(bourgeoisTitle); var bourgeoisDescription = createPetText('A wealthy bourgeois.\nIncreases money by 100 per second.', 50, 0xFFFFFF, self.bourgeoisBackground.x, self.bourgeoisBackground.y); self.addChild(bourgeoisDescription); var bourgeoisPriceText = createPetText('Price: ' + (50000 + bourgeois * 50000), 70, 0xFFD700, self.bourgeoisBackground.x, self.bourgeoisBackground.y + 100); self.addChild(bourgeoisPriceText); // Add interaction to the 'Bourgeois' item background self.bourgeoisBackground.down = function () { self.bourgeoisBackground.isPressed = true; self.bourgeoisBackground.scaleX *= 0.9; self.bourgeoisBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.bourgeoisBackground.up = function () { if (self.bourgeoisBackground.isPressed) { self.bourgeoisBackground.scaleX /= 0.9; self.bourgeoisBackground.scaleY /= 0.9; self.bourgeoisBackground.isPressed = false; // Check if the Bourgeois can be purchased var price = 50000 + bourgeois * 50000; if (money >= price && warrior >= 15) { money -= price; bourgeois += 1; bourgeoisPriceText.setText('Price: ' + (50000 + bourgeois * 50000).toLocaleString()); bourgeoisPriceText.fill = 0xFFD700; bourgeoisQuantityText.setText('Quantity: ' + bourgeois); updateMoneyPerSecond(); } else if (warrior < 15) { bourgeoisPriceText.setText('Need 15 Warriors'); // Show requirement bourgeoisPriceText.fill = 0xFF0000; // Set text color to red tween(bourgeoisPriceText, { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { bourgeoisPriceText.setText('Price: ' + (50000 + bourgeois * 50000)); // Revert to original price text bourgeoisPriceText.fill = 0xFFD700; // Revert text color to gold bourgeoisPriceText.alpha = 1; // Reset alpha } }); } else { bourgeoisPriceText.setText('Insufficient Money'); bourgeoisPriceText.fill = 0xFF0000; LK.setTimeout(function () { bourgeoisPriceText.setText('Price: ' + (50000 + bourgeois * 50000)); bourgeoisPriceText.fill = 0xFFD700; }, 2000); } } }; // Add a text display for the quantity of bourgeois in the top-right corner var bourgeoisQuantityText = new Text2('Quantity: ' + bourgeois, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); bourgeoisQuantityText.anchor.set(1, 0); bourgeoisQuantityText.x = self.bourgeoisBackground.x + self.bourgeoisBackground.width / 2 - bourgeoisQuantityText.width - 10; bourgeoisQuantityText.y = self.bourgeoisBackground.y - self.bourgeoisBackground.height / 2 + 10; self.addChild(bourgeoisQuantityText); // Add a buyable item 'King' to the upgrade page self.kingBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 3 * 2048 / 4 - 100, y: 2732 / 2 + 700, scaleX: 0.7, scaleY: 0.7 }); self.addChild(self.kingBackground); // Add 'King' item title var kingTitle = createPetText('King', 60, 0xFFFFFF, self.kingBackground.x, self.kingBackground.y - 100); self.addChild(kingTitle); var kingDescription = createPetText('A powerful king.\nIncreases money by 200 per second.', 50, 0xFFFFFF, self.kingBackground.x, self.kingBackground.y); self.addChild(kingDescription); var kingPriceText = createPetText('Price: ' + (100000 + king * 100000), 70, 0xFFD700, self.kingBackground.x, self.kingBackground.y + 100); self.addChild(kingPriceText); // Add interaction to the 'King' item background self.kingBackground.down = function () { self.kingBackground.isPressed = true; self.kingBackground.scaleX *= 0.9; self.kingBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; self.kingBackground.up = function () { if (self.kingBackground.isPressed) { self.kingBackground.scaleX /= 0.9; self.kingBackground.scaleY /= 0.9; self.kingBackground.isPressed = false; // Check if the King can be purchased var price = 100000 + king * 100000; if (money >= price && bourgeois >= 15) { money -= price; king += 1; kingPriceText.setText('Price: ' + (100000 + king * 100000).toLocaleString()); kingPriceText.fill = 0xFFD700; kingQuantityText.setText('Quantity: ' + king); updateMoneyPerSecond(); } else if (bourgeois < 15) { kingPriceText.setText('Need 15 Bourgeois'); // Show requirement kingPriceText.fill = 0xFF0000; // Set text color to red tween(kingPriceText, { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { kingPriceText.setText('Price: ' + (100000 + king * 100000)); // Revert to original price text kingPriceText.fill = 0xFFD700; // Revert text color to gold kingPriceText.alpha = 1; // Reset alpha } }); } else { kingPriceText.setText('Insufficient Money'); kingPriceText.fill = 0xFF0000; LK.setTimeout(function () { kingPriceText.setText('Price: ' + (100000 + king * 100000)); kingPriceText.fill = 0xFFD700; }, 2000); } } }; // Add a text display for the quantity of king in the top-right corner var kingQuantityText = new Text2('Quantity: ' + king, { size: 50, fill: 0xFFFFFF, font: "Medieval" }); kingQuantityText.anchor.set(1, 0); kingQuantityText.x = self.kingBackground.x + self.kingBackground.width / 2 - kingQuantityText.width - 10; kingQuantityText.y = self.kingBackground.y - self.kingBackground.height / 2 + 10; self.addChild(kingQuantityText); return self; }); // Create a Text class to display the meters covered var MeterText = Text2.expand(function () { var self = Text2.call(this, '0', { size: 100, fill: 0xFFFFFF }); self.update = function () { self.setText('Travel: ' + (meters / 1000).toFixed(2).toLocaleString() + ' km'); }; }); // Adjusted Y position for MoneyText // Create a MoneyPerSecondText class to display the money earned per second var MoneyPerSecondText = Text2.expand(function () { var self = Text2.call(this, '0', { size: 100, fill: 0xFFFFFF }); self.update = function () { self.setText('Money/Sec: ' + moneyPerSecond.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }; }); // Create a MoneyPerSecondText instance and add it to the game // Create a MoneyText class to display the amount of 'money' var MoneyText = Text2.expand(function () { var self = Text2.call(this, '0', { size: 100, fill: 0xFFFFFF }); self.update = function () { self.setText('Money: ' + money.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }; }); /**** * Initialize Game ****/ // Initialize BackgroundContainer, MidgroundContainer, and ForegroundContainer var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var CoinUpgrade = storage.CoinUpgrade || 0; var BestTime = storage.BestTime || 0; // Initialize BestTime from storage or default to 0 var complete = storage.complete || 0; // Initialize complete status from storage or default to 0 // Function to handle item interaction function handleItemInteraction(itemBackground, itemPriceText, price, purchaseKey) { itemBackground.down = function () { itemBackground.isPressed = true; itemBackground.scaleX *= 0.9; itemBackground.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; itemBackground.up = function () { if (itemBackground.isPressed) { itemBackground.scaleX /= 0.9; itemBackground.scaleY /= 0.9; itemBackground.isPressed = false; if (money >= price) { money -= price; storage[purchaseKey] = true; // Mark the item as purchased itemPriceText.setText('Purchased'); itemPriceText.fill = 0x00FF00; // Set text color to green } else { itemPriceText.setText('Insufficient Money'); itemPriceText.fill = 0xFF0000; // Set text color to red LK.setTimeout(function () { itemPriceText.setText('Price: ' + price); itemPriceText.fill = 0xFFD700; // Revert text color to gold }, 2000); // Display for 2 seconds } } }; } // Function to create item text with specified properties function createItemText(text, size, fill, x, y) { var textObj = new Text2(text, { size: size, fill: fill, font: "Medieval" }); textObj.anchor.set(0.5, 0.5); textObj.x = x; textObj.y = y; return textObj; } var monkey = storage.monkey || 0; // Load 'monkey' from storage or initialize to 0 var villager = storage.villager || 0; // Load villager from storage or initialize to 0 var timeGame = storage.timePlayed || 0; // Load time played from storage or initialize to 0 var doggy = storage.doggy || 0; // Load doggy from storage or initialize to 0 var littleMouse = storage.littleMouse || 0; var littleMousePrice = littleMouse === 0 ? 0 : littleMouse; var peasant = storage.peasant || 0; // Load peasant from storage or initialize to 0 var warrior = storage.warrior || 0; // Load warrior from storage or initialize to 0 var bourgeois = storage.bourgeois || 0; // Load bourgeois from storage or initialize to 0 var king = storage.king || 0; // Load king from storage or initialize to 0 game.showIntroductionPage = function () { // Logic to display the introduction page foregroundContainer.visible = false; introductionPage.visible = true; // Hide all other game elements to ensure only the introduction page is visible backgroundContainer.visible = false; midgroundContainer.visible = false; jump = 0; // Set jump to 0 when on the introduction page }; // Initialize the introduction page var introductionPage = new IntroductionPage(); game.addChild(introductionPage); introductionPage.visible = false; // Start with the introduction page hidden // Initialize the extras page var extrasPage = new ExtrasPage(); game.addChild(extrasPage); extrasPage.visible = false; // Start with the extras page hidden // Initialize the credits page var creditsPage = new CreditsPage(); game.addChild(creditsPage); creditsPage.visible = false; // Start with the credits page hidden // Method to show the credits page game.showCreditsPage = function () { // Logic to display the credits page foregroundContainer.visible = false; creditsPage.visible = true; // Hide all other game elements to ensure only the credits page is visible backgroundContainer.visible = false; midgroundContainer.visible = false; extrasPage.visible = false; // Ensure the extras page is hidden when credits page is visible jump = 0; // Set jump to 0 when on the credits page }; // Method to show the extras page game.showExtrasPage = function () { // Logic to display the extras page foregroundContainer.visible = false; extrasPage.visible = true; // Hide all other game elements to ensure only the extras page is visible backgroundContainer.visible = false; midgroundContainer.visible = false; creditsPage.visible = false; // Ensure the credits page is hidden when extras page is visible jump = 0; // Set jump to 0 when on the extras page }; // Initialize the rock page var rockPage = new RockPage(); game.addChild(rockPage); rockPage.visible = false; // Start with the rock page hidden // Initialize the shop page var shopPage = new ShopPage(); game.addChild(shopPage); shopPage.visible = false; // Start with the shop page hidden // Ensure shopPage is initialized before accessing its properties // Method to show the main menu game.showMainMenu = function () { // Logic to display the main menu foregroundContainer.visible = true; upgradePage.visible = false; rockPage.visible = false; // Ensure the rock page is hidden cosmeticPage.visible = false; // Ensure the cosmetic page is hidden extrasPage.visible = false; // Ensure the extras page is hidden shopPage.visible = false; // Ensure the shop page is hidden // Show all other game elements to ensure the main menu is fully visible backgroundContainer.visible = true; midgroundContainer.visible = true; jump = 0; // Set jump to 0 when on the main menu }; // Method to show the shop page game.showShopPage = function () { // Logic to display the shop page foregroundContainer.visible = false; shopPage.visible = true; // Hide all other game elements to ensure only the shop page is visible backgroundContainer.visible = false; midgroundContainer.visible = false; jump = 0; // Set jump to 0 when on the shop page }; // Method to show the upgrade page game.showUpgradePage = function () { // Logic to display the upgrade page foregroundContainer.visible = false; upgradePage.visible = true; // Hide all other game elements to ensure only the upgrade page is visible backgroundContainer.visible = false; midgroundContainer.visible = false; jump = 0; // Set jump to 0 when on the upgrade page }; // Method to show the cosmetic page game.showCosmeticPage = function () { // Logic to display the cosmetic page foregroundContainer.visible = false; cosmeticPage.visible = true; // Hide all other game elements to ensure only the cosmetic page is visible backgroundContainer.visible = false; midgroundContainer.visible = false; jump = 0; // Set jump to 0 when on the cosmetic page }; // Initialize the upgrade page var upgradePage = new UpgradePage(); game.addChild(upgradePage); upgradePage.visible = false; // Start with the upgrade page hidden // Initialize the cosmetic page var cosmeticPage = new CosmeticPage(); game.addChild(cosmeticPage); cosmeticPage.visible = false; // Start with the cosmetic page hidden // Initialize BackgrounOneContainer, BackgrounTwoContainer, MidgroundContainer, ForegroundOneContainer, ForegroundTwoContainer, GuibackgroundContainer, GuigmidroundContainer and GuiforegroundContainer var backgroundOneContainer = new BackgroundOneContainer(); var backgroundTwoContainer = new BackgroundTwoContainer(); var midgroundContainer = new MidgroundContainer(); var foregroundOneContainer = new ForegroundOneContainer(); var foregroundTwoContainer = new ForegroundTwoContainer(); var guibackgroundContainer = new GuibackgroundContainer(); var guimidgroundContainer = new GuimidgroundContainer(); var guiforegroundContainer = new GuiforegroundContainer(); // Add containers to the game in the correct order game.addChild(backgroundOneContainer); game.addChild(backgroundTwoContainer); game.addChild(midgroundContainer); game.addChild(foregroundOneContainer); game.addChild(foregroundTwoContainer); game.addChild(guibackgroundContainer); game.addChild(guimidgroundContainer); game.addChild(guiforegroundContainer); // var currentRockIndex = storage.currentRockIndex || 0; // Load saved player skin index or default to 0 var meters = storage.meters || 0; // Load saved meters or default to 0 var money = storage.money || 0; // Load saved money or default to 0 var moneyPerSecond = littleMouse * 0.02 + doggy * 0.2 + monkey * 2 + villager * 10 + peasant * 20 + warrior * 50 + bourgeois * 100 + king * 200; // Initialize moneyPerSecond based on all pets // Create a loading bar at the bottom of the screen var loadingBar = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 - 50, scaleX: 0.0, // Start with 0 scale to represent an empty bar scaleY: 0.1 // Thin bar }); foregroundContainer.addChild(loadingBar); // Function to update moneyPerSecond based on littleMouse count function updateMoneyPerSecond() { moneyPerSecond = littleMouse * 0.02 + doggy * 0.2 + monkey * 2 + villager * 10 + peasant * 20 + warrior * 50 + bourgeois * 100 + king * 200; } // Initialize a rock asset with a design var Rock = LK.getAsset('Playera0', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); backgroundContainer.addChild(Rock); // Make the rock jump when the screen is touched game.down = function (x, y, obj) { if (jump > 0 && y < 2732 / 2 + 200) { LK.getSound('rockjump').play(); // Play rockjump sound when the rock jumps player.speed = -18; // Give an initial upward speed for the jump player.y -= 10; // Adjust position slightly to ensure jump effect player.update(); // Ensure the update method is called to apply the jump jump--; // Decrease jump count } }; // Create a background asset using the saved skin index var background = LK.getAsset('World0', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add the background to the game backgroundContainer.addChild(background); // Create a clone of the background asset var backgroundClone = LK.getAsset('World0', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + background.width, y: 2732 / 2 }); // Add the clone to the game backgroundContainer.addChild(backgroundClone); // Create a second clone of the background asset var backgroundClone2 = LK.getAsset('World0', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + 2 * background.width, y: 2732 / 2 }); // Add the second clone to the game backgroundContainer.addChild(backgroundClone2); // Create a player instance and add it to the game var player = midgroundContainer.addChild(new Player()); // Position player more towards the center of the screen player.x = 2048 / 4; player.y = 2732 / 2 + 10; // Load and apply the saved player skin player.removeChild(player.playerGraphics); player.playerGraphics = player.attachAsset('Rock' + currentRockIndex, { anchorX: 0.5, anchorY: 0.5 }); player.addChild(player.playerGraphics); // Initialize a variable to track 'meters' // Initialize a variable to track available jumps var jump = 2; // Initialize a variable to track 'giros' // Create a MeterText instance and add it to the game var meterText = foregroundContainer.addChild(new MeterText()); // Position MeterText further down on the screen meterText.x = 0; meterText.y = 200; // Adjusted Y position for MeterText // Create a GirosText instance and add it to the game var moneyText = foregroundContainer.addChild(new MoneyText()); // Position MoneyText below the MeterText further down on the screen moneyText.x = 0; moneyText.y = meterText.y + meterText.height + 50; // Create a MoneyPerSecondText instance and add it to the game var goalText = new Text2('Goal for completion: 100,000,000 money', { size: 100, fill: 0xFFFFFF, font: "Medieval" }); goalText.anchor.set(0.5, 0.5); goalText.x = 2048 / 2; var moneyPerSecondText = foregroundContainer.addChild(new MoneyPerSecondText()); goalText.y = moneyPerSecondText.y + moneyPerSecondText.height + 50; foregroundContainer.addChild(goalText); // Position MoneyPerSecondText below the MoneyText further down on the screen moneyPerSecondText.x = 0; moneyPerSecondText.y = moneyText.y + moneyText.height + 50; // Adjusted Y position for MoneyPerSecondText // Initialize a variable to track 'money' // Create a list named 'rock' and add all the 'rock<number>' assets to it // Ensure rock array is initialized with all rock assets var Rock = ['Rock0', 'Rock1', 'Rock2', 'Rock3', 'Rock4', 'Rock5', 'Rock6', 'Rock7', 'Rock8', 'Rock9']; // Create a list named 'SkinSelect' var SkinSelect = []; var assets = LK.assets; if (assets) { for (var i = 0; i < assets.length; i++) { if (assets[i].id.startsWith('Playera')) { playera.push(assets[i].id); } } playera.sort(function (a, b) { return parseInt(a.replace('Playera', '')) - parseInt(b.replace('Playera', '')); }); } game.update = function () { if (CoinUpgrade >= 1) { // Add a new coin every 360 ticks (6 seconds) if (LK.ticks % 360 === 0) { var numberOfClones = Math.floor(Math.random() * 5) + 1; // Random number between 1 and 5 for (var i = 0; i < numberOfClones; i++) { var newCoin = new Coin(); newCoin.x += i * 120; // Offset each clone by 50 pixels midgroundContainer.addChild(newCoin); } } } // Increment 'meters' every second if (LK.ticks % 60 == 0) { // Check if money has reached 100,000,000 if (money >= 100000000 && !game.congratulated) { complete += 1; // Increment completion count if (timeGame < BestTime || BestTime === 0) { BestTime = timeGame; } game.congratulated = true; // Ensure this block only runs once // Create a congratulatory popup var congratsBackground = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2, scaleY: 2 }); foregroundContainer.addChild(congratsBackground); var congratsText = new Text2('Congratulations! You reached 100,000,000 money!', { size: 70, fill: 0xFFFFFF, font: "Medieval" }); congratsText.anchor.set(0.5, 0.5); congratsText.x = 2048 / 2; congratsText.y = 2732 / 2 - 100; foregroundContainer.addChild(congratsText); var resetButton = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 100, scaleX: 1.5, scaleY: 1.5 }); foregroundContainer.addChild(resetButton); var resetText = new Text2('Reset Game', { size: 100, fill: 0x000000, font: "Medieval" }); resetText.anchor.set(0.5, 0.5); resetText.x = resetButton.x; resetText.y = resetButton.y; foregroundContainer.addChild(resetText); resetButton.down = function () { resetButton.isPressed = true; resetButton.scaleX *= 0.9; resetButton.scaleY *= 0.9; LK.getSound('butomtouch').play(); }; resetButton.up = function () { if (resetButton.isPressed) { resetButton.scaleX /= 1.1; resetButton.scaleY /= 1.1; resetButton.isPressed = false; // Logic to reset the game LK.showGameOver(); } }; } meters += 1; timeGame += 1; // Increment timeGame by 1 every second if (timeGame % 3600 === 0) { var hours = timeGame / 3600; console.log('Time Played: ' + hours + ' hour(s)'); } money += moneyPerSecond; // Increase money by the amount of money/second gained each second // Update loading bar scale based on money progress towards 20,000,000 loadingBar.scaleX = Math.min(money / 20000000, 1); // Scale from 0 to 1 // Log every time 1000 meters are advanced if (meters % 1000 === 0) { console.log('Advanced 1000 meters'); // Play the 'HoundreMeters' sound every 1000 meters LK.getSound('HoundreMeters').play(); // money += 25; // Removed money increment when meters increase by 250 // Change background sprite currentRockIndex = (currentRockIndex + 1) % 8; // Cycle through 0 to 7 background.removeChild(background.playerGraphics); background.playerGraphics = background.attachAsset('Background' + currentRockIndex, { anchorX: 0.5, anchorY: 0.5 }); backgroundClone.removeChild(backgroundClone.playerGraphics); backgroundClone.playerGraphics = backgroundClone.attachAsset('Background' + currentRockIndex, { anchorX: 0.5, anchorY: 0.5 }); backgroundClone2.removeChild(backgroundClone2.playerGraphics); backgroundClone2.playerGraphics = backgroundClone2.attachAsset('Background' + currentRockIndex, { anchorX: 0.5, anchorY: 0.5 }); } // Play the 'HoundreMeters' sound at 1000 meters if (meters === 1000) { LK.getSound('HoundreMeters').play(); } } // Save progress every 1 second if (LK.ticks % 60 == 0) { storage.meters = meters; storage.money = money; storage.currentRockIndex = currentRockIndex; // Save current background skin index storage.littleMouse = littleMouse; storage.timePlayed = timeGame; // Save time played to storage storage.monkey = monkey; // Save monkey to storage storage.doggy = doggy; // Save doggy to storage storage.villager = villager; // Save villager to storage storage.peasant = peasant; // Save peasant to storage storage.warrior = warrior; // Save warrior to storage storage.bourgeois = bourgeois; // Save bourgeois to storage storage.king = king; // Save king to storage storage.CoinUpgrade = CoinUpgrade; // Save CoinUpgrade to storage storage.BestTime = BestTime; // Save BestTime to storage storage.complete = complete; // Save complete status to storage } };
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1", {
meters: 0,
money: 0,
spin: 0,
timePlayed: 0,
doggy: 0,
currentRockIndex: 0,
monkey: 0,
villager: 0,
BestTime: 0,
complete: 0
});
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Create a BackgroundOneContainer class
var BackgroundOneContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create a BackgroundTwoContainer class
var BackgroundTwoContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create a Coin class
var Coin = Container.expand(function () {
var self = Container.call(this);
// Attach the coin asset
var coinSpriteId = 'coin'; // Default to bronze coin
if (CoinUpgrade === 2) {
coinSpriteId = 'coin1'; // Silver coin
} else if (CoinUpgrade === 3) {
coinSpriteId = 'coin2'; // Golden coin
} else if (CoinUpgrade === 4) {
coinSpriteId = 'coin3'; // Diamond coin
}
var coinGraphics = self.attachAsset(coinSpriteId, {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial position and speed
self.x = 2048 + coinGraphics.width / 2; // Start off-screen to the right
self.y = player.y - 400; // Position above the player
self.speed = -12; // Further increase speed to move left faster
// Add spinning effect to the coin in the opposite direction
tween(coinGraphics, {
rotation: -Math.PI * 2
}, {
duration: 800,
easing: tween.linear,
onFinish: function onFinish() {
coinGraphics.rotation = 0; // Reset rotation after a full spin
tween(coinGraphics, {
rotation: -Math.PI * 2
}, {
duration: 800,
easing: tween.linear,
onFinish: arguments.callee
});
}
});
// Update method to move the coin
self.update = function () {
self.x += self.speed;
// Check if the coin is off-screen or collected by the player
if (self.x < -coinGraphics.width / 2) {
self.destroy();
} else if (self.intersects(player)) {
if (CoinUpgrade === 4) {
money += moneyPerSecond * 10; // Diamond coin value
} else if (CoinUpgrade === 3 && Math.random() < 0.1) {
money += moneyPerSecond * 5; // Golden coin value
} else if (CoinUpgrade === 2 && Math.random() < 0.3) {
money += moneyPerSecond * 2.5; // Silver coin value
} else {
money += moneyPerSecond * 0.5; // Regular coin value
}
LK.getSound('clutchedCoin').play(); // Play sound when coin is collected
self.destroy();
}
};
return self;
});
// Create a CosmeticPage class
var CosmeticPage = Container.expand(function () {
var self = Container.call(this);
// Add a background for the cosmetic page
var cosmeticBackground = self.attachAsset('menuCosmetic', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Add a title text for the cosmetic page
var titleText = new Text2('Cosmetic Page', {
size: 200,
fill: 0xFFFFFF,
font: "Medieval"
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 200;
self.addChild(titleText);
// Add a button to return to the main menu
var backButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 - 200
});
self.addChild(backButton);
var backText = new Text2('Back', {
size: 150,
fill: 0x000000,
font: "Medieval"
});
backText.anchor.set(0.5, 0.5);
backText.x = backButton.x;
backText.y = backButton.y;
self.addChild(backText);
// Add interaction to the back button
backButton.down = function () {
backButton.isPressed = true;
backButton.scaleX *= 0.9;
backButton.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
backButton.up = function () {
if (backButton.isPressed) {
backButton.scaleX /= 0.9;
backButton.scaleY /= 0.9;
backButton.isPressed = false;
// Logic to return to the main menu
game.showMainMenu();
}
};
// Add a cosmetic changer for rocks
var rockIndex = 0; // Start with the first rock
var Rock = ['Rock0', 'Rock1', 'Rock2', 'Rock3', 'Rock4', 'Rock5', 'Rock6', 'Rock7', 'Rock8', 'Rock9', 'Rock10', 'Rock11', 'Rock12', 'Rock13', 'Rock14', 'Rock15', 'Rock16', 'Rock17', 'Rock18', 'Rock19', 'Rock20', 'Rock21', 'Rock22', 'Rock23'];
var cosmeticDisplay = self.attachAsset('Rock' + rockIndex, {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 600 //{X} // Moved 100 pixels lower to avoid collision with bottom
});
self.addChild(cosmeticDisplay);
// Add left arrow button to change the rock cosmetic
var leftArrowButton = LK.getAsset('arrowleft', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 - 450,
y: 2732 / 2 - 300
});
self.addChild(leftArrowButton);
leftArrowButton.down = function () {
leftArrowButton.isPressed = true;
leftArrowButton.scaleX *= 0.9;
leftArrowButton.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
leftArrowButton.up = function () {
if (leftArrowButton.isPressed) {
leftArrowButton.scaleX /= 0.9;
leftArrowButton.scaleY /= 0.9;
leftArrowButton.isPressed = false;
// Change the rock cosmetic to the previous one
rockIndex = (rockIndex - 1 + Rock.length) % Rock.length; // Dynamically accommodate rock assets
self.removeChild(cosmeticDisplay);
cosmeticDisplay = self.attachAsset('Rock' + rockIndex, {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 600
});
self.addChild(cosmeticDisplay);
}
};
// Add a 'Select' button between the left and right arrow buttons
var selectButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 300
});
self.addChild(selectButton);
var selectText = new Text2('Select', {
size: 150,
fill: 0x000000,
font: "Medieval"
});
selectText.anchor.set(0.5, 0.5);
selectText.x = selectButton.x;
selectText.y = selectButton.y;
self.addChild(selectText);
// Add interaction to the select button
selectButton.down = function () {
selectButton.isPressed = true;
selectButton.scaleX *= 0.9;
selectButton.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
selectButton.up = function () {
if (selectButton.isPressed) {
selectButton.scaleX /= 0.9;
selectButton.scaleY /= 0.9;
selectButton.isPressed = false;
// Change the rock to the selected cosmetic
// Ensure cosmeticDisplay is not removed when 'Select' is pressed
player.removeChild(player.playerGraphics);
player.playerGraphics = player.attachAsset('Rock' + rockIndex, {
anchorX: 0.5,
anchorY: 0.5
});
player.addChild(player.playerGraphics);
storage.currentRockIndex = rockIndex; // Save the selected player skin index
}
};
// Add right arrow button to change the rock cosmetic
var rightArrowButton = LK.getAsset('arrowright', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + 450,
y: 2732 / 2 - 300
});
self.addChild(rightArrowButton);
rightArrowButton.down = function () {
rightArrowButton.isPressed = true;
rightArrowButton.scaleX *= 0.9;
rightArrowButton.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
rightArrowButton.up = function () {
if (rightArrowButton.isPressed) {
rightArrowButton.scaleX /= 0.9;
rightArrowButton.scaleY /= 0.9;
rightArrowButton.isPressed = false;
// Change the rock cosmetic to the next one
rockIndex = (rockIndex + 1) % Rock.length; // Dynamically accommodate rock assets
self.removeChild(cosmeticDisplay);
cosmeticDisplay = self.attachAsset('Rock' + rockIndex, {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 600
});
self.addChild(cosmeticDisplay);
}
};
return self;
});
// Create a CreditsPage class
var CreditsPage = Container.expand(function () {
var self = Container.call(this);
// Add the Slimy asset to the credits page
var slimyAsset = self.attachAsset('Slimy', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Add interaction to the Slimy asset
slimyAsset.down = function () {
// Logic to return to the extras page
game.showExtrasPage();
};
return self;
});
// Create an ExtrasPage class
var ExtrasPage = Container.expand(function () {
var self = Container.call(this);
// Add a background for the extras page
var extrasBackground = self.attachAsset('menuExtras', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Add a title text for the extras page
var titleText = new Text2('Extras Page', {
size: 200,
fill: 0xFFFFFF,
font: "Medieval"
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 200;
self.addChild(titleText);
// Add a button to return to the main menu
var backButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 - 200
});
self.addChild(backButton);
var backText = new Text2('Back', {
size: 150,
fill: 0x000000,
font: "Medieval"
});
backText.anchor.set(0.5, 0.5);
backText.x = backButton.x;
backText.y = backButton.y;
self.addChild(backText);
// Add interaction to the back button
backButton.down = function () {
backButton.isPressed = true;
backButton.scaleX *= 1.1;
backButton.scaleY *= 1.1;
LK.getSound('butomtouch').play();
};
backButton.up = function () {
if (backButton.isPressed) {
backButton.scaleX /= 1.1;
backButton.scaleY /= 1.1;
backButton.isPressed = false;
// Logic to return to the main menu
game.showMainMenu();
}
};
// Add a reset progress button
var resetButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 200
});
self.addChild(resetButton);
var resetText = new Text2('Reset Progress', {
size: 100,
fill: 0xFF0000,
font: "Medieval"
});
resetText.anchor.set(0.5, 0.5);
resetText.x = resetButton.x;
resetText.y = resetButton.y;
self.addChild(resetText);
// Add interaction to the reset button
resetButton.down = function () {
resetButton.isPressed = true;
resetButton.scaleX *= 1.1;
resetButton.scaleY *= 1.1;
LK.getSound('butomtouch').play();
};
resetButton.up = function () {
if (resetButton.isPressed) {
resetButton.scaleX /= 1.1;
resetButton.scaleY /= 1.1;
resetButton.isPressed = false;
// Custom confirmation dialog
var confirmResetBackground = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 1.5,
scaleY: 1.5
});
self.addChild(confirmResetBackground);
var confirmReset = new Text2('Are you sure you want to\nreset your progress?', {
size: 70,
//{3n} // Reduced size to fit better
fill: 0xFFFFFF,
font: "Medieval"
});
confirmReset.anchor.set(0.5, 0.5);
confirmReset.x = 2048 / 2;
confirmReset.y = 2732 / 2 - 100; // Adjusted position to avoid collision
self.addChild(confirmReset);
var yesButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 - 200,
y: 2732 / 2 + 150,
scaleX: 0.6,
// Further decrease size
scaleY: 0.6 // Further decrease size
});
self.addChild(yesButton);
var noButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + 200,
y: 2732 / 2 + 150,
scaleX: 0.6,
// Further decrease size
scaleY: 0.6 // Further decrease size
});
self.addChild(noButton);
var yesText = new Text2('Yes', {
size: 100,
fill: 0x000000,
font: "Medieval"
});
yesText.anchor.set(0.5, 0.5);
yesText.x = yesButton.x;
yesText.y = yesButton.y;
self.addChild(yesText);
var noText = new Text2('No', {
size: 100,
fill: 0x000000,
font: "Medieval"
});
noText.anchor.set(0.5, 0.5);
noText.x = noButton.x;
noText.y = noButton.y;
self.addChild(noText);
yesButton.down = function () {
yesButton.isPressed = true;
yesButton.scaleX *= 1.1;
yesButton.scaleY *= 1.1;
LK.getSound('butomtouch').play();
};
yesButton.up = function () {
if (yesButton.isPressed) {
yesButton.scaleX /= 1.1;
yesButton.scaleY /= 1.1;
yesButton.isPressed = false;
// Logic to reset progress
storage.meters = 0;
storage.money = 0;
meters = 0;
money = 0;
moneyPerSecond = 0; // Stop money increment during reset
currentRockIndex = 0;
timeGame = 0; // Reset time played
storage.timePlayed = 0; // Reset time played in storage
// Reset all pet counts and storage
littleMouse = 0;
storage.littleMouse = 0;
monkey = 0;
storage.monkey = 0;
doggy = 0;
storage.doggy = 0;
peasant = 0;
storage.peasant = 0;
warrior = 0;
storage.warrior = 0;
bourgeois = 0;
storage.bourgeois = 0;
king = 0;
storage.king = 0;
CoinUpgrade = 0; // Reset CoinUpgrade
storage.CoinUpgrade = 0; // Reset CoinUpgrade in storage
villager = 0;
storage.villager = 0;
console.log("Progress reset");
background.removeChild(background.playerGraphics);
background.playerGraphics = background.attachAsset('Background0', {
anchorX: 0.5,
anchorY: 0.5
});
backgroundClone.removeChild(backgroundClone.playerGraphics);
backgroundClone.playerGraphics = backgroundClone.attachAsset('Background0', {
anchorX: 0.5,
anchorY: 0.5
});
backgroundClone2.removeChild(backgroundClone2.playerGraphics);
backgroundClone2.playerGraphics = backgroundClone2.attachAsset('Background0', {
anchorX: 0.5,
anchorY: 0.5
});
self.removeChild(confirmReset);
self.removeChild(yesButton);
self.removeChild(noButton);
self.removeChild(yesText);
self.removeChild(noText);
self.removeChild(confirmResetBackground);
// Wait 1 second and then end the game
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
};
noButton.down = function () {
noButton.isPressed = true;
noButton.scaleX *= 1.1;
noButton.scaleY *= 1.1;
LK.getSound('butomtouch').play();
};
noButton.up = function () {
if (noButton.isPressed) {
noButton.scaleX /= 1.1;
noButton.scaleY /= 1.1;
noButton.isPressed = false;
console.log("Reset canceled");
self.removeChild(confirmReset);
self.removeChild(yesButton);
self.removeChild(noButton);
self.removeChild(yesText);
self.removeChild(noText);
self.removeChild(confirmResetBackground);
}
};
}
};
// Add a credits button
var creditsButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 550
});
self.addChild(creditsButton);
var creditsText = new Text2('Credits', {
size: 150,
fill: 0x000000,
font: "Medieval"
});
creditsText.anchor.set(0.5, 0.5);
creditsText.x = creditsButton.x;
creditsText.y = creditsButton.y;
self.addChild(creditsText);
// Add interaction to the credits button
creditsButton.down = function () {
creditsButton.isPressed = true;
creditsButton.scaleX *= 1.1;
creditsButton.scaleY *= 1.1;
LK.getSound('butomtouch').play();
};
creditsButton.up = function () {
if (creditsButton.isPressed) {
creditsButton.scaleX /= 1.1;
creditsButton.scaleY /= 1.1;
creditsButton.isPressed = false;
// Logic to show credits
game.showCreditsPage();
}
};
// Add a text display for the time played
var timePlayedText = new Text2('Time Played: 0s', {
size: 100,
fill: 0xFFFFFF,
font: "Medieval"
});
timePlayedText.anchor.set(0.5, 0.5);
timePlayedText.x = 2048 / 2;
timePlayedText.y = 2732 / 2 - 200;
self.addChild(timePlayedText);
// Update the time played text every second
LK.setInterval(function () {
var hours = Math.floor(timeGame / 3600);
var minutes = Math.floor(timeGame % 3600 / 60);
var seconds = timeGame % 60;
timePlayedText.setText('Time Played: ' + hours + 'h ' + minutes + 'm ' + seconds + 's');
}, 1000);
// Add a text display for the best time
var bestTimeText = new Text2('Best Time: ' + BestTime + 's', {
size: 100,
fill: 0xFFFFFF,
font: "Medieval"
});
bestTimeText.anchor.set(0.5, 0.5);
bestTimeText.x = 2048 / 2;
bestTimeText.y = 2732 / 2 - 100;
self.addChild(bestTimeText);
// Add a text display for the completion count
var completionText = new Text2('Completion: ' + complete, {
size: 100,
fill: 0xFFFFFF,
font: "Medieval"
});
completionText.anchor.set(0.5, 0.5);
completionText.x = 2048 / 2;
completionText.y = 2732 / 2;
self.addChild(completionText);
return self;
});
// Create a ForegroundOneContainer class
var ForegroundOneContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create a ForegroundTwoContainer class
var ForegroundTwoContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create an IntroductionPage class
var IntroductionPage = Container.expand(function () {
var self = Container.call(this);
// Add a background for the introduction page
var introductionBackground = self.attachAsset('Introduction', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Add a title text for the introduction page
var titleText = new Text2('Introduction Page', {
size: 200,
fill: 0xFFFFFF,
font: "Medieval"
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 200;
self.addChild(titleText);
// Add a button to return to the main menu
var backButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 - 200
});
self.addChild(backButton);
var backText = new Text2('Back', {
size: 150,
fill: 0x000000,
font: "Medieval"
});
backText.anchor.set(0.5, 0.5);
backText.x = backButton.x;
backText.y = backButton.y;
self.addChild(backText);
// Add interaction to the back button
backButton.down = function () {
backButton.isPressed = true;
backButton.scaleX *= 1.1;
backButton.scaleY *= 1.1;
LK.getSound('butomtouch').play();
};
backButton.up = function () {
if (backButton.isPressed) {
backButton.scaleX /= 1.1;
backButton.scaleY /= 1.1;
backButton.isPressed = false;
// Logic to return to the main menu
game.showMainMenu();
}
};
return self;
});
// Create a MidgroundContainer class
var MidgroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create a Player class
var Player = Container.expand(function () {
var self = Container.call(this);
// Create a list named 'rock' and add the 'Rock0' asset to it
var player = ['Rock0', 'Rock1', 'Rock2', 'Rock3', 'Rock4', 'Rock5', 'Rock6', 'Rock7', 'Rock8', 'Rock9', 'Rock10', 'Rock11', 'Rock12', 'Rock13', 'Rock14'];
self.playerGraphics = self.attachAsset(player[0], {
anchorX: 0.5,
anchorY: 0.5
});
// Set player speed
self.speed = 5;
// This is automatically called every game tick, if the player is attached!
self.update = function () {
self.y += self.speed;
// Add gravity to the player
if (self.y < 2732 / 2 - self.height / 2 + 50) {
self.speed += 0.5;
} else {
self.speed = 0;
self.y = 2732 / 2 - self.height / 2 + 50; // Ensure player lands correctly
jump = 2; // Reset jump count when player lands
}
// Add rotation to the player
self.rotation += 0.03;
// Play or pause rockmovement sound based on rock's position
if (self.y < 2732 / 2 - self.height / 2 + 50) {
LK.getSound('rockmovement').stop(); // Stop sound when rock is in the air
self.lastWasOnGround = false; // Track if the rock was on the ground
} else {
if (!self.lastWasOnGround) {
LK.getSound('rockFall').play(); // Play rockfall sound when rock lands
LK.setTimeout(function () {
LK.getSound('rockmovement').play({
loop: true
}); // Play sound when rock is on the ground after rockfall
}, 100); // Delay rockmovement sound by 100ms after rockfall
} else {
LK.getSound('rockmovement').play({
loop: true
}); // Ensure rockmovement sound loops continuously
}
self.lastWasOnGround = true; // Update the state to indicate rock is on the ground
}
};
});
// Create a RockPage class
var RockPage = Container.expand(function () {
var self = Container.call(this);
// Add a background for the rock page
var rockBackground = self.attachAsset('menuRock', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
return self;
});
// Create a ShopPage class
var ShopPage = Container.expand(function () {
var self = Container.call(this);
// Add a background for the shop page
var shopBackground = self.attachAsset('menuShop', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Add a title text for the shop page
var titleText = new Text2('Shop Page', {
size: 200,
fill: 0xFFFFFF,
font: "Medieval"
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 200;
self.addChild(titleText);
// Add a button to return to the main menu
var backButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 - 200
});
self.addChild(backButton);
var backText = new Text2('Back', {
size: 150,
fill: 0x000000,
font: "Medieval"
});
backText.anchor.set(0.5, 0.5);
backText.x = backButton.x;
backText.y = backButton.y;
self.addChild(backText);
// Add interaction to the back button
backButton.down = function () {
backButton.isPressed = true;
backButton.scaleX *= 1.1;
backButton.scaleY *= 1.1;
LK.getSound('butomtouch').play();
};
backButton.up = function () {
if (backButton.isPressed) {
backButton.scaleX /= 1.1;
backButton.scaleY /= 1.1;
backButton.isPressed = false;
// Logic to return to the main menu
game.showMainMenu();
}
};
// Add item asset display
self.itemBackground = {};
// Add a buyable item 'Coin Upgrade' to the shop page
self.coinUpgradeBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.coinUpgradeBackground);
// Add 'Coin Upgrade' item title
var coinUpgradeTitle = new Text2('', {
size: 60,
fill: 0xFFFFFF,
font: "Medieval"
});
coinUpgradeTitle.anchor.set(0.5, 0.5);
coinUpgradeTitle.x = self.coinUpgradeBackground.x;
coinUpgradeTitle.y = self.coinUpgradeBackground.y - 100;
self.addChild(coinUpgradeTitle);
var coinUpgradeDescription = new Text2('', {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
coinUpgradeDescription.anchor.set(0.5, 0.5);
coinUpgradeDescription.x = self.coinUpgradeBackground.x;
coinUpgradeDescription.y = self.coinUpgradeBackground.y;
self.addChild(coinUpgradeDescription);
// Set initial text based on CoinUpgrade level
if (CoinUpgrade === 0) {
coinUpgradeTitle.setText('Coin Upgrade');
coinUpgradeDescription.setText('Increases Coin Upgrade by 1.');
} else if (CoinUpgrade === 1) {
coinUpgradeTitle.setText('Bronze Coin');
coinUpgradeDescription.setText('You have upgraded to a Bronze Coin.');
} else if (CoinUpgrade === 2) {
coinUpgradeTitle.setText('Silver Coin');
coinUpgradeDescription.setText('You have upgraded to a Silver Coin.');
} else if (CoinUpgrade === 3) {
coinUpgradeTitle.setText('Golden Coin');
coinUpgradeDescription.setText('You have upgraded to a Golden Coin.');
} else if (CoinUpgrade === 4) {
coinUpgradeTitle.setText('Diamond');
coinUpgradeDescription.setText('You have upgraded to a Diamond.');
}
var coinUpgradePrice = CoinUpgrade === 0 ? 25 : CoinUpgrade === 1 ? 2500 : CoinUpgrade === 2 ? 25000 : 250000; // Set prices for each Coin Upgrade level
var coinUpgradePriceText = new Text2('Price: ' + coinUpgradePrice, {
size: 70,
fill: 0xFFD700,
font: "Medieval"
});
coinUpgradePriceText.anchor.set(0.5, 0.5);
coinUpgradePriceText.x = self.coinUpgradeBackground.x;
coinUpgradePriceText.y = self.coinUpgradeBackground.y + 100;
self.addChild(coinUpgradePriceText);
// Add interaction to the 'Coin Upgrade' item background
self.coinUpgradeBackground.down = function () {
self.coinUpgradeBackground.isPressed = true;
self.coinUpgradeBackground.scaleX *= 0.9;
self.coinUpgradeBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.coinUpgradeBackground.up = function () {
if (self.coinUpgradeBackground.isPressed) {
self.coinUpgradeBackground.scaleX /= 0.9;
self.coinUpgradeBackground.scaleY /= 0.9;
self.coinUpgradeBackground.isPressed = false;
// Check if the Coin Upgrade can be purchased
if (money >= coinUpgradePrice) {
money -= coinUpgradePrice;
if (CoinUpgrade < 4) {
CoinUpgrade += 1; // Increase CoinUpgrade by 1
coinUpgradeQuantityText.setText('Quantity: ' + CoinUpgrade); // Update the quantity display
if (CoinUpgrade === 1) {
coinUpgradeTitle.setText('Bronze Coin');
coinUpgradeDescription.setText('You have upgraded to a Bronze Coin.');
coinUpgradePrice = 2500; // Set price for Silver Coin
} else if (CoinUpgrade === 2) {
coinUpgradeTitle.setText('Silver Coin');
coinUpgradeDescription.setText('You have upgraded to a Silver Coin.');
coinUpgradePrice = 25000; // Set price for Golden Coin
} else if (CoinUpgrade === 3) {
coinUpgradeTitle.setText('Golden Coin');
coinUpgradeDescription.setText('You have upgraded to a Golden Coin.');
coinUpgradePrice = 250000; // Set price for Diamond
} else if (CoinUpgrade === 4) {
coinUpgradeTitle.setText('Diamond');
coinUpgradeDescription.setText('You have upgraded to a Diamond.');
}
coinUpgradePriceText.setText('Purchased');
coinUpgradePriceText.fill = 0x00FF00; // Set text color to green
LK.setTimeout(function () {
if (CoinUpgrade < 4) {
coinUpgradePriceText.setText('Price: ' + coinUpgradePrice);
coinUpgradePriceText.fill = 0xFFD700; // Revert text color to gold
} else {
coinUpgradePriceText.setText('Max Upgrades Reached');
coinUpgradePriceText.fill = 0xFF0000; // Set text color to red
}
}, 2000); // Display 'Purchased' for 2 seconds
} else {
coinUpgradePriceText.setText('Max Upgrades Reached');
coinUpgradePriceText.fill = 0xFF0000; // Set text color to red
}
} else {
coinUpgradePriceText.setText('Insufficient Money');
coinUpgradePriceText.fill = 0xFF0000; // Set text color to red
LK.setTimeout(function () {
coinUpgradePriceText.setText('Price: ' + coinUpgradePrice);
coinUpgradePriceText.fill = 0xFFD700; // Revert text color to gold
}, 2000); // Display for 2 seconds
}
if (CoinUpgrade >= 4) {
coinUpgradePriceText.setText('Max Upgrades Reached');
coinUpgradePriceText.fill = 0xFF0000; // Set text color to red
self.coinUpgradeBackground.down = null; // Disable button interaction
self.coinUpgradeBackground.up = null; // Disable button interaction
}
}
};
// Add a text display for the quantity of CoinUpgrade in the top-right corner
var coinUpgradeQuantityText = new Text2('Quantity: ' + CoinUpgrade, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
coinUpgradeQuantityText.anchor.set(1, 0); // Anchor to the top-right corner
coinUpgradeQuantityText.x = self.coinUpgradeBackground.x + self.coinUpgradeBackground.width / 2 - coinUpgradeQuantityText.width - 10;
coinUpgradeQuantityText.y = self.coinUpgradeBackground.y - self.coinUpgradeBackground.height / 2 + 10;
self.addChild(coinUpgradeQuantityText);
return self;
});
// Create an UpgradePage class
var UpgradePage = Container.expand(function () {
var self = Container.call(this);
// Add a background for the upgrade page
var upgradeBackground = self.attachAsset('menuUpgrade', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Add a title text for the upgrade page
var titleText = new Text2('Pets Page', {
size: 200,
fill: 0xFFFFFF,
font: "Medieval"
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 200;
self.addChild(titleText);
// Add a button to return to the main menu
var backButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 - 200
});
self.addChild(backButton);
var backText = new Text2('Back', {
size: 150,
fill: 0x000000,
font: "Medieval"
});
backText.anchor.set(0.5, 0.5);
backText.x = backButton.x;
backText.y = backButton.y;
self.addChild(backText);
// Add interaction to the back button
backButton.down = function () {
backButton.isPressed = true;
backButton.scaleX *= 1.1;
backButton.scaleY *= 1.1;
LK.getSound('butomtouch').play();
};
backButton.up = function () {
if (backButton.isPressed) {
backButton.scaleX /= 1.1;
backButton.scaleY /= 1.1;
backButton.isPressed = false;
// Logic to return to the main menu
game.showMainMenu();
littleMousePrice = littleMouse === 0 ? 0 : littleMouse;
littleMousePriceText.setText('Price: ' + littleMousePrice.toLocaleString()); // Update the price display
}
};
// Add a buyable item 'Little Mouse' to the upgrade page
self.littleMouseBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 4 + 100,
//{9C} // Adjusted for two-column layout
y: 2732 / 2 - 500,
//{9D} // Adjusted for three-row layout
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.littleMouseBackground);
// Add 'Little Mouse' item title
function createPetText(text, size, fill, x, y) {
var textObj = new Text2(text, {
size: size,
fill: fill,
font: "Medieval"
});
textObj.anchor.set(0.5, 0.5);
textObj.x = x;
textObj.y = y;
return textObj;
}
var littleMouseTitle = createPetText('Little Mouse', 60, 0xFFFFFF, self.littleMouseBackground.x, self.littleMouseBackground.y - 100);
self.addChild(littleMouseTitle);
var littleMouseDescription = createPetText('A small and nimble mouse.\nIncreases money by 0.02 per second.', 50, 0xFFFFFF, self.littleMouseBackground.x, self.littleMouseBackground.y);
self.addChild(littleMouseDescription);
var littleMousePriceText = createPetText('Price: ' + littleMousePrice, 70, 0xFFD700, self.littleMouseBackground.x, self.littleMouseBackground.y + 100);
self.addChild(littleMousePriceText);
// Add interaction to the 'Little Mouse' item background
self.littleMouseBackground.down = function () {
self.littleMouseBackground.isPressed = true;
self.littleMouseBackground.scaleX *= 0.9;
self.littleMouseBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.littleMouseBackground.up = function () {
if (self.littleMouseBackground.isPressed) {
self.littleMouseBackground.scaleX /= 0.9;
self.littleMouseBackground.scaleY /= 0.9;
self.littleMouseBackground.isPressed = false;
// Check if the Little Mouse has already been purchased
var price = littleMousePrice;
if (money >= price) {
money -= price;
littleMouse += 1; // Increase littleMouse count by 1
updateMoneyPerSecond(); // Update moneyPerSecond
littleMouseQuantityText.setText('Quantity: ' + littleMouse); // Update the quantity display
littleMousePrice = littleMouse * 1; // Update the price
littleMousePriceText.setText('Price: ' + littleMousePrice); // Update the price display
} else if (littleMousePriceText.text !== 'Insufficient Money') {
littleMousePriceText.setText('Insufficient Money'); // Show insufficient money message
littleMousePriceText.fill = 0xFF0000; // Set text color to red
LK.setTimeout(function () {
littleMousePriceText.setText('Price: ' + littleMousePrice); // Revert to original price text
littleMousePriceText.fill = 0xFFD700; // Revert text color to gold
}, 2000); // Display for 2 seconds
}
}
};
// Add a text display for the quantity of littleMouse in the top-right corner
var littleMouseQuantityText = new Text2('Quantity: ' + littleMouse, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
littleMouseQuantityText.anchor.set(1, 0); // Anchor to the top-right corner
littleMouseQuantityText.x = self.littleMouseBackground.x + self.littleMouseBackground.width / 2 - littleMouseQuantityText.width - 10;
littleMouseQuantityText.y = self.littleMouseBackground.y - self.littleMouseBackground.height / 2 + 10;
self.addChild(littleMouseQuantityText);
// Add a buyable item 'Doggy' to the upgrade page
self.doggyBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 3 * 2048 / 4 - 100,
//{a7} // Adjusted for two-column layout
y: 2732 / 2 - 500,
//{a8} // Adjusted for three-row layout
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.doggyBackground);
// Add 'Doggy' item title
var doggyTitle = createPetText('Doggy', 60, 0xFFFFFF, self.doggyBackground.x, self.doggyBackground.y - 100);
self.addChild(doggyTitle);
var doggyDescription = createPetText('A loyal companion.\nIncreases money by 0.2 per second.', 50, 0xFFFFFF, self.doggyBackground.x, self.doggyBackground.y);
self.addChild(doggyDescription);
var doggyPriceText = createPetText('Price: ' + (10 + doggy * 10), 70, 0xFFD700, self.doggyBackground.x, self.doggyBackground.y + 100);
self.addChild(doggyPriceText);
// Add interaction to the 'Doggy' item background
self.doggyBackground.down = function () {
self.doggyBackground.isPressed = true;
self.doggyBackground.scaleX *= 0.9;
self.doggyBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.doggyBackground.up = function () {
if (self.doggyBackground.isPressed) {
self.doggyBackground.scaleX /= 0.9;
self.doggyBackground.scaleY /= 0.9;
self.doggyBackground.isPressed = false;
// Check if the Doggy can be purchased
var price = 10 + doggy * 10;
if (money >= price && littleMouse >= 15) {
money -= price;
doggy += 1; // Increase doggy count by 1
doggyPriceText.setText('Price: ' + (10 + doggy * 10).toLocaleString()); // Update the price display
doggyPriceText.fill = 0xFFD700; // Set text color to gold
doggyQuantityText.setText('Quantity: ' + doggy); // Update the quantity display
updateMoneyPerSecond(); // Update moneyPerSecond
} else if (littleMouse < 15) {
doggyPriceText.setText('Need 15 Little Mice'); // Show requirement
doggyPriceText.fill = 0xFF0000; // Set text color to red
tween(doggyPriceText, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
doggyPriceText.setText('Price: ' + (10 + doggy * 10)); // Revert to original price text
doggyPriceText.fill = 0xFFD700; // Revert text color to gold
doggyPriceText.alpha = 1; // Reset alpha
}
});
} else {
doggyPriceText.setText('Insufficient Money'); // Show insufficient money message
doggyPriceText.fill = 0xFF0000; // Set text color to red
LK.setTimeout(function () {
doggyPriceText.setText('Price: ' + (10 + doggy * 10)); // Revert to original price text
doggyPriceText.fill = 0xFFD700; // Revert text color to gold
}, 2000); // Display for 2 seconds
}
}
};
// Add a text display for the quantity of doggy in the top-right corner
var doggyQuantityText = new Text2('Quantity: ' + doggy, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
doggyQuantityText.anchor.set(1, 0); // Anchor to the top-right corner
doggyQuantityText.x = self.doggyBackground.x + self.doggyBackground.width / 2 - doggyQuantityText.width - 10;
doggyQuantityText.y = self.doggyBackground.y - self.doggyBackground.height / 2 + 10;
self.addChild(doggyQuantityText);
// Add a buyable item 'Monkey' to the upgrade page
self.monkeyBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 4 + 100,
//{aB} // Adjusted for two-column layout
y: 2732 / 2 - 100,
//{aC} // Adjusted for three-row layout
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.monkeyBackground);
// Add 'Monkey' item title
var monkeyTitle = createPetText('Monkey', 60, 0xFFFFFF, self.monkeyBackground.x, self.monkeyBackground.y - 100);
self.addChild(monkeyTitle);
var monkeyDescription = createPetText('A playful monkey.\nIncreases money by 2 per second.', 50, 0xFFFFFF, self.monkeyBackground.x, self.monkeyBackground.y);
self.addChild(monkeyDescription);
var monkeyPriceText = createPetText('Price: ' + (100 + monkey * 100), 70, 0xFFD700, self.monkeyBackground.x, self.monkeyBackground.y + 100);
self.addChild(monkeyPriceText);
// Add interaction to the 'Monkey' item background
self.monkeyBackground.down = function () {
self.monkeyBackground.isPressed = true;
self.monkeyBackground.scaleX *= 0.9;
self.monkeyBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.monkeyBackground.up = function () {
if (self.monkeyBackground.isPressed) {
self.monkeyBackground.scaleX /= 0.9;
self.monkeyBackground.scaleY /= 0.9;
self.monkeyBackground.isPressed = false;
// Check if the Monkey can be purchased
var price = 100 + monkey * 100;
if (money >= price && doggy >= 15) {
money -= price;
monkey += 1; // Increase monkey count by 1
monkeyPriceText.setText('Price: ' + (100 + monkey * 100).toLocaleString()); // Update the price display
monkeyPriceText.fill = 0xFFD700; // Set text color to gold
monkeyQuantityText.setText('Quantity: ' + monkey); // Update the quantity display
updateMoneyPerSecond(); // Update moneyPerSecond
} else if (doggy < 15) {
monkeyPriceText.setText('Need 15 Doggies'); // Show requirement
monkeyPriceText.fill = 0xFF0000; // Set text color to red
tween(monkeyPriceText, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
monkeyPriceText.setText('Price: ' + (100 + monkey * 100)); // Revert to original price text
monkeyPriceText.fill = 0xFFD700; // Revert text color to gold
monkeyPriceText.alpha = 1; // Reset alpha
}
});
} else {
monkeyPriceText.setText('Insufficient Money'); // Show insufficient money message
monkeyPriceText.fill = 0xFF0000; // Set text color to red
LK.setTimeout(function () {
monkeyPriceText.setText('Price: ' + (100 + monkey * 100)); // Revert to original price text
monkeyPriceText.fill = 0xFFD700; // Revert text color to gold
}, 2000); // Display for 2 seconds
}
}
};
// Add a text display for the quantity of monkey in the top-right corner
var monkeyQuantityText = new Text2('Quantity: ' + monkey, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
monkeyQuantityText.anchor.set(1, 0); // Anchor to the top-right corner
monkeyQuantityText.x = self.monkeyBackground.x + self.monkeyBackground.width / 2 - monkeyQuantityText.width - 10;
monkeyQuantityText.y = self.monkeyBackground.y - self.monkeyBackground.height / 2 + 10;
self.addChild(monkeyQuantityText);
// Add a buyable item 'Villager' to the upgrade page
self.villagerBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 3 * 2048 / 4 - 100,
y: 2732 / 2 - 100,
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.villagerBackground);
// Add 'Villager' item title
var villagerTitle = createPetText('Villager', 60, 0xFFFFFF, self.villagerBackground.x, self.villagerBackground.y - 100);
self.addChild(villagerTitle);
var villagerDescription = createPetText('A helpful villager.\nIncreases money by 10 per second.', 50, 0xFFFFFF, self.villagerBackground.x, self.villagerBackground.y);
self.addChild(villagerDescription);
var villagerPriceText = createPetText('Price: ' + (1000 + villager * 1000), 70, 0xFFD700, self.villagerBackground.x, self.villagerBackground.y + 100);
self.addChild(villagerPriceText);
// Add interaction to the 'Villager' item background
self.villagerBackground.down = function () {
self.villagerBackground.isPressed = true;
self.villagerBackground.scaleX *= 0.9;
self.villagerBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.villagerBackground.up = function () {
if (self.villagerBackground.isPressed) {
self.villagerBackground.scaleX /= 0.9;
self.villagerBackground.scaleY /= 0.9;
self.villagerBackground.isPressed = false;
// Check if the Villager can be purchased
var price = 1000 + villager * 1000;
if (money >= price && monkey >= 15) {
money -= price;
villager += 1; // Increase villager count by 1
villagerPriceText.setText('Price: ' + (1000 + villager * 1000).toLocaleString()); // Update the price display
villagerPriceText.fill = 0xFFD700; // Set text color to gold
villagerQuantityText.setText('Quantity: ' + villager); // Update the quantity display
updateMoneyPerSecond(); // Update moneyPerSecond
} else if (monkey < 15) {
villagerPriceText.setText('Need 15 Monkeys'); // Show requirement
villagerPriceText.fill = 0xFF0000; // Set text color to red
tween(villagerPriceText, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
villagerPriceText.setText('Price: ' + (1000 + villager * 1000)); // Revert to original price text
villagerPriceText.fill = 0xFFD700; // Revert text color to gold
villagerPriceText.alpha = 1; // Reset alpha
}
});
} else {
villagerPriceText.setText('Insufficient Money'); // Show insufficient money message
villagerPriceText.fill = 0xFF0000; // Set text color to red
LK.setTimeout(function () {
villagerPriceText.setText('Price: ' + (1000 + villager * 1000)); // Revert to original price text
villagerPriceText.fill = 0xFFD700; // Revert text color to gold
}, 2000); // Display for 2 seconds
}
}
};
// Add a text display for the quantity of villager in the top-right corner
var villagerQuantityText = new Text2('Quantity: ' + villager, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
villagerQuantityText.anchor.set(1, 0); // Anchor to the top-right corner
villagerQuantityText.x = self.villagerBackground.x + self.villagerBackground.width / 2 - villagerQuantityText.width - 10;
villagerQuantityText.y = self.villagerBackground.y - self.villagerBackground.height / 2 + 10;
self.addChild(villagerQuantityText);
// Add a buyable item 'Peasant' to the upgrade page
self.peasantBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 4 + 100,
y: 2732 / 2 + 300,
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.peasantBackground);
// Add 'Peasant' item title
var peasantTitle = createPetText('Peasant', 60, 0xFFFFFF, self.peasantBackground.x, self.peasantBackground.y - 100);
self.addChild(peasantTitle);
var peasantDescription = createPetText('A hardworking peasant.\nIncreases money by 20 per second.', 50, 0xFFFFFF, self.peasantBackground.x, self.peasantBackground.y);
self.addChild(peasantDescription);
var peasantPriceText = createPetText('Price: ' + (5000 + peasant * 5000), 70, 0xFFD700, self.peasantBackground.x, self.peasantBackground.y + 100);
self.addChild(peasantPriceText);
// Add interaction to the 'Peasant' item background
self.peasantBackground.down = function () {
self.peasantBackground.isPressed = true;
self.peasantBackground.scaleX *= 0.9;
self.peasantBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.peasantBackground.up = function () {
if (self.peasantBackground.isPressed) {
self.peasantBackground.scaleX /= 0.9;
self.peasantBackground.scaleY /= 0.9;
self.peasantBackground.isPressed = false;
// Check if the Peasant can be purchased
var price = 5000 + peasant * 5000;
if (money >= price && villager >= 15) {
money -= price;
peasant += 1;
peasantPriceText.setText('Price: ' + (5000 + peasant * 5000).toLocaleString());
peasantPriceText.fill = 0xFFD700;
peasantQuantityText.setText('Quantity: ' + peasant);
updateMoneyPerSecond();
} else if (villager < 15) {
peasantPriceText.setText('Need 15 Villagers'); // Show requirement
peasantPriceText.fill = 0xFF0000; // Set text color to red
tween(peasantPriceText, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
peasantPriceText.setText('Price: ' + (5000 + peasant * 5000)); // Revert to original price text
peasantPriceText.fill = 0xFFD700; // Revert text color to gold
peasantPriceText.alpha = 1; // Reset alpha
}
});
} else {
peasantPriceText.setText('Insufficient Money');
peasantPriceText.fill = 0xFF0000;
LK.setTimeout(function () {
peasantPriceText.setText('Price: ' + (5000 + peasant * 5000));
peasantPriceText.fill = 0xFFD700;
}, 2000);
}
}
};
// Add a text display for the quantity of peasant in the top-right corner
var peasantQuantityText = new Text2('Quantity: ' + peasant, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
peasantQuantityText.anchor.set(1, 0);
peasantQuantityText.x = self.peasantBackground.x + self.peasantBackground.width / 2 - peasantQuantityText.width - 10;
peasantQuantityText.y = self.peasantBackground.y - self.peasantBackground.height / 2 + 10;
self.addChild(peasantQuantityText);
// Add a buyable item 'Warrior' to the upgrade page
self.warriorBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 3 * 2048 / 4 - 100,
y: 2732 / 2 + 300,
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.warriorBackground);
// Add 'Warrior' item title
var warriorTitle = createPetText('Warrior', 60, 0xFFFFFF, self.warriorBackground.x, self.warriorBackground.y - 100);
self.addChild(warriorTitle);
var warriorDescription = createPetText('A brave warrior.\nIncreases money by 50 per second.', 50, 0xFFFFFF, self.warriorBackground.x, self.warriorBackground.y);
self.addChild(warriorDescription);
var warriorPriceText = createPetText('Price: ' + (20000 + warrior * 20000), 70, 0xFFD700, self.warriorBackground.x, self.warriorBackground.y + 100);
self.addChild(warriorPriceText);
// Add interaction to the 'Warrior' item background
self.warriorBackground.down = function () {
self.warriorBackground.isPressed = true;
self.warriorBackground.scaleX *= 0.9;
self.warriorBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.warriorBackground.up = function () {
if (self.warriorBackground.isPressed) {
self.warriorBackground.scaleX /= 0.9;
self.warriorBackground.scaleY /= 0.9;
self.warriorBackground.isPressed = false;
// Check if the Warrior can be purchased
var price = 20000 + warrior * 20000;
if (money >= price && peasant >= 15) {
money -= price;
warrior += 1;
warriorPriceText.setText('Price: ' + (20000 + warrior * 20000).toLocaleString());
warriorPriceText.fill = 0xFFD700;
warriorQuantityText.setText('Quantity: ' + warrior);
updateMoneyPerSecond();
} else if (peasant < 15) {
warriorPriceText.setText('Need 15 Peasants'); // Show requirement
warriorPriceText.fill = 0xFF0000; // Set text color to red
tween(warriorPriceText, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
warriorPriceText.setText('Price: ' + (20000 + warrior * 20000)); // Revert to original price text
warriorPriceText.fill = 0xFFD700; // Revert text color to gold
warriorPriceText.alpha = 1; // Reset alpha
}
});
} else {
warriorPriceText.setText('Insufficient Money');
warriorPriceText.fill = 0xFF0000;
LK.setTimeout(function () {
warriorPriceText.setText('Price: ' + (20000 + warrior * 20000));
warriorPriceText.fill = 0xFFD700;
}, 2000);
}
}
};
// Add a text display for the quantity of warrior in the top-right corner
var warriorQuantityText = new Text2('Quantity: ' + warrior, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
warriorQuantityText.anchor.set(1, 0);
warriorQuantityText.x = self.warriorBackground.x + self.warriorBackground.width / 2 - warriorQuantityText.width - 10;
warriorQuantityText.y = self.warriorBackground.y - self.warriorBackground.height / 2 + 10;
self.addChild(warriorQuantityText);
// Add a buyable item 'Bourgeois' to the upgrade page
self.bourgeoisBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 4 + 100,
y: 2732 / 2 + 700,
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.bourgeoisBackground);
// Add 'Bourgeois' item title
var bourgeoisTitle = createPetText('Bourgeois', 60, 0xFFFFFF, self.bourgeoisBackground.x, self.bourgeoisBackground.y - 100);
self.addChild(bourgeoisTitle);
var bourgeoisDescription = createPetText('A wealthy bourgeois.\nIncreases money by 100 per second.', 50, 0xFFFFFF, self.bourgeoisBackground.x, self.bourgeoisBackground.y);
self.addChild(bourgeoisDescription);
var bourgeoisPriceText = createPetText('Price: ' + (50000 + bourgeois * 50000), 70, 0xFFD700, self.bourgeoisBackground.x, self.bourgeoisBackground.y + 100);
self.addChild(bourgeoisPriceText);
// Add interaction to the 'Bourgeois' item background
self.bourgeoisBackground.down = function () {
self.bourgeoisBackground.isPressed = true;
self.bourgeoisBackground.scaleX *= 0.9;
self.bourgeoisBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.bourgeoisBackground.up = function () {
if (self.bourgeoisBackground.isPressed) {
self.bourgeoisBackground.scaleX /= 0.9;
self.bourgeoisBackground.scaleY /= 0.9;
self.bourgeoisBackground.isPressed = false;
// Check if the Bourgeois can be purchased
var price = 50000 + bourgeois * 50000;
if (money >= price && warrior >= 15) {
money -= price;
bourgeois += 1;
bourgeoisPriceText.setText('Price: ' + (50000 + bourgeois * 50000).toLocaleString());
bourgeoisPriceText.fill = 0xFFD700;
bourgeoisQuantityText.setText('Quantity: ' + bourgeois);
updateMoneyPerSecond();
} else if (warrior < 15) {
bourgeoisPriceText.setText('Need 15 Warriors'); // Show requirement
bourgeoisPriceText.fill = 0xFF0000; // Set text color to red
tween(bourgeoisPriceText, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
bourgeoisPriceText.setText('Price: ' + (50000 + bourgeois * 50000)); // Revert to original price text
bourgeoisPriceText.fill = 0xFFD700; // Revert text color to gold
bourgeoisPriceText.alpha = 1; // Reset alpha
}
});
} else {
bourgeoisPriceText.setText('Insufficient Money');
bourgeoisPriceText.fill = 0xFF0000;
LK.setTimeout(function () {
bourgeoisPriceText.setText('Price: ' + (50000 + bourgeois * 50000));
bourgeoisPriceText.fill = 0xFFD700;
}, 2000);
}
}
};
// Add a text display for the quantity of bourgeois in the top-right corner
var bourgeoisQuantityText = new Text2('Quantity: ' + bourgeois, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
bourgeoisQuantityText.anchor.set(1, 0);
bourgeoisQuantityText.x = self.bourgeoisBackground.x + self.bourgeoisBackground.width / 2 - bourgeoisQuantityText.width - 10;
bourgeoisQuantityText.y = self.bourgeoisBackground.y - self.bourgeoisBackground.height / 2 + 10;
self.addChild(bourgeoisQuantityText);
// Add a buyable item 'King' to the upgrade page
self.kingBackground = self.attachAsset('ItemShopMarco', {
anchorX: 0.5,
anchorY: 0.5,
x: 3 * 2048 / 4 - 100,
y: 2732 / 2 + 700,
scaleX: 0.7,
scaleY: 0.7
});
self.addChild(self.kingBackground);
// Add 'King' item title
var kingTitle = createPetText('King', 60, 0xFFFFFF, self.kingBackground.x, self.kingBackground.y - 100);
self.addChild(kingTitle);
var kingDescription = createPetText('A powerful king.\nIncreases money by 200 per second.', 50, 0xFFFFFF, self.kingBackground.x, self.kingBackground.y);
self.addChild(kingDescription);
var kingPriceText = createPetText('Price: ' + (100000 + king * 100000), 70, 0xFFD700, self.kingBackground.x, self.kingBackground.y + 100);
self.addChild(kingPriceText);
// Add interaction to the 'King' item background
self.kingBackground.down = function () {
self.kingBackground.isPressed = true;
self.kingBackground.scaleX *= 0.9;
self.kingBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
self.kingBackground.up = function () {
if (self.kingBackground.isPressed) {
self.kingBackground.scaleX /= 0.9;
self.kingBackground.scaleY /= 0.9;
self.kingBackground.isPressed = false;
// Check if the King can be purchased
var price = 100000 + king * 100000;
if (money >= price && bourgeois >= 15) {
money -= price;
king += 1;
kingPriceText.setText('Price: ' + (100000 + king * 100000).toLocaleString());
kingPriceText.fill = 0xFFD700;
kingQuantityText.setText('Quantity: ' + king);
updateMoneyPerSecond();
} else if (bourgeois < 15) {
kingPriceText.setText('Need 15 Bourgeois'); // Show requirement
kingPriceText.fill = 0xFF0000; // Set text color to red
tween(kingPriceText, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
kingPriceText.setText('Price: ' + (100000 + king * 100000)); // Revert to original price text
kingPriceText.fill = 0xFFD700; // Revert text color to gold
kingPriceText.alpha = 1; // Reset alpha
}
});
} else {
kingPriceText.setText('Insufficient Money');
kingPriceText.fill = 0xFF0000;
LK.setTimeout(function () {
kingPriceText.setText('Price: ' + (100000 + king * 100000));
kingPriceText.fill = 0xFFD700;
}, 2000);
}
}
};
// Add a text display for the quantity of king in the top-right corner
var kingQuantityText = new Text2('Quantity: ' + king, {
size: 50,
fill: 0xFFFFFF,
font: "Medieval"
});
kingQuantityText.anchor.set(1, 0);
kingQuantityText.x = self.kingBackground.x + self.kingBackground.width / 2 - kingQuantityText.width - 10;
kingQuantityText.y = self.kingBackground.y - self.kingBackground.height / 2 + 10;
self.addChild(kingQuantityText);
return self;
});
// Create a Text class to display the meters covered
var MeterText = Text2.expand(function () {
var self = Text2.call(this, '0', {
size: 100,
fill: 0xFFFFFF
});
self.update = function () {
self.setText('Travel: ' + (meters / 1000).toFixed(2).toLocaleString() + ' km');
};
});
// Adjusted Y position for MoneyText
// Create a MoneyPerSecondText class to display the money earned per second
var MoneyPerSecondText = Text2.expand(function () {
var self = Text2.call(this, '0', {
size: 100,
fill: 0xFFFFFF
});
self.update = function () {
self.setText('Money/Sec: ' + moneyPerSecond.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ","));
};
});
// Create a MoneyPerSecondText instance and add it to the game
// Create a MoneyText class to display the amount of 'money'
var MoneyText = Text2.expand(function () {
var self = Text2.call(this, '0', {
size: 100,
fill: 0xFFFFFF
});
self.update = function () {
self.setText('Money: ' + money.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ","));
};
});
/****
* Initialize Game
****/
// Initialize BackgroundContainer, MidgroundContainer, and ForegroundContainer
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var CoinUpgrade = storage.CoinUpgrade || 0;
var BestTime = storage.BestTime || 0; // Initialize BestTime from storage or default to 0
var complete = storage.complete || 0; // Initialize complete status from storage or default to 0
// Function to handle item interaction
function handleItemInteraction(itemBackground, itemPriceText, price, purchaseKey) {
itemBackground.down = function () {
itemBackground.isPressed = true;
itemBackground.scaleX *= 0.9;
itemBackground.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
itemBackground.up = function () {
if (itemBackground.isPressed) {
itemBackground.scaleX /= 0.9;
itemBackground.scaleY /= 0.9;
itemBackground.isPressed = false;
if (money >= price) {
money -= price;
storage[purchaseKey] = true; // Mark the item as purchased
itemPriceText.setText('Purchased');
itemPriceText.fill = 0x00FF00; // Set text color to green
} else {
itemPriceText.setText('Insufficient Money');
itemPriceText.fill = 0xFF0000; // Set text color to red
LK.setTimeout(function () {
itemPriceText.setText('Price: ' + price);
itemPriceText.fill = 0xFFD700; // Revert text color to gold
}, 2000); // Display for 2 seconds
}
}
};
}
// Function to create item text with specified properties
function createItemText(text, size, fill, x, y) {
var textObj = new Text2(text, {
size: size,
fill: fill,
font: "Medieval"
});
textObj.anchor.set(0.5, 0.5);
textObj.x = x;
textObj.y = y;
return textObj;
}
var monkey = storage.monkey || 0; // Load 'monkey' from storage or initialize to 0
var villager = storage.villager || 0; // Load villager from storage or initialize to 0
var timeGame = storage.timePlayed || 0; // Load time played from storage or initialize to 0
var doggy = storage.doggy || 0; // Load doggy from storage or initialize to 0
var littleMouse = storage.littleMouse || 0;
var littleMousePrice = littleMouse === 0 ? 0 : littleMouse;
var peasant = storage.peasant || 0; // Load peasant from storage or initialize to 0
var warrior = storage.warrior || 0; // Load warrior from storage or initialize to 0
var bourgeois = storage.bourgeois || 0; // Load bourgeois from storage or initialize to 0
var king = storage.king || 0; // Load king from storage or initialize to 0
game.showIntroductionPage = function () {
// Logic to display the introduction page
foregroundContainer.visible = false;
introductionPage.visible = true;
// Hide all other game elements to ensure only the introduction page is visible
backgroundContainer.visible = false;
midgroundContainer.visible = false;
jump = 0; // Set jump to 0 when on the introduction page
};
// Initialize the introduction page
var introductionPage = new IntroductionPage();
game.addChild(introductionPage);
introductionPage.visible = false; // Start with the introduction page hidden
// Initialize the extras page
var extrasPage = new ExtrasPage();
game.addChild(extrasPage);
extrasPage.visible = false; // Start with the extras page hidden
// Initialize the credits page
var creditsPage = new CreditsPage();
game.addChild(creditsPage);
creditsPage.visible = false; // Start with the credits page hidden
// Method to show the credits page
game.showCreditsPage = function () {
// Logic to display the credits page
foregroundContainer.visible = false;
creditsPage.visible = true;
// Hide all other game elements to ensure only the credits page is visible
backgroundContainer.visible = false;
midgroundContainer.visible = false;
extrasPage.visible = false; // Ensure the extras page is hidden when credits page is visible
jump = 0; // Set jump to 0 when on the credits page
};
// Method to show the extras page
game.showExtrasPage = function () {
// Logic to display the extras page
foregroundContainer.visible = false;
extrasPage.visible = true;
// Hide all other game elements to ensure only the extras page is visible
backgroundContainer.visible = false;
midgroundContainer.visible = false;
creditsPage.visible = false; // Ensure the credits page is hidden when extras page is visible
jump = 0; // Set jump to 0 when on the extras page
};
// Initialize the rock page
var rockPage = new RockPage();
game.addChild(rockPage);
rockPage.visible = false; // Start with the rock page hidden
// Initialize the shop page
var shopPage = new ShopPage();
game.addChild(shopPage);
shopPage.visible = false; // Start with the shop page hidden
// Ensure shopPage is initialized before accessing its properties
// Method to show the main menu
game.showMainMenu = function () {
// Logic to display the main menu
foregroundContainer.visible = true;
upgradePage.visible = false;
rockPage.visible = false; // Ensure the rock page is hidden
cosmeticPage.visible = false; // Ensure the cosmetic page is hidden
extrasPage.visible = false; // Ensure the extras page is hidden
shopPage.visible = false; // Ensure the shop page is hidden
// Show all other game elements to ensure the main menu is fully visible
backgroundContainer.visible = true;
midgroundContainer.visible = true;
jump = 0; // Set jump to 0 when on the main menu
};
// Method to show the shop page
game.showShopPage = function () {
// Logic to display the shop page
foregroundContainer.visible = false;
shopPage.visible = true;
// Hide all other game elements to ensure only the shop page is visible
backgroundContainer.visible = false;
midgroundContainer.visible = false;
jump = 0; // Set jump to 0 when on the shop page
};
// Method to show the upgrade page
game.showUpgradePage = function () {
// Logic to display the upgrade page
foregroundContainer.visible = false;
upgradePage.visible = true;
// Hide all other game elements to ensure only the upgrade page is visible
backgroundContainer.visible = false;
midgroundContainer.visible = false;
jump = 0; // Set jump to 0 when on the upgrade page
};
// Method to show the cosmetic page
game.showCosmeticPage = function () {
// Logic to display the cosmetic page
foregroundContainer.visible = false;
cosmeticPage.visible = true;
// Hide all other game elements to ensure only the cosmetic page is visible
backgroundContainer.visible = false;
midgroundContainer.visible = false;
jump = 0; // Set jump to 0 when on the cosmetic page
};
// Initialize the upgrade page
var upgradePage = new UpgradePage();
game.addChild(upgradePage);
upgradePage.visible = false; // Start with the upgrade page hidden
// Initialize the cosmetic page
var cosmeticPage = new CosmeticPage();
game.addChild(cosmeticPage);
cosmeticPage.visible = false; // Start with the cosmetic page hidden
// Initialize BackgrounOneContainer, BackgrounTwoContainer, MidgroundContainer, ForegroundOneContainer, ForegroundTwoContainer, GuibackgroundContainer, GuigmidroundContainer and GuiforegroundContainer
var backgroundOneContainer = new BackgroundOneContainer();
var backgroundTwoContainer = new BackgroundTwoContainer();
var midgroundContainer = new MidgroundContainer();
var foregroundOneContainer = new ForegroundOneContainer();
var foregroundTwoContainer = new ForegroundTwoContainer();
var guibackgroundContainer = new GuibackgroundContainer();
var guimidgroundContainer = new GuimidgroundContainer();
var guiforegroundContainer = new GuiforegroundContainer();
// Add containers to the game in the correct order
game.addChild(backgroundOneContainer);
game.addChild(backgroundTwoContainer);
game.addChild(midgroundContainer);
game.addChild(foregroundOneContainer);
game.addChild(foregroundTwoContainer);
game.addChild(guibackgroundContainer);
game.addChild(guimidgroundContainer);
game.addChild(guiforegroundContainer);
//
var currentRockIndex = storage.currentRockIndex || 0; // Load saved player skin index or default to 0
var meters = storage.meters || 0; // Load saved meters or default to 0
var money = storage.money || 0; // Load saved money or default to 0
var moneyPerSecond = littleMouse * 0.02 + doggy * 0.2 + monkey * 2 + villager * 10 + peasant * 20 + warrior * 50 + bourgeois * 100 + king * 200; // Initialize moneyPerSecond based on all pets
// Create a loading bar at the bottom of the screen
var loadingBar = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 - 50,
scaleX: 0.0,
// Start with 0 scale to represent an empty bar
scaleY: 0.1 // Thin bar
});
foregroundContainer.addChild(loadingBar);
// Function to update moneyPerSecond based on littleMouse count
function updateMoneyPerSecond() {
moneyPerSecond = littleMouse * 0.02 + doggy * 0.2 + monkey * 2 + villager * 10 + peasant * 20 + warrior * 50 + bourgeois * 100 + king * 200;
}
// Initialize a rock asset with a design
var Rock = LK.getAsset('Playera0', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
backgroundContainer.addChild(Rock);
// Make the rock jump when the screen is touched
game.down = function (x, y, obj) {
if (jump > 0 && y < 2732 / 2 + 200) {
LK.getSound('rockjump').play(); // Play rockjump sound when the rock jumps
player.speed = -18; // Give an initial upward speed for the jump
player.y -= 10; // Adjust position slightly to ensure jump effect
player.update(); // Ensure the update method is called to apply the jump
jump--; // Decrease jump count
}
};
// Create a background asset using the saved skin index
var background = LK.getAsset('World0', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Add the background to the game
backgroundContainer.addChild(background);
// Create a clone of the background asset
var backgroundClone = LK.getAsset('World0', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + background.width,
y: 2732 / 2
});
// Add the clone to the game
backgroundContainer.addChild(backgroundClone);
// Create a second clone of the background asset
var backgroundClone2 = LK.getAsset('World0', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + 2 * background.width,
y: 2732 / 2
});
// Add the second clone to the game
backgroundContainer.addChild(backgroundClone2);
// Create a player instance and add it to the game
var player = midgroundContainer.addChild(new Player());
// Position player more towards the center of the screen
player.x = 2048 / 4;
player.y = 2732 / 2 + 10;
// Load and apply the saved player skin
player.removeChild(player.playerGraphics);
player.playerGraphics = player.attachAsset('Rock' + currentRockIndex, {
anchorX: 0.5,
anchorY: 0.5
});
player.addChild(player.playerGraphics);
// Initialize a variable to track 'meters'
// Initialize a variable to track available jumps
var jump = 2;
// Initialize a variable to track 'giros'
// Create a MeterText instance and add it to the game
var meterText = foregroundContainer.addChild(new MeterText());
// Position MeterText further down on the screen
meterText.x = 0;
meterText.y = 200; // Adjusted Y position for MeterText
// Create a GirosText instance and add it to the game
var moneyText = foregroundContainer.addChild(new MoneyText());
// Position MoneyText below the MeterText further down on the screen
moneyText.x = 0;
moneyText.y = meterText.y + meterText.height + 50;
// Create a MoneyPerSecondText instance and add it to the game
var goalText = new Text2('Goal for completion: 100,000,000 money', {
size: 100,
fill: 0xFFFFFF,
font: "Medieval"
});
goalText.anchor.set(0.5, 0.5);
goalText.x = 2048 / 2;
var moneyPerSecondText = foregroundContainer.addChild(new MoneyPerSecondText());
goalText.y = moneyPerSecondText.y + moneyPerSecondText.height + 50;
foregroundContainer.addChild(goalText);
// Position MoneyPerSecondText below the MoneyText further down on the screen
moneyPerSecondText.x = 0;
moneyPerSecondText.y = moneyText.y + moneyText.height + 50; // Adjusted Y position for MoneyPerSecondText
// Initialize a variable to track 'money'
// Create a list named 'rock' and add all the 'rock<number>' assets to it
// Ensure rock array is initialized with all rock assets
var Rock = ['Rock0', 'Rock1', 'Rock2', 'Rock3', 'Rock4', 'Rock5', 'Rock6', 'Rock7', 'Rock8', 'Rock9'];
// Create a list named 'SkinSelect'
var SkinSelect = [];
var assets = LK.assets;
if (assets) {
for (var i = 0; i < assets.length; i++) {
if (assets[i].id.startsWith('Playera')) {
playera.push(assets[i].id);
}
}
playera.sort(function (a, b) {
return parseInt(a.replace('Playera', '')) - parseInt(b.replace('Playera', ''));
});
}
game.update = function () {
if (CoinUpgrade >= 1) {
// Add a new coin every 360 ticks (6 seconds)
if (LK.ticks % 360 === 0) {
var numberOfClones = Math.floor(Math.random() * 5) + 1; // Random number between 1 and 5
for (var i = 0; i < numberOfClones; i++) {
var newCoin = new Coin();
newCoin.x += i * 120; // Offset each clone by 50 pixels
midgroundContainer.addChild(newCoin);
}
}
}
// Increment 'meters' every second
if (LK.ticks % 60 == 0) {
// Check if money has reached 100,000,000
if (money >= 100000000 && !game.congratulated) {
complete += 1; // Increment completion count
if (timeGame < BestTime || BestTime === 0) {
BestTime = timeGame;
}
game.congratulated = true; // Ensure this block only runs once
// Create a congratulatory popup
var congratsBackground = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2,
scaleY: 2
});
foregroundContainer.addChild(congratsBackground);
var congratsText = new Text2('Congratulations! You reached 100,000,000 money!', {
size: 70,
fill: 0xFFFFFF,
font: "Medieval"
});
congratsText.anchor.set(0.5, 0.5);
congratsText.x = 2048 / 2;
congratsText.y = 2732 / 2 - 100;
foregroundContainer.addChild(congratsText);
var resetButton = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 100,
scaleX: 1.5,
scaleY: 1.5
});
foregroundContainer.addChild(resetButton);
var resetText = new Text2('Reset Game', {
size: 100,
fill: 0x000000,
font: "Medieval"
});
resetText.anchor.set(0.5, 0.5);
resetText.x = resetButton.x;
resetText.y = resetButton.y;
foregroundContainer.addChild(resetText);
resetButton.down = function () {
resetButton.isPressed = true;
resetButton.scaleX *= 0.9;
resetButton.scaleY *= 0.9;
LK.getSound('butomtouch').play();
};
resetButton.up = function () {
if (resetButton.isPressed) {
resetButton.scaleX /= 1.1;
resetButton.scaleY /= 1.1;
resetButton.isPressed = false;
// Logic to reset the game
LK.showGameOver();
}
};
}
meters += 1;
timeGame += 1; // Increment timeGame by 1 every second
if (timeGame % 3600 === 0) {
var hours = timeGame / 3600;
console.log('Time Played: ' + hours + ' hour(s)');
}
money += moneyPerSecond; // Increase money by the amount of money/second gained each second
// Update loading bar scale based on money progress towards 20,000,000
loadingBar.scaleX = Math.min(money / 20000000, 1); // Scale from 0 to 1
// Log every time 1000 meters are advanced
if (meters % 1000 === 0) {
console.log('Advanced 1000 meters');
// Play the 'HoundreMeters' sound every 1000 meters
LK.getSound('HoundreMeters').play();
// money += 25; // Removed money increment when meters increase by 250
// Change background sprite
currentRockIndex = (currentRockIndex + 1) % 8; // Cycle through 0 to 7
background.removeChild(background.playerGraphics);
background.playerGraphics = background.attachAsset('Background' + currentRockIndex, {
anchorX: 0.5,
anchorY: 0.5
});
backgroundClone.removeChild(backgroundClone.playerGraphics);
backgroundClone.playerGraphics = backgroundClone.attachAsset('Background' + currentRockIndex, {
anchorX: 0.5,
anchorY: 0.5
});
backgroundClone2.removeChild(backgroundClone2.playerGraphics);
backgroundClone2.playerGraphics = backgroundClone2.attachAsset('Background' + currentRockIndex, {
anchorX: 0.5,
anchorY: 0.5
});
}
// Play the 'HoundreMeters' sound at 1000 meters
if (meters === 1000) {
LK.getSound('HoundreMeters').play();
}
}
// Save progress every 1 second
if (LK.ticks % 60 == 0) {
storage.meters = meters;
storage.money = money;
storage.currentRockIndex = currentRockIndex; // Save current background skin index
storage.littleMouse = littleMouse;
storage.timePlayed = timeGame; // Save time played to storage
storage.monkey = monkey; // Save monkey to storage
storage.doggy = doggy; // Save doggy to storage
storage.villager = villager; // Save villager to storage
storage.peasant = peasant; // Save peasant to storage
storage.warrior = warrior; // Save warrior to storage
storage.bourgeois = bourgeois; // Save bourgeois to storage
storage.king = king; // Save king to storage
storage.CoinUpgrade = CoinUpgrade; // Save CoinUpgrade to storage
storage.BestTime = BestTime; // Save BestTime to storage
storage.complete = complete; // Save complete status to storage
}
};
que no contenga sombras ni luces
una cabeza de moai redonda. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Una esfera de hierro. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Una esfera de oro. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
una piedra redonda musgosa. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
la bandera de argentina redonda. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
moneda de cobre. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
moneda de silver. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
moneda de gold. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
diamante Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Una rueda de carretilla medieval. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
pelota de basquetbal modelo Molten. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
pelota de futbol hecha de hielo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Bola disco. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Una bola de voley de planta. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Una bola de pinchos. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Una bola de lana. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Agrega una esfera que dentro contenga un cielo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Una esfera con la via láctea. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
proporción 1000-2000, marios más robustos y sin tanto relieve
Un papel medieval con una enorme flecha hacia la izquierda de pintura en medio. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Esfera del dragon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Esfera demoniaca. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Esfera de hada. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
una manzana redonda. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un capiraba redondo como una pelota. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Un armadillo hecho bolita. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Una estrella redondita. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Mejorar el diseños de lás casas para que sean más medievales y aumentar su calidad, más arboles y mejorar la calidad del cesped