User prompt
Please fix the bug: 'storage.has is not a function' in or related to this line: 'if (storage.has('record')) {' Line Number: 477
User prompt
el record queda en memoria y el numero alcanzado hasta que un jugador lo supere
User prompt
agrega las 3 vidad del jugador visibles, el recor ocultalo y muestralo al perder
User prompt
agrega las vidas que estaban
User prompt
los bonos colisiona a playerball y le dan 10 puntos
User prompt
borra y elimina all bonus and superBonus code to only handle animation and orbit, removing all point, life, and record logic, solo deja los de dar puntos activo
User prompt
ahoa hagamos que el bonus de puntos
User prompt
resetea todas las funciones y codigos de bonus que no sean de animacion y orbita
User prompt
Please fix the bug: 'storage.getItem is not a function' in or related to this line: 'tween(homeGraphics, {' Line Number: 557 ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
el numero grande de record mostrara la puntuacion maxima en una partida y se quedara en memoria, solo cambiara si se supera con el nuevo recor
User prompt
por que los bonus dejaron de dar puntos, areglalo
User prompt
corrige y elimina funciones que eviten ganar puntos
User prompt
el jugador al colisionar con los bonos y gana 10 puntos
User prompt
asegurate de poder ganar puntos
User prompt
cada vida debe perderse en el juego
User prompt
quita la condicion de no ganar puntos
User prompt
quita logica para no acumular puntos
User prompt
agrega Titulo-rectangulo al mail splash y colocalo en ligar del texto orbit
User prompt
coloca la imagen Titulo-rectangilo por texto orbit
User prompt
coloca titulo-rectangulo por texto orbit
User prompt
ajusta lines en background
User prompt
mas tranparencia
User prompt
dale 50 de tranparencia a la imagen de fondo
User prompt
el color negro del background ponlo azul oscuro navy
User prompt
agrega al los stage lines como fondo
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Define Bonus class var Bonus = Container.expand(function () { var self = Container.call(this); // Attach a bonus asset (use a star-like color and ellipse shape for visibility) var bonusGraphics = self.attachAsset('bonus', { anchorX: 0.5, anchorY: 0.5 }); // Orbit parameters self.orbitRadius = 170; // Default closer to center, will be overridden in Game Code self.orbitAngle = Math.random() * Math.PI * 2; // Random start // self.orbitSpeed will be set per instance in Game Code // Update method for orbiting self.update = function () { self.orbitAngle += self.orbitSpeed; self.x = 1024 + self.orbitRadius * Math.cos(self.orbitAngle); self.y = 1366 + self.orbitRadius * Math.sin(self.orbitAngle); }; return self; }); // Define Deco class var Deco = Container.expand(function () { var self = Container.call(this); // Use the 'deco' asset from Assets section var decoGraphics = self.attachAsset('deco', { anchorX: 0.5, anchorY: 0.5 }); // Optionally, scale for visual distinction decoGraphics.scaleX = 1.5; decoGraphics.scaleY = 1.5; // Deco does not move or update by default, but you can add animation here if needed self.orbitRadius = 170; // Default to match average bonus orbit, will be overridden in Game Code self.orbitAngle = Math.random() * Math.PI * 2; self.orbitSpeed = -0.03; // Slower by default, will be overridden in Game Code if needed self.update = function () { self.orbitAngle += self.orbitSpeed; self.x = 1024 + self.orbitRadius * Math.cos(self.orbitAngle); self.y = 1366 + self.orbitRadius * Math.sin(self.orbitAngle); }; return self; }); // Position near the top // Define Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); // Attach default 'enemy' asset (restored to default color and shape) var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); // Orbit parameters (will be set per instance in Game Code) self.orbitRadius = 400; // Default, will be overridden self.orbitAngle = Math.random() * Math.PI * 2; self.orbitSpeed = -0.03; // Default, will be overridden // Elliptical orbit support (optional, set in Game Code) self.isElliptical = false; self.ellipseA = undefined; self.ellipseB = undefined; // Update method for orbiting and rotation (like Deco) self.update = function () { self.orbitAngle += self.orbitSpeed; if (self.isElliptical && typeof self.ellipseA === "number" && typeof self.ellipseB === "number") { self.x = 1024 + self.ellipseA * Math.cos(self.orbitAngle); self.y = 1366 + self.ellipseB * Math.sin(self.orbitAngle); } else { self.x = 1024 + self.orbitRadius * Math.cos(self.orbitAngle); self.y = 1366 + self.orbitRadius * Math.sin(self.orbitAngle); } }; return self; }); // Define Home class var Home = Container.expand(function () { var self = Container.call(this); // Attach the 'home' asset from Assets section (ensure we use the asset named 'home') var homeGraphics = self.attachAsset('home', { anchorX: 0.5, anchorY: 0.5 }); // Center position self.x = 1024; self.y = 1366; // No update needed (static) return self; }); // Define Player class var Player = Container.expand(function () { var self = Container.call(this); // Attach player asset var playerGraphics = self.attachAsset('Ballplayer', { anchorX: 0.5, anchorY: 0.5 }); // Set initial position and movement properties self.speed = 2.5; // Lowered for better perception // Update method for player movement self.update = function () { // Movement handled by keyboard events }; }); /**** * Initialize Game ****/ // Reset Assets section to initial state // Reset Asteroid class definition //<Assets used in the game will automatically appear here> // Reset Planet class definition // Reset Star class definition // Reset Initialize Game section to initial state // Reset Game Code section to initial state var game = new LK.Game({ backgroundColor: 0x001233 }); /**** * Game Code ****/ // --- Fullscreen flashing overlay (cuadrado, titilea a 3ms, color por nivel) --- // Add stage lines as a background image behind all gameplay elements var stageLinesBg = LK.getAsset('lines', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, // Use the actual asset size for scaling to fit the screen scaleX: 2048 / 573.44, scaleY: 2732 / 1019.45 }); stageLinesBg.alpha = 0.10; stageLinesBg.zIndex = -1000000; // ensure it's behind everything game.addChild(stageLinesBg); var flashingOverlay = new Container(); var overlayAsset = LK.getAsset('stage', { anchorX: 0, anchorY: 0 }); // Make overlay a perfect square, centered overlayAsset.width = 2048; overlayAsset.height = 2048; overlayAsset.shape = 'box'; overlayAsset.alpha = 0; // Center the square vertically overlayAsset.y = (2732 - 2048) / 2; flashingOverlay.addChild(overlayAsset); // Place overlay at the very back (lowest zIndex) flashingOverlay.zIndex = -99999; game.addChild(flashingOverlay); // 10 tonalidades para los 10 primeros niveles (puedes ajustar los colores a gusto) var overlayStageColors = [0x0074D9, // azul 0x39CCCC, // cyan 0x3D9970, // verde 0x2ECC40, // verde claro 0xFFDC00, // amarillo 0xFF851B, // naranja 0xFF4136, // rojo 0xB10DC9, // violeta 0xF012BE, // magenta 0x85144b // vino ]; // Función para actualizar el color del overlay según el nivel actual function updateOverlayColorForLevel(level) { var idx = ((typeof level === "number" ? level : 1) - 1) % overlayStageColors.length; overlayAsset.color = overlayStageColors[idx]; if (typeof overlayAsset.tint !== "undefined") overlayAsset.tint = overlayAsset.color; } // Hook inicial para el color (nivel 1) updateOverlayColorForLevel(typeof currentLevel !== "undefined" ? currentLevel : 1); // Animación de titileo function flashOverlay() { tween(overlayAsset, { alpha: 0.2 }, { duration: 4, easing: tween.linear, onFinish: function onFinish() { tween(overlayAsset, { alpha: 0 }, { duration: 4, easing: tween.linear, onFinish: flashOverlay }); } }); } flashOverlay(); // Hook para cambiar el color del overlay cuando cambie el nivel function onLevelChange_updateOverlayColor(newLevel) { updateOverlayColorForLevel(newLevel); } // Sobrescribe los botones de nivel y el botón de jugar para actualizar el color del overlay if (typeof splashLevelBtns !== "undefined" && splashLevelBtns.length) { for (var i = 0; i < splashLevelBtns.length; i++) { if (splashLevelBtns[i] && splashLevelBtns[i].down) { (function (btn, idx) { var originalDown = btn.down; btn.down = function (x, y, obj) { onLevelChange_updateOverlayColor(idx + 1); originalDown.call(this, x, y, obj); }; })(splashLevelBtns[i], i); } } } if (typeof splashBtn !== "undefined" && splashBtn && splashBtn.down) { var originalSplashBtnDown = splashBtn.down; splashBtn.down = function (x, y, obj) { onLevelChange_updateOverlayColor(typeof currentLevel !== "undefined" ? currentLevel : 1); originalSplashBtnDown.call(this, x, y, obj); }; } // --- Splash Screen Overlay --- var splashOverlay = new Container(); splashOverlay.zIndex = 999999; // Ensure on top of everything, including overlays // Game Title (replaces Titulo-rectangulo image with ORBIT text) var splashTitle = new Text2('ORBIT', { size: 480, fill: 0xFFFFFF, font: "'Impact','Arial Black',Tahoma", fontWeight: "bold" }); splashTitle.anchor.set(0.5, 0.5); splashTitle.x = 1024; splashTitle.y = 600; splashOverlay.addChild(splashTitle); // Subtitle var splashSubtitle = new Text2('Un universo hostil donde el más grande se traga al más pequeño', { size: 56, fill: 0xE0E0E0, font: "'Arial Rounded MT Bold','Arial Rounded MT','Arial Rounded','Arial','Arial Black',Tahoma" }); splashSubtitle.anchor.set(0.5, 0.5); splashSubtitle.x = 1024; splashSubtitle.y = 900; splashOverlay.addChild(splashSubtitle); // --- Level Select Buttons (1-10) --- // Place buttons in two horizontal rows of 5, centered horizontally, near the bottom var splashLevelBtns = []; var splashLevelBtnSize = 90; var splashLevelBtnRowSpacing = 120; var splashLevelBtnY1 = 2100; // First row Y var splashLevelBtnY2 = splashLevelBtnY1 + splashLevelBtnRowSpacing; // Second row Y // Calculate perfectly equidistant X positions for 5 buttons per row, centered horizontally, near the bottom var numBtnsPerRow = 5; var totalBtnWidth = numBtnsPerRow * splashLevelBtnSize; var centerMargin = 320; // Increase margin to bring buttons closer to center var availableWidth = 2048 - 2 * centerMargin; var btnSpacing = (availableWidth - totalBtnWidth) / (numBtnsPerRow - 1); var btnStartX = centerMargin + splashLevelBtnSize / 2; for (var i = 1; i <= 10; i++) { var btn = new Text2('Nivel ' + i, { size: 60, fill: 0xFFFFFF, font: "'Arial Rounded MT Bold','Arial Rounded MT','Arial Rounded','Arial','Arial Black',Tahoma" }); btn.anchor.set(0.5, 0.5); // Row 1: i=1..5, Row 2: i=6..10 if (i <= 5) { btn.x = btnStartX + (i - 1) * (splashLevelBtnSize + btnSpacing); btn.y = splashLevelBtnY1; } else { btn.x = btnStartX + (i - 6) * (splashLevelBtnSize + btnSpacing); btn.y = splashLevelBtnY2; } btn.interactive = true; btn.buttonMode = true; btn.alpha = 0.93; // Closure for correct level (function (levelNum) { btn.down = function (x, y, obj) { // Reset lives and nextLifeScore on level select lives = 3; nextLifeScore = 1000; updateLivesText(); // Remove splash, show UI, start at selected level if (splashOverlay && splashOverlay.parent) splashOverlay.parent.removeChild(splashOverlay); if (typeof levelText !== "undefined") levelText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = false; if (typeof recordTopText !== "undefined") recordTopText.visible = false; if (typeof scoreText !== "undefined") scoreText.visible = true; if (typeof gotoLevel4Btn !== "undefined") gotoLevel4Btn.visible = true; if (typeof gotoLevel3Btn !== "undefined") gotoLevel3Btn.visible = true; if (typeof currentLevel !== "undefined") currentLevel = levelNum; if (typeof levelText !== "undefined" && levelText.setText) levelText.setText('Nivel ' + levelNum); if (typeof spawnEnemiesForLevel === "function") spawnEnemiesForLevel(levelNum); // Add rotation/orbit variants: some reverse, some elliptical for (var k = 0; typeof enemies !== "undefined" && k < enemies.length; k++) { if ((k + levelNum) % 3 === 0 && levelNum > 4) { enemies[k].ellipseA = enemies[k].orbitRadius; enemies[k].ellipseB = Math.max(120, enemies[k].orbitRadius - 60 - Math.random() * 80); enemies[k].isElliptical = true; } else { enemies[k].isElliptical = false; } if (levelNum > 6 && k % 2 === 0) { enemies[k].orbitSpeed = -Math.abs(enemies[k].orbitSpeed); } else { enemies[k].orbitSpeed = Math.abs(enemies[k].orbitSpeed); } } // Reset player to starting position for next level (center bottom of the screen) if (typeof player !== "undefined") { player.x = 1024; player.y = 2632; if (typeof centerX !== "undefined" && typeof centerY !== "undefined") { player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); } for (var j = 0; typeof enemies !== "undefined" && j < enemies.length; j++) { enemies[j].orbitAngle = Math.random() * Math.PI * 2; } player.lastRadius = player.radius + 1; } }; })(i); splashOverlay.addChild(btn); splashLevelBtns.push(btn); } // Start Button var splashBtn = new Text2('JUGAR', { size: 160, fill: 0xFFFFFF, font: "'Impact','Arial Black',Tahoma", fontWeight: "bold" }); splashBtn.anchor.set(0.5, 0.5); splashBtn.x = 1024; splashBtn.y = 1400; splashBtn.interactive = true; splashBtn.buttonMode = true; splashBtn.alpha = 0.97; splashOverlay.addChild(splashBtn); // Add overlay to game game.addChild(splashOverlay); // Hide all gameplay UI while splash is visible if (typeof levelText !== "undefined") levelText.visible = false; if (typeof scoreText !== "undefined") scoreText.visible = false; if (typeof recordLabelText !== "undefined") recordLabelText.visible = false; if (typeof recordTopText !== "undefined") recordTopText.visible = false; if (typeof gotoLevel4Btn !== "undefined") gotoLevel4Btn.visible = false; if (typeof gotoLevel3Btn !== "undefined") gotoLevel3Btn.visible = false; // Start button event: remove splash, show UI, start game splashBtn.down = function (x, y, obj) { // Reset lives and nextLifeScore on game start lives = 3; nextLifeScore = 1000; updateLivesText(); if (splashOverlay && splashOverlay.parent) splashOverlay.parent.removeChild(splashOverlay); if (typeof levelText !== "undefined") levelText.visible = true; if (typeof scoreText !== "undefined") scoreText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = false; if (typeof recordTopText !== "undefined") recordTopText.visible = false; if (typeof gotoLevel4Btn !== "undefined") gotoLevel4Btn.visible = true; if (typeof gotoLevel3Btn !== "undefined") gotoLevel3Btn.visible = true; }; // Allow starting the game by tapping anywhere on the splashOverlay (not just the JUGAR button) splashOverlay.interactive = true; splashOverlay.down = function (x, y, obj) { // Only start if splashOverlay is still present if (splashOverlay && splashOverlay.parent) { // Call the JUGAR button's down handler to start the game if (typeof splashBtn !== "undefined" && splashBtn && typeof splashBtn.down === "function") { splashBtn.down(x, y, obj); } } }; // Stages configuration object // Import tween plugin for color cycling var stages = {}; // --- Create 11 stage objects, each on its own outward orbit --- var stages = []; var stageCount = 11; var baseStageRadius = 200; var stageRadiusStep = 80; // Each stage is 80px further out for (var i = 0; i < stageCount; i++) { var stage = new Container(); var stageGraphics = stage.attachAsset('stage', { anchorX: 0.5, anchorY: 0.5 }); stage.orbitRadius = baseStageRadius + i * stageRadiusStep; stage.orbitSpeed = -3.5 * (0.24 + i * 0.024); // Increased speed: rotate opposite to bonuses stage.orbitAngle = Math.random() * Math.PI * 2; stage.isStage = true; // Mark for clarity // --- Multicolor cycling effect using tween --- (function (stageGraphics, i) { // Define a set of bright, vivid colors to cycle through var colorCycle = [0xff3b3b, // bright red 0xfff200, // yellow 0x00ff90, // bright green 0x00e0ff, // cyan 0x3b6cff, // blue 0xc54ce4, // purple 0xff5ef7, // pink 0xffa500 // orange ]; var colorIndex = i % colorCycle.length; var nextColorIndex = (colorIndex + 1) % colorCycle.length; var tweenDuration = 900 + Math.floor(Math.random() * 600); // Vary duration for each stage function tweenToNextColor() { var fromColor = colorCycle[colorIndex]; var toColor = colorCycle[nextColorIndex]; // Animate color property using tween (correct API) tween(stageGraphics, { color: toColor }, { duration: tweenDuration, easing: tween.linear, onFinish: function onFinish() { colorIndex = nextColorIndex; nextColorIndex = (colorIndex + 1) % colorCycle.length; tweenToNextColor(); } }); } // Set initial color and start cycling stageGraphics.color = colorCycle[colorIndex]; if (typeof stageGraphics.tint !== "undefined") { stageGraphics.tint = stageGraphics.color; } tweenToNextColor(); })(stageGraphics, i); // --- End multicolor cycling effect --- stage.update = function () { this.orbitAngle += this.orbitSpeed; this.x = 1024 + this.orbitRadius * Math.cos(this.orbitAngle); this.y = 1366 + this.orbitRadius * Math.sin(this.orbitAngle); }; stage.setSize = function (newSize) { // Defensive: Only allow positive numbers if (typeof newSize === "number" && newSize > 0) { // The asset is always the first child if (this.children && this.children.length > 0 && this.children[0]) { var asset = this.children[0]; // Set both width and height to newSize (ellipse remains circular) asset.width = newSize; asset.height = newSize; } } }; game.addChild(stage); stages.push(stage); } // Add the home object at the center var home = game.addChild(new Home()); // Add the player to the game (after home, so player is above home) var player = game.addChild(new Player()); // Ensure player is always above home in the display list if (home && player && home.parent && player.parent && home.parent === player.parent) { var parent = home.parent; // Remove and re-add player to ensure it's above home parent.removeChild(player); parent.addChild(player); } // Make the home object flash its alpha from 0 to 1 in a blinking effect per 1ms if (home && home.children && home.children.length > 0 && home.children[0]) { // Use tween to animate alpha from 0 to 1 and back, repeating forever, with 1ms duration for each fade var _blinkHomeAlpha = function blinkHomeAlpha() { // Fade out to alpha 0 tween(homeGraphics, { alpha: 0 }, { duration: 1, easing: tween.linear, onFinish: function onFinish() { // Fade in to alpha 1 tween(homeGraphics, { alpha: 1 }, { duration: 1, easing: tween.linear, onFinish: _blinkHomeAlpha }); } }); }; var homeGraphics = home.children[0]; // Defensive: clear any previous alpha homeGraphics.alpha = 1; _blinkHomeAlpha(); } // Hide the home object while splashOverlay is visible if (typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent) { home.visible = false; } // Hide the player object while splashOverlay is visible if (typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent) { if (typeof player !== "undefined") player.visible = false; } // When splashOverlay is removed (game starts), show the home object if (typeof splashBtn !== "undefined" && splashBtn && splashBtn.down) { var originalSplashBtnDown = splashBtn.down; splashBtn.down = function (x, y, obj) { if (home) home.visible = true; if (player) player.visible = true; originalSplashBtnDown.call(this, x, y, obj); }; } // Also for level select buttons if (typeof splashLevelBtns !== "undefined" && splashLevelBtns.length) { for (var i = 0; i < splashLevelBtns.length; i++) { if (splashLevelBtns[i] && splashLevelBtns[i].down) { (function (btn) { var originalDown = btn.down; btn.down = function (x, y, obj) { if (home) home.visible = true; if (player) player.visible = true; originalDown.call(this, x, y, obj); }; })(splashLevelBtns[i]); } } } // Add a player to the game // (moved above, after home, to ensure correct z-order) // Add 12 deco objects, all sharing the same orbit (same radius, speed, and direction) var decos = []; var decoCount = 12; var sharedDecoOrbitRadius = 800; // Increased: All decos on a wider orbit var sharedDecoOrbitSpeed = -0.9; // Reduced deco orbit speed (was -1.2) for (var i = 0; i < decoCount; i++) { var deco = game.addChild(new Deco()); // Assign a random light color to the deco's graphics if (deco.children && deco.children.length > 0 && deco.children[0]) { var r = 200 + Math.floor(Math.random() * 56); var g = 200 + Math.floor(Math.random() * 56); var b = 200 + Math.floor(Math.random() * 56); var lightColor = r << 16 | g << 8 | b; deco.children[0].color = lightColor; if (typeof deco.children[0].tint !== "undefined") { deco.children[0].tint = lightColor; } } deco.orbitRadius = sharedDecoOrbitRadius; deco.orbitAngle = Math.PI * 2 / decoCount * i; deco.orbitSpeed = sharedDecoOrbitSpeed; decos.push(deco); } // Duplicate the outer deco orbit: add a second set of 12 decos on the same outer orbit, offset for visual separation var decosOuter2 = []; for (var i = 0; i < decoCount; i++) { var deco2 = game.addChild(new Deco()); // Assign a random light color to the deco's graphics if (deco2.children && deco2.children.length > 0 && deco2.children[0]) { var r = 200 + Math.floor(Math.random() * 56); var g = 200 + Math.floor(Math.random() * 56); var b = 200 + Math.floor(Math.random() * 56); var lightColor = r << 16 | g << 8 | b; deco2.children[0].color = lightColor; if (typeof deco2.children[0].tint !== "undefined") { deco2.children[0].tint = lightColor; } } deco2.orbitRadius = sharedDecoOrbitRadius; deco2.orbitAngle = Math.PI * 2 / decoCount * i + Math.PI / decoCount; // offset for separation deco2.orbitSpeed = sharedDecoOrbitSpeed; decosOuter2.push(deco2); } // Add a third deco orbit, now with a larger radius for a bigger outer deco ring var decosOuter3 = []; var sharedDecoOuter3OrbitRadius = sharedDecoOrbitRadius + 200; // Increased: much larger than outer orbits var sharedDecoOuter3OrbitSpeed = sharedDecoOrbitSpeed; // Same speed as other outer orbits for (var i = 0; i < decoCount; i++) { var deco3 = game.addChild(new Deco()); // Assign a random light color to the deco's graphics if (deco3.children && deco3.children.length > 0 && deco3.children[0]) { var r = 200 + Math.floor(Math.random() * 56); var g = 200 + Math.floor(Math.random() * 56); var b = 200 + Math.floor(Math.random() * 56); var lightColor = r << 16 | g << 8 | b; deco3.children[0].color = lightColor; if (typeof deco3.children[0].tint !== "undefined") { deco3.children[0].tint = lightColor; } } deco3.orbitRadius = sharedDecoOuter3OrbitRadius; deco3.orbitAngle = Math.PI * 2 / decoCount * i + Math.PI / (decoCount * 2); // offset for visual separation deco3.orbitSpeed = sharedDecoOuter3OrbitSpeed; decosOuter3.push(deco3); } // Duplicate the largest deco orbit: add a second set of 12 decos on the same largest orbit, offset for visual separation var decosOuter3b = []; for (var i = 0; i < decoCount; i++) { var deco3b = game.addChild(new Deco()); // Assign a random light color to the deco's graphics if (deco3b.children && deco3b.children.length > 0 && deco3b.children[0]) { var r = 200 + Math.floor(Math.random() * 56); var g = 200 + Math.floor(Math.random() * 56); var b = 200 + Math.floor(Math.random() * 56); var lightColor = r << 16 | g << 8 | b; deco3b.children[0].color = lightColor; if (typeof deco3b.children[0].tint !== "undefined") { deco3b.children[0].tint = lightColor; } } deco3b.orbitRadius = sharedDecoOuter3OrbitRadius; deco3b.orbitAngle = Math.PI * 2 / decoCount * i + Math.PI / decoCount; // further offset for separation deco3b.orbitSpeed = sharedDecoOuter3OrbitSpeed; decosOuter3b.push(deco3b); } // Add a second deco orbit with half the radius and same count var decosInner = []; var sharedDecoInnerOrbitRadius = sharedDecoOrbitRadius / 2; for (var i = 0; i < decoCount; i++) { var decoInner = game.addChild(new Deco()); // Assign a random light color to the deco's graphics if (decoInner.children && decoInner.children.length > 0 && decoInner.children[0]) { var r = 200 + Math.floor(Math.random() * 56); var g = 200 + Math.floor(Math.random() * 56); var b = 200 + Math.floor(Math.random() * 56); var lightColor = r << 16 | g << 8 | b; decoInner.children[0].color = lightColor; if (typeof decoInner.children[0].tint !== "undefined") { decoInner.children[0].tint = lightColor; } decoInner.children[0].scaleX = 0.7; decoInner.children[0].scaleY = 0.7; } decoInner.orbitRadius = sharedDecoInnerOrbitRadius; decoInner.orbitAngle = Math.PI * 2 / decoCount * i + Math.PI / decoCount; // offset for visual separation decoInner.orbitSpeed = sharedDecoOrbitSpeed; decosInner.push(decoInner); } // Add 6 new enemies in a close orbit near the center var closeEnemyCount = 6; var closeEnemyOrbitRadius = 400; // Ampliado: más lejos del centro, pero aún dentro de la órbita de deco var closeEnemyOrbitSpeed = -0.003; // Reduced to 25% speed for enemy2 (slower) var closeEnemies = []; // Use the original first colors for close enemies, and assign each a unique color // Cambia el color rojo (0xe60000) por un verde brillante (0x00ff90) var originalColors = [0x00ff90, // bright green (antes era rojo) // strong red (reemplazado) // blue 0x484de8, // magenta 0xf30cdc, // cyan 0x00e0ff, // yellow 0xffeb5e, // blueish 0x4c7fb9]; var usedColors = []; var _loop = function _loop() { closeEnemy = game.addChild(new Enemy()); // Assign a random multicolor to the close enemy's graphics if (closeEnemy.children && closeEnemy.children.length > 0 && closeEnemy.children[0]) { var _tweenToNextColorEnemy2 = function tweenToNextColorEnemy2() { var fromColor = colorCycle[colorIndex]; var toColor = colorCycle[nextColorIndex]; tween(enemyGraphics, { color: toColor }, { duration: tweenDuration, easing: tween.linear, onFinish: function onFinish() { colorIndex = nextColorIndex; nextColorIndex = (colorIndex + 1) % colorCycle.length; _tweenToNextColorEnemy2(); } }); }; // Multicolor cycling effect for close enemies (enemy2) colorCycle = [0xff3b3b, // bright red 0xfff200, // yellow 0x00ff90, // bright green 0x00e0ff, // cyan 0x3b6cff, // blue 0xc54ce4, // purple 0xff5ef7, // pink 0xffa500 // orange ]; colorIndex = Math.floor(Math.random() * colorCycle.length); nextColorIndex = (colorIndex + 1) % colorCycle.length; tweenDuration = 900 + Math.floor(Math.random() * 600); enemyGraphics = closeEnemy.children[0]; enemyGraphics.color = colorCycle[colorIndex]; if (typeof enemyGraphics.tint !== "undefined") { enemyGraphics.tint = enemyGraphics.color; } _tweenToNextColorEnemy2(); } closeEnemy.orbitRadius = closeEnemyOrbitRadius; closeEnemy.orbitAngle = Math.PI * 2 / closeEnemyCount * i; closeEnemy.orbitSpeed = closeEnemyOrbitSpeed; closeEnemies.push(closeEnemy); }, closeEnemy, colorCycle, colorIndex, nextColorIndex, tweenDuration, enemyGraphics; for (var i = 0; i < closeEnemyCount; i++) { _loop(); } // Removed orbitingEnemy from the deco orbit var orbitingEnemy = undefined; // Define orbits so that all 3 are separated by at least 600px (radius difference) // Minimum separation between orbits: 600px var orbits = [170, 770, 1100]; // Reduced the outermost orbit radius from 1370 to 1100 // Create three bonus objects, each occupying a unique orbit var bonuses = []; for (var i = 0; i < 3; i++) { var b = game.addChild(new Bonus()); b.orbitIndex = i; b.orbitRadius = orbits[i]; b.orbitSpeed = 0.04 + Math.random() * 0.09; // Distribute bonuses evenly around the circle b.orbitAngle = Math.PI * 2 / 3 * i; bonuses.push(b); } // Add a new fast-orbiting object (superBonus) that orbits faster than all bonuses var superBonus = game.addChild(new Bonus()); superBonus.orbitIndex = 3; // Not on the same orbits as bonuses, but can use a new or existing radius superBonus.orbitRadius = 320; // Reduced radius to keep inside screen superBonus.orbitSpeed = 0.18 + Math.random() * 0.04; // Much faster than normal bonuses superBonus.orbitAngle = Math.random() * Math.PI * 2; // (Removed unnecessary update of deco.orbitRadius) // Add level number display at the top center of the screen var levelText = new Text2('Nivel 1', { size: 100, fill: 0xFFFFFF, font: "'Impact','Arial Black',Tahoma" }); levelText.anchor.set(0.5, 0); // Center horizontally, top edge LK.gui.top.addChild(levelText); // --- Lives system --- // Start with 3 lives var lives = 3; var maxLives = 9; // Optional: cap max lives // Track score at which next extra life is granted var nextLifeScore = 1000; // Display lives below the level display var livesText = new Text2('❤❤❤', { size: 60, fill: 0xA020F0, // purple font: "'Impact','Arial Black',Tahoma" }); livesText.anchor.set(0.5, 0); livesText.y = levelText.height + 10; LK.gui.top.addChild(livesText); // Helper to update lives display function updateLivesText() { // Show one heart per life, up to maxLives var heart = '❤'; var txt = ''; for (var i = 0; i < Math.min(lives, maxLives); i++) txt += heart; livesText.setText(txt); } updateLivesText(); // Add record display below the level display at the top center, with "Record" label smaller and number larger, stacked vertically and centered var recordLabelText = new Text2('Record', { size: 90, fill: 0xA020F0, font: "'Impact','Arial Black',Tahoma" }); recordLabelText.anchor.set(0.5, 0); // Center horizontally, top edge recordLabelText.y = levelText.height + 10; // 10px below levelText recordLabelText.visible = false; recordLabelText.alpha = 0.75; LK.gui.top.addChild(recordLabelText); var recordTopText = new Text2('0', { size: 260, fill: 0xA020F0, font: "'Impact','Arial Black',Tahoma" }); recordTopText.anchor.set(0.5, 0); // Center horizontally, top edge recordTopText.y = recordLabelText.y + recordLabelText.height - 10; // Stack number below label, slight overlap for tightness recordTopText.visible = false; recordTopText.alpha = 0.75; LK.gui.top.addChild(recordTopText); // Update levelText to show the current level at game start if (typeof currentLevel !== "undefined" && typeof levelText !== "undefined" && levelText.setText) { levelText.setText('Nivel ' + currentLevel); } // Update recordTopText to show the current record at game start if (typeof record !== "undefined" && typeof recordTopText !== "undefined" && recordTopText.setText) { recordTopText.setText('' + record); } // Add score display at the bottom center in purple, only the number and centered var score = 0; var scoreText = new Text2('0', { size: 100, fill: 0xA020F0, // purple font: "'Impact','Arial Black',Tahoma" }); scoreText.anchor.set(0.5, 1); // Centered horizontally, bottom edge LK.gui.bottom.addChild(scoreText); // --- Add a button to jump to level 4 --- var gotoLevel4Btn = new Text2('Ir a Nivel 4', { size: 80, fill: 0xFFFFFF, font: "'Impact','Arial Black',Tahoma" }); gotoLevel4Btn.anchor.set(0.5, 0.5); // Place the button at the bottom right, but not in the very corner (avoid overlap with system UI) gotoLevel4Btn.x = LK.gui.width - 300; gotoLevel4Btn.y = LK.gui.height - 180; gotoLevel4Btn.interactive = true; gotoLevel4Btn.buttonMode = true; gotoLevel4Btn.alpha = 0.92; LK.gui.bottom.addChild(gotoLevel4Btn); // Button event: jump to level 4 gotoLevel4Btn.down = function (x, y, obj) { if (typeof currentLevel !== "undefined" && currentLevel !== 4) { currentLevel = 4; // Cambia el color del overlay al nivel 4 if (typeof onLevelChange_updateOverlayColor === "function") onLevelChange_updateOverlayColor(4); if (typeof levelText !== "undefined" && levelText.setText) { levelText.setText('Nivel ' + currentLevel); } spawnEnemiesForLevel(currentLevel); // Add rotation/orbit variants: some reverse, some elliptical for (var k = 0; k < enemies.length; k++) { if ((k + currentLevel) % 3 === 0 && currentLevel > 4) { enemies[k].ellipseA = enemies[k].orbitRadius; enemies[k].ellipseB = Math.max(120, enemies[k].orbitRadius - 60 - Math.random() * 80); enemies[k].isElliptical = true; } else { enemies[k].isElliptical = false; } if (currentLevel > 6 && k % 2 === 0) { enemies[k].orbitSpeed = -Math.abs(enemies[k].orbitSpeed); } else { enemies[k].orbitSpeed = Math.abs(enemies[k].orbitSpeed); } } // Reset player to starting position for next level (center bottom of the screen) player.x = 1024; player.y = 2632; player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); for (var j = 0; j < enemies.length; j++) { enemies[j].orbitAngle = Math.random() * Math.PI * 2; } player.lastRadius = player.radius + 1; } }; // --- Add a button to jump to level 3 --- var gotoLevel3Btn = new Text2('Ir a Nivel 3', { size: 80, fill: 0xFFFFFF, font: "'Impact','Arial Black',Tahoma" }); gotoLevel3Btn.anchor.set(0.5, 0.5); // Place the button at the bottom right, above the level 4 button gotoLevel3Btn.x = LK.gui.width - 300; gotoLevel3Btn.y = LK.gui.height - 300; gotoLevel3Btn.interactive = true; gotoLevel3Btn.buttonMode = true; gotoLevel3Btn.alpha = 0.92; LK.gui.bottom.addChild(gotoLevel3Btn); // Button event: jump to level 3 gotoLevel3Btn.down = function (x, y, obj) { if (typeof currentLevel !== "undefined" && currentLevel !== 3) { currentLevel = 3; // Cambia el color del overlay al nivel 3 if (typeof onLevelChange_updateOverlayColor === "function") onLevelChange_updateOverlayColor(3); if (typeof levelText !== "undefined" && levelText.setText) { levelText.setText('Nivel ' + currentLevel); } spawnEnemiesForLevel(currentLevel); // Add rotation/orbit variants: some reverse, some elliptical for (var k = 0; k < enemies.length; k++) { if ((k + currentLevel) % 3 === 0 && currentLevel > 4) { enemies[k].ellipseA = enemies[k].orbitRadius; enemies[k].ellipseB = Math.max(120, enemies[k].orbitRadius - 60 - Math.random() * 80); enemies[k].isElliptical = true; } else { enemies[k].isElliptical = false; } if (currentLevel > 6 && k % 2 === 0) { enemies[k].orbitSpeed = -Math.abs(enemies[k].orbitSpeed); } else { enemies[k].orbitSpeed = Math.abs(enemies[k].orbitSpeed); } } // Reset player to starting position for next level (center bottom of the screen) player.x = 1024; player.y = 2632; player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); for (var j = 0; j < enemies.length; j++) { enemies[j].orbitAngle = Math.random() * Math.PI * 2; } player.lastRadius = player.radius + 1; } }; // Record always starts at 0 and is not persisted var record = 0; // Set initial position of the player (bottom of the screen for splash/inicio) player.x = 1024; // Center horizontally player.y = 2632; // Always at the bottom (100px from bottom edge) // Store the center of the screen for easy reference var centerX = 1024; var centerY = 1366; // Define orbits var orbits = [110, 170, 230]; // Track the player's current angle and radius from the center player.angle = Math.atan2(player.y - centerY, player.x - centerX); player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); // Keyboard controls removed for compatibility; player movement is now handled by other means. // Function to find the next closest orbit function getNextOrbit(currentY) { var currentOrbit = 2732 - currentY; for (var i = 0; i < orbits.length; i++) { if (orbits[i] > currentOrbit) { return 2732 - orbits[i]; } ; // --- Super Bonus object update and collision (fastest orbiting object) --- if (typeof superBonus !== "undefined" && superBonus) { superBonus.update(); if (superBonus.lastWasIntersecting === undefined) superBonus.lastWasIntersecting = false; // Aumenta un poquitín el área de colisión para superBonus var superBonusCollisionWidth = (superBonus.width ? superBonus.width : 25) * 0.7; var superBonusCollisionHeight = (superBonus.height ? superBonus.height : 25) * 0.7; var superBonusCollisionLeft = superBonus.x - superBonusCollisionWidth / 2; var superBonusCollisionRight = superBonus.x + superBonusCollisionWidth / 2; var superBonusCollisionTop = superBonus.y - superBonusCollisionHeight / 2; var superBonusCollisionBottom = superBonus.y + superBonusCollisionHeight / 2; var sbIntersecting = player.x > superBonusCollisionLeft && player.x < superBonusCollisionRight && player.y > superBonusCollisionTop && player.y < superBonusCollisionBottom; if (!superBonus.lastWasIntersecting && sbIntersecting) { // Player just collected the super bonus! score += 200; if (typeof scoreText !== "undefined" && scoreText.setText) { scoreText.setText('' + score); } // Update record if needed if (score > record) { record = score; } if (typeof pointsText !== "undefined" && pointsText.setText) { pointsText.setText('Record: ' + record); } // Update recordTopText at the top center as well if (typeof recordTopText !== "undefined" && recordTopText.setText) { recordTopText.setText('' + record); } // Move superBonus to a new random angle and randomize its speed (always fast) superBonus.orbitAngle = Math.random() * Math.PI * 2; superBonus.orbitSpeed = 0.18 + Math.random() * 0.04; } superBonus.lastWasIntersecting = sbIntersecting; } ; // --- Deco fast counter-orbit update for all decos --- if (typeof decos !== "undefined" && decos.length) { for (var i = 0; i < decos.length; i++) { var deco = decos[i]; deco.orbitAngle += deco.orbitSpeed; deco.x = centerX + deco.orbitRadius * Math.cos(deco.orbitAngle); deco.y = centerY + deco.orbitRadius * Math.sin(deco.orbitAngle); // --- Collision detection: player initiates collision with deco --- // Deco no longer kills the player; collisions are ignored for game over logic if (player.lastWasIntersectingDeco === undefined) player.lastWasIntersectingDeco = []; if (player.lastWasIntersectingDeco[i] === undefined) player.lastWasIntersectingDeco[i] = false; // Aumenta un poquitín el área de colisión para deco var decoCollisionWidth = (deco.width ? deco.width : 15) * 0.7; var decoCollisionHeight = (deco.height ? deco.height : 15) * 0.7; var decoCollisionLeft = deco.x - decoCollisionWidth / 2; var decoCollisionRight = deco.x + decoCollisionWidth / 2; var decoCollisionTop = deco.y - decoCollisionHeight / 2; var decoCollisionBottom = deco.y + decoCollisionHeight / 2; var playerHitsDeco = player.x > decoCollisionLeft && player.x < decoCollisionRight && player.y > decoCollisionTop && player.y < decoCollisionBottom; player.lastWasIntersectingDeco[i] = playerHitsDeco; // --- Deco's own collision detection for legacy/compatibility --- if (deco.lastWasIntersecting === undefined) deco.lastWasIntersecting = false; // Aumenta un poquitín el área de colisión para deco (legacy/compatibilidad) var decoCollisionWidth2 = (deco.width ? deco.width : 15) * 0.7; var decoCollisionHeight2 = (deco.height ? deco.height : 15) * 0.7; var decoCollisionLeft2 = deco.x - decoCollisionWidth2 / 2; var decoCollisionRight2 = deco.x + decoCollisionWidth2 / 2; var decoCollisionTop2 = deco.y - decoCollisionHeight2 / 2; var decoCollisionBottom2 = deco.y + decoCollisionHeight2 / 2; var decoIntersecting = player.x > decoCollisionLeft2 && player.x < decoCollisionRight2 && player.y > decoCollisionTop2 && player.y < decoCollisionBottom2; deco.lastWasIntersecting = decoIntersecting; // --- Deco kills playerball as well (if playerball is a different object) --- if (typeof playerball !== "undefined" && playerball) { if (deco.lastWasIntersectingPlayerball === undefined) deco.lastWasIntersectingPlayerball = false; // Aumenta un poquitín el área de colisión para deco vs playerball var decoCollisionWidth3 = (deco.width ? deco.width : 15) * 0.7; var decoCollisionHeight3 = (deco.height ? deco.height : 15) * 0.7; var decoCollisionLeft3 = deco.x - decoCollisionWidth3 / 2; var decoCollisionRight3 = deco.x + decoCollisionWidth3 / 2; var decoCollisionTop3 = deco.y - decoCollisionHeight3 / 2; var decoCollisionBottom3 = deco.y + decoCollisionHeight3 / 2; var decoHitsPlayerball = playerball.x > decoCollisionLeft3 && playerball.x < decoCollisionRight3 && playerball.y > decoCollisionTop3 && playerball.y < decoCollisionBottom3; deco.lastWasIntersectingPlayerball = decoHitsPlayerball; } // --- Deco collides with playerball or player (combined logic) --- if (typeof playerball !== "undefined" && playerball) { if (deco.lastWasIntersectingPlayerOrBall === undefined) deco.lastWasIntersectingPlayerOrBall = false; // Aumenta un poquitín el área de colisión para deco vs player o playerball var decoCollisionWidth4 = (deco.width ? deco.width : 15) * 0.7; var decoCollisionHeight4 = (deco.height ? deco.height : 15) * 0.7; var decoCollisionLeft4 = deco.x - decoCollisionWidth4 / 2; var decoCollisionRight4 = deco.x + decoCollisionWidth4 / 2; var decoCollisionTop4 = deco.y - decoCollisionHeight4 / 2; var decoCollisionBottom4 = deco.y + decoCollisionHeight4 / 2; var decoHitsPlayerOrBall = player.x > decoCollisionLeft4 && player.x < decoCollisionRight4 && player.y > decoCollisionTop4 && player.y < decoCollisionBottom4 || playerball.x > decoCollisionLeft4 && playerball.x < decoCollisionRight4 && playerball.y > decoCollisionTop4 && playerball.y < decoCollisionBottom4; deco.lastWasIntersectingPlayerOrBall = decoHitsPlayerOrBall; } else { // Only player exists if (deco.lastWasIntersectingPlayerOrBall === undefined) deco.lastWasIntersectingPlayerOrBall = false; // Aumenta un poquitín el área de colisión para deco vs player (solo player existe) var decoCollisionWidth5 = (deco.width ? deco.width : 15) * 0.7; var decoCollisionHeight5 = (deco.height ? deco.height : 15) * 0.7; var decoCollisionLeft5 = deco.x - decoCollisionWidth5 / 2; var decoCollisionRight5 = deco.x + decoCollisionWidth5 / 2; var decoCollisionTop5 = deco.y - decoCollisionHeight5 / 2; var decoCollisionBottom5 = deco.y + decoCollisionHeight5 / 2; var decoHitsPlayer = player.x > decoCollisionLeft5 && player.x < decoCollisionRight5 && player.y > decoCollisionTop5 && player.y < decoCollisionBottom5; deco.lastWasIntersectingPlayerOrBall = decoHitsPlayer; } } } } ; ; // Add a new orbit to the end of the array to create an infinite loop var newOrbit = orbits[orbits.length - 1] + 400; orbits.push(newOrbit); return 2732 - newOrbit; } // Track if right mouse button is held down var rightMouseDown = false; // Track if left mouse button is held down var leftMouseDown = false; // Track which direction the player should move: -1 for left, 1 for right, 0 for none var playerMoveDirection = 0; // Add event listener for mouse/touch down game.down = function (x, y, obj) { // x is in game coordinates (0 to 2048) if (x < 1024) { // Pressed on left half: move player right (clockwise) playerMoveDirection = 1; } else { // Pressed on right half: move player left (counterclockwise) playerMoveDirection = -1; } }; // Add event listener for mouse/touch up to stop moving game.up = function (x, y, obj) { playerMoveDirection = 0; }; // Set initial number of enemies for level 1 (3 enemies), and increase by 1 per level up to 20 levels var currentLevel = 1; var maxLevels = 20; var enemies = []; function spawnEnemiesForLevel(level) { // Remove existing enemies from game for (var i = 0; i < enemies.length; i++) { if (enemies[i].parent) enemies[i].parent.removeChild(enemies[i]); } enemies = []; // Number of enemies increases by 1 per level, starting at 3, max 22 at level 20 var numEnemies = Math.min(3 + (level - 1), 3 + (maxLevels - 1)); // Amplified enemy orbits: increase all base radii for even wider orbits var baseRadii = [370, 540, 710, 880, 1050, 1220, 1390, 1560]; var _loop2 = function _loop2() { enemy = game.addChild(new Enemy()); // Assign a random multicolor to the enemy's graphics if (enemy.children && enemy.children.length > 0 && enemy.children[0]) { var _tweenToNextColorEnemy = function tweenToNextColorEnemy() { var fromColor = colorCycle[colorIndex]; var toColor = colorCycle[nextColorIndex]; tween(enemyGraphics, { color: toColor }, { duration: tweenDuration, easing: tween.linear, onFinish: function onFinish() { colorIndex = nextColorIndex; nextColorIndex = (colorIndex + 1) % colorCycle.length; _tweenToNextColorEnemy(); } }); }; // Multicolor cycling effect for main enemies (enemy) colorCycle = [0xff3b3b, // bright red 0xfff200, // yellow 0x00ff90, // bright green 0x00e0ff, // cyan 0x3b6cff, // blue 0xc54ce4, // purple 0xff5ef7, // pink 0xffa500 // orange ]; colorIndex = Math.floor(Math.random() * colorCycle.length); nextColorIndex = (colorIndex + 1) % colorCycle.length; tweenDuration = 900 + Math.floor(Math.random() * 600); enemyGraphics = enemy.children[0]; enemyGraphics.color = colorCycle[colorIndex]; if (typeof enemyGraphics.tint !== "undefined") { enemyGraphics.tint = enemyGraphics.color; } _tweenToNextColorEnemy(); } enemy.x = 1024; enemy.y = 1366; // Distribute orbits and angles for variety baseRadius = baseRadii[i % baseRadii.length]; enemy.orbitRadius = baseRadius + Math.floor(Math.random() * 120); enemy.orbitAngle = Math.random() * Math.PI * 2; enemy.orbitSpeed = 0.004 + Math.random() * 0.003; // Alternate direction: odd = counterclockwise, even = clockwise if (i % 2 === 1) { enemy.orbitSpeed *= -1; enemy.isCounterClockwise = true; } else { enemy.isCounterClockwise = false; } enemy.speed = 1.2 + Math.random() * 1.5; // Add random direction change timer for some enemies enemy.canChangeDirection = Math.random() < 0.5; // 50% chance if (enemy.canChangeDirection) { enemy.directionChangeInterval = 60 + Math.floor(Math.random() * 120); // 1-3 seconds enemy.directionChangeTick = 0; } enemies.push(enemy); }, enemy, colorCycle, colorIndex, nextColorIndex, tweenDuration, enemyGraphics, baseRadius; for (var i = 0; i < numEnemies; i++) { _loop2(); } } // Spawn initial enemies for level 1 spawnEnemiesForLevel(currentLevel); // Play Vertigo music at the start of the game, ensure it loops LK.playMusic('Vertigo', { loop: true }); // Update method for orbiting game.update = function () { // Gravity: each frame, pull the player a bit toward the center if (typeof currentLevel === "undefined") { var gravityStrength = 2.4; } else { // Increase gravityStrength by 0.004 per level (más aceleración) var gravityStrength = 2.4 + (currentLevel - 1) * 0.004; } // Prevent player from moving from the bottom during splash screen (inicio) var splashActive = typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent; if (splashActive) { // Keep player at bottom center player.x = 1024; player.y = 2632; player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); // Always reset scale to 1 on splash if (player.children && player.children[0]) { player.children[0].scaleX = 1; player.children[0].scaleY = 1; } } else { // --- GRAVITY TOWARD CENTER --- // Calculate vector from player to center var dx = centerX - player.x; var dy = centerY - player.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 1) { // Normalize direction var nx = dx / dist; var ny = dy / dist; // Move player toward center by gravityStrength, but don't overshoot var moveDist = Math.min(gravityStrength, dist); player.x += nx * moveDist; player.y += ny * moveDist; // Update angle and radius for orbit logic player.angle = Math.atan2(player.y - centerY, player.x - centerX); player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); } // Smooth and continuous player movement (left/right orbit) if (typeof playerMoveDirection !== "undefined" && playerMoveDirection !== 0) { // Adjust this value for desired rotation speed (radians per frame) // Further reduced moveSpeed for even slower left/right movement var moveSpeed = 0.012; player.angle += playerMoveDirection * moveSpeed; // Recalculate position based on new angle, keep radius player.x = centerX + player.radius * Math.cos(player.angle); player.y = centerY + player.radius * Math.sin(player.angle); } // --- Player scaling as it approaches the center --- // Defensive: only scale if player has a child (the graphics) if (player.children && player.children[0]) { // Define the min and max radius for scaling var maxRadius = 1500; // Farthest distance for full size var minRadius = 80; // Closest distance for min size var minScale = 0.5; // 50% at center var maxScale = 1.0; // 100% at farthest // Clamp radius between min and max var clampedRadius = Math.max(minRadius, Math.min(maxRadius, player.radius)); // Linear interpolation for scale var t = (clampedRadius - minRadius) / (maxRadius - minRadius); var targetScale = minScale + (maxScale - minScale) * t; // Tween only if scale is different enough to avoid jitter var currentScale = player.children[0].scaleX; if (Math.abs(currentScale - targetScale) > 0.01) { tween.stop(player.children[0], { scaleX: true, scaleY: true }); tween(player.children[0], { scaleX: targetScale, scaleY: targetScale }, { duration: 120, easing: tween.linear }); } } } // --- LEVEL SYSTEM: Track and progress levels up to 20 --- if (typeof currentLevel === "undefined") { var currentLevel = 1; var maxLevels = 20; } if (player.lastRadius === undefined) player.lastRadius = player.radius; // Check if player just reached the home object at the center this frame if (home && player && home.lastWasIntersecting === undefined) home.lastWasIntersecting = false; var playerAtHome = home && player && home.intersects(player); // Advance to next stage/level if player just reached home (center) if (home && player && !home.lastWasIntersecting && playerAtHome) { // Defensive: only advance if not on splash var splashActive = typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent; if (!splashActive) { // --- Award points based on entry direction --- // We'll use the player's last position (lastX, lastY) to determine the entry direction var entryPoints = 0; if (typeof player.lastY !== "undefined" && typeof player.lastX !== "undefined") { // Center coordinates var cx = centerX; var cy = centerY; // Entry vector: from last position to center var dx = cx - player.lastX; var dy = cy - player.lastY; // Normalize var mag = Math.sqrt(dx * dx + dy * dy); var ndx = dx / (mag || 1); var ndy = dy / (mag || 1); // Angle in degrees (0 = right, 90 = down, 180 = left, -90 = up) var angle = Math.atan2(ndy, ndx) * 180 / Math.PI; // Determine entry region // From below (bottom): angle between 60 and 120 // From lower sides: angle between 30-60 (right-lower), 120-150 (left-lower) // From upper sides: angle between -30 to 30 (right-upper), 150 to 180 or -180 to -150 (left-upper) // From above (top): angle between -120 and -60 if (angle >= 60 && angle <= 120) { entryPoints = 20; // From below } else if (angle > 30 && angle < 60 || angle > 120 && angle < 150) { entryPoints = 50; // From lower sides } else if (angle > -30 && angle < 30 || angle > 150 || angle < -150) { entryPoints = 100; // From upper sides } else if (angle >= -120 && angle <= -60) { entryPoints = 200; // From above } else { entryPoints = 20; // Fallback, treat as from below } } else { entryPoints = 20; // Fallback if no last position } score += entryPoints; if (typeof scoreText !== "undefined" && scoreText.setText) { scoreText.setText('' + score); } // Update record if needed if (score > record) { record = score; } if (typeof pointsText !== "undefined" && pointsText.setText) { pointsText.setText('Record: ' + record); } if (typeof recordTopText !== "undefined" && recordTopText.setText) { recordTopText.setText('' + record); } // --- Vida extra cada 1000 puntos --- while (score >= nextLifeScore) { if (lives < maxLives) { lives++; updateLivesText(); } nextLifeScore += 1000; } // Always advance to the next stage in sequence, wrapping if needed if (typeof currentLevel !== "undefined" && typeof maxLevels !== "undefined") { // Properly increment currentLevel, wrapping to 1 after maxLevels currentLevel++; if (currentLevel > maxLevels) currentLevel = 1; // Update overlay color for new level if (typeof onLevelChange_updateOverlayColor === "function") onLevelChange_updateOverlayColor(currentLevel); // Update level text if (typeof levelText !== "undefined" && levelText.setText) levelText.setText('Nivel ' + currentLevel); // Spawn new enemies for the new level if (typeof spawnEnemiesForLevel === "function") spawnEnemiesForLevel(currentLevel); // Add rotation/orbit variants: some reverse, some elliptical for (var k = 0; typeof enemies !== "undefined" && k < enemies.length; k++) { if ((k + currentLevel) % 3 === 0 && currentLevel > 4) { enemies[k].ellipseA = enemies[k].orbitRadius; enemies[k].ellipseB = Math.max(120, enemies[k].orbitRadius - 60 - Math.random() * 80); enemies[k].isElliptical = true; } else { enemies[k].isElliptical = false; } if (currentLevel > 6 && k % 2 === 0) { enemies[k].orbitSpeed = -Math.abs(enemies[k].orbitSpeed); } else { enemies[k].orbitSpeed = Math.abs(enemies[k].orbitSpeed); } } // Reset player to starting position for next level (center bottom of the screen) player.x = 1024; player.y = 2632; if (typeof centerX !== "undefined" && typeof centerY !== "undefined") { player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); } for (var j = 0; typeof enemies !== "undefined" && j < enemies.length; j++) { enemies[j].orbitAngle = Math.random() * Math.PI * 2; } player.lastRadius = player.radius + 1; } } } // Track lastWasIntersecting for home if (home) home.lastWasIntersecting = playerAtHome; player.lastRadius = player.radius; // Track lastWasIntersecting for home if (home) home.lastWasIntersecting = playerAtHome; player.lastRadius = player.radius; // Move player towards the center if right mouse button is held down (extra boost) if (typeof rightMouseDown !== "undefined" && rightMouseDown) { // Each frame, move the player 3.5px closer to the center, but not below a minimum radius of 80 player.radius = Math.max(80, player.radius - 3.5); player.x = centerX + player.radius * Math.cos(player.angle); player.y = centerY + player.radius * Math.sin(player.angle); } // Rotate player if left mouse button is held down if (typeof leftMouseDown !== "undefined" && leftMouseDown) { player.angle += 0.035; // Slower, smoother rotation for perception // When rotating, accelerate gravity (move faster to center) player.radius = Math.max(80, player.radius - gravityStrength * 2.5); player.x = centerX + player.radius * Math.cos(player.angle); player.y = centerY + player.radius * Math.sin(player.angle); } // Update all miniparticles (if any) if (game.children && game.children.length) { for (var i = game.children.length - 1; i >= 0; i--) { var c = game.children[i]; if (c && typeof c.update === "function" && c.vx !== undefined && c.vy !== undefined && c.life !== undefined) { c.update(); } } } // --- Only lose one life per frame, even if multiple enemies collide --- var lifeLostThisFrame = false; enemies.forEach(function (enemy) { // Randomly change direction if enabled, but only after 3 full orbits in one direction if (enemy.canChangeDirection) { if (enemy.directionChangeTick === undefined) enemy.directionChangeTick = 0; if (enemy.orbitDirectionStartAngle === undefined) enemy.orbitDirectionStartAngle = enemy.orbitAngle; if (enemy.orbitsInCurrentDirection === undefined) enemy.orbitsInCurrentDirection = 0; enemy.directionChangeTick++; // Calculate how many full orbits have been completed in the current direction var angleDiff = enemy.orbitAngle - enemy.orbitDirectionStartAngle; // Normalize to [0, 2PI) var fullOrbits = Math.abs(angleDiff) / (Math.PI * 2); // Only increment if we passed a full orbit since last check if (enemy.lastFullOrbits === undefined) enemy.lastFullOrbits = 0; if (Math.floor(fullOrbits) > enemy.lastFullOrbits) { enemy.orbitsInCurrentDirection += Math.floor(fullOrbits) - enemy.lastFullOrbits; enemy.lastFullOrbits = Math.floor(fullOrbits); } if (enemy.directionChangeTick >= enemy.directionChangeInterval && enemy.orbitsInCurrentDirection >= 3) { // Flip direction enemy.orbitSpeed *= -1; enemy.directionChangeTick = 0; // Reset orbit tracking for new direction enemy.orbitDirectionStartAngle = enemy.orbitAngle; enemy.orbitsInCurrentDirection = 0; enemy.lastFullOrbits = 0; // Optionally, randomize next interval enemy.directionChangeInterval = 60 + Math.floor(Math.random() * 120); } } enemy.orbitAngle += enemy.orbitSpeed; if (enemy.isElliptical) { // Elliptical orbit var a = enemy.ellipseA || enemy.orbitRadius; var b = enemy.ellipseB || enemy.orbitRadius - 60; enemy.x = centerX + a * Math.cos(enemy.orbitAngle); enemy.y = centerY + b * Math.sin(enemy.orbitAngle); } else { // Circular orbit enemy.x = centerX + enemy.orbitRadius * Math.cos(enemy.orbitAngle); enemy.y = centerY + enemy.orbitRadius * Math.sin(enemy.orbitAngle); } // --- Collision detection with player --- if (enemy.lastWasIntersecting === undefined) enemy.lastWasIntersecting = false; // Aumenta un poquitín el área de colisión para el enemy var enemyCollisionWidth = (enemy.width ? enemy.width : 150) * 0.8; var enemyCollisionHeight = (enemy.height ? enemy.height : 150) * 0.8; var enemyCollisionLeft = enemy.x - enemyCollisionWidth / 2; var enemyCollisionRight = enemy.x + enemyCollisionWidth / 2; var enemyCollisionTop = enemy.y - enemyCollisionHeight / 2; var enemyCollisionBottom = enemy.y + enemyCollisionHeight / 2; var isIntersecting = player.x > enemyCollisionLeft && player.x < enemyCollisionRight && player.y > enemyCollisionTop && player.y < enemyCollisionBottom; // Prevent player death/game over if splashOverlay is visible var splashActive = typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent; if (!splashActive) { if (!enemy.lastWasIntersecting && isIntersecting && !lifeLostThisFrame) { // Collision just started, lose a life lifeLostThisFrame = true; LK.effects.flashScreen(0xff0000, 1000); LK.getSound('Dead').play(); lives--; updateLivesText(); // Miniparticle explosion effect if (player && player.parent) { var miniparticleCount = 18; var miniparticleSpeed = 12; var miniparticleLifetime = 700; for (var mp = 0; mp < miniparticleCount; mp++) { var angle = Math.PI * 2 / miniparticleCount * mp + Math.random() * 0.2; var p = new Container(); var g = p.attachAsset('Ballplayer', { anchorX: 0.5, anchorY: 0.5 }); g.width = player.children[0].width * 0.22; g.height = player.children[0].height * 0.22; g.alpha = 0.85; p.x = player.x; p.y = player.y; p.vx = Math.cos(angle) * (miniparticleSpeed + Math.random() * 2); p.vy = Math.sin(angle) * (miniparticleSpeed + Math.random() * 2); p.life = miniparticleLifetime; p.update = function () { this.x += this.vx; this.y += this.vy; this.vx *= 0.96; this.vy *= 0.96; this.life -= 16; if (this.children[0]) this.children[0].alpha = Math.max(0, this.children[0].alpha - 0.045); if (this.life <= 0 && this.parent) this.parent.removeChild(this); }; game.addChild(p); } // Hide player immediately player.visible = false; // If no lives left, show game over after miniparticleLifetime if (lives <= 0) { LK.setTimeout(function () { if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); }, miniparticleLifetime); } else { // Respawn player after miniparticleLifetime LK.setTimeout(function () { player.x = 1024; player.y = 2632; player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); player.visible = true; }, miniparticleLifetime); } } else { if (lives <= 0) { if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } else { // Respawn player immediately if not using miniparticle effect player.x = 1024; player.y = 2632; player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); player.visible = true; } } } } enemy.lastWasIntersecting = isIntersecting; }); // --- enemy2 (closeEnemies and orbitingEnemy) kill the player on collision --- if (typeof closeEnemies !== "undefined" && closeEnemies.length) { var lifeLostThisFrameClose = false; for (var i = 0; i < closeEnemies.length; i++) { var cEnemy = closeEnemies[i]; if (cEnemy.lastWasIntersecting === undefined) cEnemy.lastWasIntersecting = false; // Aumenta un poquitín el área de colisión para closeEnemy var cEnemyCollisionWidth = (cEnemy.width ? cEnemy.width : 90) * 0.8; var cEnemyCollisionHeight = (cEnemy.height ? cEnemy.height : 90) * 0.8; var cEnemyCollisionLeft = cEnemy.x - cEnemyCollisionWidth / 2; var cEnemyCollisionRight = cEnemy.x + cEnemyCollisionWidth / 2; var cEnemyCollisionTop = cEnemy.y - cEnemyCollisionHeight / 2; var cEnemyCollisionBottom = cEnemy.y + cEnemyCollisionHeight / 2; var cEnemyIntersecting = player.x > cEnemyCollisionLeft && player.x < cEnemyCollisionRight && player.y > cEnemyCollisionTop && player.y < cEnemyCollisionBottom; // Prevent player death/game over if splashOverlay is visible var splashActive = typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent; if (!splashActive) { if (!cEnemy.lastWasIntersecting && cEnemyIntersecting && !lifeLostThisFrameClose) { // enemy2 kills the player: lose a life lifeLostThisFrameClose = true; LK.effects.flashScreen(0xff0000, 1000); LK.getSound('Dead').play(); lives--; updateLivesText(); if (lives <= 0) { if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } else { // Respawn player after short delay player.visible = false; LK.setTimeout(function () { player.x = 1024; player.y = 2632; player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); player.visible = true; }, 700); } } } cEnemy.lastWasIntersecting = cEnemyIntersecting; } } if (typeof orbitingEnemy !== "undefined" && orbitingEnemy) { if (orbitingEnemy.lastWasIntersecting === undefined) orbitingEnemy.lastWasIntersecting = false; // Aumenta un poquitín el área de colisión para orbitingEnemy var oEnemyCollisionWidth = (orbitingEnemy.width ? orbitingEnemy.width : 90) * 0.8; var oEnemyCollisionHeight = (orbitingEnemy.height ? orbitingEnemy.height : 90) * 0.8; var oEnemyCollisionLeft = orbitingEnemy.x - oEnemyCollisionWidth / 2; var oEnemyCollisionRight = orbitingEnemy.x + oEnemyCollisionWidth / 2; var oEnemyCollisionTop = orbitingEnemy.y - oEnemyCollisionHeight / 2; var oEnemyCollisionBottom = orbitingEnemy.y + oEnemyCollisionHeight / 2; var oEnemyIntersecting = player.x > oEnemyCollisionLeft && player.x < oEnemyCollisionRight && player.y > oEnemyCollisionTop && player.y < oEnemyCollisionBottom; // Prevent player death/game over if splashOverlay is visible var splashActive = typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent; if (!splashActive) { if (!orbitingEnemy.lastWasIntersecting && oEnemyIntersecting && !lifeLostThisFrameClose) { lifeLostThisFrameClose = true; LK.effects.flashScreen(0xff0000, 1000); LK.getSound('Dead').play(); lives--; updateLivesText(); if (lives <= 0) { if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } else { // Respawn player after short delay player.visible = false; LK.setTimeout(function () { player.x = 1024; player.y = 2632; player.radius = Math.sqrt((player.x - centerX) * (player.x - centerX) + (player.y - centerY) * (player.y - centerY)); player.angle = Math.atan2(player.y - centerY, player.x - centerX); player.visible = true; }, 700); } } } orbitingEnemy.lastWasIntersecting = oEnemyIntersecting; } // --- Stage object update (orbiting) --- if (typeof stage !== "undefined" && stage) { stage.update(); } // --- Bonus objects update and collision (three bonuses, one per orbit) --- if (bonuses && bonuses.length) { for (var i = 0; i < bonuses.length; i++) { var bonus = bonuses[i]; bonus.update(); if (bonus.lastWasIntersecting === undefined) bonus.lastWasIntersecting = false; // Aumenta un poquitín el área de colisión para bonus var bonusCollisionWidth = (bonus.width ? bonus.width : 25) * 0.7; var bonusCollisionHeight = (bonus.height ? bonus.height : 25) * 0.7; var bonusCollisionLeft = bonus.x - bonusCollisionWidth / 2; var bonusCollisionRight = bonus.x + bonusCollisionWidth / 2; var bonusCollisionTop = bonus.y - bonusCollisionHeight / 2; var bonusCollisionBottom = bonus.y + bonusCollisionHeight / 2; var bIntersecting = player.x > bonusCollisionLeft && player.x < bonusCollisionRight && player.y > bonusCollisionTop && player.y < bonusCollisionBottom; if (!bonus.lastWasIntersecting && bIntersecting) { // Mueve el bonus a una nueva posición aleatoria en su órbita bonus.orbitAngle = Math.random() * Math.PI * 2; bonus.orbitSpeed = 0.04 + Math.random() * 0.09; } // Track last player position for next frame player.lastX = player.x; player.lastY = player.y; bonus.lastWasIntersecting = bIntersecting; } } // --- Super Bonus update and collision (fastest orbiting object) --- if (typeof superBonus !== "undefined" && superBonus) { superBonus.update(); if (superBonus.lastWasIntersecting === undefined) superBonus.lastWasIntersecting = false; var superBonusCollisionWidth = (superBonus.width ? superBonus.width : 25) * 0.7; var superBonusCollisionHeight = (superBonus.height ? superBonus.height : 25) * 0.7; var superBonusCollisionLeft = superBonus.x - superBonusCollisionWidth / 2; var superBonusCollisionRight = superBonus.x + superBonusCollisionWidth / 2; var superBonusCollisionTop = superBonus.y - superBonusCollisionHeight / 2; var superBonusCollisionBottom = superBonus.y + superBonusCollisionHeight / 2; var sbIntersecting = player.x > superBonusCollisionLeft && player.x < superBonusCollisionRight && player.y > superBonusCollisionTop && player.y < superBonusCollisionBottom; if (!superBonus.lastWasIntersecting && sbIntersecting) { // Player just collected the super bonus! score += 200; if (typeof scoreText !== "undefined" && scoreText.setText) { scoreText.setText('' + score); } // Update record if needed if (score > record) { record = score; } if (typeof pointsText !== "undefined" && pointsText.setText) { pointsText.setText('Record: ' + record); } if (typeof recordTopText !== "undefined" && recordTopText.setText) { recordTopText.setText('' + record); } // --- Grant extra life every 1000 points --- while (score >= nextLifeScore) { if (lives < maxLives) { lives++; updateLivesText(); } nextLifeScore += 1000; } // Move superBonus to a new random angle and randomize its speed (always fast) superBonus.orbitAngle = Math.random() * Math.PI * 2; superBonus.orbitSpeed = 0.18 + Math.random() * 0.04; } superBonus.lastWasIntersecting = sbIntersecting; } };
===================================================================
--- original.js
+++ change.js
@@ -125,10 +125,10 @@
/****
* Game Code
****/
-// Add stage lines as a background image behind all gameplay elements
// --- Fullscreen flashing overlay (cuadrado, titilea a 3ms, color por nivel) ---
+// Add stage lines as a background image behind all gameplay elements
var stageLinesBg = LK.getAsset('lines', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
@@ -231,15 +231,18 @@
}
// --- Splash Screen Overlay ---
var splashOverlay = new Container();
splashOverlay.zIndex = 999999; // Ensure on top of everything, including overlays
-// Game Title: use Titulo-rectangulo image as splash title
-var splashTitle = LK.getAsset('Titulo-rectangulo', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 1024,
- y: 600
+// Game Title (replaces Titulo-rectangulo image with ORBIT text)
+var splashTitle = new Text2('ORBIT', {
+ size: 480,
+ fill: 0xFFFFFF,
+ font: "'Impact','Arial Black',Tahoma",
+ fontWeight: "bold"
});
+splashTitle.anchor.set(0.5, 0.5);
+splashTitle.x = 1024;
+splashTitle.y = 600;
splashOverlay.addChild(splashTitle);
// Subtitle
var splashSubtitle = new Text2('Un universo hostil donde el más grande se traga al más pequeño', {
size: 56,
@@ -953,32 +956,28 @@
var superBonusCollisionRight = superBonus.x + superBonusCollisionWidth / 2;
var superBonusCollisionTop = superBonus.y - superBonusCollisionHeight / 2;
var superBonusCollisionBottom = superBonus.y + superBonusCollisionHeight / 2;
var sbIntersecting = player.x > superBonusCollisionLeft && player.x < superBonusCollisionRight && player.y > superBonusCollisionTop && player.y < superBonusCollisionBottom;
- // Prevent points if splashOverlay is visible
- var splashActive = typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent;
- if (!splashActive) {
- if (!superBonus.lastWasIntersecting && sbIntersecting) {
- // Player just collected the super bonus!
- score += 200;
- if (typeof scoreText !== "undefined" && scoreText.setText) {
- scoreText.setText('' + score);
- }
- // Update record if needed
- if (score > record) {
- record = score;
- }
- if (typeof pointsText !== "undefined" && pointsText.setText) {
- pointsText.setText('Record: ' + record);
- }
- // Update recordTopText at the top center as well
- if (typeof recordTopText !== "undefined" && recordTopText.setText) {
- recordTopText.setText('' + record);
- }
- // Move superBonus to a new random angle and randomize its speed (always fast)
- superBonus.orbitAngle = Math.random() * Math.PI * 2;
- superBonus.orbitSpeed = 0.18 + Math.random() * 0.04;
+ if (!superBonus.lastWasIntersecting && sbIntersecting) {
+ // Player just collected the super bonus!
+ score += 200;
+ if (typeof scoreText !== "undefined" && scoreText.setText) {
+ scoreText.setText('' + score);
}
+ // Update record if needed
+ if (score > record) {
+ record = score;
+ }
+ if (typeof pointsText !== "undefined" && pointsText.setText) {
+ pointsText.setText('Record: ' + record);
+ }
+ // Update recordTopText at the top center as well
+ if (typeof recordTopText !== "undefined" && recordTopText.setText) {
+ recordTopText.setText('' + record);
+ }
+ // Move superBonus to a new random angle and randomize its speed (always fast)
+ superBonus.orbitAngle = Math.random() * Math.PI * 2;
+ superBonus.orbitSpeed = 0.18 + Math.random() * 0.04;
}
superBonus.lastWasIntersecting = sbIntersecting;
}
;
@@ -1632,11 +1631,9 @@
var bonusCollisionRight = bonus.x + bonusCollisionWidth / 2;
var bonusCollisionTop = bonus.y - bonusCollisionHeight / 2;
var bonusCollisionBottom = bonus.y + bonusCollisionHeight / 2;
var bIntersecting = player.x > bonusCollisionLeft && player.x < bonusCollisionRight && player.y > bonusCollisionTop && player.y < bonusCollisionBottom;
- // Prevent points if splashOverlay is visible
- var splashActive = typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent;
- if (!bonus.lastWasIntersecting && bIntersecting && !splashActive) {
+ if (!bonus.lastWasIntersecting && bIntersecting) {
// Mueve el bonus a una nueva posición aleatoria en su órbita
bonus.orbitAngle = Math.random() * Math.PI * 2;
bonus.orbitSpeed = 0.04 + Math.random() * 0.09;
}
@@ -1656,38 +1653,35 @@
var superBonusCollisionRight = superBonus.x + superBonusCollisionWidth / 2;
var superBonusCollisionTop = superBonus.y - superBonusCollisionHeight / 2;
var superBonusCollisionBottom = superBonus.y + superBonusCollisionHeight / 2;
var sbIntersecting = player.x > superBonusCollisionLeft && player.x < superBonusCollisionRight && player.y > superBonusCollisionTop && player.y < superBonusCollisionBottom;
- var splashActive = typeof splashOverlay !== "undefined" && splashOverlay && splashOverlay.parent;
- if (!splashActive) {
- if (!superBonus.lastWasIntersecting && sbIntersecting) {
- // Player just collected the super bonus!
- score += 200;
- if (typeof scoreText !== "undefined" && scoreText.setText) {
- scoreText.setText('' + score);
+ if (!superBonus.lastWasIntersecting && sbIntersecting) {
+ // Player just collected the super bonus!
+ score += 200;
+ if (typeof scoreText !== "undefined" && scoreText.setText) {
+ scoreText.setText('' + score);
+ }
+ // Update record if needed
+ if (score > record) {
+ record = score;
+ }
+ if (typeof pointsText !== "undefined" && pointsText.setText) {
+ pointsText.setText('Record: ' + record);
+ }
+ if (typeof recordTopText !== "undefined" && recordTopText.setText) {
+ recordTopText.setText('' + record);
+ }
+ // --- Grant extra life every 1000 points ---
+ while (score >= nextLifeScore) {
+ if (lives < maxLives) {
+ lives++;
+ updateLivesText();
}
- // Update record if needed
- if (score > record) {
- record = score;
- }
- if (typeof pointsText !== "undefined" && pointsText.setText) {
- pointsText.setText('Record: ' + record);
- }
- if (typeof recordTopText !== "undefined" && recordTopText.setText) {
- recordTopText.setText('' + record);
- }
- // --- Grant extra life every 1000 points ---
- while (score >= nextLifeScore) {
- if (lives < maxLives) {
- lives++;
- updateLivesText();
- }
- nextLifeScore += 1000;
- }
- // Move superBonus to a new random angle and randomize its speed (always fast)
- superBonus.orbitAngle = Math.random() * Math.PI * 2;
- superBonus.orbitSpeed = 0.18 + Math.random() * 0.04;
+ nextLifeScore += 1000;
}
+ // Move superBonus to a new random angle and randomize its speed (always fast)
+ superBonus.orbitAngle = Math.random() * Math.PI * 2;
+ superBonus.orbitSpeed = 0.18 + Math.random() * 0.04;
}
superBonus.lastWasIntersecting = sbIntersecting;
}
};
\ No newline at end of file
Dead
Sound effect
MusicaInicio
Music
musica4
Music
musica1
Music
musica7
Music
musica10
Music
musica13
Music
musica16
Music
musica19
Music
musica22
Music
musica25
Music
musica28
Music
musica2
Music
musica3
Music
musica5
Music
musica6
Music
musica8
Music
musica9
Music
musica11
Music
musica12
Music
musica14
Music
musica15
Music
musica17
Music
musica18
Music
musica20
Music
musica21
Music
musica23
Music
musica24
Music
musica26
Music
musica27
Music
musica29
Music
musica30
Music