User prompt
haz que no se muestre la pagina principal
User prompt
haz que la pagina inicial sea introducción
User prompt
crea una pagina 4 llamada introducción separado de las demás paginas
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'foregroundContainer.addChild(introductionAsset);' Line Number: 379
User prompt
haz que se muestre en foreground
User prompt
Agrega el asset introductión a la escena
User prompt
haz que introducción se muestre por 4 segundos
User prompt
cuando se inicia no se muestra la introducción
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'foregroundContainer.addChild(introductionScreen);' Line Number: 379
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'foregroundContainer.addChild(introductionScreen);' Line Number: 379
User prompt
agregalo a foreground
User prompt
Cuando se inicie juego agrega una introduccion por unos segundos con el asset introduction
User prompt
Please fix the bug: 'Uncaught TypeError: LK.getSound(...).pause is not a function' in or related to this line: 'LK.getSound('rockmovement').pause(); // Pause rockmovement sound when switching to another page' Line Number: 423
User prompt
haz que el sonido de movimiento de la roca se pause cuando se esta en otra pagina
User prompt
Extras page aun se muestra cuando se abre menu principal
User prompt
crea una pagina 4 llamada extras separado de las demás paginas
User prompt
cosmetic page aun se muestra cuando se abre menu principal
User prompt
crea una pagina 4 llamada Cosmetic separado de las demas paginas
User prompt
Rock page aun se muestra cuando se abre menu principal
User prompt
crea una pagina 3 llamada Rock separado de la pagina 1 (juego base) y pagina 2 (Upgrade)
User prompt
Repite la acción para rock page, cosmetic page y extras page
User prompt
cuando se abre menu upgrade aun se muestra contenido de menu principal
User prompt
crea una pagina 2 llamada Upgrade separado de la pagina 1 (juego base) menu
User prompt
agrega todo el juego principal como parte de pagina 1
User prompt
arregla el fallo que al cambiar de vuelta a pagina 1 no se muestra ningun objeto y se sigue mostrando pagina 2
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1", { meters: 0, money: 0, spin: 0 }); /**** * Classes ****/ // Create a BackgroundContainer class var BackgroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create a ForegroundContainer class var ForegroundContainer = Container.expand(function () { var self = Container.call(this); 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 rock = ['Rock0', 'Rock1', 'Rock2', 'Rock3', 'Rock4']; // Attach a shape asset to represent the player self.playerGraphics = self.attachAsset(rock[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.05; // 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 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('Meters: ' + (meters / 1000).toFixed(2) + ' km'); }; }); // 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); }; }); /**** * Initialize Game ****/ // Initialize BackgroundContainer, MidgroundContainer, and ForegroundContainer var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Page 2: Setup for the second page with a rock var page2 = function page2() { // Remove all children from the main game containers to hide page 1 backgroundContainer.removeChildren(); midgroundContainer.removeChildren(); foregroundContainer.removeChildren(); // Initialize containers for page2 var backgroundContainer2 = new BackgroundContainer(); var midgroundContainer2 = new MidgroundContainer(); var foregroundContainer2 = new ForegroundContainer(); // Add containers to the game in the correct order game.addChild(backgroundContainer2); game.addChild(midgroundContainer2); game.addChild(foregroundContainer2); // Add a rock asset to the midground container var rockAsset = LK.getAsset('Rock0', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); midgroundContainer2.addChild(rockAsset); }; // Page 1: Initial setup for the game var page1 = function page1() { // Remove all children from the main game containers to hide page 2 backgroundContainer.removeChildren(); midgroundContainer.removeChildren(); foregroundContainer.removeChildren(); // Initialize containers for page1 var backgroundContainer1 = new BackgroundContainer(); var midgroundContainer1 = new MidgroundContainer(); var foregroundContainer1 = new ForegroundContainer(); // Add containers to the game in the correct order game.addChild(backgroundContainer1); game.addChild(midgroundContainer1); game.addChild(foregroundContainer1); // Add the 'bottom' asset to the foreground container var bottomAsset1 = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 550, y: 1870 }); foregroundContainer1.addChild(bottomAsset1); // Add interaction to increase size by 10% on press and revert on release bottomAsset1.down = function () { if (foregroundContainer1.children.some(function (child) { return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id); })) { return; // Disable touch if any menu is open } bottomAsset1.isPressed = true; bottomAsset1.scaleX *= 1.1; bottomAsset1.scaleY *= 1.1; LK.getSound('butomtouch').play(); // Open the upgrade menu // Close any existing menu before opening a new one closeAllMenus(); var menuUpgrade1 = LK.getAsset('menuUpgrade', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); foregroundContainer1.addChild(menuUpgrade1); // Add a 'Close' button to the 'menuUpgrade' asset var closeButton1 = LK.getAsset('closingPaper', { anchorX: 1.0, anchorY: 0.0, x: menuUpgrade1.x + menuUpgrade1.width / 2, y: menuUpgrade1.y - menuUpgrade1.height / 2 }); foregroundContainer1.addChild(closeButton1); // Add interaction to close the menuUpgrade when closingPaper is touched closeButton1.down = function () { LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched foregroundContainer1.removeChild(menuUpgrade1); foregroundContainer1.removeChild(closeButton1); }; }; bottomAsset1.up = function () { if (bottomAsset1.isPressed) { bottomAsset1.scaleX /= 1.1; bottomAsset1.scaleY /= 1.1; bottomAsset1.isPressed = false; } }; }; // Define the closeAllMenus function to close all open menus function closeAllMenus() { // Logic to close all menus, if any are open // This can be implemented by removing all menu assets from the foregroundContainer // Example: foregroundContainer.removeChild(menuUpgrade); foregroundContainer.removeChild(menuRock); etc. } game.currentPage = 1; // Initialize currentPage to track the current page 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 () { if (foregroundContainer.children.some(function (child) { return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id); })) { return; // Disable touch if any menu is open } bottomAsset.isPressed = true; bottomAsset.scaleX *= 1.1; bottomAsset.scaleY *= 1.1; LK.getSound('butomtouch').play(); // Open the upgrade menu // Close any existing menu before opening a new one closeAllMenus(); var menuUpgrade = LK.getAsset('menuUpgrade', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); foregroundContainer.addChild(menuUpgrade); // Add a 'Close' button to the 'menuUpgrade' asset var closeButton = LK.getAsset('closingPaper', { anchorX: 1.0, // Top-right corner anchorY: 0.0, x: menuUpgrade.x + menuUpgrade.width / 2, // Position at the top-right corner of the menu y: menuUpgrade.y - menuUpgrade.height / 2 }); foregroundContainer.addChild(closeButton); // Add interaction to close the menuUpgrade when closingPaper is touched closeButton.down = function () { LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched foregroundContainer.removeChild(menuUpgrade); foregroundContainer.removeChild(closeButton); }; }; bottomAsset.up = function () { if (bottomAsset.isPressed) { bottomAsset.scaleX /= 1.1; bottomAsset.scaleY /= 1.1; bottomAsset.isPressed = false; } }; // Add text to the bottom asset var bottomText = new Text2('Upgrade', { size: 150, // Very large size 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 bottomRockAsset = LK.getAsset('bottom', { anchorX: 0.5, anchorY: 0.5, x: 1500, // Positioned parallel to bottomUpgrade on the right side y: 1870 }); foregroundContainer.addChild(bottomRockAsset); // Add interaction to increase size by 10% on press and revert on release bottomRockAsset.down = function () { if (foregroundContainer.children.some(function (child) { return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id); })) { return; // Disable touch if any menu is open } bottomRockAsset.isPressed = true; bottomRockAsset.scaleX *= 1.1; bottomRockAsset.scaleY *= 1.1; LK.getSound('butomtouch').play(); // Create and display the menuRock asset // Close any existing menu before opening a new one closeAllMenus(); var menuRock = LK.getAsset('menuRock', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); foregroundContainer.addChild(menuRock); // Add a 'Close1' button to the 'menuRock' asset var close1Button = LK.getAsset('closingPaper', { anchorX: 1.0, // Top-right corner anchorY: 0.0, x: menuRock.x + menuRock.width / 2, // Position at the top-right corner of the menu y: menuRock.y - menuRock.height / 2 }); foregroundContainer.addChild(close1Button); // Add interaction to close the menuRock when closingPaper is touched close1Button.down = function () { LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched foregroundContainer.removeChild(menuRock); foregroundContainer.removeChild(close1Button); }; }; bottomRockAsset.up = function () { if (bottomRockAsset.isPressed) { bottomRockAsset.scaleX /= 1.1; bottomRockAsset.scaleY /= 1.1; bottomRockAsset.isPressed = false; } }; // Add text to the bottomRock asset var bottomRockText = new Text2('Rock', { size: 150, // Very large size fill: 0x000000, // Black color font: "Medieval" // Medieval style }); bottomRockText.anchor.set(0.5, 0.5); // Centered on both axes bottomRockText.x = bottomRockAsset.x; bottomRockText.y = bottomRockAsset.y; foregroundContainer.addChild(bottomRockText); // 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 () { if (foregroundContainer.children.some(function (child) { return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id); })) { return; // Disable touch if any menu is open } bottomCosmeticAsset.isPressed = true; bottomCosmeticAsset.scaleX *= 1.1; bottomCosmeticAsset.scaleY *= 1.1; LK.getSound('butomtouch').play(); // Create and display the menuCosmetic asset // Close any existing menu before opening a new one closeAllMenus(); var menuCosmetic = LK.getAsset('menuCosmetic', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); foregroundContainer.addChild(menuCosmetic); // Add a 'Close' button to the 'menuCosmetic' asset var closeCosmeticButton = LK.getAsset('closingPaper', { anchorX: 1.0, // Top-right corner anchorY: 0.0, x: menuCosmetic.x + menuCosmetic.width / 2, y: menuCosmetic.y - menuCosmetic.height / 2 }); foregroundContainer.addChild(closeCosmeticButton); // Add interaction to close the menuCosmetic when closingPaper is touched closeCosmeticButton.down = function () { LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched foregroundContainer.removeChild(menuCosmetic); foregroundContainer.removeChild(closeCosmeticButton); }; }; bottomCosmeticAsset.up = function () { if (bottomCosmeticAsset.isPressed) { bottomCosmeticAsset.scaleX /= 1.1; bottomCosmeticAsset.scaleY /= 1.1; bottomCosmeticAsset.isPressed = false; } }; // 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 () { if (foregroundContainer.children.some(function (child) { return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id); })) { return; // Disable touch if any menu is open } bottomExtrasAsset.isPressed = true; bottomExtrasAsset.scaleX *= 1.1; bottomExtrasAsset.scaleY *= 1.1; LK.getSound('butomtouch').play(); // Create and display the menuExtras asset // Close any existing menu before opening a new one closeAllMenus(); var menuExtras = LK.getAsset('menuExtras', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); foregroundContainer.addChild(menuExtras); // Add a 'Close' button to the 'menuExtras' asset var closeExtrasButton = LK.getAsset('closingPaper', { anchorX: 1.0, anchorY: 0.0, x: menuExtras.x + menuExtras.width / 2, y: menuExtras.y - menuExtras.height / 2 }); foregroundContainer.addChild(closeExtrasButton); // Add interaction to close the menuExtras when closingPaper is touched closeExtrasButton.down = function () { LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched foregroundContainer.removeChild(menuExtras); foregroundContainer.removeChild(closeExtrasButton); }; }; bottomExtrasAsset.up = function () { if (bottomExtrasAsset.isPressed) { bottomExtrasAsset.scaleX /= 1.1; bottomExtrasAsset.scaleY /= 1.1; bottomExtrasAsset.isPressed = false; } }; // 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 background 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 // Initialize a rock asset with a design var rock = LK.getAsset('Rock0', { 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 } if (game.currentPage === 1) { page2(); // Change to page 2 when the screen is touched game.currentPage = 2; } else { page1(); // Change to page 1 when the screen is touched game.currentPage = 1; } }; // 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; // 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; // Adjusted Y position for MoneyText // 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('Rock')) { rock.push(assets[i].id); } } rock.sort(function (a, b) { return parseInt(a.replace('Rock', '')) - parseInt(b.replace('Rock', '')); }); } game.update = function () { background.x -= 5; backgroundClone.x -= 5; backgroundClone2.x -= 5; 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; // Log every time 250 meters are advanced if (meters % 250 === 0) { console.log('Advanced 250 meters'); // Play the 'HoundreMeters' sound every 250 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 250 meters if (meters === 250) { 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 } };
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1", {
meters: 0,
money: 0,
spin: 0
});
/****
* Classes
****/
// Create a BackgroundContainer class
var BackgroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Create a ForegroundContainer class
var ForegroundContainer = Container.expand(function () {
var self = Container.call(this);
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 rock = ['Rock0', 'Rock1', 'Rock2', 'Rock3', 'Rock4'];
// Attach a shape asset to represent the player
self.playerGraphics = self.attachAsset(rock[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.05;
// 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 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('Meters: ' + (meters / 1000).toFixed(2) + ' km');
};
});
// 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);
};
});
/****
* Initialize Game
****/
// Initialize BackgroundContainer, MidgroundContainer, and ForegroundContainer
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Page 2: Setup for the second page with a rock
var page2 = function page2() {
// Remove all children from the main game containers to hide page 1
backgroundContainer.removeChildren();
midgroundContainer.removeChildren();
foregroundContainer.removeChildren();
// Initialize containers for page2
var backgroundContainer2 = new BackgroundContainer();
var midgroundContainer2 = new MidgroundContainer();
var foregroundContainer2 = new ForegroundContainer();
// Add containers to the game in the correct order
game.addChild(backgroundContainer2);
game.addChild(midgroundContainer2);
game.addChild(foregroundContainer2);
// Add a rock asset to the midground container
var rockAsset = LK.getAsset('Rock0', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
midgroundContainer2.addChild(rockAsset);
};
// Page 1: Initial setup for the game
var page1 = function page1() {
// Remove all children from the main game containers to hide page 2
backgroundContainer.removeChildren();
midgroundContainer.removeChildren();
foregroundContainer.removeChildren();
// Initialize containers for page1
var backgroundContainer1 = new BackgroundContainer();
var midgroundContainer1 = new MidgroundContainer();
var foregroundContainer1 = new ForegroundContainer();
// Add containers to the game in the correct order
game.addChild(backgroundContainer1);
game.addChild(midgroundContainer1);
game.addChild(foregroundContainer1);
// Add the 'bottom' asset to the foreground container
var bottomAsset1 = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 550,
y: 1870
});
foregroundContainer1.addChild(bottomAsset1);
// Add interaction to increase size by 10% on press and revert on release
bottomAsset1.down = function () {
if (foregroundContainer1.children.some(function (child) {
return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id);
})) {
return; // Disable touch if any menu is open
}
bottomAsset1.isPressed = true;
bottomAsset1.scaleX *= 1.1;
bottomAsset1.scaleY *= 1.1;
LK.getSound('butomtouch').play();
// Open the upgrade menu
// Close any existing menu before opening a new one
closeAllMenus();
var menuUpgrade1 = LK.getAsset('menuUpgrade', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
foregroundContainer1.addChild(menuUpgrade1);
// Add a 'Close' button to the 'menuUpgrade' asset
var closeButton1 = LK.getAsset('closingPaper', {
anchorX: 1.0,
anchorY: 0.0,
x: menuUpgrade1.x + menuUpgrade1.width / 2,
y: menuUpgrade1.y - menuUpgrade1.height / 2
});
foregroundContainer1.addChild(closeButton1);
// Add interaction to close the menuUpgrade when closingPaper is touched
closeButton1.down = function () {
LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched
foregroundContainer1.removeChild(menuUpgrade1);
foregroundContainer1.removeChild(closeButton1);
};
};
bottomAsset1.up = function () {
if (bottomAsset1.isPressed) {
bottomAsset1.scaleX /= 1.1;
bottomAsset1.scaleY /= 1.1;
bottomAsset1.isPressed = false;
}
};
};
// Define the closeAllMenus function to close all open menus
function closeAllMenus() {
// Logic to close all menus, if any are open
// This can be implemented by removing all menu assets from the foregroundContainer
// Example: foregroundContainer.removeChild(menuUpgrade); foregroundContainer.removeChild(menuRock); etc.
}
game.currentPage = 1; // Initialize currentPage to track the current page
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 () {
if (foregroundContainer.children.some(function (child) {
return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id);
})) {
return; // Disable touch if any menu is open
}
bottomAsset.isPressed = true;
bottomAsset.scaleX *= 1.1;
bottomAsset.scaleY *= 1.1;
LK.getSound('butomtouch').play();
// Open the upgrade menu
// Close any existing menu before opening a new one
closeAllMenus();
var menuUpgrade = LK.getAsset('menuUpgrade', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
foregroundContainer.addChild(menuUpgrade);
// Add a 'Close' button to the 'menuUpgrade' asset
var closeButton = LK.getAsset('closingPaper', {
anchorX: 1.0,
// Top-right corner
anchorY: 0.0,
x: menuUpgrade.x + menuUpgrade.width / 2,
// Position at the top-right corner of the menu
y: menuUpgrade.y - menuUpgrade.height / 2
});
foregroundContainer.addChild(closeButton);
// Add interaction to close the menuUpgrade when closingPaper is touched
closeButton.down = function () {
LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched
foregroundContainer.removeChild(menuUpgrade);
foregroundContainer.removeChild(closeButton);
};
};
bottomAsset.up = function () {
if (bottomAsset.isPressed) {
bottomAsset.scaleX /= 1.1;
bottomAsset.scaleY /= 1.1;
bottomAsset.isPressed = false;
}
};
// Add text to the bottom asset
var bottomText = new Text2('Upgrade', {
size: 150,
// Very large size
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 bottomRockAsset = LK.getAsset('bottom', {
anchorX: 0.5,
anchorY: 0.5,
x: 1500,
// Positioned parallel to bottomUpgrade on the right side
y: 1870
});
foregroundContainer.addChild(bottomRockAsset);
// Add interaction to increase size by 10% on press and revert on release
bottomRockAsset.down = function () {
if (foregroundContainer.children.some(function (child) {
return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id);
})) {
return; // Disable touch if any menu is open
}
bottomRockAsset.isPressed = true;
bottomRockAsset.scaleX *= 1.1;
bottomRockAsset.scaleY *= 1.1;
LK.getSound('butomtouch').play();
// Create and display the menuRock asset
// Close any existing menu before opening a new one
closeAllMenus();
var menuRock = LK.getAsset('menuRock', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
foregroundContainer.addChild(menuRock);
// Add a 'Close1' button to the 'menuRock' asset
var close1Button = LK.getAsset('closingPaper', {
anchorX: 1.0,
// Top-right corner
anchorY: 0.0,
x: menuRock.x + menuRock.width / 2,
// Position at the top-right corner of the menu
y: menuRock.y - menuRock.height / 2
});
foregroundContainer.addChild(close1Button);
// Add interaction to close the menuRock when closingPaper is touched
close1Button.down = function () {
LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched
foregroundContainer.removeChild(menuRock);
foregroundContainer.removeChild(close1Button);
};
};
bottomRockAsset.up = function () {
if (bottomRockAsset.isPressed) {
bottomRockAsset.scaleX /= 1.1;
bottomRockAsset.scaleY /= 1.1;
bottomRockAsset.isPressed = false;
}
};
// Add text to the bottomRock asset
var bottomRockText = new Text2('Rock', {
size: 150,
// Very large size
fill: 0x000000,
// Black color
font: "Medieval" // Medieval style
});
bottomRockText.anchor.set(0.5, 0.5); // Centered on both axes
bottomRockText.x = bottomRockAsset.x;
bottomRockText.y = bottomRockAsset.y;
foregroundContainer.addChild(bottomRockText);
// 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 () {
if (foregroundContainer.children.some(function (child) {
return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id);
})) {
return; // Disable touch if any menu is open
}
bottomCosmeticAsset.isPressed = true;
bottomCosmeticAsset.scaleX *= 1.1;
bottomCosmeticAsset.scaleY *= 1.1;
LK.getSound('butomtouch').play();
// Create and display the menuCosmetic asset
// Close any existing menu before opening a new one
closeAllMenus();
var menuCosmetic = LK.getAsset('menuCosmetic', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
foregroundContainer.addChild(menuCosmetic);
// Add a 'Close' button to the 'menuCosmetic' asset
var closeCosmeticButton = LK.getAsset('closingPaper', {
anchorX: 1.0,
// Top-right corner
anchorY: 0.0,
x: menuCosmetic.x + menuCosmetic.width / 2,
y: menuCosmetic.y - menuCosmetic.height / 2
});
foregroundContainer.addChild(closeCosmeticButton);
// Add interaction to close the menuCosmetic when closingPaper is touched
closeCosmeticButton.down = function () {
LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched
foregroundContainer.removeChild(menuCosmetic);
foregroundContainer.removeChild(closeCosmeticButton);
};
};
bottomCosmeticAsset.up = function () {
if (bottomCosmeticAsset.isPressed) {
bottomCosmeticAsset.scaleX /= 1.1;
bottomCosmeticAsset.scaleY /= 1.1;
bottomCosmeticAsset.isPressed = false;
}
};
// 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 () {
if (foregroundContainer.children.some(function (child) {
return ['menuUpgrade', 'menuRock', 'menuCosmetic', 'menuExtras'].includes(child.id);
})) {
return; // Disable touch if any menu is open
}
bottomExtrasAsset.isPressed = true;
bottomExtrasAsset.scaleX *= 1.1;
bottomExtrasAsset.scaleY *= 1.1;
LK.getSound('butomtouch').play();
// Create and display the menuExtras asset
// Close any existing menu before opening a new one
closeAllMenus();
var menuExtras = LK.getAsset('menuExtras', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
foregroundContainer.addChild(menuExtras);
// Add a 'Close' button to the 'menuExtras' asset
var closeExtrasButton = LK.getAsset('closingPaper', {
anchorX: 1.0,
anchorY: 0.0,
x: menuExtras.x + menuExtras.width / 2,
y: menuExtras.y - menuExtras.height / 2
});
foregroundContainer.addChild(closeExtrasButton);
// Add interaction to close the menuExtras when closingPaper is touched
closeExtrasButton.down = function () {
LK.getSound('papeltouch').play(); // Play papeltouch sound when closingPaper is touched
foregroundContainer.removeChild(menuExtras);
foregroundContainer.removeChild(closeExtrasButton);
};
};
bottomExtrasAsset.up = function () {
if (bottomExtrasAsset.isPressed) {
bottomExtrasAsset.scaleX /= 1.1;
bottomExtrasAsset.scaleY /= 1.1;
bottomExtrasAsset.isPressed = false;
}
};
// 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 background 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
// Initialize a rock asset with a design
var rock = LK.getAsset('Rock0', {
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
}
if (game.currentPage === 1) {
page2(); // Change to page 2 when the screen is touched
game.currentPage = 2;
} else {
page1(); // Change to page 1 when the screen is touched
game.currentPage = 1;
}
};
// 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;
// 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; // Adjusted Y position for MoneyText
// 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('Rock')) {
rock.push(assets[i].id);
}
}
rock.sort(function (a, b) {
return parseInt(a.replace('Rock', '')) - parseInt(b.replace('Rock', ''));
});
}
game.update = function () {
background.x -= 5;
backgroundClone.x -= 5;
backgroundClone2.x -= 5;
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;
// Log every time 250 meters are advanced
if (meters % 250 === 0) {
console.log('Advanced 250 meters');
// Play the 'HoundreMeters' sound every 250 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 250 meters
if (meters === 250) {
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
}
};
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