User prompt
arregla el falo que hace que los textos no sigan su objeto correspondido
User prompt
Add scrolling functionality to the buyables on the Pets Page
User prompt
repite lo mismo para shoppage
User prompt
ajusta el tamaño del asset menuUpgrade para que sea el tamaño de todo el fondo
User prompt
Haz que cuando se cambie de pagina el valor de jump siempre sea 0 y que no pueda saltar
User prompt
haz quew reset reinicie doggy y monkey
User prompt
arrelga el bug que hace que cuando se compra una nueva mascota el texto money/sec y su ganancia en vez de sumarse el valor que asigna la mascota suma la cantidad actual de money por segundos + la cantidad de mascotas
User prompt
cuando se compra una nueva mascota el texto money/sec y su ganancia en vez de sumarse el valor que asigna la mascota suma la cantidad actual de money por segundos + la cantidad de mascotas
User prompt
cambia el text de upgrade page que dice "upgrade page" a "pets page"
User prompt
Change the text of the upgrade button to 'Pets'
User prompt
cambia el texto de upgrade bottom a pet
User prompt
ajusta el mismo tamaño a todos los back butom
User prompt
el tamaño ddel bottom back de upgrade page no es identico al de los demás back butom
Code edit (1 edits merged)
Please save this source code
User prompt
haz que el espaciado sea el mismo entre buyable
User prompt
ajusta la posición de los buyables de upgrade page
User prompt
arregla money por segundos, la ganancio no es la misma que la mencionada por el display
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'itemBackground')' in or related to this line: 'shopPage.itemBackground.bronzeCoinPurchased = true;' Line Number: 1332
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'itemBackground')' in or related to this line: 'shopPage.itemBackground.bronzeCoinPurchased = true;' Line Number: 1332
User prompt
haz que el valor de las monedas de bronze sea siempre money por segundos + 50%
User prompt
agrega un nuevo buyable para monkey
User prompt
haz que monkey aumente monedas por segundos en 1
User prompt
haz que reset progress reinicie los monkeys
User prompt
doggy no hizo que inclemente la variable money por segundo
User prompt
haz que la variable monkey se guarde globalmente y cargue al iniciar el juego
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1", { meters: 0, money: 0, spin: 0, timePlayed: 0, doggy: 0, currentRockIndex: 0 }); /**** * Classes ****/ // Create a BackgroundContainer class var BackgroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create a BronzeCoin class var BronzeCoin = Container.expand(function () { var self = Container.call(this); // Attach the coin asset var coinGraphics = self.attachAsset('coin0', { anchorX: 0.5, anchorY: 0.5 }); // Set initial position off-screen to the right self.x = 2048 + coinGraphics.width / 2; self.y = Math.random() * (1400 - 590) + 590; // Random Y position within a range // Set speed for moving left self.speed = -8; // Set the correct speed for BronzeCoin // Update function to move the coin self.update = function () { self.x += self.speed; self.rotation -= 0.05; // Reverse rotation direction and slow down the rotation speed // Check for collision with player if (self.intersects(player)) { money += 1; // Increase money by 1 LK.getSound('clutchedCoin').play(); // Play the 'clutchedCoin' sound self.destroy(); return; // Exit the function to prevent further execution } // Remove the coin if it goes off-screen to the left if (self.lastX >= -coinGraphics.width / 2 && self.x < -coinGraphics.width / 2) { self.destroy(); // Set a timer to respawn the BronzeCoin every 5-8 seconds var respawnTime = Math.floor(Math.random() * 3000) + 5000; // Random time between 5000ms and 8000ms LK.setTimeout(function () { var newBronzeCoin = new BronzeCoin(); // Set a random Y position for the new coin, within a range newBronzeCoin.y = Math.random() * (1400 - 590) + 590; midgroundContainer.addChild(newBronzeCoin); }, respawnTime); } }; 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 *= 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 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']; 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 *= 1.1; leftArrowButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; leftArrowButton.up = function () { if (leftArrowButton.isPressed) { leftArrowButton.scaleX /= 1.1; leftArrowButton.scaleY /= 1.1; 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 *= 1.1; selectButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; selectButton.up = function () { if (selectButton.isPressed) { selectButton.scaleX /= 1.1; selectButton.scaleY /= 1.1; 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 *= 1.1; rightArrowButton.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; rightArrowButton.up = function () { if (rightArrowButton.isPressed) { rightArrowButton.scaleX /= 1.1; rightArrowButton.scaleY /= 1.1; 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 confirmReset = new Text2('Are you sure you want to reset your progress?', { size: 100, fill: 0xFFFFFF, font: "Medieval" }); confirmReset.anchor.set(0.5, 0.5); confirmReset.x = 2048 / 2; confirmReset.y = 2732 / 2; 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; storage.coinEnable = false; storage.SilvercoinEnable = false; storage.goldcoinEnable = false; meters = 0; money = 0; coinEnable = false; SilvercoinEnable = false; goldcoinEnable = false; littleMouse = 0; // Reset littleMouse count currentRockIndex = 0; monkey = 0; // Reset monkey count storage.monkey = 0; // Reset monkey count in storage doggy = 0; // Reset doggy count storage.doggy = 0; // Reset doggy count in storage 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); // 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); } }; } }; // 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; self.addChild(timePlayedText); // Update the time played text every second LK.setInterval(function () { var minutes = Math.floor(timeGame / 60); var seconds = timeGame % 60; timePlayedText.setText('Time Played: ' + minutes + 'm ' + seconds + 's'); }, 1000); return self; }); // Create a ForegroundContainer class var ForegroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create a GoldCoin class var GoldCoin = Container.expand(function () { var self = Container.call(this); // Attach the gold coin asset var coinGraphics = self.attachAsset('coin2', { anchorX: 0.5, anchorY: 0.5 }); // Set initial position off-screen to the right self.x = 2048 + coinGraphics.width / 2; self.y = Math.random() * (1400 - 590) + 590; // Random Y position within a range // Set speed for moving left self.speed = -18; // Set the correct speed for GoldCoin // Update function to move the coin self.update = function () { self.x += self.speed; self.rotation -= 0.05; // Check for collision with player if (self.intersects(player)) { money += 25; // Increase money by 25 for gold coin LK.getSound('clutchedCoin').play(); self.destroy(); return; } // Remove the coin if it goes off-screen to the left if (self.lastX >= -coinGraphics.width / 2 && self.x < -coinGraphics.width / 2) { self.destroy(); } }; 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 a purchasable item to the shop page self.itemBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 600, // Adjusted position to fit better scaleX: 0.8, // Reduced size to fit in menuShop scaleY: 0.8 // Reduced size to fit in menuShop }); self.addChild(self.itemBackground); // Add item title var itemTitle = new Text2('Bronze Coin', { size: 80, //{6d} // Decreased size fill: 0xFFFFFF, font: "Medieval" }); itemTitle.anchor.set(0.5, 0.5); itemTitle.x = self.itemBackground.x; // Centered horizontally itemTitle.y = self.itemBackground.y - 150; self.addChild(itemTitle); // Add item description var itemDescription = new Text2('A shiny bronze coin\nwith little value.', { size: 60, fill: 0xFFFFFF, font: "Medieval" }); itemDescription.anchor.set(0.5, 0.5); itemDescription.x = self.itemBackground.x; // Centered horizontally itemDescription.y = self.itemBackground.y; self.addChild(itemDescription); // Add item price var itemPrice = new Text2('Price: 100', { size: 70, fill: 0xFFD700, font: "Medieval" }); itemPrice.anchor.set(0.5, 0.5); itemPrice.x = self.itemBackground.x; // Centered horizontally itemPrice.y = self.itemBackground.y + 150; self.addChild(itemPrice); // Add interaction to the item background self.itemBackground.down = function () { self.itemBackground.isPressed = true; self.itemBackground.scaleX *= 1.1; self.itemBackground.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; self.itemBackground.up = function () { if (self.itemBackground.isPressed) { self.itemBackground.scaleX /= 1.1; self.itemBackground.scaleY /= 1.1; self.itemBackground.isPressed = false; // Check if the BronzeCoin has already been purchased if (!self.itemBackground.bronzeCoinPurchased && !coinEnable && money >= 100) { money -= 100; // Enable coin spawning coinEnable = true; // Mark the BronzeCoin as purchased self.itemBackground.bronzeCoinPurchased = true; // Update item price to 'Purchased' itemPrice.setText('Purchased'); // Disable touch for Bronze Coin self.itemBackground.down = null; self.itemBackground.up = null; } } }; // Add item asset display // Add a purchasable silver coin item to the shop page self.silverItemBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 100, // Adjusted position to fit better scaleX: 0.8, // Reduced size to fit in menuShop scaleY: 0.8 // Reduced size to fit in menuShop }); self.addChild(self.silverItemBackground); // Add silver coin item title var silverItemTitle = new Text2('Silver Coin', { size: 80, fill: 0xFFFFFF, font: "Medieval" }); silverItemTitle.anchor.set(0.5, 0.5); silverItemTitle.x = self.silverItemBackground.x; // Centered horizontally silverItemTitle.y = self.silverItemBackground.y - 100; // Adjusted top margin by 50 pixels self.addChild(silverItemTitle); // Add silver coin item description var silverItemDescription = new Text2('A shiny silver coin\nwith moderate value.', { size: 60, fill: 0xFFFFFF, font: "Medieval" }); silverItemDescription.anchor.set(0.5, 0.5); silverItemDescription.x = self.silverItemBackground.x; // Centered horizontally silverItemDescription.y = self.silverItemBackground.y; self.addChild(silverItemDescription); // Add silver coin item price var silverItemPrice = new Text2('Price: 700', { size: 70, fill: 0xFFD700, font: "Medieval" }); silverItemPrice.anchor.set(0.5, 0.5); silverItemPrice.x = self.silverItemBackground.x; // Centered horizontally silverItemPrice.y = self.silverItemBackground.y + 150; self.addChild(silverItemPrice); // Add interaction to the silver item background self.silverItemBackground.down = function () { self.silverItemBackground.isPressed = true; self.silverItemBackground.scaleX *= 1.1; self.silverItemBackground.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; self.silverItemBackground.up = function () { if (self.silverItemBackground.isPressed) { self.silverItemBackground.scaleX /= 1.1; self.silverItemBackground.scaleY /= 1.1; self.silverItemBackground.isPressed = false; // Check if the SilverCoin has already been purchased if (!self.silverItemBackground.silverCoinPurchased && !SilvercoinEnable && money >= 700) { money -= 700; SilvercoinEnable = true; self.silverItemBackground.silverCoinPurchased = true; silverItemPrice.setText('Purchased'); // Update item price to 'Purchased' // Disable touch for Silver Coin self.silverItemBackground.down = null; self.silverItemBackground.up = null; } } }; // Add a purchasable golden coin item to the shop page self.goldenItemBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 400, // Adjusted position to fit better scaleX: 0.8, // Reduced size to fit in menuShop scaleY: 0.8 // Reduced size to fit in menuShop }); self.addChild(self.goldenItemBackground); // Add golden coin item title var goldenItemTitle = new Text2('Golden Coin', { size: 80, fill: 0xFFFFFF, font: "Medieval" }); goldenItemTitle.anchor.set(0.5, 0.5); goldenItemTitle.x = self.goldenItemBackground.x; // Centered horizontally goldenItemTitle.y = self.goldenItemBackground.y - 100; // Adjusted top margin by 50 pixels self.addChild(goldenItemTitle); // Add golden coin item description var goldenItemDescription = new Text2('A shiny golden coin\nwith high value.', { size: 60, fill: 0xFFFFFF, font: "Medieval" }); goldenItemDescription.anchor.set(0.5, 0.5); goldenItemDescription.x = self.goldenItemBackground.x; // Centered horizontally goldenItemDescription.y = self.goldenItemBackground.y; self.addChild(goldenItemDescription); // Add golden coin item price var goldenItemPrice = new Text2('Price: 2400', { size: 70, fill: 0xFFD700, font: "Medieval" }); goldenItemPrice.anchor.set(0.5, 0.5); goldenItemPrice.x = self.goldenItemBackground.x; // Centered horizontally goldenItemPrice.y = self.goldenItemBackground.y + 150; self.addChild(goldenItemPrice); // Add interaction to the golden item background self.goldenItemBackground.down = function () { self.goldenItemBackground.isPressed = true; self.goldenItemBackground.scaleX *= 1.1; self.goldenItemBackground.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; self.goldenItemBackground.up = function () { if (self.goldenItemBackground.isPressed) { self.goldenItemBackground.scaleX /= 1.1; self.goldenItemBackground.scaleY /= 1.1; self.goldenItemBackground.isPressed = false; // Check if the GoldenCoin has already been purchased if (!self.goldenItemBackground.goldenCoinPurchased && !goldcoinEnable && money >= 2400) { money -= 2400; goldcoinEnable = true; // Mark the GoldenCoin as purchased self.goldenItemBackground.goldenCoinPurchased = true; } if (goldcoinEnable) { // Update item price to 'Purchased' goldenItemPrice.setText('Purchased'); // Disable touch for Golden Coin self.goldenItemBackground.down = null; self.goldenItemBackground.up = null; } } }; return self; }); // Create a SilverCoin class var SilverCoin = Container.expand(function () { var self = Container.call(this); // Attach the silver coin asset var coinGraphics = self.attachAsset('coin1', { anchorX: 0.5, anchorY: 0.5 }); // Set initial position off-screen to the right self.x = 2048 + coinGraphics.width / 2; self.y = Math.random() * (1400 - 590) + 590; // Random Y position within a range // Set speed for moving left self.speed = -15; // Set the correct speed for SilverCoin // Update function to move the coin self.update = function () { self.x += self.speed; self.rotation -= 0.05; // Check for collision with player if (self.intersects(player)) { money += 5; // Increase money by 5 for silver coin LK.getSound('clutchedCoin').play(); self.destroy(); return; } // Remove the coin if it goes off-screen to the left if (self.lastX >= -coinGraphics.width / 2 && self.x < -coinGraphics.width / 2) { self.destroy(); } }; 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); } }; // Add a buyable item 'Little Mouse' to the upgrade page self.littleMouseBackground = self.attachAsset('ItemShopMarco', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 500, // Adjusted position for consistent spacing scaleX: 0.8, scaleY: 0.8 }); self.addChild(self.littleMouseBackground); // Add 'Little Mouse' item title var littleMouseTitle = new Text2('Little Mouse', { size: 80, fill: 0xFFFFFF, font: "Medieval" }); littleMouseTitle.anchor.set(0.5, 0.5); littleMouseTitle.x = self.littleMouseBackground.x; littleMouseTitle.y = self.littleMouseBackground.y - 150; self.addChild(littleMouseTitle); // Add 'Little Mouse' item description var littleMouseDescription = new Text2('A small and nimble mouse.\nIncreases money by 0.01 per second.', { size: 60, fill: 0xFFFFFF, font: "Medieval" }); littleMouseDescription.anchor.set(0.5, 0.5); littleMouseDescription.x = self.littleMouseBackground.x; littleMouseDescription.y = self.littleMouseBackground.y; self.addChild(littleMouseDescription); // Add 'Little Mouse' item price var littleMousePriceText = new Text2('Price: ' + littleMousePrice, { size: 70, fill: 0xFFD700, font: "Medieval" }); littleMousePriceText.anchor.set(0.5, 0.5); littleMousePriceText.x = self.littleMouseBackground.x; littleMousePriceText.y = self.littleMouseBackground.y + 150; self.addChild(littleMousePriceText); // Add interaction to the 'Little Mouse' item background self.littleMouseBackground.down = function () { self.littleMouseBackground.isPressed = true; self.littleMouseBackground.scaleX *= 1.1; self.littleMouseBackground.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; self.littleMouseBackground.up = function () { if (self.littleMouseBackground.isPressed) { self.littleMouseBackground.scaleX /= 1.1; self.littleMouseBackground.scaleY /= 1.1; self.littleMouseBackground.isPressed = false; // Check if the Little Mouse has already been purchased var price = littleMouse === 0 ? 0 : littleMouse; 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 === 0 ? 0 : littleMouse; // Update the price littleMousePriceText.setText('Price: ' + littleMousePrice); // Update the price display } } }; // 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 - 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: 2048 / 2, y: 2732 / 2, // Adjusted position for consistent spacing scaleX: 0.8, scaleY: 0.8 }); self.addChild(self.doggyBackground); // Add 'Doggy' item title var doggyTitle = new Text2('Doggy', { size: 80, fill: 0xFFFFFF, font: "Medieval" }); doggyTitle.anchor.set(0.5, 0.5); doggyTitle.x = self.doggyBackground.x; doggyTitle.y = self.doggyBackground.y - 150; self.addChild(doggyTitle); // Add 'Doggy' item description var doggyDescription = new Text2('A loyal companion.\nIncreases money by 0.1 per second.', { size: 60, fill: 0xFFFFFF, font: "Medieval" }); doggyDescription.anchor.set(0.5, 0.5); doggyDescription.x = self.doggyBackground.x; doggyDescription.y = self.doggyBackground.y; self.addChild(doggyDescription); // Add 'Doggy' item price var doggyPriceText = new Text2('Price: ' + (10 + doggy * 10), { size: 70, fill: 0xFFD700, font: "Medieval" }); doggyPriceText.anchor.set(0.5, 0.5); doggyPriceText.x = self.doggyBackground.x; doggyPriceText.y = self.doggyBackground.y + 150; self.addChild(doggyPriceText); // Add interaction to the 'Doggy' item background self.doggyBackground.down = function () { self.doggyBackground.isPressed = true; self.doggyBackground.scaleX *= 1.1; self.doggyBackground.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; self.doggyBackground.up = function () { if (self.doggyBackground.isPressed) { self.doggyBackground.scaleX /= 1.1; self.doggyBackground.scaleY /= 1.1; self.doggyBackground.isPressed = false; // Check if the Doggy can be purchased var price = 10 + doggy * 10; if (money >= price) { money -= price; doggy += 1; // Increase doggy count by 1 doggyPriceText.setText('Price: ' + (10 + doggy * 10)); // Update the price display } } }; // 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 - 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 / 2, y: 2732 / 2 + 500, // Adjusted position for consistent spacing scaleX: 0.8, scaleY: 0.8 }); self.addChild(self.monkeyBackground); // Add 'Monkey' item title var monkeyTitle = new Text2('Monkey', { size: 80, fill: 0xFFFFFF, font: "Medieval" }); monkeyTitle.anchor.set(0.5, 0.5); monkeyTitle.x = self.monkeyBackground.x; monkeyTitle.y = self.monkeyBackground.y - 150; self.addChild(monkeyTitle); // Add 'Monkey' item description var monkeyDescription = new Text2('A playful monkey.\nIncreases money by 1 per second.', { size: 60, fill: 0xFFFFFF, font: "Medieval" }); monkeyDescription.anchor.set(0.5, 0.5); monkeyDescription.x = self.monkeyBackground.x; monkeyDescription.y = self.monkeyBackground.y; self.addChild(monkeyDescription); // Add 'Monkey' item price var monkeyPriceText = new Text2('Price: ' + (100 + monkey * 100), { size: 70, fill: 0xFFD700, font: "Medieval" }); monkeyPriceText.anchor.set(0.5, 0.5); monkeyPriceText.x = self.monkeyBackground.x; monkeyPriceText.y = self.monkeyBackground.y + 150; self.addChild(monkeyPriceText); // Add interaction to the 'Monkey' item background self.monkeyBackground.down = function () { self.monkeyBackground.isPressed = true; self.monkeyBackground.scaleX *= 1.1; self.monkeyBackground.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; self.monkeyBackground.up = function () { if (self.monkeyBackground.isPressed) { self.monkeyBackground.scaleX /= 1.1; self.monkeyBackground.scaleY /= 1.1; self.monkeyBackground.isPressed = false; // Check if the Monkey can be purchased var price = 100 + monkey * 100; if (money >= price) { money -= price; monkey += 1; // Increase monkey count by 1 monkeyPriceText.setText('Price: ' + (100 + monkey * 100)); // Update the price display updateMoneyPerSecond(); // Update moneyPerSecond } } }; // 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 - 10; monkeyQuantityText.y = self.monkeyBackground.y - self.monkeyBackground.height / 2 + 10; self.addChild(monkeyQuantityText); // Add scrolling functionality for buyables var scrollSpeed = 10; var isScrolling = false; var startY = 0; var currentY = 0; self.down = function (x, y, obj) { isScrolling = true; startY = y; }; self.move = function (x, y, obj) { if (isScrolling) { currentY = y; var deltaY = currentY - startY; self.littleMouseBackground.y += deltaY; littleMouseTitle.y += deltaY; littleMouseDescription.y += deltaY; littleMousePriceText.y += deltaY; littleMouseQuantityText.y += deltaY; self.doggyBackground.y += deltaY; doggyTitle.y += deltaY; doggyDescription.y += deltaY; doggyPriceText.y += deltaY; doggyQuantityText.y += deltaY; self.monkeyBackground.y += deltaY; monkeyTitle.y += deltaY; monkeyDescription.y += deltaY; monkeyPriceText.y += deltaY; monkeyQuantityText.y += deltaY; startY = currentY; } }; self.up = function (x, y, obj) { isScrolling = false; }; 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) + ' 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)); }; }); // 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 >= 1000000 ? money.toExponential(2) : money.toFixed(2))); }; }); /**** * Initialize Game ****/ // Initialize BackgroundContainer, MidgroundContainer, and ForegroundContainer var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var monkey = storage.monkey || 0; // Load 'monkey' 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 coinEnable = storage.coinEnable !== undefined ? storage.coinEnable : false; var SilvercoinEnable = storage.SilvercoinEnable !== undefined ? storage.SilvercoinEnable : false; var goldcoinEnable = storage.goldcoinEnable !== undefined ? storage.goldcoinEnable : false; // Check and update the state of buyable coins if (coinEnable) { shopPage.itemBackground.bronzeCoinPurchased = true; shopPage.itemBackground.down = null; shopPage.itemBackground.up = null; shopPage.itemBackground.getChildByName('itemPrice').setText('Purchased'); } if (SilvercoinEnable) { shopPage.silverItemBackground.silverCoinPurchased = true; shopPage.silverItemBackground.down = null; shopPage.silverItemBackground.up = null; shopPage.silverItemBackground.getChildByName('silverItemPrice').setText('Purchased'); } if (goldcoinEnable) { shopPage.goldenItemBackground.goldenCoinPurchased = true; shopPage.goldenItemBackground.down = null; shopPage.goldenItemBackground.up = null; shopPage.goldenItemBackground.getChildByName('goldenItemPrice').setText('Purchased'); } // Set a constant timer to respawn between 1 to 5 BronzeCoins every 6 seconds var respawnInterval = 6000; // Constant time of 6000ms (6 seconds) LK.setInterval(function () { if (coinEnable) { if (SilvercoinEnable && Math.random() < 0.5) { // 50% chance var numberOfSilverCoins = Math.floor(Math.random() * 2) + 1; // Random number between 1 and 2 for (var j = 0; j < numberOfSilverCoins; j++) { (function (index) { LK.setTimeout(function () { var newSilverCoin = new SilverCoin(); newSilverCoin.y = Math.random() * (1400 - 590) + 590; // Random Y position within a range midgroundContainer.addChild(newSilverCoin); }, index * 200); // Delay each coin by 200ms multiplied by its index })(j); } } if (goldcoinEnable && Math.random() < 0.1) { // 10% chance var numberOfGoldCoins = Math.floor(Math.random() * 2) + 1; // Random number between 1 and 2 for (var k = 0; k < numberOfGoldCoins; k++) { (function (index) { LK.setTimeout(function () { var newGoldCoin = new GoldCoin(); newGoldCoin.y = Math.random() * (1400 - 590) + 590; // Random Y position within a range midgroundContainer.addChild(newGoldCoin); }, index * 200); // Delay each coin by 200ms multiplied by its index })(k); } } var numberOfCoins = Math.floor(Math.random() * 5) + 1; // Random number between 1 and 5 for (var i = 0; i < numberOfCoins; i++) { (function (index) { LK.setTimeout(function () { var newBronzeCoin = new BronzeCoin(); // Set a random Y position for each new coin, within a range newBronzeCoin.y = Math.random() * (1400 - 590) + 590; midgroundContainer.addChild(newBronzeCoin); }, index * 200); // Delay each coin by 200ms multiplied by its index })(i); } } }, respawnInterval); 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 LK.setTimeout(function () { // Check and update the state of buyable coins if (coinEnable) { shopPage.itemBackground.bronzeCoinPurchased = true; shopPage.itemBackground.down = null; shopPage.itemBackground.up = null; shopPage.itemBackground.getChildByName('itemPrice').setText('Purchased'); } if (SilvercoinEnable) { shopPage.silverItemBackground.silverCoinPurchased = true; shopPage.silverItemBackground.down = null; shopPage.silverItemBackground.up = null; shopPage.silverItemBackground.getChildByName('silverItemPrice').setText('Purchased'); } if (goldcoinEnable) { shopPage.goldenItemBackground.goldenCoinPurchased = true; shopPage.goldenItemBackground.down = null; shopPage.goldenItemBackground.up = null; shopPage.goldenItemBackground.getChildByName('goldenItemPrice').setText('Purchased'); } }, 0); // 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 BackgroundContainer, MidgroundContainer, and ForegroundContainer var backgroundContainer = new BackgroundContainer(); var midgroundContainer = new MidgroundContainer(); var foregroundContainer = new ForegroundContainer(); // Add containers to the game in the correct order game.addChild(backgroundContainer); game.addChild(midgroundContainer); game.addChild(foregroundContainer); // Add the 'bottom' asset to the foreground container var bottomAsset = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 550, y: 1870 }); foregroundContainer.addChild(bottomAsset); // Add interaction to increase size by 10% on press and revert on release bottomAsset.down = function () { bottomAsset.isPressed = true; bottomAsset.scaleX *= 1.1; bottomAsset.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; bottomAsset.up = function () { if (bottomAsset.isPressed) { bottomAsset.scaleX /= 1.1; bottomAsset.scaleY /= 1.1; bottomAsset.isPressed = false; // Logic to switch to the Upgrade page game.showUpgradePage(); } }; // Add text to the bottom asset var bottomText = new Text2('Pets', { size: 150, fill: 0x000000, // Black color font: "Medieval" // Medieval style }); bottomText.anchor.set(0.5, 0.5); // Centered on both axes bottomText.x = bottomAsset.x; bottomText.y = bottomAsset.y; foregroundContainer.addChild(bottomText); // Add the 'bottomRock' asset parallel to 'bottomUpgrade' on the right side var bottomShopAsset = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 1500, // Positioned parallel to bottomUpgrade on the right side y: 1870 }); foregroundContainer.addChild(bottomShopAsset); // Add interaction to increase size by 10% on press and revert on release bottomShopAsset.down = function () { bottomShopAsset.isPressed = true; bottomShopAsset.scaleX *= 1.1; bottomShopAsset.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; bottomShopAsset.up = function () { if (bottomShopAsset.isPressed) { bottomShopAsset.scaleX /= 1.1; bottomShopAsset.scaleY /= 1.1; bottomShopAsset.isPressed = false; // Logic to switch to the Shop page game.showShopPage(); } }; // Add text to the bottomRock asset var bottomShopText = new Text2('Shop', { size: 150, // Very large size fill: 0x000000, // Black color font: "Medieval" // Medieval style }); bottomShopText.anchor.set(0.5, 0.5); // Centered on both axes bottomShopText.x = bottomShopAsset.x; bottomShopText.y = bottomShopAsset.y; foregroundContainer.addChild(bottomShopText); // Add the 'bottomCosmetic' asset 450 pixels below 'bottomUpgrade' var bottomCosmeticAsset = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 550, y: 1870 + 430 }); foregroundContainer.addChild(bottomCosmeticAsset); // Add interaction to increase size by 10% on press and revert on release bottomCosmeticAsset.down = function () { bottomCosmeticAsset.isPressed = true; bottomCosmeticAsset.scaleX *= 1.1; bottomCosmeticAsset.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; bottomCosmeticAsset.up = function () { if (bottomCosmeticAsset.isPressed) { bottomCosmeticAsset.scaleX /= 1.1; bottomCosmeticAsset.scaleY /= 1.1; bottomCosmeticAsset.isPressed = false; // Logic to switch to the Cosmetic page game.showCosmeticPage(); } }; // Add text to the bottomCosmetic asset var bottomCosmeticText = new Text2('Cosmetic', { size: 150, // Very large size fill: 0x000000, // Black color font: "Medieval" // Medieval style }); bottomCosmeticText.anchor.set(0.5, 0.5); // Centered on both axes bottomCosmeticText.x = bottomCosmeticAsset.x; bottomCosmeticText.y = bottomCosmeticAsset.y; foregroundContainer.addChild(bottomCosmeticText); // Add the 'bottomExtras' asset 430 pixels below 'bottomRock' var bottomExtrasAsset = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 1500, y: 1870 + 430 }); foregroundContainer.addChild(bottomExtrasAsset); // Add interaction to increase size by 10% on press and revert on release bottomExtrasAsset.down = function () { bottomExtrasAsset.isPressed = true; bottomExtrasAsset.scaleX *= 1.1; bottomExtrasAsset.scaleY *= 1.1; LK.getSound('butomtouch').play(); }; bottomExtrasAsset.up = function () { if (bottomExtrasAsset.isPressed) { bottomExtrasAsset.scaleX /= 1.1; bottomExtrasAsset.scaleY /= 1.1; bottomExtrasAsset.isPressed = false; // Logic to switch to the Extras page game.showExtrasPage(); } }; // Add text to the bottomExtras asset var bottomExtrasText = new Text2('Extras', { size: 150, // Very large size fill: 0x000000, // Black color font: "Medieval" // Medieval style }); bottomExtrasText.anchor.set(0.5, 0.5); // Centered on both axes bottomExtrasText.x = bottomExtrasAsset.x; bottomExtrasText.y = bottomExtrasAsset.y; foregroundContainer.addChild(bottomExtrasText); 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.01 + monkey * 1; // Initialize moneyPerSecond based on littleMouse and monkey count // Function to update moneyPerSecond based on littleMouse count function updateMoneyPerSecond() { moneyPerSecond = littleMouse * 0.01 + doggy * 0.1 + monkey * 1; } // 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('Background' + currentRockIndex, { 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('Background' + currentRockIndex, { 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('Background' + currentRockIndex, { 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 moneyPerSecondText = foregroundContainer.addChild(new MoneyPerSecondText()); // 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 () { background.x -= 5; backgroundClone.x -= 5; backgroundClone2.x -= 5; // Update all BronzeCoins only if purchased if (shopPage.itemBackground.bronzeCoinPurchased) { midgroundContainer.children.forEach(function (child) { if (child instanceof BronzeCoin) { child.update(); // if (SilvercoinEnable && Math.random() < 0.33) { // 33% chance // child.destroy(); // Remove the BronzeCoin // var newSilverCoin = new SilverCoin(); // Use SilverCoin class // midgroundContainer.addChild(newSilverCoin); // } } }); } if (background.x + background.width < 0) { background.x = backgroundClone2.x + background.width; } if (backgroundClone.x + backgroundClone.width < 0) { backgroundClone.x = background.x + background.width; } if (backgroundClone2.x + backgroundClone2.width < 0) { backgroundClone2.x = backgroundClone.x + backgroundClone.width; } // Increment 'meters' every second if (LK.ticks % 60 == 0) { meters += 1; timeGame += 1; // Increment timeGame by 1 every second money += moneyPerSecond; // Increase money by the amount of money/second gained each second // 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.coinEnable = coinEnable; storage.SilvercoinEnable = SilvercoinEnable; storage.goldcoinEnable = goldcoinEnable; storage.littleMouse = littleMouse; storage.timePlayed = timeGame; // Save time played to storage storage.doggy = doggy; // Save doggy to storage } };
===================================================================
--- original.js
+++ change.js
@@ -1232,10 +1232,22 @@
if (isScrolling) {
currentY = y;
var deltaY = currentY - startY;
self.littleMouseBackground.y += deltaY;
+ littleMouseTitle.y += deltaY;
+ littleMouseDescription.y += deltaY;
+ littleMousePriceText.y += deltaY;
+ littleMouseQuantityText.y += deltaY;
self.doggyBackground.y += deltaY;
+ doggyTitle.y += deltaY;
+ doggyDescription.y += deltaY;
+ doggyPriceText.y += deltaY;
+ doggyQuantityText.y += deltaY;
self.monkeyBackground.y += deltaY;
+ monkeyTitle.y += deltaY;
+ monkeyDescription.y += deltaY;
+ monkeyPriceText.y += deltaY;
+ monkeyQuantityText.y += deltaY;
startY = currentY;
}
};
self.up = function (x, y, obj) {
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