User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var lengthValue = new Text2(storage.editorState.currentLevel.length.toString(), {' Line Number: 5039 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.editorState.currentLevel = {};' Line Number: 4764 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.editorState = {' Line Number: 4758 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add more level editor elements
User prompt
Add a update
User prompt
Add more level editor elements
User prompt
Add a map packs button and a level editor button
User prompt
Update get all shop items βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add 4 more shops βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add 4 more shops βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add get all shop items βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add add 6 more commands βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add 3 more shops βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add a add 10000 gems and coins to owner commands βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.dailyShopItems.push({' Line Number: 2408 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Checkpoint = Container.expand(function (x, y) { var self = Container.call(this); var checkpointGraphics = self.attachAsset('checkpoint', { anchorX: 0.5, anchorY: 1.0 }); self.x = x; self.y = y; self.activated = false; return self; }); var Coin = Container.expand(function (x, y) { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.x = x; self.y = y; self.collected = false; self.rotationSpeed = 0.05; self.update = function () { if (!self.collected) { coinGraphics.rotation += self.rotationSpeed; } }; return self; }); var Ground = Container.expand(function (x, y, width) { var self = Container.call(this); var groundGraphics = self.attachAsset('ground', { anchorX: 0, anchorY: 0 }); groundGraphics.width = width || 200; self.x = x; self.y = y; return self; }); var LevelButton = Container.expand(function (levelNum, x, y) { var self = Container.call(this); var buttonGraphics = self.attachAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); self.levelNum = levelNum; self.x = x; self.y = y; self.locked = levelNum > 1 && !storage.completedLevels[levelNum - 1]; // Set button color based on status if (self.locked) { buttonGraphics.tint = 0x666666; } else if (storage.completedLevels[levelNum]) { buttonGraphics.tint = 0x00ff00; } // Level number text self.levelText = new Text2(levelNum.toString(), { size: 40, fill: 0xFFFFFF }); self.levelText.anchor.set(0.5, 0.3); self.addChild(self.levelText); // Coin count text var coinCount = storage.levelCoins[levelNum] || 0; var maxCoins = levelData[levelNum] ? levelData[levelNum].coins.length : 0; self.coinText = new Text2(coinCount + '/' + maxCoins, { size: 25, fill: 0xFFD700 }); self.coinText.anchor.set(0.5, 0.7); self.addChild(self.coinText); self.down = function (x, y, obj) { if (!self.locked) { currentLevel = self.levelNum; showGameplay(); } }; return self; }); var Platform = Container.expand(function (x, y, width) { var self = Container.call(this); var platformGraphics = self.attachAsset('platform', { anchorX: 0, anchorY: 0 }); platformGraphics.width = width || 200; self.x = x; self.y = y; return self; }); var Player = Container.expand(function () { var self = Container.call(this); self.isShipMode = false; self.playerGraphics = null; self.shipGraphics = null; self.setMode = function (isShip) { if (self.playerGraphics) { self.removeChild(self.playerGraphics); self.playerGraphics = null; } if (self.shipGraphics) { self.removeChild(self.shipGraphics); self.shipGraphics = null; } self.isShipMode = isShip; if (isShip) { self.shipGraphics = self.attachAsset('ship', { anchorX: 0.5, anchorY: 0.5 }); // Apply purchased ship color if (storage.shipColor) { self.shipGraphics.tint = storage.shipColor; } // Apply size reduction if (storage.smallSize) { self.shipGraphics.scaleX = 0.75; self.shipGraphics.scaleY = 0.75; } } else { self.playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 1.0 }); // Apply purchased player color if (storage.playerColor) { self.playerGraphics.tint = storage.playerColor; } // Apply size reduction if (storage.smallSize) { self.playerGraphics.scaleX = 0.75; self.playerGraphics.scaleY = 0.75; } } }; // Initialize with player mode self.setMode(false); self.velocityY = 0; self.isGrounded = false; self.isDead = false; self.isFlying = false; self.isSwinging = false; self.swingAnchor = null; self.swingAngle = 0; self.swingLength = 0; self.swingSpeed = 0; self.jump = function () { if (self.isShipMode) { if (!self.isDead) { self.isFlying = true; self.velocityY = -12; LK.getSound('jump').play(); } } else { if (self.isGrounded && !self.isDead) { var jumpPower = storage.jumpBoost ? -30 : -24; self.velocityY = jumpPower; self.isGrounded = false; LK.getSound('jump').play(); } } }; self.stopJump = function () { if (self.isShipMode) { self.isFlying = false; } else if (self.isSwinging) { // Release from swing var releaseVelX = Math.cos(self.swingAngle + Math.PI / 2) * self.swingSpeed * 0.8; var releaseVelY = Math.sin(self.swingAngle + Math.PI / 2) * self.swingSpeed * 0.8; self.velocityY = releaseVelY; self.releaseVelX = releaseVelX; self.isSwinging = false; if (self.swingAnchor) { self.swingAnchor.deactivateSwing(); self.swingAnchor = null; } } }; self.update = function () { if (self.isDead) return; // Trail effect if (storage.trail) { var trailParticle = LK.getAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); trailParticle.x = self.x; trailParticle.y = self.y; trailParticle.scaleX = 0.3; trailParticle.scaleY = 0.3; trailParticle.alpha = 0.6; trailParticle.tint = storage.playerColor || 0x00ff00; game.addChild(trailParticle); // Fade out trail particle tween(trailParticle, { alpha: 0, scaleX: 0, scaleY: 0 }, { duration: 500, onComplete: function onComplete() { game.removeChild(trailParticle); } }); } if (self.isSwinging) { // Swing physics var gravity = 0.8; var dampening = 0.995; // Apply gravity to swing speed var gravityForce = gravity * Math.cos(self.swingAngle); self.swingSpeed += gravityForce; self.swingSpeed *= dampening; // Update swing angle self.swingAngle += self.swingSpeed / self.swingLength; // Update player position based on swing self.x = self.swingAnchor.x + Math.cos(self.swingAngle) * self.swingLength; self.y = self.swingAnchor.y + Math.sin(self.swingAngle) * self.swingLength; // Update rope visual if exists if (self.swingAnchor.rope) { self.swingAnchor.rope.rotation = self.swingAngle; } } else if (self.isShipMode) { // Ship mode physics if (self.isFlying) { self.velocityY -= 2.5; } else { self.velocityY += 2.0; } // Limit ship velocity if (self.velocityY > 18) self.velocityY = 18; if (self.velocityY < -18) self.velocityY = -18; self.y += self.velocityY; // Ship ground collision if (self.y >= groundLevel - 20) { self.y = groundLevel - 20; self.velocityY = 0; } // Ship ceiling collision if (self.y <= 100) { self.y = 100; self.velocityY = 0; } } else { // Regular cube mode physics if (self.releaseVelX) { // Apply horizontal velocity from swing release self.x += self.releaseVelX; self.releaseVelX *= 0.95; // Decay horizontal velocity if (Math.abs(self.releaseVelX) < 0.5) { self.releaseVelX = 0; } } self.velocityY += 2.0; self.y += self.velocityY; // Ground collision if (self.y >= groundLevel) { self.y = groundLevel; self.velocityY = 0; self.isGrounded = true; self.releaseVelX = 0; // Stop horizontal movement on ground } } }; return self; }); var Spike = Container.expand(function (x, y) { var self = Container.call(this); var spikeGraphics = self.attachAsset('spike', { anchorX: 0.5, anchorY: 1.0 }); self.x = x; self.y = y; return self; }); var SwingAnchor = Container.expand(function (x, y) { var self = Container.call(this); var anchorGraphics = self.attachAsset('swingAnchor', { anchorX: 0.5, anchorY: 0.5 }); self.x = x; self.y = y; self.isActive = false; self.rope = null; self.activateSwing = function (player) { if (!self.isActive && !player.isSwinging) { self.isActive = true; player.isSwinging = true; player.swingAnchor = self; player.swingAngle = Math.atan2(player.y - self.y, player.x - self.x); player.swingLength = Math.sqrt(Math.pow(player.x - self.x, 2) + Math.pow(player.y - self.y, 2)); player.swingSpeed = 0; // Create visual rope self.rope = LK.getAsset('ground', { anchorX: 0, anchorY: 0.5 }); self.rope.width = player.swingLength; self.rope.height = 4; self.rope.tint = 0x8B4513; self.rope.x = self.x; self.rope.y = self.y; self.rope.rotation = self.swingAngle; game.addChild(self.rope); // Animate anchor activation tween(anchorGraphics, { scaleX: 1.5, scaleY: 1.5 }, { duration: 200, easing: tween.bounceOut }); } }; self.deactivateSwing = function () { self.isActive = false; if (self.rope) { game.removeChild(self.rope); self.rope = null; } tween(anchorGraphics, { scaleX: 1, scaleY: 1 }, { duration: 150 }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222222 }); /**** * Game Code ****/ // Game states var gameState = 'menu'; // 'menu' or 'playing' var currentLevel = 1; var maxLevels = 68; var groundLevel = 2400; var cameraX = 0; var scrollSpeed = 12; // Player variables var player; var playerStartX = 300; var playerStartY = groundLevel; // Level data var obstacles = []; var platforms = []; var grounds = []; var checkpoints = []; var swingAnchors = []; var coins = []; var currentCheckpoint = 0; var levelData = {}; // UI elements var levelButtons = []; var backButton; var levelCompleteText; var deathCount = 0; var godModeEnabled = false; var speedBoostEnabled = false; var debugInfoVisible = false; var debugText = null; // Storage initialization if (!storage.completedLevels) { storage.completedLevels = {}; } if (!storage.currentLevel) { storage.currentLevel = 1; } if (!storage.totalCoins) { storage.totalCoins = 0; } if (!storage.levelCoins) { storage.levelCoins = {}; } if (!storage.dailyLevelDate) { storage.dailyLevelDate = ''; } if (!storage.dailyLevelCompleted) { storage.dailyLevelCompleted = false; } if (!storage.dailyLevelCoins) { storage.dailyLevelCoins = 0; } // Shop storage initialization if (!storage.shopPurchases) { storage.shopPurchases = {}; } if (!storage.playerColor) { storage.playerColor = 0x00ff00; // Default green } if (!storage.shipColor) { storage.shipColor = 0x0088ff; // Default blue } if (!storage.speedMultiplier) { storage.speedMultiplier = 1.0; } if (!storage.coinMagnet) { storage.coinMagnet = false; } if (!storage.checkpoint) { storage.checkpoint = false; } if (!storage.jumpBoost) { storage.jumpBoost = false; } if (!storage.shield) { storage.shield = false; } if (!storage.smallSize) { storage.smallSize = false; } if (!storage.trail) { storage.trail = false; } if (!storage.shieldUsed) { storage.shieldUsed = false; } // Daily shop storage initialization if (!storage.dailyShopDate) { storage.dailyShopDate = ''; } if (!storage.dailyShopItems) { storage.dailyShopItems = []; } if (!storage.dailyShopPurchases) { storage.dailyShopPurchases = {}; } // Gem shop storage initialization if (!storage.totalGems) { storage.totalGems = 10; // Start with 10 gems } if (!storage.gemShopPurchases) { storage.gemShopPurchases = {}; } // Arcade shop storage initialization if (!storage.arcadeTokens) { storage.arcadeTokens = 25; // Start with 25 arcade tokens } if (!storage.arcadeShopPurchases) { storage.arcadeShopPurchases = {}; } // Arcade shop screen function showArcadeShop() { gameState = 'arcadeShop'; game.removeChildren(); // Title var titleText = new Text2('Retro Arcade Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Arcade token display var tokenDisplayText = new Text2('Arcade Tokens: ' + storage.arcadeTokens, { size: 60, fill: 0x00ff88 }); tokenDisplayText.anchor.set(0.5, 0); tokenDisplayText.x = 1024; tokenDisplayText.y = 250; game.addChild(tokenDisplayText); // Arcade shop items var arcadeShopItems = [{ name: 'Neon Player', price: 8, type: 'playerColor', value: 0x00ff44, description: 'Classic arcade neon green' }, { name: 'Pixel Player', price: 12, type: 'playerColor', value: 0xff0088, description: 'Retro pixel magenta color' }, { name: 'Retro Ship', price: 10, type: 'shipColor', value: 0x00ffaa, description: 'Old school arcade ship' }, { name: 'Classic Ship', price: 15, type: 'shipColor', value: 0xffaa00, description: 'Vintage golden ship' }, { name: 'Arcade Boost', price: 20, type: 'speedMultiplier', value: 1.8, description: 'Arcade-style speed boost' }, { name: 'Retro Jump', price: 18, type: 'jumpBoost', value: true, description: 'Classic arcade jump power' }, { name: 'Pixel Trail', price: 15, type: 'trail', value: true, description: 'Pixelated trail effect' }, { name: 'Coin Vacuum', price: 25, type: 'coinMagnet', value: true, description: 'Powerful coin collection' }, { name: 'Arcade Shield', price: 30, type: 'shield', value: true, description: 'Retro protection system' }, { name: 'Mini Mode', price: 22, type: 'smallSize', value: true, description: 'Tiny arcade character' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < arcadeShopItems.length; i++) { var item = arcadeShopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.arcadeShopPurchases[item.name] || false; var canAfford = storage.arcadeTokens >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0x00ff88; // Arcade green for affordable } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' tokens', { size: 25, fill: isPurchased ? 0x00ff00 : 0x00ff88 }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.arcadeTokens -= itemToPurchase.price; storage.arcadeShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showArcadeShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(arcadeShopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Power shop screen function showPowerShop() { gameState = 'powerShop'; game.removeChildren(); // Title var titleText = new Text2('Ultimate Power Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Power point display var powerDisplayText = new Text2('Power Points: ' + storage.powerPoints, { size: 60, fill: 0xff4400 }); powerDisplayText.anchor.set(0.5, 0); powerDisplayText.x = 1024; powerDisplayText.y = 250; game.addChild(powerDisplayText); // Power shop items var powerShopItems = [{ name: 'Laser Player', price: 12, type: 'playerColor', value: 0xff0022, description: 'High-energy laser red' }, { name: 'Plasma Player', price: 15, type: 'playerColor', value: 0x0044ff, description: 'Electric blue plasma' }, { name: 'Rocket Ship', price: 18, type: 'shipColor', value: 0xff2200, description: 'Powerful rocket ship' }, { name: 'Turbo Ship', price: 20, type: 'shipColor', value: 0x00aaff, description: 'Super-charged turbo ship' }, { name: 'Hyper Speed', price: 25, type: 'speedMultiplier', value: 2.5, description: 'Extreme speed enhancement' }, { name: 'Power Jump', price: 22, type: 'jumpBoost', value: true, description: 'Maximum jump power' }, { name: 'Energy Shield', price: 35, type: 'shield', value: true, description: 'Advanced energy protection' }, { name: 'Power Trail', price: 20, type: 'trail', value: true, description: 'High-energy trail effect' }, { name: 'Magnet Field', price: 30, type: 'coinMagnet', value: true, description: 'Electromagnetic coin attraction' }, { name: 'Micro Form', price: 28, type: 'smallSize', value: true, description: 'Compressed power form' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < powerShopItems.length; i++) { var item = powerShopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.powerShopPurchases[item.name] || false; var canAfford = storage.powerPoints >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0xff4400; // Power orange for affordable } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' power', { size: 25, fill: isPurchased ? 0x00ff00 : 0xff4400 }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.powerPoints -= itemToPurchase.price; storage.powerShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showPowerShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(powerShopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Cosmetic shop screen function showCosmeticShop() { gameState = 'cosmeticShop'; game.removeChildren(); // Title var titleText = new Text2('Beauty & Cosmetic Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Beauty coin display var beautyDisplayText = new Text2('Beauty Coins: ' + storage.beautyCoins, { size: 60, fill: 0x8844ff }); beautyDisplayText.anchor.set(0.5, 0); beautyDisplayText.x = 1024; beautyDisplayText.y = 250; game.addChild(beautyDisplayText); // Cosmetic shop items var cosmeticShopItems = [{ name: 'Rose Player', price: 10, type: 'playerColor', value: 0xff6699, description: 'Beautiful rose pink' }, { name: 'Lavender Player', price: 12, type: 'playerColor', value: 0x9966ff, description: 'Elegant lavender purple' }, { name: 'Mint Player', price: 8, type: 'playerColor', value: 0x66ffaa, description: 'Fresh mint green' }, { name: 'Peach Ship', price: 14, type: 'shipColor', value: 0xffaa66, description: 'Soft peach colored ship' }, { name: 'Coral Ship', price: 16, type: 'shipColor', value: 0xff7766, description: 'Vibrant coral ship' }, { name: 'Graceful Speed', price: 18, type: 'speedMultiplier', value: 1.6, description: 'Elegant movement boost' }, { name: 'Fairy Jump', price: 15, type: 'jumpBoost', value: true, description: 'Magical jump enhancement' }, { name: 'Sparkle Trail', price: 20, type: 'trail', value: true, description: 'Glittering sparkle trail' }, { name: 'Beauty Shield', price: 25, type: 'shield', value: true, description: 'Protective beauty aura' }, { name: 'Delicate Form', price: 22, type: 'smallSize', value: true, description: 'Petite elegant size' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < cosmeticShopItems.length; i++) { var item = cosmeticShopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.cosmeticShopPurchases[item.name] || false; var canAfford = storage.beautyCoins >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0x8844ff; // Purple for affordable } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' beauty', { size: 25, fill: isPurchased ? 0x00ff00 : 0x8844ff }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.beautyCoins -= itemToPurchase.price; storage.cosmeticShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showCosmeticShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(cosmeticShopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Power shop storage initialization if (!storage.powerPoints) { storage.powerPoints = 15; // Start with 15 power points } if (!storage.powerShopPurchases) { storage.powerShopPurchases = {}; } // Cosmetic shop storage initialization if (!storage.beautyCoins) { storage.beautyCoins = 20; // Start with 20 beauty coins } if (!storage.cosmeticShopPurchases) { storage.cosmeticShopPurchases = {}; } // Expedition shop storage initialization if (!storage.expeditionTokens) { storage.expeditionTokens = 30; // Start with 30 expedition tokens } if (!storage.expeditionShopPurchases) { storage.expeditionShopPurchases = {}; } // Mystic shop storage initialization if (!storage.mysticCrystals) { storage.mysticCrystals = 12; // Start with 12 mystic crystals } if (!storage.mysticShopPurchases) { storage.mysticShopPurchases = {}; } // Elite shop storage initialization if (!storage.eliteCredits) { storage.eliteCredits = 8; // Start with 8 elite credits } if (!storage.eliteShopPurchases) { storage.eliteShopPurchases = {}; } // VIP shop storage initialization if (!storage.vipPoints) { storage.vipPoints = 5; // Start with 5 VIP points } if (!storage.vipShopPurchases) { storage.vipShopPurchases = {}; } // Generate daily level based on current date function generateDailyLevel() { var today = new Date(); var dateString = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate(); // Check if daily level needs to be regenerated if (storage.dailyLevelDate !== dateString) { storage.dailyLevelDate = dateString; storage.dailyLevelCompleted = false; storage.dailyLevelCoins = 0; } // Generate daily level using date as seed for consistency var dayOfYear = Math.floor((today - new Date(today.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24)); var seed = dayOfYear + today.getFullYear() * 365; levelData['daily'] = { spikes: [], platforms: [], checkpoints: [], swingAnchors: [], coins: [], length: 3000, shipMode: seed % 3 === 0 // Ship mode every 3rd type of pattern }; // Generate pattern based on seed var patternType = seed % 5; if (patternType === 0) { // Spike gauntlet for (var i = 0; i < 8; i++) { levelData['daily'].spikes.push({ x: 800 + i * 300, y: groundLevel }); if (i % 2 === 1) { levelData['daily'].spikes.push({ x: 840 + i * 300, y: groundLevel }); } } } else if (patternType === 1) { // Platform jumps with swings for (var i = 0; i < 6; i++) { levelData['daily'].platforms.push({ x: 700 + i * 400, y: groundLevel - 120, width: 120 }); levelData['daily'].spikes.push({ x: 820 + i * 400, y: groundLevel - 120 }); if (i < 5) { levelData['daily'].swingAnchors.push({ x: 1000 + i * 400, y: groundLevel - 250 }); } } } else if (patternType === 2) { // Mixed chaos for (var i = 0; i < 10; i++) { if (i % 3 === 0) { levelData['daily'].platforms.push({ x: 700 + i * 250, y: groundLevel - 100, width: 100 }); } else { levelData['daily'].spikes.push({ x: 700 + i * 250, y: groundLevel }); } } } else if (patternType === 3) { // Staircase challenge for (var i = 0; i < 7; i++) { levelData['daily'].platforms.push({ x: 700 + i * 300, y: groundLevel - i * 50, width: 150 }); levelData['daily'].spikes.push({ x: 850 + i * 300, y: groundLevel - i * 50 }); } } else { // Speed run for (var i = 0; i < 12; i++) { levelData['daily'].spikes.push({ x: 700 + i * 200, y: groundLevel }); if (i % 4 === 3) { levelData['daily'].spikes.push({ x: 720 + i * 200, y: groundLevel }); } } } // Add daily coins (always 5 coins for daily level) for (var i = 0; i < 5; i++) { levelData['daily'].coins.push({ x: 600 + (i + 1) * (levelData['daily'].length / 6), y: groundLevel - 100 - i % 3 * 40 }); } // Add checkpoints levelData['daily'].checkpoints.push({ x: 1500, y: groundLevel }); levelData['daily'].checkpoints.push({ x: 2250, y: groundLevel }); } // Initialize level data with unique patterns for each level function initializeLevelData() { for (var i = 1; i <= 68; i++) { levelData[i] = { spikes: [], platforms: [], checkpoints: [], swingAnchors: [], coins: [], length: 2500 + i * 150, shipMode: false }; // Define unique patterns for each level if (i === 1) { // Level 1: Ship mode tutorial - simple gaps levelData[i].shipMode = true; levelData[i].length = 2000; for (var s = 0; s < 3; s++) { levelData[i].spikes.push({ x: 1000 + s * 600, y: groundLevel }); levelData[i].spikes.push({ x: 1000 + s * 600, y: groundLevel - 300 }); // Add coins between spikes if (s < 2) { levelData[i].coins.push({ x: 1300 + s * 600, y: groundLevel - 150 }); } } } else if (i === 2) { // Level 2: Single spike jumps for (var s = 0; s < 4; s++) { levelData[i].spikes.push({ x: 800 + s * 400, y: groundLevel }); // Add coin above each spike levelData[i].coins.push({ x: 800 + s * 400, y: groundLevel - 100 }); } } else if (i === 3) { // Level 3: Double spike jumps for (var s = 0; s < 3; s++) { levelData[i].spikes.push({ x: 800 + s * 500, y: groundLevel }); levelData[i].spikes.push({ x: 840 + s * 500, y: groundLevel }); } } else if (i === 4) { // Level 4: Platform jumps with swing anchors for (var p = 0; p < 4; p++) { levelData[i].platforms.push({ x: 800 + p * 400, y: groundLevel - 120, width: 150 }); levelData[i].spikes.push({ x: 975 + p * 400, y: groundLevel - 120 }); // Add swing anchor between platforms if (p < 3) { levelData[i].swingAnchors.push({ x: 1075 + p * 400, y: groundLevel - 200 }); } } } else if (i === 5) { // Level 5: Spike clusters for (var c = 0; c < 3; c++) { for (var s = 0; s < 3; s++) { levelData[i].spikes.push({ x: 800 + c * 600 + s * 50, y: groundLevel }); } // Add coin above each cluster levelData[i].coins.push({ x: 850 + c * 600, y: groundLevel - 120 }); } } else if (i >= 6 && i <= 10) { // Levels 6-10: Mixed patterns with increasing difficulty var patternType = (i - 6) % 3; if (patternType === 0) { // Alternating single and double spikes for (var s = 0; s < 5; s++) { levelData[i].spikes.push({ x: 700 + s * 350, y: groundLevel }); if (s % 2 === 1) { levelData[i].spikes.push({ x: 740 + s * 350, y: groundLevel }); } // Add coins between spikes if (s < 4) { levelData[i].coins.push({ x: 875 + s * 350, y: groundLevel - 80 }); } } } else if (patternType === 1) { // Platform hopping for (var p = 0; p < 4; p++) { var height = groundLevel - 100 - p % 2 * 80; levelData[i].platforms.push({ x: 800 + p * 350, y: height, width: 120 }); levelData[i].spikes.push({ x: 920 + p * 350, y: height }); } } else { // Triple spike jumps for (var t = 0; t < 3; t++) { for (var s = 0; s < 3; s++) { levelData[i].spikes.push({ x: 800 + t * 500 + s * 45, y: groundLevel }); } } } } else if (i >= 11 && i <= 20) { // Levels 11-20: Advanced patterns var complexity = i - 10; if (i % 4 === 1) { // Staircase platforms with spikes for (var st = 0; st < 5; st++) { var stairY = groundLevel - st * 60; levelData[i].platforms.push({ x: 700 + st * 300, y: stairY, width: 150 }); levelData[i].spikes.push({ x: 850 + st * 300, y: stairY }); } } else if (i % 4 === 2) { // Ship mode level levelData[i].shipMode = true; for (var s = 0; s < 6; s++) { levelData[i].spikes.push({ x: 800 + s * 300, y: groundLevel }); levelData[i].spikes.push({ x: 800 + s * 300, y: groundLevel - 250 }); } } else if (i % 4 === 3) { // Maze-like platforms with swing challenges for (var m = 0; m < 4; m++) { var upper = m % 2 === 0; var platY = upper ? groundLevel - 200 : groundLevel - 100; levelData[i].platforms.push({ x: 700 + m * 400, y: platY, width: 200 }); levelData[i].spikes.push({ x: 800 + m * 400, y: platY }); // Add swing anchors for advanced navigation if (m < 3) { levelData[i].swingAnchors.push({ x: 900 + m * 400, y: groundLevel - 300 }); } } } else { // Rapid fire spikes for (var r = 0; r < 8; r++) { levelData[i].spikes.push({ x: 700 + r * 200, y: groundLevel }); } } } else if (i >= 21 && i <= 35) { // Levels 21-35: Expert patterns if (i % 5 === 1) { // Multi-level platforms for (var ml = 0; ml < 3; ml++) { for (var level = 0; level < 3; level++) { var platY = groundLevel - 80 - level * 70; levelData[i].platforms.push({ x: 700 + ml * 500 + level * 100, y: platY, width: 100 }); if (level < 2) { levelData[i].spikes.push({ x: 750 + ml * 500 + level * 100, y: platY }); } } // Add challenging coin placement levelData[i].coins.push({ x: 850 + ml * 500, y: groundLevel - 250 }); } } else if (i % 5 === 2) { // Ship maze levelData[i].shipMode = true; for (var sm = 0; sm < 5; sm++) { levelData[i].spikes.push({ x: 800 + sm * 250, y: groundLevel }); levelData[i].spikes.push({ x: 825 + sm * 250, y: groundLevel - 150 }); levelData[i].spikes.push({ x: 850 + sm * 250, y: groundLevel - 300 }); } } else if (i % 5 === 3) { // Wave pattern spikes for (var w = 0; w < 8; w++) { var wave = Math.sin(w * 0.8) * 100; levelData[i].spikes.push({ x: 700 + w * 150, y: groundLevel + wave }); } } else if (i % 5 === 4) { // Tight platform sequences for (var tp = 0; tp < 6; tp++) { levelData[i].platforms.push({ x: 700 + tp * 250, y: groundLevel - 120, width: 80 }); levelData[i].spikes.push({ x: 780 + tp * 250, y: groundLevel - 120 }); levelData[i].spikes.push({ x: 950 + tp * 250, y: groundLevel }); } } else { // Spike walls for (var sw = 0; sw < 4; sw++) { for (var wall = 0; wall < 4; wall++) { levelData[i].spikes.push({ x: 800 + sw * 400, y: groundLevel - wall * 50 }); } } } } else { // Levels 36-50: Master difficulty var masterPattern = (i - 35) % 8; if (masterPattern === 0) { // Ultimate ship challenge levelData[i].shipMode = true; for (var uc = 0; uc < 10; uc++) { levelData[i].spikes.push({ x: 600 + uc * 180, y: groundLevel }); levelData[i].spikes.push({ x: 620 + uc * 180, y: groundLevel - 100 }); levelData[i].spikes.push({ x: 640 + uc * 180, y: groundLevel - 200 }); levelData[i].spikes.push({ x: 660 + uc * 180, y: groundLevel - 300 }); // Add very challenging coins if (uc % 3 === 0) { levelData[i].coins.push({ x: 630 + uc * 180, y: groundLevel - 150 }); } } } else if (masterPattern === 1) { // Precision platform jumps for (var pp = 0; pp < 8; pp++) { levelData[i].platforms.push({ x: 700 + pp * 200, y: groundLevel - 60 - pp % 3 * 40, width: 60 }); levelData[i].spikes.push({ x: 730 + pp * 200, y: groundLevel - 60 - pp % 3 * 40 }); } } else if (masterPattern === 2) { // Chaos mode - random but beatable for (var ch = 0; ch < 12; ch++) { if (ch % 3 === 0) { levelData[i].platforms.push({ x: 600 + ch * 150, y: groundLevel - 100, width: 100 }); } else { levelData[i].spikes.push({ x: 600 + ch * 150, y: groundLevel }); } } } else if (masterPattern === 3) { // Double layer platforms for (var dl = 0; dl < 5; dl++) { levelData[i].platforms.push({ x: 700 + dl * 300, y: groundLevel - 100, width: 120 }); levelData[i].platforms.push({ x: 760 + dl * 300, y: groundLevel - 180, width: 120 }); levelData[i].spikes.push({ x: 820 + dl * 300, y: groundLevel - 100 }); levelData[i].spikes.push({ x: 880 + dl * 300, y: groundLevel - 180 }); } } else if (masterPattern === 4) { // Speed run spikes for (var sr = 0; sr < 15; sr++) { levelData[i].spikes.push({ x: 600 + sr * 120, y: groundLevel }); if (sr % 3 === 2) { levelData[i].spikes.push({ x: 620 + sr * 120, y: groundLevel }); } } } else if (masterPattern === 5) { // Alternating ship/cube sections if (i % 2 === 0) { levelData[i].shipMode = true; } for (var as = 0; as < 8; as++) { levelData[i].spikes.push({ x: 700 + as * 200, y: groundLevel }); if (levelData[i].shipMode) { levelData[i].spikes.push({ x: 720 + as * 200, y: groundLevel - 200 }); } } } else if (masterPattern === 6) { // Extreme precision for (var ep = 0; ep < 6; ep++) { levelData[i].platforms.push({ x: 700 + ep * 250, y: groundLevel - 90, width: 50 }); levelData[i].spikes.push({ x: 725 + ep * 250, y: groundLevel - 90 }); levelData[i].spikes.push({ x: 750 + ep * 250, y: groundLevel - 90 }); levelData[i].spikes.push({ x: 950 + ep * 250, y: groundLevel }); } } else { // Final boss level patterns for (var fb = 0; fb < 5; fb++) { // Complex multi-height obstacles for (var h = 0; h < 4; h++) { if ((fb + h) % 2 === 0) { levelData[i].spikes.push({ x: 700 + fb * 300 + h * 40, y: groundLevel - h * 60 }); } else { levelData[i].platforms.push({ x: 700 + fb * 300 + h * 40, y: groundLevel - h * 60, width: 80 }); } } } } } // Special level 51 pattern with starting swing if (i === 51) { // Start with a swing anchor at the beginning levelData[i].swingAnchors.push({ x: 500, y: groundLevel - 150 }); // Add platform to swing to levelData[i].platforms.push({ x: 700, y: groundLevel - 100, width: 120 }); // Add spikes after platform for (var s51 = 0; s51 < 5; s51++) { levelData[i].spikes.push({ x: 900 + s51 * 200, y: groundLevel }); } // Add more swing anchors throughout level levelData[i].swingAnchors.push({ x: 1200, y: groundLevel - 200 }); levelData[i].swingAnchors.push({ x: 1600, y: groundLevel - 180 }); // Add challenging platform sequence for (var p51 = 0; p51 < 4; p51++) { levelData[i].platforms.push({ x: 1800 + p51 * 300, y: groundLevel - 120 - p51 % 2 * 60, width: 100 }); levelData[i].spikes.push({ x: 1850 + p51 * 300, y: groundLevel - 120 - p51 % 2 * 60 }); } } // Levels 52-68: Next page ultra-hard levels if (i >= 52 && i <= 68) { var ultraPattern = (i - 52) % 17; if (ultraPattern === 0) { // Level 52: Moving spike walls for (var msw = 0; msw < 6; msw++) { for (var wall = 0; wall < 5; wall++) { levelData[i].spikes.push({ x: 800 + msw * 350, y: groundLevel - wall * 45 }); } // Add narrow safe passage levelData[i].platforms.push({ x: 950 + msw * 350, y: groundLevel - 150, width: 60 }); } } else if (ultraPattern === 1) { // Level 53: Ship tunnel nightmare levelData[i].shipMode = true; for (var stn = 0; stn < 12; stn++) { levelData[i].spikes.push({ x: 700 + stn * 150, y: groundLevel }); levelData[i].spikes.push({ x: 725 + stn * 150, y: groundLevel - 80 }); levelData[i].spikes.push({ x: 750 + stn * 150, y: groundLevel - 160 }); levelData[i].spikes.push({ x: 775 + stn * 150, y: groundLevel - 240 }); } } else if (ultraPattern === 2) { // Level 54: Triple layer platform maze for (var tlm = 0; tlm < 5; tlm++) { // Bottom layer levelData[i].platforms.push({ x: 700 + tlm * 400, y: groundLevel - 80, width: 80 }); levelData[i].spikes.push({ x: 780 + tlm * 400, y: groundLevel - 80 }); // Middle layer levelData[i].platforms.push({ x: 850 + tlm * 400, y: groundLevel - 160, width: 80 }); levelData[i].spikes.push({ x: 930 + tlm * 400, y: groundLevel - 160 }); // Top layer levelData[i].platforms.push({ x: 1000 + tlm * 400, y: groundLevel - 240, width: 80 }); levelData[i].spikes.push({ x: 1080 + tlm * 400, y: groundLevel - 240 }); } } else if (ultraPattern === 3) { // Level 55: Swing chain challenge for (var scc = 0; scc < 8; scc++) { levelData[i].swingAnchors.push({ x: 600 + scc * 250, y: groundLevel - 200 - scc % 3 * 50 }); // Add spikes below each swing point levelData[i].spikes.push({ x: 575 + scc * 250, y: groundLevel }); levelData[i].spikes.push({ x: 625 + scc * 250, y: groundLevel }); } } else if (ultraPattern === 4) { // Level 56: Rapid fire precision for (var rfp = 0; rfp < 20; rfp++) { levelData[i].spikes.push({ x: 600 + rfp * 80, y: groundLevel }); if (rfp % 4 === 3) { levelData[i].spikes.push({ x: 620 + rfp * 80, y: groundLevel }); levelData[i].spikes.push({ x: 640 + rfp * 80, y: groundLevel }); } } } else if (ultraPattern === 5) { // Level 57: Alternating cube/ship sections for (var acs = 0; acs < 8; acs++) { if (acs < 4) { // Cube section levelData[i].spikes.push({ x: 700 + acs * 200, y: groundLevel }); levelData[i].platforms.push({ x: 800 + acs * 200, y: groundLevel - 100, width: 100 }); } else { // Ship section indicators (spikes arranged for ship mode) levelData[i].spikes.push({ x: 700 + acs * 200, y: groundLevel }); levelData[i].spikes.push({ x: 720 + acs * 200, y: groundLevel - 150 }); } } if (i % 2 === 1) { levelData[i].shipMode = true; } } else if (ultraPattern === 6) { // Level 58: Micro platforms for (var mp = 0; mp < 10; mp++) { levelData[i].platforms.push({ x: 700 + mp * 180, y: groundLevel - 100 - mp % 4 * 30, width: 40 }); levelData[i].spikes.push({ x: 740 + mp * 180, y: groundLevel - 100 - mp % 4 * 30 }); levelData[i].spikes.push({ x: 880 + mp * 180, y: groundLevel }); } } else if (ultraPattern === 7) { // Level 59: Ceiling and floor spikes levelData[i].shipMode = true; for (var cfs = 0; cfs < 10; cfs++) { levelData[i].spikes.push({ x: 700 + cfs * 150, y: groundLevel }); levelData[i].spikes.push({ x: 725 + cfs * 150, y: groundLevel - 300 }); // Create narrow safe corridor if (cfs % 3 === 1) { levelData[i].coins.push({ x: 712 + cfs * 150, y: groundLevel - 150 }); } } } else if (ultraPattern === 8) { // Level 60: Swing through spike field for (var stsf = 0; stsf < 6; stsf++) { levelData[i].swingAnchors.push({ x: 700 + stsf * 300, y: groundLevel - 250 }); // Dense spike field below for (var sf = 0; sf < 5; sf++) { levelData[i].spikes.push({ x: 600 + stsf * 300 + sf * 50, y: groundLevel }); levelData[i].spikes.push({ x: 625 + stsf * 300 + sf * 50, y: groundLevel - 60 }); } } } else if (ultraPattern === 9) { // Level 61: Stairway to hell for (var sth = 0; sth < 8; sth++) { var stairHeight = groundLevel - sth * 40; levelData[i].platforms.push({ x: 700 + sth * 150, y: stairHeight, width: 70 }); levelData[i].spikes.push({ x: 770 + sth * 150, y: stairHeight }); levelData[i].spikes.push({ x: 850 + sth * 150, y: groundLevel }); } } else if (ultraPattern === 10) { // Level 62: Ship slalom levelData[i].shipMode = true; for (var ss = 0; ss < 15; ss++) { var slalomY = groundLevel - 150 + Math.sin(ss * 0.8) * 100; levelData[i].spikes.push({ x: 700 + ss * 120, y: slalomY }); levelData[i].spikes.push({ x: 720 + ss * 120, y: slalomY + 50 }); } } else if (ultraPattern === 11) { // Level 63: Platform chains for (var pc = 0; pc < 6; pc++) { for (var chain = 0; chain < 4; chain++) { levelData[i].platforms.push({ x: 700 + pc * 350 + chain * 70, y: groundLevel - 80 - chain * 60, width: 50 }); if (chain < 3) { levelData[i].spikes.push({ x: 725 + pc * 350 + chain * 70, y: groundLevel - 80 - chain * 60 }); } } } } else if (ultraPattern === 12) { // Level 64: Double swing challenge for (var dsc = 0; dsc < 5; dsc++) { levelData[i].swingAnchors.push({ x: 700 + dsc * 400, y: groundLevel - 200 }); levelData[i].swingAnchors.push({ x: 900 + dsc * 400, y: groundLevel - 180 }); // Spike barriers for (var sb = 0; sb < 6; sb++) { levelData[i].spikes.push({ x: 650 + dsc * 400 + sb * 40, y: groundLevel }); } } } else if (ultraPattern === 13) { // Level 65: Speed demon for (var sd = 0; sd < 25; sd++) { levelData[i].spikes.push({ x: 600 + sd * 60, y: groundLevel }); if (sd % 5 === 2) { levelData[i].spikes.push({ x: 615 + sd * 60, y: groundLevel }); levelData[i].spikes.push({ x: 630 + sd * 60, y: groundLevel }); } } } else if (ultraPattern === 14) { // Level 66: Ship maze finale levelData[i].shipMode = true; for (var smf = 0; smf < 8; smf++) { levelData[i].spikes.push({ x: 700 + smf * 200, y: groundLevel }); levelData[i].spikes.push({ x: 720 + smf * 200, y: groundLevel - 80 }); levelData[i].spikes.push({ x: 740 + smf * 200, y: groundLevel - 160 }); levelData[i].spikes.push({ x: 760 + smf * 200, y: groundLevel - 240 }); levelData[i].spikes.push({ x: 780 + smf * 200, y: groundLevel - 320 }); } } else if (ultraPattern === 15) { // Level 67: Ultimate precision test for (var upt = 0; upt < 12; upt++) { levelData[i].platforms.push({ x: 700 + upt * 150, y: groundLevel - 80 - upt % 3 * 80, width: 30 }); levelData[i].spikes.push({ x: 730 + upt * 150, y: groundLevel - 80 - upt % 3 * 80 }); levelData[i].spikes.push({ x: 850 + upt * 150, y: groundLevel }); } } else { // Level 68: Final boss gauntlet for (var fbg = 0; fbg < 6; fbg++) { // Multi-height spike walls for (var wall = 0; wall < 6; wall++) { levelData[i].spikes.push({ x: 700 + fbg * 400, y: groundLevel - wall * 50 }); } // Narrow platform escape levelData[i].platforms.push({ x: 750 + fbg * 400, y: groundLevel - 200, width: 40 }); // Swing anchor for advanced navigation levelData[i].swingAnchors.push({ x: 850 + fbg * 400, y: groundLevel - 300 }); // More spikes after swing for (var afterSpike = 0; afterSpike < 4; afterSpike++) { levelData[i].spikes.push({ x: 900 + fbg * 400 + afterSpike * 30, y: groundLevel }); } } } } // Add default coins if none were added yet if (levelData[i].coins.length === 0) { var coinCount = Math.max(2, Math.floor(i / 5) + 1); for (var c = 0; c < coinCount; c++) { levelData[i].coins.push({ x: 600 + c * (levelData[i].length / (coinCount + 1)), y: groundLevel - 80 - c % 3 * 40 }); } } // Add checkpoints based on level length var checkpointCount = Math.max(1, Math.floor(levelData[i].length / 800)); for (var k = 1; k <= checkpointCount; k++) { levelData[i].checkpoints.push({ x: k * (levelData[i].length / (checkpointCount + 1)), y: groundLevel }); } } } // UI Setup function setupUI() { // Score display var scoreText = new Text2('Level: ' + currentLevel, { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0, 0); scoreText.x = 120; scoreText.y = 50; LK.gui.topLeft.addChild(scoreText); // Coin counter var coinText = new Text2('Coins: ' + storage.totalCoins, { size: 50, fill: 0xFFD700 }); coinText.anchor.set(0, 0); coinText.x = 120; coinText.y = 120; LK.gui.topLeft.addChild(coinText); // Gem counter var gemText = new Text2('Gems: ' + storage.totalGems, { size: 50, fill: 0xFF00FF }); gemText.anchor.set(0, 0); gemText.x = 120; gemText.y = 190; LK.gui.topLeft.addChild(gemText); // Arcade token counter var arcadeText = new Text2('Tokens: ' + storage.arcadeTokens, { size: 45, fill: 0x00ff88 }); arcadeText.anchor.set(0, 0); arcadeText.x = 120; arcadeText.y = 260; LK.gui.topLeft.addChild(arcadeText); // Power point counter var powerText = new Text2('Power: ' + storage.powerPoints, { size: 45, fill: 0xff4400 }); powerText.anchor.set(0, 0); powerText.x = 120; powerText.y = 320; LK.gui.topLeft.addChild(powerText); // Beauty coin counter var beautyText = new Text2('Beauty: ' + storage.beautyCoins, { size: 45, fill: 0x8844ff }); beautyText.anchor.set(0, 0); beautyText.x = 120; beautyText.y = 380; LK.gui.topLeft.addChild(beautyText); // Expedition token counter var expeditionText = new Text2('Expedition: ' + storage.expeditionTokens, { size: 40, fill: 0xaa8800 }); expeditionText.anchor.set(0, 0); expeditionText.x = 120; expeditionText.y = 440; LK.gui.topLeft.addChild(expeditionText); // Mystic crystal counter var mysticText = new Text2('Mystic: ' + storage.mysticCrystals, { size: 40, fill: 0x9966cc }); mysticText.anchor.set(0, 0); mysticText.x = 120; mysticText.y = 500; LK.gui.topLeft.addChild(mysticText); // Elite credit counter var eliteText = new Text2('Elite: ' + storage.eliteCredits, { size: 40, fill: 0xcc6600 }); eliteText.anchor.set(0, 0); eliteText.x = 120; eliteText.y = 560; LK.gui.topLeft.addChild(eliteText); // VIP point counter var vipText = new Text2('VIP: ' + storage.vipPoints, { size: 40, fill: 0xffd700 }); vipText.anchor.set(0, 0); vipText.x = 120; vipText.y = 620; LK.gui.topLeft.addChild(vipText); } // Level selection menu function showLevelMenu() { gameState = 'menu'; game.removeChildren(); levelButtons = []; // Title var titleText = new Text2('Geometry Dash: 50 Levels', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 200; game.addChild(titleText); // Create level buttons in grid var buttonsPerRow = 5; var buttonSpacing = 220; var startX = 1024 - (buttonsPerRow - 1) * buttonSpacing / 2; var startY = 480; for (var i = 1; i <= maxLevels; i++) { var row = Math.floor((i - 1) / buttonsPerRow); var col = (i - 1) % buttonsPerRow; var buttonX = startX + col * buttonSpacing; var buttonY = startY + row * 150; var levelBtn = game.addChild(new LevelButton(i, buttonX, buttonY)); levelButtons.push(levelBtn); } // Daily level button var dailyButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); dailyButton.x = 1024; dailyButton.y = startY + Math.ceil(maxLevels / buttonsPerRow) * 150 + 250; dailyButton.tint = storage.dailyLevelCompleted ? 0x00ff00 : 0xff6600; dailyButton.scaleX = 1.2; dailyButton.scaleY = 1.2; game.addChild(dailyButton); var dailyText = new Text2('DAILY', { size: 35, fill: 0xFFFFFF }); dailyText.anchor.set(0.5, 0.3); dailyText.x = dailyButton.x; dailyText.y = dailyButton.y; game.addChild(dailyText); var dailyCoinText = new Text2(storage.dailyLevelCoins + '/5', { size: 25, fill: 0xFFD700 }); dailyCoinText.anchor.set(0.5, 0.7); dailyCoinText.x = dailyButton.x; dailyCoinText.y = dailyButton.y; game.addChild(dailyCoinText); dailyButton.down = function (x, y, obj) { currentLevel = 'daily'; showGameplay(); }; // Video button var videoButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); videoButton.x = 1024; videoButton.y = startY + Math.ceil(maxLevels / buttonsPerRow) * 150 + 400; videoButton.tint = 0x9933ff; game.addChild(videoButton); var videoText = new Text2('Video', { size: 40, fill: 0xFFFFFF }); videoText.anchor.set(0.5, 0.5); videoText.x = videoButton.x; videoText.y = videoButton.y; game.addChild(videoText); videoButton.down = function (x, y, obj) { showVideoTutorial(); }; // Shop button var shopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); shopButton.x = 924; shopButton.y = 300; shopButton.tint = 0x00aaff; game.addChild(shopButton); var shopText = new Text2('Shop', { size: 40, fill: 0xFFFFFF }); shopText.anchor.set(0.5, 0.5); shopText.x = shopButton.x; shopText.y = shopButton.y; game.addChild(shopText); shopButton.down = function (x, y, obj) { showShop(); }; // Daily Shop button var dailyShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); dailyShopButton.x = 1124; dailyShopButton.y = 300; dailyShopButton.tint = 0xff6600; game.addChild(dailyShopButton); var dailyShopText = new Text2('Daily Shop', { size: 32, fill: 0xFFFFFF }); dailyShopText.anchor.set(0.5, 0.5); dailyShopText.x = dailyShopButton.x; dailyShopText.y = dailyShopButton.y; game.addChild(dailyShopText); dailyShopButton.down = function (x, y, obj) { showDailyShop(); }; // Gem Shop button var gemShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); gemShopButton.x = 724; gemShopButton.y = 300; gemShopButton.tint = 0xff00ff; game.addChild(gemShopButton); var gemShopText = new Text2('Gem Shop', { size: 32, fill: 0xFFFFFF }); gemShopText.anchor.set(0.5, 0.5); gemShopText.x = gemShopButton.x; gemShopText.y = gemShopButton.y; game.addChild(gemShopText); gemShopButton.down = function (x, y, obj) { showGemShop(); }; // Arcade Shop button var arcadeShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); arcadeShopButton.x = 524; arcadeShopButton.y = 300; arcadeShopButton.tint = 0x00ff88; game.addChild(arcadeShopButton); var arcadeShopText = new Text2('Arcade Shop', { size: 28, fill: 0xFFFFFF }); arcadeShopText.anchor.set(0.5, 0.5); arcadeShopText.x = arcadeShopButton.x; arcadeShopText.y = arcadeShopButton.y; game.addChild(arcadeShopText); arcadeShopButton.down = function (x, y, obj) { showArcadeShop(); }; // Power Shop button var powerShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); powerShopButton.x = 824; powerShopButton.y = 450; powerShopButton.tint = 0xff4400; game.addChild(powerShopButton); var powerShopText = new Text2('Power Shop', { size: 32, fill: 0xFFFFFF }); powerShopText.anchor.set(0.5, 0.5); powerShopText.x = powerShopButton.x; powerShopText.y = powerShopButton.y; game.addChild(powerShopText); powerShopButton.down = function (x, y, obj) { showPowerShop(); }; // Cosmetic Shop button var cosmeticShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); cosmeticShopButton.x = 1224; cosmeticShopButton.y = 450; cosmeticShopButton.tint = 0x8844ff; game.addChild(cosmeticShopButton); var cosmeticShopText = new Text2('Cosmetic Shop', { size: 28, fill: 0xFFFFFF }); cosmeticShopText.anchor.set(0.5, 0.5); cosmeticShopText.x = cosmeticShopButton.x; cosmeticShopText.y = cosmeticShopButton.y; game.addChild(cosmeticShopText); cosmeticShopButton.down = function (x, y, obj) { showCosmeticShop(); }; // Expedition Shop button var expeditionShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); expeditionShopButton.x = 424; expeditionShopButton.y = 600; expeditionShopButton.tint = 0xaa8800; game.addChild(expeditionShopButton); var expeditionShopText = new Text2('Expedition', { size: 28, fill: 0xFFFFFF }); expeditionShopText.anchor.set(0.5, 0.5); expeditionShopText.x = expeditionShopButton.x; expeditionShopText.y = expeditionShopButton.y; game.addChild(expeditionShopText); expeditionShopButton.down = function (x, y, obj) { showExpeditionShop(); }; // Mystic Shop button var mysticShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); mysticShopButton.x = 624; mysticShopButton.y = 600; mysticShopButton.tint = 0x9966cc; game.addChild(mysticShopButton); var mysticShopText = new Text2('Mystic', { size: 32, fill: 0xFFFFFF }); mysticShopText.anchor.set(0.5, 0.5); mysticShopText.x = mysticShopButton.x; mysticShopText.y = mysticShopButton.y; game.addChild(mysticShopText); mysticShopButton.down = function (x, y, obj) { showMysticShop(); }; // Elite Shop button var eliteShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); eliteShopButton.x = 824; eliteShopButton.y = 600; eliteShopButton.tint = 0xcc6600; game.addChild(eliteShopButton); var eliteShopText = new Text2('Elite', { size: 32, fill: 0xFFFFFF }); eliteShopText.anchor.set(0.5, 0.5); eliteShopText.x = eliteShopButton.x; eliteShopText.y = eliteShopButton.y; game.addChild(eliteShopText); eliteShopButton.down = function (x, y, obj) { showEliteShop(); }; // VIP Shop button var vipShopButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); vipShopButton.x = 1224; vipShopButton.y = 600; vipShopButton.tint = 0xffd700; game.addChild(vipShopButton); var vipShopText = new Text2('VIP', { size: 32, fill: 0xFFFFFF }); vipShopText.anchor.set(0.5, 0.5); vipShopText.x = vipShopButton.x; vipShopText.y = vipShopButton.y; game.addChild(vipShopText); vipShopButton.down = function (x, y, obj) { showVipShop(); }; // Map Packs button var mapPacksButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); mapPacksButton.x = 624; mapPacksButton.y = 750; mapPacksButton.tint = 0x00cc66; game.addChild(mapPacksButton); var mapPacksText = new Text2('Map Packs', { size: 32, fill: 0xFFFFFF }); mapPacksText.anchor.set(0.5, 0.5); mapPacksText.x = mapPacksButton.x; mapPacksText.y = mapPacksButton.y; game.addChild(mapPacksText); mapPacksButton.down = function (x, y, obj) { showMapPacks(); }; // Level Editor button var levelEditorButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); levelEditorButton.x = 1424; levelEditorButton.y = 750; levelEditorButton.tint = 0xff6600; game.addChild(levelEditorButton); var levelEditorText = new Text2('Level Editor', { size: 28, fill: 0xFFFFFF }); levelEditorText.anchor.set(0.5, 0.5); levelEditorText.x = levelEditorButton.x; levelEditorText.y = levelEditorButton.y; game.addChild(levelEditorText); levelEditorButton.down = function (x, y, obj) { showLevelEditor(); }; // Owner commands button (moved down) var ownerButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); ownerButton.x = 1024; ownerButton.y = 750; ownerButton.tint = 0xffaa00; game.addChild(ownerButton); var ownerText = new Text2('Owner', { size: 40, fill: 0xFFFFFF }); ownerText.anchor.set(0.5, 0.5); ownerText.x = ownerButton.x; ownerText.y = ownerButton.y; game.addChild(ownerText); ownerButton.down = function (x, y, obj) { showOwnerCommands(); }; } // Show gameplay function showGameplay() { gameState = 'playing'; game.removeChildren(); // Reset camera cameraX = 0; currentCheckpoint = 0; deathCount = 0; // Reset shield for new level storage.shieldUsed = false; // Create player player = game.addChild(new Player()); player.x = playerStartX; player.y = playerStartY; // Set ship mode based on level data if (levelData[currentLevel] && levelData[currentLevel].shipMode) { player.setMode(true); player.y = groundLevel - 200; // Start ship higher up } else { player.setMode(false); } // Load current level loadLevel(currentLevel); } // Load level obstacles function loadLevel(levelNum) { obstacles = []; platforms = []; grounds = []; checkpoints = []; swingAnchors = []; coins = []; var level = levelData[levelNum]; if (!level) { // If level data doesn't exist, create a basic level level = { spikes: [], platforms: [], checkpoints: [], swingAnchors: [], coins: [], length: 3000, shipMode: false }; } // Create ground segments for (var x = 0; x <= level.length + 1000; x += 200) { var ground = game.addChild(new Ground(x, groundLevel, 200)); grounds.push(ground); } // Create spikes for (var i = 0; i < level.spikes.length; i++) { var spikeData = level.spikes[i]; var spike = game.addChild(new Spike(spikeData.x, spikeData.y)); obstacles.push(spike); } // Create platforms for (var j = 0; j < level.platforms.length; j++) { var platformData = level.platforms[j]; var platform = game.addChild(new Platform(platformData.x, platformData.y, platformData.width)); platforms.push(platform); } // Create checkpoints for (var k = 0; k < level.checkpoints.length; k++) { var checkpointData = level.checkpoints[k]; var checkpoint = game.addChild(new Checkpoint(checkpointData.x, checkpointData.y)); checkpoints.push(checkpoint); } // Create swing anchors for (var s = 0; s < level.swingAnchors.length; s++) { var anchorData = level.swingAnchors[s]; var swingAnchor = game.addChild(new SwingAnchor(anchorData.x, anchorData.y)); swingAnchors.push(swingAnchor); } // Create coins for (var c = 0; c < level.coins.length; c++) { var coinData = level.coins[c]; var coin = game.addChild(new Coin(coinData.x, coinData.y)); coins.push(coin); } } // Handle player death function handlePlayerDeath() { if (player.isDead || godModeEnabled) return; // Check shield protection if (storage.shield && !storage.shieldUsed) { storage.shieldUsed = true; LK.effects.flashScreen(0x00ffff, 300); LK.effects.flashObject(player, 0x00ffff, 1000); return; // Shield absorbs hit } player.isDead = true; deathCount++; LK.effects.flashScreen(0xff0000, 500); LK.getSound('death').play(); // Respawn after delay LK.setTimeout(function () { respawnPlayer(); }, 1000); } // Respawn player at checkpoint function respawnPlayer() { player.isDead = false; player.velocityY = 0; player.isGrounded = false; if (currentCheckpoint > 0 && checkpoints[currentCheckpoint - 1]) { player.x = checkpoints[currentCheckpoint - 1].x; cameraX = checkpoints[currentCheckpoint - 1].x - 400; } else { player.x = playerStartX; cameraX = 0; } player.y = groundLevel; } // Handle level completion function completeLevel() { if (currentLevel === 'daily') { storage.dailyLevelCompleted = true; // Give 2 gems for daily level completion storage.totalGems += 2; // Give 3 arcade tokens for daily level storage.arcadeTokens += 3; // Give 2 power points for daily level storage.powerPoints += 2; // Give 2 beauty coins for daily level storage.beautyCoins += 2; } else { storage.completedLevels[currentLevel] = true; // Give 1 gem for regular level completion storage.totalGems += 1; // Give arcade tokens based on level (1-2 tokens) storage.arcadeTokens += Math.floor(currentLevel / 10) + 1; // Give power points based on level difficulty storage.powerPoints += Math.floor(currentLevel / 15) + 1; // Give beauty coins for completing levels storage.beautyCoins += Math.floor(currentLevel / 12) + 1; // Give expedition tokens for completing levels storage.expeditionTokens += Math.floor(currentLevel / 8) + 1; // Give mystic crystals for completing harder levels if (currentLevel >= 20) { storage.mysticCrystals += Math.floor(currentLevel / 25) + 1; } // Give elite credits for completing very hard levels if (currentLevel >= 35) { storage.eliteCredits += Math.floor(currentLevel / 40) + 1; } // Give VIP points for completing the hardest levels if (currentLevel >= 50) { storage.vipPoints += Math.floor(currentLevel / 60) + 1; } } LK.getSound('complete').play(); LK.effects.flashScreen(0x00ff00, 1000); // Show completion message var completeText = new Text2('Level Complete!', { size: 100, fill: 0x00FF00 }); completeText.anchor.set(0.5, 0.5); completeText.x = 1024; completeText.y = 1366; game.addChild(completeText); // Return to menu after delay LK.setTimeout(function () { showLevelMenu(); }, 2000); } // Input handling game.down = function (x, y, obj) { if (gameState === 'playing' && player && !player.isDead) { player.jump(); } }; game.up = function (x, y, obj) { if (gameState === 'playing' && player && !player.isDead) { player.stopJump(); } }; // Main game loop game.update = function () { if (gameState !== 'playing' || !player || player.isDead) return; // Auto-scroll camera with speed multiplier var currentScrollSpeed = scrollSpeed * (storage.speedMultiplier || 1.0); cameraX += currentScrollSpeed; player.x += currentScrollSpeed; // Update camera position var targetCameraX = player.x - 400; if (targetCameraX > cameraX) { cameraX = targetCameraX; } // Position all game objects relative to camera game.x = -cameraX; // Check obstacle collisions for (var i = 0; i < obstacles.length; i++) { var obstacle = obstacles[i]; if (player.intersects(obstacle)) { handlePlayerDeath(); break; } } // Check platform collisions (simple top collision) for (var j = 0; j < platforms.length; j++) { var platform = platforms[j]; if (player.intersects(platform) && player.velocityY > 0) { var playerBottom = player.y; var platformTop = platform.y; if (playerBottom >= platformTop && playerBottom <= platformTop + 20) { player.y = platformTop; player.velocityY = 0; player.isGrounded = true; } } } // Check checkpoint activation for (var k = 0; k < checkpoints.length; k++) { var checkpoint = checkpoints[k]; if (!checkpoint.activated && player.intersects(checkpoint)) { checkpoint.activated = true; currentCheckpoint = k + 1; LK.effects.flashObject(checkpoint, 0x00ffff, 500); } } // Check swing anchor activation for (var s = 0; s < swingAnchors.length; s++) { var anchor = swingAnchors[s]; if (!anchor.isActive && !player.isSwinging && player.intersects(anchor)) { var distance = Math.sqrt(Math.pow(player.x - anchor.x, 2) + Math.pow(player.y - anchor.y, 2)); if (distance < 80) { // Activation range anchor.activateSwing(player); break; } } } // Check coin collection for (var c = 0; c < coins.length; c++) { var coin = coins[c]; // Coin magnet effect if (!coin.collected && storage.coinMagnet) { var coinDistance = Math.sqrt(Math.pow(player.x - coin.x, 2) + Math.pow(player.y - coin.y, 2)); if (coinDistance < 150) { // Magnet range // Move coin towards player var magnetForce = 8; var dirX = (player.x - coin.x) / coinDistance; var dirY = (player.y - coin.y) / coinDistance; coin.x += dirX * magnetForce; coin.y += dirY * magnetForce; } } if (!coin.collected && player.intersects(coin)) { coin.collected = true; coin.visible = false; storage.totalCoins++; // Update level-specific coin tracking if (currentLevel === 'daily') { storage.dailyLevelCoins++; } else { if (!storage.levelCoins[currentLevel]) { storage.levelCoins[currentLevel] = 0; } storage.levelCoins[currentLevel]++; } // Play coin sound and visual effect LK.getSound('coin').play(); LK.effects.flashObject(coin, 0xFFD700, 300); // Update coin counter var coinTexts = LK.gui.topLeft.children; for (var t = 0; t < coinTexts.length; t++) { if (coinTexts[t].text && coinTexts[t].text.indexOf('Coins:') === 0) { coinTexts[t].setText('Coins: ' + storage.totalCoins); break; } } } } // Check level completion var levelLength = levelData[currentLevel] ? levelData[currentLevel].length : 3000; if (player.x >= levelLength) { completeLevel(); } // Check if player fell off screen if (player.y > 2800) { handlePlayerDeath(); } // Update debug info if (debugInfoVisible && debugText) { var debugInfo = 'X: ' + Math.floor(player.x) + '\nY: ' + Math.floor(player.y) + '\nVelocity Y: ' + Math.floor(player.velocityY) + '\nCheckpoint: ' + currentCheckpoint + '\nDeaths: ' + deathCount + '\nGod Mode: ' + (godModeEnabled ? 'ON' : 'OFF') + '\nSpeed Boost: ' + (speedBoostEnabled ? 'ON' : 'OFF'); debugText.setText(debugInfo); } }; // Video tutorial screen function showVideoTutorial() { gameState = 'video'; game.removeChildren(); // Title var titleText = new Text2('How to Beat Geometry Dash', { size: 70, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Instructions sections var instructions = ['BASIC CONTROLS:', 'β’ Tap/Click to jump in cube mode', 'β’ Hold to fly up in ship mode', 'β’ Release to fall down in ship mode', '', 'GAMEPLAY TIPS:', 'β’ Red spikes = deadly obstacles', 'β’ Gray platforms = safe to land on', 'β’ Cyan checkpoints = save your progress', 'β’ Green squares = completed levels', '', 'LEVEL PROGRESSION:', 'β’ Levels 1-10: Learn basic mechanics', 'β’ Levels 11-20: Master timing and ship mode', 'β’ Levels 21-35: Expert precision required', 'β’ Levels 36-50: Ultimate challenges', '', 'SURVIVAL STRATEGY:', 'β’ Practice timing on easier levels first', 'β’ Use checkpoints to avoid restarting', 'β’ Ship levels require smooth control', 'β’ Platform levels need precise jumps']; var instructionY = 300; var lineHeight = 45; for (var i = 0; i < instructions.length; i++) { var line = instructions[i]; var isHeader = line.endsWith(':'); var fontSize = isHeader ? 50 : 40; var color = isHeader ? 0x00FF00 : 0xFFFFFF; var instructionText = new Text2(line, { size: fontSize, fill: color }); instructionText.anchor.set(0, 0); instructionText.x = 200; instructionY += line === '' ? lineHeight * 0.5 : lineHeight; instructionText.y = instructionY; game.addChild(instructionText); } // Demo visual elements var demoY = 1800; // Show cube example var demoCube = LK.getAsset('player', { anchorX: 0.5, anchorY: 1.0 }); demoCube.x = 400; demoCube.y = demoY; game.addChild(demoCube); var cubeLabel = new Text2('Cube Mode', { size: 35, fill: 0x00FF00 }); cubeLabel.anchor.set(0.5, 0); cubeLabel.x = demoCube.x; cubeLabel.y = demoY + 20; game.addChild(cubeLabel); // Show ship example var demoShip = LK.getAsset('ship', { anchorX: 0.5, anchorY: 0.5 }); demoShip.x = 800; demoShip.y = demoY - 30; game.addChild(demoShip); var shipLabel = new Text2('Ship Mode', { size: 35, fill: 0x0088FF }); shipLabel.anchor.set(0.5, 0); shipLabel.x = demoShip.x; shipLabel.y = demoY + 20; game.addChild(shipLabel); // Show spike example var demoSpike = LK.getAsset('spike', { anchorX: 0.5, anchorY: 1.0 }); demoSpike.x = 1200; demoSpike.y = demoY; game.addChild(demoSpike); var spikeLabel = new Text2('Deadly Spike', { size: 35, fill: 0xFF0000 }); spikeLabel.anchor.set(0.5, 0); spikeLabel.x = demoSpike.x; spikeLabel.y = demoY + 20; game.addChild(spikeLabel); // Show platform example var demoPlatform = LK.getAsset('platform', { anchorX: 0, anchorY: 0 }); demoPlatform.x = 1500; demoPlatform.y = demoY - 40; demoPlatform.width = 150; game.addChild(demoPlatform); var platformLabel = new Text2('Safe Platform', { size: 35, fill: 0x888888 }); platformLabel.anchor.set(0.5, 0); platformLabel.x = demoPlatform.x + 75; platformLabel.y = demoY + 20; game.addChild(platformLabel); // Animate demo elements var animTime = 0; var videoUpdateTimer = LK.setInterval(function () { animTime += 0.1; // Bounce cube demoCube.y = demoY + Math.abs(Math.sin(animTime * 2)) * -30; // Float ship demoShip.y = demoY - 30 + Math.sin(animTime) * 15; // Pulse spike demoSpike.alpha = 0.7 + Math.sin(animTime * 3) * 0.3; }, 50); // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 2400; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { LK.clearInterval(videoUpdateTimer); showLevelMenu(); }; } // Shop screen function showShop() { gameState = 'shop'; game.removeChildren(); // Title var titleText = new Text2('Geometry Dash Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Coin display var coinDisplayText = new Text2('Coins: ' + storage.totalCoins, { size: 60, fill: 0xFFD700 }); coinDisplayText.anchor.set(0.5, 0); coinDisplayText.x = 1024; coinDisplayText.y = 250; game.addChild(coinDisplayText); // Shop items var shopItems = [{ name: 'Red Player', price: 100, type: 'playerColor', value: 0xff0000, description: 'Change player color to red' }, { name: 'Blue Player', price: 100, type: 'playerColor', value: 0x0000ff, description: 'Change player color to blue' }, { name: 'Yellow Player', price: 150, type: 'playerColor', value: 0xffff00, description: 'Change player color to yellow' }, { name: 'Purple Player', price: 150, type: 'playerColor', value: 0xff00ff, description: 'Change player color to purple' }, { name: 'Orange Player', price: 120, type: 'playerColor', value: 0xff8800, description: 'Change player color to orange' }, { name: 'Cyan Player', price: 120, type: 'playerColor', value: 0x00ffff, description: 'Change player color to cyan' }, { name: 'Pink Player', price: 180, type: 'playerColor', value: 0xff69b4, description: 'Change player color to pink' }, { name: 'Red Ship', price: 120, type: 'shipColor', value: 0xff0000, description: 'Change ship color to red' }, { name: 'Green Ship', price: 120, type: 'shipColor', value: 0x00ff00, description: 'Change ship color to green' }, { name: 'Yellow Ship', price: 180, type: 'shipColor', value: 0xffff00, description: 'Change ship color to yellow' }, { name: 'Purple Ship', price: 180, type: 'shipColor', value: 0xff00ff, description: 'Change ship color to purple' }, { name: 'Orange Ship', price: 160, type: 'shipColor', value: 0xff8800, description: 'Change ship color to orange' }, { name: 'Speed Boost', price: 300, type: 'speedMultiplier', value: 1.5, description: 'Increase movement speed by 50%' }, { name: 'Super Speed', price: 600, type: 'speedMultiplier', value: 2.0, description: 'Double movement speed' }, { name: 'Coin Magnet', price: 500, type: 'coinMagnet', value: true, description: 'Automatically collect nearby coins' }, { name: 'Extra Checkpoint', price: 250, type: 'checkpoint', value: true, description: 'Add extra checkpoints in levels' }, { name: 'Jump Boost', price: 400, type: 'jumpBoost', value: true, description: 'Jump 25% higher in cube mode' }, { name: 'Shield Protection', price: 800, type: 'shield', value: true, description: 'Survive one spike hit per level' }, { name: 'Size Reduction', price: 350, type: 'smallSize', value: true, description: 'Make player 25% smaller' }, { name: 'Trail Effect', price: 200, type: 'trail', value: true, description: 'Leave a colorful trail behind' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < shopItems.length; i++) { var item = shopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.shopPurchases[item.name] || false; var canAfford = storage.totalCoins >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0x0088ff; // Blue for affordable } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' coins', { size: 25, fill: isPurchased ? 0x00ff00 : 0xFFD700 }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.totalCoins -= itemToPurchase.price; storage.shopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(shopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Generate daily shop items function generateDailyShop() { var today = new Date(); var dateString = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate(); // Check if daily shop needs to be regenerated if (storage.dailyShopDate !== dateString) { storage.dailyShopDate = dateString; storage.dailyShopPurchases = {}; // Generate daily shop using date as seed for consistency var dayOfYear = Math.floor((today - new Date(today.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24)); var seed = dayOfYear + today.getFullYear() * 365; // All possible shop items var allItems = [{ name: 'Red Player', originalPrice: 100, type: 'playerColor', value: 0xff0000, description: 'Change player color to red' }, { name: 'Blue Player', originalPrice: 100, type: 'playerColor', value: 0x0000ff, description: 'Change player color to blue' }, { name: 'Yellow Player', originalPrice: 150, type: 'playerColor', value: 0xffff00, description: 'Change player color to yellow' }, { name: 'Purple Player', originalPrice: 150, type: 'playerColor', value: 0xff00ff, description: 'Change player color to purple' }, { name: 'Orange Player', originalPrice: 120, type: 'playerColor', value: 0xff8800, description: 'Change player color to orange' }, { name: 'Cyan Player', originalPrice: 120, type: 'playerColor', value: 0x00ffff, description: 'Change player color to cyan' }, { name: 'Pink Player', originalPrice: 180, type: 'playerColor', value: 0xff69b4, description: 'Change player color to pink' }, { name: 'Red Ship', originalPrice: 120, type: 'shipColor', value: 0xff0000, description: 'Change ship color to red' }, { name: 'Green Ship', originalPrice: 120, type: 'shipColor', value: 0x00ff00, description: 'Change ship color to green' }, { name: 'Yellow Ship', originalPrice: 180, type: 'shipColor', value: 0xffff00, description: 'Change ship color to yellow' }, { name: 'Purple Ship', originalPrice: 180, type: 'shipColor', value: 0xff00ff, description: 'Change ship color to purple' }, { name: 'Orange Ship', originalPrice: 160, type: 'shipColor', value: 0xff8800, description: 'Change ship color to orange' }, { name: 'Speed Boost', originalPrice: 300, type: 'speedMultiplier', value: 1.5, description: 'Increase movement speed by 50%' }, { name: 'Super Speed', originalPrice: 600, type: 'speedMultiplier', value: 2.0, description: 'Double movement speed' }, { name: 'Coin Magnet', originalPrice: 500, type: 'coinMagnet', value: true, description: 'Automatically collect nearby coins' }, { name: 'Extra Checkpoint', originalPrice: 250, type: 'checkpoint', value: true, description: 'Add extra checkpoints in levels' }, { name: 'Jump Boost', originalPrice: 400, type: 'jumpBoost', value: true, description: 'Jump 25% higher in cube mode' }, { name: 'Shield Protection', originalPrice: 800, type: 'shield', value: true, description: 'Survive one spike hit per level' }, { name: 'Size Reduction', originalPrice: 350, type: 'smallSize', value: true, description: 'Make player 25% smaller' }, { name: 'Trail Effect', originalPrice: 200, type: 'trail', value: true, description: 'Leave a colorful trail behind' }]; // Initialize daily shop items if not exists if (!storage.dailyShopItems) { storage.dailyShopItems = []; } // Select 3 random items for daily shop storage.dailyShopItems = []; var usedIndices = []; for (var i = 0; i < 3; i++) { var randomIndex; do { randomIndex = (seed + i * 7) % allItems.length; } while (usedIndices.indexOf(randomIndex) !== -1); usedIndices.push(randomIndex); var selectedItem = allItems[randomIndex]; // Apply random discount (20-50%) var discount = 20 + (seed + i * 3) % 31; var discountedPrice = Math.floor(selectedItem.originalPrice * (100 - discount) / 100); storage.dailyShopItems.push({ name: selectedItem.name, price: discountedPrice, discount: discount, type: selectedItem.type, value: selectedItem.value, description: selectedItem.description }); } } } // Daily shop screen function showDailyShop() { gameState = 'dailyShop'; game.removeChildren(); // Generate daily shop if needed generateDailyShop(); // Title var titleText = new Text2('Daily Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Date display var today = new Date(); var dateString = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate(); var dateText = new Text2('Date: ' + dateString, { size: 50, fill: 0x00FF00 }); dateText.anchor.set(0.5, 0); dateText.x = 1024; dateText.y = 250; game.addChild(dateText); // Coin display var coinDisplayText = new Text2('Coins: ' + storage.totalCoins, { size: 60, fill: 0xFFD700 }); coinDisplayText.anchor.set(0.5, 0); coinDisplayText.x = 1024; coinDisplayText.y = 320; game.addChild(coinDisplayText); // Shop items var itemY = 450; for (var i = 0; i < storage.dailyShopItems.length; i++) { var item = storage.dailyShopItems[i]; var currentItemY = itemY + i * 200; // Check if item is already purchased var isPurchased = storage.dailyShopPurchases[item.name] || false; var canAfford = storage.totalCoins >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = 1024; itemButton.y = currentItemY; itemButton.scaleX = 2.5; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0xff6600; // Orange for daily special } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 35, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = 1024; nameText.y = currentItemY - 25; game.addChild(nameText); // Item price and discount var discountText = item.discount + '% OFF!'; var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' coins (' + discountText + ')', { size: 28, fill: isPurchased ? 0x00ff00 : 0xFFD700 }); priceText.anchor.set(0.5, 0.5); priceText.x = 1024; priceText.y = currentItemY + 10; game.addChild(priceText); // Description var descText = new Text2(item.description, { size: 24, fill: 0xCCCCCC }); descText.anchor.set(0.5, 0.5); descText.x = 1024; descText.y = currentItemY + 35; game.addChild(descText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.totalCoins -= itemToPurchase.price; storage.dailyShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showDailyShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + storage.dailyShopItems.length * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Gem shop screen function showGemShop() { gameState = 'gemShop'; game.removeChildren(); // Title var titleText = new Text2('Premium Gem Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Gem display var gemDisplayText = new Text2('Gems: ' + storage.totalGems, { size: 60, fill: 0xFF00FF }); gemDisplayText.anchor.set(0.5, 0); gemDisplayText.x = 1024; gemDisplayText.y = 250; game.addChild(gemDisplayText); // Premium shop items var gemShopItems = [{ name: 'Rainbow Player', price: 5, type: 'playerColor', value: 0x00ffff, description: 'Exclusive rainbow-like cyan player' }, { name: 'Golden Player', price: 8, type: 'playerColor', value: 0xffd700, description: 'Luxurious golden player color' }, { name: 'Diamond Ship', price: 10, type: 'shipColor', value: 0xb9f2ff, description: 'Sparkling diamond ship' }, { name: 'Ruby Ship', price: 8, type: 'shipColor', value: 0xe0115f, description: 'Deep ruby red ship' }, { name: 'Ultra Speed', price: 15, type: 'speedMultiplier', value: 3.0, description: 'Triple movement speed' }, { name: 'Mega Jump', price: 12, type: 'jumpBoost', value: true, description: 'Jump 50% higher than normal' }, { name: 'Double Shield', price: 20, type: 'shield', value: true, description: 'Survive two spike hits per level' }, { name: 'Coin Multiplier x2', price: 25, type: 'coinMultiplier', value: 2.0, description: 'Double all coin rewards' }, { name: 'Ghost Mode', price: 30, type: 'ghostMode', value: true, description: 'Pass through spikes for 5 seconds' }, { name: 'Level Skip Token', price: 50, type: 'skipToken', value: true, description: 'Skip any level instantly' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < gemShopItems.length; i++) { var item = gemShopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.gemShopPurchases[item.name] || false; var canAfford = storage.totalGems >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0xff00ff; // Magenta for gem shop } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' gems', { size: 25, fill: isPurchased ? 0x00ff00 : 0xFF00FF }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.totalGems -= itemToPurchase.price; storage.gemShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showGemShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(gemShopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Owner commands screen function showOwnerCommands() { gameState = 'owner'; game.removeChildren(); // Title var titleText = new Text2('Owner Commands', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 200; game.addChild(titleText); // Command buttons // Initialize page tracking if not exists if (!storage.ownerCommandsPage) { storage.ownerCommandsPage = 1; } var allCommandButtons = [{ text: 'Unlock All Levels', action: unlockAllLevels }, { text: 'Reset Progress', action: resetProgress }, { text: 'Complete All Levels', action: completeAllLevels }, { text: 'Give 1000 Coins', action: giveCoins }, { text: 'Give 10000 Coins', action: give10000Coins }, { text: 'Reset Coins', action: resetCoins }, { text: 'Give 100 Gems', action: giveGems }, { text: 'Give 10000 Gems', action: give10000Gems }, { text: 'Reset Gems', action: resetGems }, { text: 'Complete Daily Level', action: completeDailyLevel }, { text: 'Reset Daily Level', action: resetDailyLevel }, { text: 'Skip to Level 25', action: skipToLevel25 }, { text: 'Skip to Level 50', action: skipToLevel50 }, { text: 'God Mode On', action: enableGodMode }, { text: 'God Mode Off', action: disableGodMode }, { text: 'Speed Boost On', action: enableSpeedBoost }, { text: 'Speed Boost Off', action: disableSpeedBoost }, { text: 'Show Debug Info', action: showDebugInfo }, { text: 'Clear Debug Info', action: clearDebugInfo }, { text: 'Teleport to End', action: teleportToEnd }, { text: 'Toggle Invincibility', action: toggleInvincibility }, { text: 'Max All Shop Items', action: maxAllShopItems }, { text: 'Reset Shop Purchases', action: resetShopPurchases }, { text: 'Instant Level Complete', action: instantLevelComplete }, { text: 'Unlock Daily Shop', action: unlockDailyShop }, { text: 'Reset All Data', action: resetAllData }, { text: 'Enable Infinite Jumps', action: setInfiniteJumps }, { text: 'Disable Infinite Jumps', action: disableInfiniteJumps }, { text: 'Give All Currencies', action: giveAllCurrencies }, { text: 'Enable Slow Motion', action: enableSlowMotion }, { text: 'Disable Slow Motion', action: disableSlowMotion }, { text: 'Unlock All Shops', action: unlockAllShops }, { text: 'Get All Shop Items', action: getAllShopItems }]; var commandsPerPage = 10; var totalPages = Math.ceil(allCommandButtons.length / commandsPerPage); var currentPage = storage.ownerCommandsPage || 1; // Get commands for current page var startIndex = (currentPage - 1) * commandsPerPage; var endIndex = Math.min(startIndex + commandsPerPage, allCommandButtons.length); var commandButtons = allCommandButtons.slice(startIndex, endIndex); // Add navigation buttons if (currentPage < totalPages) { commandButtons.push({ text: 'Next Page (' + (currentPage + 1) + '/' + totalPages + ')', action: function action() { storage.ownerCommandsPage = currentPage + 1; showOwnerCommands(); } }); } if (currentPage > 1) { commandButtons.push({ text: 'Previous Page (' + (currentPage - 1) + '/' + totalPages + ')', action: function action() { storage.ownerCommandsPage = currentPage - 1; showOwnerCommands(); } }); } // Add back to menu as last option commandButtons.push({ text: 'Back to Menu', action: showLevelMenu }); var buttonY = 400; for (var i = 0; i < commandButtons.length; i++) { var cmdButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); cmdButton.x = 1024; cmdButton.y = buttonY + i * 150; cmdButton.tint = 0x444444; game.addChild(cmdButton); var cmdText = new Text2(commandButtons[i].text, { size: 35, fill: 0xFFFFFF }); cmdText.anchor.set(0.5, 0.5); cmdText.x = cmdButton.x; cmdText.y = cmdButton.y; game.addChild(cmdText); cmdButton.commandAction = commandButtons[i].action; cmdButton.down = function (x, y, obj) { this.commandAction(); }; } } // Owner command functions function unlockAllLevels() { for (var i = 1; i <= maxLevels; i++) { storage.completedLevels[i] = false; // Unlocked but not completed } showLevelMenu(); } function setInfiniteJumps() { storage.infiniteJumps = true; showOwnerCommands(); } function disableInfiniteJumps() { storage.infiniteJumps = false; showOwnerCommands(); } function giveAllCurrencies() { storage.totalCoins += 50000; storage.totalGems += 1000; storage.arcadeTokens += 500; storage.powerPoints += 300; storage.beautyCoins += 400; showOwnerCommands(); } function enableSlowMotion() { storage.slowMotion = true; scrollSpeed = 6; // Half speed showOwnerCommands(); } function disableSlowMotion() { storage.slowMotion = false; scrollSpeed = 12; // Normal speed showOwnerCommands(); } function getAllShopItems() { // Get all shop items from every shop var allShopItems = [ // Regular shop items 'Red Player', 'Blue Player', 'Yellow Player', 'Purple Player', 'Orange Player', 'Cyan Player', 'Pink Player', 'Red Ship', 'Green Ship', 'Yellow Ship', 'Purple Ship', 'Orange Ship', 'Speed Boost', 'Super Speed', 'Coin Magnet', 'Extra Checkpoint', 'Jump Boost', 'Shield Protection', 'Size Reduction', 'Trail Effect', // Gem shop items 'Rainbow Player', 'Golden Player', 'Diamond Ship', 'Ruby Ship', 'Ultra Speed', 'Mega Jump', 'Double Shield', 'Coin Multiplier x2', 'Ghost Mode', 'Level Skip Token', // Arcade shop items 'Neon Player', 'Pixel Player', 'Retro Ship', 'Classic Ship', 'Arcade Boost', 'Retro Jump', 'Pixel Trail', 'Coin Vacuum', 'Arcade Shield', 'Mini Mode', // Power shop items 'Laser Player', 'Plasma Player', 'Rocket Ship', 'Turbo Ship', 'Hyper Speed', 'Power Jump', 'Energy Shield', 'Power Trail', 'Magnet Field', 'Micro Form', // Cosmetic shop items 'Rose Player', 'Lavender Player', 'Mint Player', 'Peach Ship', 'Coral Ship', 'Graceful Speed', 'Fairy Jump', 'Sparkle Trail', 'Beauty Shield', 'Delicate Form', // Expedition shop items 'Explorer Player', 'Jungle Player', 'Desert Ship', 'Mountain Ship', 'Explorer Speed', 'Pathfinder Jump', 'Survival Shield', 'Tracker Trail', 'Treasure Magnet', 'Compact Form', // Mystic shop items 'Ethereal Player', 'Spirit Player', 'Void Ship', 'Crystal Ship', 'Mystic Velocity', 'Astral Jump', 'Mystic Barrier', 'Spirit Trail', 'Soul Magnet', 'Wisp Form', // Elite shop items 'Commander Player', 'General Player', 'Warship', 'Stealth Ship', 'Tactical Speed', 'Combat Jump', 'Armor Plating', 'Smoke Trail', 'Resource Scanner', 'Compact Armor', // VIP shop items 'Platinum Player', 'Diamond Player', 'Luxury Ship', 'Executive Ship', 'VIP Velocity', 'Executive Jump', 'VIP Protection', 'Luxury Trail', 'Wealth Magnet', 'Elite Compact']; // Mark all items as purchased in all shops for (var i = 0; i < allShopItems.length; i++) { storage.shopPurchases[allShopItems[i]] = true; storage.dailyShopPurchases[allShopItems[i]] = true; storage.gemShopPurchases[allShopItems[i]] = true; storage.arcadeShopPurchases[allShopItems[i]] = true; storage.powerShopPurchases[allShopItems[i]] = true; storage.cosmeticShopPurchases[allShopItems[i]] = true; storage.expeditionShopPurchases[allShopItems[i]] = true; storage.mysticShopPurchases[allShopItems[i]] = true; storage.eliteShopPurchases[allShopItems[i]] = true; storage.vipShopPurchases[allShopItems[i]] = true; } // Apply the best upgrades from each category (VIP has the highest values) storage.playerColor = 0xb9f2ff; // Diamond Player (VIP) storage.shipColor = 0xe5e4e2; // Executive Ship (VIP) storage.speedMultiplier = 3.5; // VIP Velocity (highest speed) storage.coinMagnet = true; storage.checkpoint = true; storage.jumpBoost = true; storage.shield = true; storage.smallSize = true; storage.trail = true; storage.coinMultiplier = 2.0; storage.ghostMode = true; storage.skipToken = true; showOwnerCommands(); } function unlockAllShops() { // Unlock all shop items from all stores var allShopItems = ['Red Player', 'Blue Player', 'Yellow Player', 'Purple Player', 'Orange Player', 'Cyan Player', 'Pink Player', 'Red Ship', 'Green Ship', 'Yellow Ship', 'Purple Ship', 'Orange Ship', 'Speed Boost', 'Super Speed', 'Coin Magnet', 'Extra Checkpoint', 'Jump Boost', 'Shield Protection', 'Size Reduction', 'Trail Effect']; for (var i = 0; i < allShopItems.length; i++) { storage.shopPurchases[allShopItems[i]] = true; storage.dailyShopPurchases[allShopItems[i]] = true; storage.gemShopPurchases[allShopItems[i]] = true; storage.arcadeShopPurchases[allShopItems[i]] = true; storage.powerShopPurchases[allShopItems[i]] = true; storage.cosmeticShopPurchases[allShopItems[i]] = true; } showOwnerCommands(); } function resetProgress() { storage.completedLevels = {}; storage.totalCoins = 0; storage.levelCoins = {}; showLevelMenu(); } function completeAllLevels() { for (var i = 1; i <= maxLevels; i++) { storage.completedLevels[i] = true; } showLevelMenu(); } function giveCoins() { storage.totalCoins += 1000; showOwnerCommands(); } function give10000Coins() { storage.totalCoins += 10000; showOwnerCommands(); } function resetCoins() { storage.totalCoins = 0; storage.levelCoins = {}; showOwnerCommands(); } function completeDailyLevel() { storage.dailyLevelCompleted = true; storage.dailyLevelCoins = 5; showOwnerCommands(); } function resetDailyLevel() { storage.dailyLevelCompleted = false; storage.dailyLevelCoins = 0; showOwnerCommands(); } function skipToLevel25() { for (var i = 1; i <= 25; i++) { storage.completedLevels[i] = true; } showLevelMenu(); } function skipToLevel50() { for (var i = 1; i <= 50; i++) { storage.completedLevels[i] = true; } showLevelMenu(); } function enableGodMode() { godModeEnabled = true; showOwnerCommands(); } function disableGodMode() { godModeEnabled = false; showOwnerCommands(); } function enableSpeedBoost() { speedBoostEnabled = true; scrollSpeed = 24; // Double speed showOwnerCommands(); } function disableSpeedBoost() { speedBoostEnabled = false; scrollSpeed = 12; // Normal speed showOwnerCommands(); } function showDebugInfo() { debugInfoVisible = true; if (!debugText) { debugText = new Text2('Debug Info', { size: 30, fill: 0x00FF00 }); debugText.anchor.set(0, 0); debugText.x = 120; debugText.y = 180; LK.gui.topLeft.addChild(debugText); } showOwnerCommands(); } function clearDebugInfo() { debugInfoVisible = false; if (debugText) { LK.gui.topLeft.removeChild(debugText); debugText = null; } showOwnerCommands(); } function giveGems() { storage.totalGems += 100; showOwnerCommands(); } function give10000Gems() { storage.totalGems += 10000; showOwnerCommands(); } function resetGems() { storage.totalGems = 0; showOwnerCommands(); } function teleportToEnd() { if (gameState === 'playing' && player) { var levelLength = levelData[currentLevel] ? levelData[currentLevel].length : 3000; player.x = levelLength - 100; cameraX = levelLength - 500; } showGameplay(); } function toggleInvincibility() { godModeEnabled = !godModeEnabled; showOwnerCommands(); } function maxAllShopItems() { var allShopItemNames = ['Red Player', 'Blue Player', 'Yellow Player', 'Purple Player', 'Orange Player', 'Cyan Player', 'Pink Player', 'Red Ship', 'Green Ship', 'Yellow Ship', 'Purple Ship', 'Orange Ship', 'Speed Boost', 'Super Speed', 'Coin Magnet', 'Extra Checkpoint', 'Jump Boost', 'Shield Protection', 'Size Reduction', 'Trail Effect']; for (var i = 0; i < allShopItemNames.length; i++) { storage.shopPurchases[allShopItemNames[i]] = true; } // Apply all effects storage.playerColor = 0xff69b4; // Pink storage.shipColor = 0xffff00; // Yellow storage.speedMultiplier = 2.0; storage.coinMagnet = true; storage.checkpoint = true; storage.jumpBoost = true; storage.shield = true; storage.smallSize = true; storage.trail = true; showOwnerCommands(); } function resetShopPurchases() { storage.shopPurchases = {}; storage.dailyShopPurchases = {}; storage.gemShopPurchases = {}; // Reset to defaults storage.playerColor = 0x00ff00; storage.shipColor = 0x0088ff; storage.speedMultiplier = 1.0; storage.coinMagnet = false; storage.checkpoint = false; storage.jumpBoost = false; storage.shield = false; storage.smallSize = false; storage.trail = false; showOwnerCommands(); } function instantLevelComplete() { if (gameState === 'playing') { completeLevel(); } showOwnerCommands(); } function unlockDailyShop() { // Force regenerate daily shop with all items available storage.dailyShopDate = ''; generateDailyShop(); showOwnerCommands(); } function resetAllData() { storage.completedLevels = {}; storage.totalCoins = 0; storage.levelCoins = {}; storage.totalGems = 0; storage.shopPurchases = {}; storage.dailyShopPurchases = {}; storage.gemShopPurchases = {}; storage.dailyLevelCompleted = false; storage.dailyLevelCoins = 0; storage.ownerCommandsPage = 1; // Reset to defaults storage.playerColor = 0x00ff00; storage.shipColor = 0x0088ff; storage.speedMultiplier = 1.0; storage.coinMagnet = false; storage.checkpoint = false; storage.jumpBoost = false; storage.shield = false; storage.smallSize = false; storage.trail = false; showLevelMenu(); } // Initialize game initializeLevelData(); setupUI(); showLevelMenu(); // Expedition shop screen function showExpeditionShop() { gameState = 'expeditionShop'; game.removeChildren(); // Title var titleText = new Text2('Adventure Expedition Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Expedition token display var expeditionDisplayText = new Text2('Expedition Tokens: ' + storage.expeditionTokens, { size: 60, fill: 0xaa8800 }); expeditionDisplayText.anchor.set(0.5, 0); expeditionDisplayText.x = 1024; expeditionDisplayText.y = 250; game.addChild(expeditionDisplayText); // Expedition shop items var expeditionShopItems = [{ name: 'Explorer Player', price: 10, type: 'playerColor', value: 0xaa8800, description: 'Rugged explorer brown' }, { name: 'Jungle Player', price: 12, type: 'playerColor', value: 0x228b22, description: 'Deep forest green' }, { name: 'Desert Ship', price: 15, type: 'shipColor', value: 0xdaa520, description: 'Sandy desert gold ship' }, { name: 'Mountain Ship', price: 18, type: 'shipColor', value: 0x696969, description: 'Stone mountain gray ship' }, { name: 'Explorer Speed', price: 22, type: 'speedMultiplier', value: 1.7, description: 'Adventure-tuned speed boost' }, { name: 'Pathfinder Jump', price: 20, type: 'jumpBoost', value: true, description: 'Expert navigation jump' }, { name: 'Survival Shield', price: 28, type: 'shield', value: true, description: 'Wilderness protection gear' }, { name: 'Tracker Trail', price: 16, type: 'trail', value: true, description: 'Leave expedition markers' }, { name: 'Treasure Magnet', price: 26, type: 'coinMagnet', value: true, description: 'Find hidden treasures' }, { name: 'Compact Form', price: 24, type: 'smallSize', value: true, description: 'Lightweight travel mode' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < expeditionShopItems.length; i++) { var item = expeditionShopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.expeditionShopPurchases[item.name] || false; var canAfford = storage.expeditionTokens >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0xaa8800; // Expedition brown for affordable } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' tokens', { size: 25, fill: isPurchased ? 0x00ff00 : 0xaa8800 }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.expeditionTokens -= itemToPurchase.price; storage.expeditionShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showExpeditionShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(expeditionShopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Mystic shop screen function showMysticShop() { gameState = 'mysticShop'; game.removeChildren(); // Title var titleText = new Text2('Mystic Crystal Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Mystic crystal display var mysticDisplayText = new Text2('Mystic Crystals: ' + storage.mysticCrystals, { size: 60, fill: 0x9966cc }); mysticDisplayText.anchor.set(0.5, 0); mysticDisplayText.x = 1024; mysticDisplayText.y = 250; game.addChild(mysticDisplayText); // Mystic shop items var mysticShopItems = [{ name: 'Ethereal Player', price: 8, type: 'playerColor', value: 0x9966cc, description: 'Mystical purple essence' }, { name: 'Spirit Player', price: 10, type: 'playerColor', value: 0x66ccff, description: 'Ghostly blue aura' }, { name: 'Void Ship', price: 12, type: 'shipColor', value: 0x330066, description: 'Dark void vessel' }, { name: 'Crystal Ship', price: 14, type: 'shipColor', value: 0xcc99ff, description: 'Crystalline magic ship' }, { name: 'Mystic Velocity', price: 18, type: 'speedMultiplier', value: 2.2, description: 'Supernatural speed' }, { name: 'Astral Jump', price: 16, type: 'jumpBoost', value: true, description: 'Transcendental leap' }, { name: 'Mystic Barrier', price: 22, type: 'shield', value: true, description: 'Magical protection ward' }, { name: 'Spirit Trail', price: 14, type: 'trail', value: true, description: 'Ethereal energy trail' }, { name: 'Soul Magnet', price: 20, type: 'coinMagnet', value: true, description: 'Attract mystical essence' }, { name: 'Wisp Form', price: 18, type: 'smallSize', value: true, description: 'Ghostly miniature form' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < mysticShopItems.length; i++) { var item = mysticShopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.mysticShopPurchases[item.name] || false; var canAfford = storage.mysticCrystals >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0x9966cc; // Mystic purple for affordable } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' crystals', { size: 25, fill: isPurchased ? 0x00ff00 : 0x9966cc }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.mysticCrystals -= itemToPurchase.price; storage.mysticShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showMysticShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(mysticShopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Elite shop screen function showEliteShop() { gameState = 'eliteShop'; game.removeChildren(); // Title var titleText = new Text2('Elite Command Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // Elite credit display var eliteDisplayText = new Text2('Elite Credits: ' + storage.eliteCredits, { size: 60, fill: 0xcc6600 }); eliteDisplayText.anchor.set(0.5, 0); eliteDisplayText.x = 1024; eliteDisplayText.y = 250; game.addChild(eliteDisplayText); // Elite shop items var eliteShopItems = [{ name: 'Commander Player', price: 6, type: 'playerColor', value: 0xcc6600, description: 'Elite bronze commander' }, { name: 'General Player', price: 8, type: 'playerColor', value: 0x444444, description: 'Battle-hardened gray' }, { name: 'Warship', price: 10, type: 'shipColor', value: 0x663300, description: 'Military tactical vessel' }, { name: 'Stealth Ship', price: 12, type: 'shipColor', value: 0x222222, description: 'Black ops stealth craft' }, { name: 'Tactical Speed', price: 15, type: 'speedMultiplier', value: 2.8, description: 'Military-grade velocity' }, { name: 'Combat Jump', price: 14, type: 'jumpBoost', value: true, description: 'Enhanced tactical leap' }, { name: 'Armor Plating', price: 18, type: 'shield', value: true, description: 'Heavy defensive armor' }, { name: 'Smoke Trail', price: 12, type: 'trail', value: true, description: 'Tactical smoke screen' }, { name: 'Resource Scanner', price: 16, type: 'coinMagnet', value: true, description: 'Military resource detector' }, { name: 'Compact Armor', price: 14, type: 'smallSize', value: true, description: 'Streamlined combat form' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < eliteShopItems.length; i++) { var item = eliteShopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.eliteShopPurchases[item.name] || false; var canAfford = storage.eliteCredits >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0xcc6600; // Elite bronze for affordable } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' credits', { size: 25, fill: isPurchased ? 0x00ff00 : 0xcc6600 }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.eliteCredits -= itemToPurchase.price; storage.eliteShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showEliteShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(eliteShopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // VIP shop screen function showVipShop() { gameState = 'vipShop'; game.removeChildren(); // Title var titleText = new Text2('Exclusive VIP Shop', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 150; game.addChild(titleText); // VIP point display var vipDisplayText = new Text2('VIP Points: ' + storage.vipPoints, { size: 60, fill: 0xffd700 }); vipDisplayText.anchor.set(0.5, 0); vipDisplayText.x = 1024; vipDisplayText.y = 250; game.addChild(vipDisplayText); // VIP shop items var vipShopItems = [{ name: 'Platinum Player', price: 4, type: 'playerColor', value: 0xe5e4e2, description: 'Exclusive platinum finish' }, { name: 'Diamond Player', price: 5, type: 'playerColor', value: 0xb9f2ff, description: 'Ultimate diamond luxury' }, { name: 'Luxury Ship', price: 4, type: 'shipColor', value: 0xffd700, description: 'Golden luxury vessel' }, { name: 'Executive Ship', price: 5, type: 'shipColor', value: 0xe5e4e2, description: 'Platinum executive craft' }, { name: 'VIP Velocity', price: 5, type: 'speedMultiplier', value: 3.5, description: 'Maximum luxury speed' }, { name: 'Executive Jump', price: 4, type: 'jumpBoost', value: true, description: 'First-class jump power' }, { name: 'VIP Protection', price: 5, type: 'shield', value: true, description: 'Premium security system' }, { name: 'Luxury Trail', price: 3, type: 'trail', value: true, description: 'Golden luxury trail' }, { name: 'Wealth Magnet', price: 4, type: 'coinMagnet', value: true, description: 'Attract premium rewards' }, { name: 'Elite Compact', price: 4, type: 'smallSize', value: true, description: 'Exclusive miniaturization' }]; var itemY = 400; var itemsPerRow = 2; var itemSpacing = 400; for (var i = 0; i < vipShopItems.length; i++) { var item = vipShopItems[i]; var row = Math.floor(i / itemsPerRow); var col = i % itemsPerRow; var itemX = 1024 - (itemsPerRow - 1) * itemSpacing / 2 + col * itemSpacing; var currentItemY = itemY + row * 200; // Check if item is already purchased var isPurchased = storage.vipShopPurchases[item.name] || false; var canAfford = storage.vipPoints >= item.price; // Item button var itemButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); itemButton.x = itemX; itemButton.y = currentItemY; itemButton.scaleX = 1.8; itemButton.scaleY = 1.2; if (isPurchased) { itemButton.tint = 0x00ff00; // Green for purchased } else if (canAfford) { itemButton.tint = 0xffd700; // Gold for VIP } else { itemButton.tint = 0x666666; // Gray for too expensive } game.addChild(itemButton); // Item name var nameText = new Text2(item.name, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = itemX; nameText.y = currentItemY - 20; game.addChild(nameText); // Item price var priceText = new Text2(isPurchased ? 'OWNED' : item.price + ' VIP', { size: 25, fill: isPurchased ? 0x00ff00 : 0xffd700 }); priceText.anchor.set(0.5, 0.5); priceText.x = itemX; priceText.y = currentItemY + 20; game.addChild(priceText); // Purchase logic if (!isPurchased && canAfford) { itemButton.shopItem = item; itemButton.down = function (x, y, obj) { var itemToPurchase = this.shopItem; storage.vipPoints -= itemToPurchase.price; storage.vipShopPurchases[itemToPurchase.name] = true; storage[itemToPurchase.type] = itemToPurchase.value; showVipShop(); // Refresh shop display }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = itemY + Math.ceil(vipShopItems.length / itemsPerRow) * 200 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Map packs screen function showMapPacks() { gameState = 'mapPacks'; game.removeChildren(); // Title var titleText = new Text2('Map Packs', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 200; game.addChild(titleText); // Map pack list var mapPacks = [{ name: 'Classic Pack', description: 'Original 10 levels', levels: '1-10', color: 0x00ff00, unlocked: true }, { name: 'Advanced Pack', description: 'Challenging levels', levels: '11-25', color: 0xffaa00, unlocked: storage.completedLevels[10] || false }, { name: 'Expert Pack', description: 'Master difficulty', levels: '26-40', color: 0xff4400, unlocked: storage.completedLevels[25] || false }, { name: 'Ultimate Pack', description: 'Extreme challenges', levels: '41-68', color: 0xff0066, unlocked: storage.completedLevels[40] || false }, { name: 'Daily Pack', description: 'Special daily levels', levels: 'Daily', color: 0x9933ff, unlocked: true }, { name: 'Community Pack', description: 'User-created levels', levels: 'Custom', color: 0x33aaff, unlocked: true }]; var packY = 400; for (var i = 0; i < mapPacks.length; i++) { var pack = mapPacks[i]; var currentPackY = packY + i * 180; // Pack button var packButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); packButton.x = 1024; packButton.y = currentPackY; packButton.scaleX = 2.5; packButton.scaleY = 1.4; if (pack.unlocked) { packButton.tint = pack.color; } else { packButton.tint = 0x666666; } game.addChild(packButton); // Pack name var nameText = new Text2(pack.name, { size: 40, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = 1024; nameText.y = currentPackY - 25; game.addChild(nameText); // Pack info var infoText = new Text2(pack.description + ' (' + pack.levels + ')', { size: 28, fill: pack.unlocked ? 0xCCCCCC : 0x888888 }); infoText.anchor.set(0.5, 0.5); infoText.x = 1024; infoText.y = currentPackY + 15; game.addChild(infoText); // Status var statusText = new Text2(pack.unlocked ? 'AVAILABLE' : 'LOCKED', { size: 24, fill: pack.unlocked ? 0x00ff00 : 0xff4444 }); statusText.anchor.set(0.5, 0.5); statusText.x = 1024; statusText.y = currentPackY + 45; game.addChild(statusText); if (pack.unlocked) { packButton.mapPack = pack; packButton.down = function (x, y, obj) { // For now, just return to level menu // Could implement pack-specific level selection here showLevelMenu(); }; } } // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = packY + mapPacks.length * 180 + 100; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 40, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; } // Level editor screen function showLevelEditor() { gameState = 'levelEditor'; game.removeChildren(); // Initialize editor state if not exists if (!storage.editorState) { storage.editorState = { selectedTool: 'Add Spike', gridSize: 40, showGrid: true, cameraX: 0, cameraY: 0, currentLevel: { spikes: [], platforms: [], coins: [], checkpoints: [], swingAnchors: [], length: 3000 } }; } // Title var titleText = new Text2('Level Editor', { size: 60, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 50; game.addChild(titleText); // Tool selection display var selectedToolText = new Text2('Selected: ' + storage.editorState.selectedTool, { size: 30, fill: 0x00ff88 }); selectedToolText.anchor.set(0, 0); selectedToolText.x = 50; selectedToolText.y = 120; game.addChild(selectedToolText); // Grid toggle button var gridButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); gridButton.x = 200; gridButton.y = 200; gridButton.scaleX = 0.8; gridButton.scaleY = 0.6; gridButton.tint = storage.editorState.showGrid ? 0x00ff00 : 0x666666; game.addChild(gridButton); var gridText = new Text2('Grid: ' + (storage.editorState.showGrid ? 'ON' : 'OFF'), { size: 20, fill: 0xFFFFFF }); gridText.anchor.set(0.5, 0.5); gridText.x = gridButton.x; gridText.y = gridButton.y; game.addChild(gridText); gridButton.down = function (x, y, obj) { storage.editorState.showGrid = !storage.editorState.showGrid; showLevelEditor(); }; // Canvas area background var canvasArea = LK.getAsset('ground', { anchorX: 0, anchorY: 0 }); canvasArea.x = 50; canvasArea.y = 300; canvasArea.width = 1900; canvasArea.height = 1200; canvasArea.tint = 0x222222; game.addChild(canvasArea); // Draw grid if enabled if (storage.editorState.showGrid) { var gridSize = storage.editorState.gridSize; // Vertical lines for (var x = canvasArea.x; x < canvasArea.x + canvasArea.width; x += gridSize) { var vLine = LK.getAsset('ground', { anchorX: 0, anchorY: 0 }); vLine.x = x; vLine.y = canvasArea.y; vLine.width = 2; vLine.height = canvasArea.height; vLine.tint = 0x444444; vLine.alpha = 0.3; game.addChild(vLine); } // Horizontal lines for (var y = canvasArea.y; y < canvasArea.y + canvasArea.height; y += gridSize) { var hLine = LK.getAsset('ground', { anchorX: 0, anchorY: 0 }); hLine.x = canvasArea.x; hLine.y = y; hLine.width = canvasArea.width; hLine.height = 2; hLine.tint = 0x444444; hLine.alpha = 0.3; game.addChild(hLine); } } // Ground line reference var groundLine = LK.getAsset('ground', { anchorX: 0, anchorY: 0 }); groundLine.x = canvasArea.x; groundLine.y = canvasArea.y + canvasArea.height - 200; groundLine.width = canvasArea.width; groundLine.height = 4; groundLine.tint = 0x444444; game.addChild(groundLine); var groundLabel = new Text2('Ground Level', { size: 20, fill: 0x888888 }); groundLabel.anchor.set(0, 0); groundLabel.x = canvasArea.x + 10; groundLabel.y = groundLine.y - 25; game.addChild(groundLabel); // Tool categories var toolCategories = [{ name: 'Objects', tools: [{ name: 'Add Spike', color: 0xff0000, icon: 'spike', description: 'Place deadly spikes' }, { name: 'Add Platform', color: 0x888888, icon: 'platform', description: 'Create safe platforms' }, { name: 'Add Coin', color: 0xffd700, icon: 'coin', description: 'Place collectible coins' }, { name: 'Add Checkpoint', color: 0x00ffff, icon: 'checkpoint', description: 'Set save points' }, { name: 'Add Swing', color: 0xffaa00, icon: 'swingAnchor', description: 'Create swing anchors' }] }, { name: 'Actions', tools: [{ name: 'Select', color: 0xffffff, icon: 'levelButton', description: 'Select and move objects' }, { name: 'Delete', color: 0x880000, icon: 'levelButton', description: 'Remove objects' }, { name: 'Copy', color: 0x0088ff, icon: 'levelButton', description: 'Duplicate objects' }] }, { name: 'Level', tools: [{ name: 'Test Level', color: 0x00ff00, icon: 'levelButton', description: 'Play your creation' }, { name: 'Save Level', color: 0x0088ff, icon: 'levelButton', description: 'Store your level' }, { name: 'Load Level', color: 0x9933ff, icon: 'levelButton', description: 'Open saved level' }, { name: 'Clear All', color: 0xff4400, icon: 'levelButton', description: 'Delete everything' }] }]; // Tool palette on the left side var paletteX = 50; var paletteY = 250; var currentY = paletteY; for (var cat = 0; cat < toolCategories.length; cat++) { var category = toolCategories[cat]; // Category header var categoryHeader = new Text2(category.name, { size: 25, fill: 0x00ff88 }); categoryHeader.anchor.set(0, 0); categoryHeader.x = paletteX; categoryHeader.y = currentY; game.addChild(categoryHeader); currentY += 35; // Category tools for (var t = 0; t < category.tools.length; t++) { var tool = category.tools[t]; // Tool button var toolButton = LK.getAsset('levelButton', { anchorX: 0, anchorY: 0.5 }); toolButton.x = paletteX; toolButton.y = currentY; toolButton.scaleX = 0.6; toolButton.scaleY = 0.5; toolButton.tint = storage.editorState.selectedTool === tool.name ? 0x00ff00 : tool.color; game.addChild(toolButton); // Tool icon if (tool.icon !== 'levelButton') { var toolIcon = LK.getAsset(tool.icon, { anchorX: 0.5, anchorY: 0.5 }); toolIcon.x = toolButton.x + 60; toolIcon.y = toolButton.y; toolIcon.scaleX = 0.3; toolIcon.scaleY = 0.3; game.addChild(toolIcon); } // Tool name var toolNameText = new Text2(tool.name, { size: 18, fill: 0xFFFFFF }); toolNameText.anchor.set(0, 0.5); toolNameText.x = paletteX + 120; toolNameText.y = currentY; game.addChild(toolNameText); toolButton.toolData = tool; toolButton.down = function (x, y, obj) { var selectedTool = this.toolData; storage.editorState.selectedTool = selectedTool.name; if (selectedTool.name === 'Test Level') { testCurrentLevel(); } else if (selectedTool.name === 'Save Level') { saveCurrentLevel(); } else if (selectedTool.name === 'Load Level') { loadLevelDialog(); } else if (selectedTool.name === 'Clear All') { clearCurrentLevel(); } else { showLevelEditor(); // Refresh to show selection } }; currentY += 40; } currentY += 20; // Space between categories } // Properties panel var propsX = 1650; var propsY = 250; var propsHeader = new Text2('Properties', { size: 30, fill: 0x00ff88 }); propsHeader.anchor.set(0, 0); propsHeader.x = propsX; propsHeader.y = propsY; game.addChild(propsHeader); // Level length setting var lengthLabel = new Text2('Level Length:', { size: 20, fill: 0xCCCCCC }); lengthLabel.anchor.set(0, 0); lengthLabel.x = propsX; lengthLabel.y = propsY + 50; game.addChild(lengthLabel); var lengthValue = new Text2(storage.editorState.currentLevel.length.toString(), { size: 18, fill: 0xFFFFFF }); lengthValue.anchor.set(0, 0); lengthValue.x = propsX; lengthValue.y = propsY + 75; game.addChild(lengthValue); // Length adjustment buttons var lengthUpButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); lengthUpButton.x = propsX + 150; lengthUpButton.y = propsY + 75; lengthUpButton.scaleX = 0.3; lengthUpButton.scaleY = 0.4; lengthUpButton.tint = 0x00ff00; game.addChild(lengthUpButton); var lengthUpText = new Text2('+500', { size: 16, fill: 0xFFFFFF }); lengthUpText.anchor.set(0.5, 0.5); lengthUpText.x = lengthUpButton.x; lengthUpText.y = lengthUpButton.y; game.addChild(lengthUpText); lengthUpButton.down = function (x, y, obj) { storage.editorState.currentLevel.length += 500; showLevelEditor(); }; var lengthDownButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); lengthDownButton.x = propsX + 220; lengthDownButton.y = propsY + 75; lengthDownButton.scaleX = 0.3; lengthDownButton.scaleY = 0.4; lengthDownButton.tint = 0xff4400; game.addChild(lengthDownButton); var lengthDownText = new Text2('-500', { size: 16, fill: 0xFFFFFF }); lengthDownText.anchor.set(0.5, 0.5); lengthDownText.x = lengthDownButton.x; lengthDownText.y = lengthDownButton.y; game.addChild(lengthDownText); lengthDownButton.down = function (x, y, obj) { if (storage.editorState.currentLevel.length > 1000) { storage.editorState.currentLevel.length -= 500; showLevelEditor(); } }; // Object count display var objectCounts = ['Spikes: ' + storage.editorState.currentLevel.spikes.length, 'Platforms: ' + storage.editorState.currentLevel.platforms.length, 'Coins: ' + storage.editorState.currentLevel.coins.length, 'Checkpoints: ' + storage.editorState.currentLevel.checkpoints.length, 'Swing Anchors: ' + storage.editorState.currentLevel.swingAnchors.length]; for (var o = 0; o < objectCounts.length; o++) { var countText = new Text2(objectCounts[o], { size: 18, fill: 0xCCCCCC }); countText.anchor.set(0, 0); countText.x = propsX; countText.y = propsY + 120 + o * 25; game.addChild(countText); } // Canvas interaction area canvasArea.down = function (x, y, obj) { handleCanvasClick(x, y); }; // Instructions var instructionsText = new Text2('Click on canvas to place objects. Use tools on the left.', { size: 30, fill: 0x00ff88 }); instructionsText.anchor.set(0.5, 0); instructionsText.x = 1024; instructionsText.y = 1550; game.addChild(instructionsText); // Render current level objects renderLevelObjects(); } // Handle canvas clicks for object placement function handleCanvasClick(x, y) { var tool = storage.editorState.selectedTool; var gridSize = storage.editorState.gridSize; // Snap to grid if enabled if (storage.editorState.showGrid) { x = Math.round(x / gridSize) * gridSize; y = Math.round(y / gridSize) * gridSize; } // Convert canvas coordinates to world coordinates var worldX = x + storage.editorState.cameraX; var worldY = y; if (tool === 'Add Spike') { storage.editorState.currentLevel.spikes.push({ x: worldX, y: worldY }); } else if (tool === 'Add Platform') { storage.editorState.currentLevel.platforms.push({ x: worldX, y: worldY, width: 200 }); } else if (tool === 'Add Coin') { storage.editorState.currentLevel.coins.push({ x: worldX, y: worldY }); } else if (tool === 'Add Checkpoint') { storage.editorState.currentLevel.checkpoints.push({ x: worldX, y: worldY }); } else if (tool === 'Add Swing') { storage.editorState.currentLevel.swingAnchors.push({ x: worldX, y: worldY }); } showLevelEditor(); // Refresh to show new object } // Render level objects on canvas function renderLevelObjects() { var canvasX = 50; var canvasY = 300; var level = storage.editorState.currentLevel; // Render spikes for (var i = 0; i < level.spikes.length; i++) { var spike = level.spikes[i]; var spikeGraphic = LK.getAsset('spike', { anchorX: 0.5, anchorY: 1.0 }); spikeGraphic.x = canvasX + spike.x - storage.editorState.cameraX; spikeGraphic.y = canvasY + spike.y; spikeGraphic.scaleX = 0.5; spikeGraphic.scaleY = 0.5; game.addChild(spikeGraphic); } // Render platforms for (var j = 0; j < level.platforms.length; j++) { var platform = level.platforms[j]; var platformGraphic = LK.getAsset('platform', { anchorX: 0, anchorY: 0 }); platformGraphic.x = canvasX + platform.x - storage.editorState.cameraX; platformGraphic.y = canvasY + platform.y; platformGraphic.width = platform.width; platformGraphic.scaleY = 0.5; game.addChild(platformGraphic); } // Render coins for (var k = 0; k < level.coins.length; k++) { var coin = level.coins[k]; var coinGraphic = LK.getAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); coinGraphic.x = canvasX + coin.x - storage.editorState.cameraX; coinGraphic.y = canvasY + coin.y; coinGraphic.scaleX = 0.5; coinGraphic.scaleY = 0.5; game.addChild(coinGraphic); } // Render checkpoints for (var l = 0; l < level.checkpoints.length; l++) { var checkpoint = level.checkpoints[l]; var checkpointGraphic = LK.getAsset('checkpoint', { anchorX: 0.5, anchorY: 1.0 }); checkpointGraphic.x = canvasX + checkpoint.x - storage.editorState.cameraX; checkpointGraphic.y = canvasY + checkpoint.y; checkpointGraphic.scaleX = 0.5; checkpointGraphic.scaleY = 0.5; game.addChild(checkpointGraphic); } // Render swing anchors for (var m = 0; m < level.swingAnchors.length; m++) { var anchor = level.swingAnchors[m]; var anchorGraphic = LK.getAsset('swingAnchor', { anchorX: 0.5, anchorY: 0.5 }); anchorGraphic.x = canvasX + anchor.x - storage.editorState.cameraX; anchorGraphic.y = canvasY + anchor.y; anchorGraphic.scaleX = 0.5; anchorGraphic.scaleY = 0.5; game.addChild(anchorGraphic); } } // Test current level function testCurrentLevel() { // Save current level as a test level levelData['test'] = { spikes: storage.editorState.currentLevel.spikes.slice(), platforms: storage.editorState.currentLevel.platforms.slice(), coins: storage.editorState.currentLevel.coins.slice(), checkpoints: storage.editorState.currentLevel.checkpoints.slice(), swingAnchors: storage.editorState.currentLevel.swingAnchors.slice(), length: storage.editorState.currentLevel.length, shipMode: false }; currentLevel = 'test'; showGameplay(); } // Save current level function saveCurrentLevel() { if (!storage.customLevels) { storage.customLevels = {}; } var levelName = 'custom_' + Date.now(); storage.customLevels[levelName] = { spikes: storage.editorState.currentLevel.spikes.slice(), platforms: storage.editorState.currentLevel.platforms.slice(), coins: storage.editorState.currentLevel.coins.slice(), checkpoints: storage.editorState.currentLevel.checkpoints.slice(), swingAnchors: storage.editorState.currentLevel.swingAnchors.slice(), length: storage.editorState.currentLevel.length, shipMode: false }; showLevelEditor(); } // Load level dialog (simplified) function loadLevelDialog() { if (storage.customLevels && Object.keys(storage.customLevels).length > 0) { var firstLevel = Object.keys(storage.customLevels)[0]; storage.editorState.currentLevel = { spikes: storage.customLevels[firstLevel].spikes.slice(), platforms: storage.customLevels[firstLevel].platforms.slice(), coins: storage.customLevels[firstLevel].coins.slice(), checkpoints: storage.customLevels[firstLevel].checkpoints.slice(), swingAnchors: storage.customLevels[firstLevel].swingAnchors.slice(), length: storage.customLevels[firstLevel].length }; } showLevelEditor(); } // Clear current level function clearCurrentLevel() { storage.editorState.currentLevel = { spikes: [], platforms: [], coins: [], checkpoints: [], swingAnchors: [], length: 3000 }; showLevelEditor(); // Camera control buttons var cameraControlsY = 1580; // Pan left button var panLeftButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); panLeftButton.x = 300; panLeftButton.y = cameraControlsY; panLeftButton.scaleX = 0.6; panLeftButton.scaleY = 0.6; panLeftButton.tint = 0x0088ff; game.addChild(panLeftButton); var panLeftText = new Text2('< Pan', { size: 20, fill: 0xFFFFFF }); panLeftText.anchor.set(0.5, 0.5); panLeftText.x = panLeftButton.x; panLeftText.y = panLeftButton.y; game.addChild(panLeftText); panLeftButton.down = function (x, y, obj) { storage.editorState.cameraX -= 200; if (storage.editorState.cameraX < 0) storage.editorState.cameraX = 0; showLevelEditor(); }; // Pan right button var panRightButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); panRightButton.x = 450; panRightButton.y = cameraControlsY; panRightButton.scaleX = 0.6; panRightButton.scaleY = 0.6; panRightButton.tint = 0x0088ff; game.addChild(panRightButton); var panRightText = new Text2('Pan >', { size: 20, fill: 0xFFFFFF }); panRightText.anchor.set(0.5, 0.5); panRightText.x = panRightButton.x; panRightText.y = panRightButton.y; game.addChild(panRightText); panRightButton.down = function (x, y, obj) { storage.editorState.cameraX += 200; var maxCamera = Math.max(0, storage.editorState.currentLevel.length - 1500); if (storage.editorState.cameraX > maxCamera) storage.editorState.cameraX = maxCamera; showLevelEditor(); }; // Reset camera button var resetCameraButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); resetCameraButton.x = 600; resetCameraButton.y = cameraControlsY; resetCameraButton.scaleX = 0.6; resetCameraButton.scaleY = 0.6; resetCameraButton.tint = 0xff8800; game.addChild(resetCameraButton); var resetCameraText = new Text2('Reset View', { size: 18, fill: 0xFFFFFF }); resetCameraText.anchor.set(0.5, 0.5); resetCameraText.x = resetCameraButton.x; resetCameraText.y = resetCameraButton.y; game.addChild(resetCameraText); resetCameraButton.down = function (x, y, obj) { storage.editorState.cameraX = 0; storage.editorState.cameraY = 0; showLevelEditor(); }; // Grid size controls var gridSizeLabel = new Text2('Grid: ' + storage.editorState.gridSize + 'px', { size: 18, fill: 0xCCCCCC }); gridSizeLabel.anchor.set(0.5, 0.5); gridSizeLabel.x = 800; gridSizeLabel.y = cameraControlsY; game.addChild(gridSizeLabel); var gridUpButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); gridUpButton.x = 900; gridUpButton.y = cameraControlsY; gridUpButton.scaleX = 0.4; gridUpButton.scaleY = 0.5; gridUpButton.tint = 0x00ff00; game.addChild(gridUpButton); var gridUpText = new Text2('+', { size: 20, fill: 0xFFFFFF }); gridUpText.anchor.set(0.5, 0.5); gridUpText.x = gridUpButton.x; gridUpText.y = gridUpButton.y; game.addChild(gridUpText); gridUpButton.down = function (x, y, obj) { if (storage.editorState.gridSize < 80) { storage.editorState.gridSize += 20; showLevelEditor(); } }; var gridDownButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); gridDownButton.x = 950; gridDownButton.y = cameraControlsY; gridDownButton.scaleX = 0.4; gridDownButton.scaleY = 0.5; gridDownButton.tint = 0xff4400; game.addChild(gridDownButton); var gridDownText = new Text2('-', { size: 20, fill: 0xFFFFFF }); gridDownText.anchor.set(0.5, 0.5); gridDownText.x = gridDownButton.x; gridDownText.y = gridDownButton.y; game.addChild(gridDownText); gridDownButton.down = function (x, y, obj) { if (storage.editorState.gridSize > 20) { storage.editorState.gridSize -= 20; showLevelEditor(); } }; // Camera position display var cameraInfoText = new Text2('Camera X: ' + storage.editorState.cameraX, { size: 18, fill: 0x888888 }); cameraInfoText.anchor.set(0, 0); cameraInfoText.x = 1200; cameraInfoText.y = cameraControlsY - 10; game.addChild(cameraInfoText); // Back button var backButton = LK.getAsset('levelButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1700; backButton.y = cameraControlsY; backButton.scaleX = 0.8; backButton.scaleY = 0.8; backButton.tint = 0x666666; game.addChild(backButton); var backText = new Text2('Back to Menu', { size: 24, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backText.x = backButton.x; backText.y = backButton.y; game.addChild(backText); backButton.down = function (x, y, obj) { showLevelMenu(); }; }
===================================================================
--- original.js
+++ change.js
@@ -4727,21 +4727,23 @@
gameState = 'levelEditor';
game.removeChildren();
// Initialize editor state if not exists
if (!storage.editorState) {
- storage.editorState = {};
- storage.editorState.selectedTool = 'Add Spike';
- storage.editorState.gridSize = 40;
- storage.editorState.showGrid = true;
- storage.editorState.cameraX = 0;
- storage.editorState.cameraY = 0;
- storage.editorState.currentLevel = {};
- storage.editorState.currentLevel.spikes = [];
- storage.editorState.currentLevel.platforms = [];
- storage.editorState.currentLevel.coins = [];
- storage.editorState.currentLevel.checkpoints = [];
- storage.editorState.currentLevel.swingAnchors = [];
- storage.editorState.currentLevel.length = 3000;
+ storage.editorState = {
+ selectedTool: 'Add Spike',
+ gridSize: 40,
+ showGrid: true,
+ cameraX: 0,
+ cameraY: 0,
+ currentLevel: {
+ spikes: [],
+ platforms: [],
+ coins: [],
+ checkpoints: [],
+ swingAnchors: [],
+ length: 3000
+ }
+ };
}
// Title
var titleText = new Text2('Level Editor', {
size: 60,