User prompt
empieza el juego con tap o click en la pantalla
User prompt
has hover al boton
User prompt
pongamos el boton a funcionar
User prompt
bajalo un poco
User prompt
pasa el boton para adelante
User prompt
subelo mas
User prompt
mueve el boton abajo
User prompt
pon el boton por encima de todos los objetos
User prompt
ayudame con el boton, no funciona y es algo muy basico
User prompt
Pon JUGAR y ue funcione al darle click o tap que vaya al nivel1
User prompt
pon el iniciar o empezar juego en el texto
User prompt
revisalo
User prompt
al hacer click en jugar inicia nivel1
User prompt
habilita el boton jugar para iniciar el juego
User prompt
Replace rectangular JUGAR button with a circular purple button on splash
User prompt
el boton de JUGAR circular morado
User prompt
agrega un rectanulo para boton de JUGAR
User prompt
en el splah o pantalla de inicio habra una musica diferente a la del nivel1
User prompt
ahora seran 30 mundos o niveles ok
User prompt
coloca Titulo-rectangulo encima de todos los objetos y enemigos
User prompt
el titulo debe ir por encima de todo
User prompt
el jugador no se movera hasta no dar tap o click en la pantalla de inicio
User prompt
el splash y el juego se quedan en stanby hasta dar click en la pantalla para empezar
User prompt
splash screen no es jugable, aca no habra jugador, solo al iniciar aparece el nivel1
User prompt
Please fix the bug: 'player is null' in or related to this line: 'player.x = 1024; // Center horizontally' Line Number: 606
/**** * 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 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 () { // Prevent player movement until splash is dismissed if (typeof game !== "undefined" && (game._splashActive === true || typeof splashActive !== "undefined" && splashActive === true)) { return; } // 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: 0x000000 }); /**** * Game Code ****/ // While splashActive, do not allow any gameplay (player is hidden, no controls, no level running) // Block all gameplay and input except splash tap until splash is dismissed game._splashActive = true; var originalGameUpdate = game.update; game.update = function () { if (game._splashActive) return; if (typeof originalGameUpdate === "function") originalGameUpdate(); }; var originalGameUp = game.up; game.up = function (x, y, obj) { if (game._splashActive) return; if (typeof originalGameUp === "function") originalGameUp(x, y, obj); }; // Helper to generate a random pastel color function randomPastelColor() { var r = 180 + Math.floor(Math.random() * 75); var g = 180 + Math.floor(Math.random() * 75); var b = 180 + Math.floor(Math.random() * 75); return r << 16 | g << 8 | b; } // Store background asset and color for per-level colorization var bgLinesColor = randomPastelColor(); var bgLines = LK.getAsset('lines', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 2048 / 573.44, scaleY: 2732 / 1019.45 }); bgLines.alpha = 0.2; bgLines.color = bgLinesColor; if (typeof bgLines.tint !== "undefined") { bgLines.tint = bgLinesColor; } game.addChildAt(bgLines, 0); // Add as the very first child (background) // Import tween plugin for color cycling // Reduced collision function: returns true if a and b are within a reduced collision range (scale < 1 for smaller hitbox) function reducedCollision(a, b, scale) { if (!a || !b || !a.children || !b.children || !a.children[0] || !b.children[0]) return false; var aw = a.children[0].width * scale, ah = a.children[0].height * scale; var bw = b.children[0].width * scale, bh = b.children[0].height * scale; var dx = a.x - b.x, dy = a.y - b.y; var dist = Math.sqrt(dx * dx + dy * dy); var minDist = (Math.max(aw, ah) + Math.max(bw, bh)) * 0.5 * 0.5; return dist < minDist; } // Stages configuration object 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 = [0x7fff4f, // apple green 0xffa500, // orange 0xff5ef7, // pink 0xff3b3b, // red 0x00e0ff, // light blue 0x3b6cff, // blue 0xc54ce4, // purple 0xfff200 // yellow ]; 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); } // --- SPLASH SCREEN SETUP --- // Create splash container var splashContainer = new Container(); // Add Titulo-rectangulo asset centered var splashTitle = LK.getAsset('Titulo-rectangulo', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); splashContainer.addChild(splashTitle); // Add a rectangle as a JUGAR button below the title var jugarButtonY = 1366 + 420; // 420px below center (Titulo-rectangulo is 1062px tall, so this is ~half below) var jugarButton = LK.getAsset('bonus', { anchorX: 0.5, anchorY: 0.5, width: 500, height: 160, color: 0x00cfff, x: 1024, y: jugarButtonY }); jugarButton.alpha = 0.92; splashContainer.addChild(jugarButton); // Add "JUGAR" text on top of the button var jugarText = new Text2('JUGAR', { size: 110, fill: 0xFFFFFF, font: "'Impact','Arial Black',Tahoma" }); jugarText.anchor.set(0.5, 0.5); jugarText.x = 1024; jugarText.y = jugarButtonY; splashContainer.addChild(jugarText); game.addChild(splashContainer); // Always keep splashContainer (and its title) above all other children game.setChildIndex(splashContainer, game.children.length - 1); // Defensive: ensure splashContainer stays on top after any addChild/addChildAt var _originalAddChild = game.addChild; game.addChild = function (child) { var result = _originalAddChild.apply(this, arguments); if (splashContainer && splashContainer.parent === game) { game.setChildIndex(splashContainer, game.children.length - 1); } return result; }; var _originalAddChildAt = game.addChildAt; game.addChildAt = function (child, index) { var result = _originalAddChildAt.apply(this, arguments); if (splashContainer && splashContainer.parent === game) { game.setChildIndex(splashContainer, game.children.length - 1); } return result; }; // Add a player to the game var player = game.addChild(new Player()); // 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 = [0x7fff4f, // apple green 0xffa500, // orange 0xff5ef7, // pink 0xff3b3b, // red 0x00e0ff, // light blue 0x3b6cff, // blue 0xc54ce4, // purple 0xfff200 // yellow ]; 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]; // Increase bonus speed a little per level var bonusSpeedIncrease = typeof currentLevel !== "undefined" ? (currentLevel - 1) * 0.002 : 0; // 0.002 per level (was 0.004) // Make outer bonuses orbit more slowly, inner ones faster // The further from the center, the slower the orbit // Use a formula that decreases speed as orbitIndex increases // REDUCED SPEED: Lowered all bonus orbit speeds for a much slower effect // If the bonus is in the center (i==0), use baseSpeed. If it's in the extra inner line (i==1), make it slower than center but faster than the outermost. var baseSpeed = 0.025; // was 0.045, now even slower for innermost var minSpeed = 0.005; // was 0.01, now even slower for outermost // For 3 orbits: 0=center, 1=extra inner, 2=outermost // Center: fastest, extra inner: slower, outermost: slowest var t = i / 2; // 0 for center, 0.5 for extra inner, 1 for outermost var speed = baseSpeed * (1 - t) + minSpeed * t; // linear interpolation b.orbitSpeed = speed + Math.random() * 0.007 + bonusSpeedIncrease * (0.5 + 0.5 * (1 - t)); // random range halved // 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 // Increase superBonus speed a little per level var superBonusSpeedIncrease = typeof currentLevel !== "undefined" ? (currentLevel - 1) * 0.003 : 0; // 0.003 per level (was 0.006) superBonus.orbitSpeed = 0.18 + Math.random() * 0.04 + superBonusSpeedIncrease; // 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); // 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); // Hide record display by default (already set above), will show on game over // 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); // Record is persisted using storage plugin var record = 0; var storedRecord = storage.record; if (storedRecord !== null && storedRecord !== undefined) { storedRecord = parseInt(storedRecord); if (!isNaN(storedRecord)) record = storedRecord; } // --- LIVES SYSTEM --- // Number of lives (default 9) var lives = 9; var maxLives = 9; // Display lives (hearts) below the 'Nivel' text at the top center (GUI coordinates) var livesHearts = []; var heartSpacing = 70; // px between hearts var heartSize = 64; // asset size // Remove old livesText if present if (typeof livesText !== "undefined" && livesText && livesText.parent) { livesText.parent.removeChild(livesText); } var livesText = undefined; // Create a container for hearts and add to LK.gui.top var livesContainer = new Container(); LK.gui.top.addChild(livesContainer); // Position livesContainer below the levelText // levelText is anchored at (0.5, 0), so its y is 0 livesContainer.x = 0; // Will be centered by anchor livesContainer.y = levelText.height + 90; // Much further below 'Nivel' (was 10) // Center the container horizontally at the top center livesContainer.anchorX = 0.5; livesContainer.anchorY = 0; // Create and add heart assets for each life, positioned in the container for (var i = 0; i < maxLives; i++) { var heart = LK.getAsset('heart8bit', { anchorX: 0.5, anchorY: 0.5, x: (i - (maxLives - 1) / 2) * heartSpacing, y: 0, width: heartSize, height: heartSize }); livesContainer.addChild(heart); livesHearts.push(heart); } // Helper to update lives display (show/hide hearts) function updateLivesText() { for (var i = 0; i < maxLives; i++) { if (livesHearts[i]) { livesHearts[i].visible = i < lives; // Optionally, fade out lost hearts livesHearts[i].alpha = i < lives ? 1 : 0.25; } } } updateLivesText(); // Hide record display at the start of the game if (typeof recordTopText !== "undefined") recordTopText.visible = false; if (typeof recordLabelText !== "undefined") recordLabelText.visible = false; // Set initial position of the player player.x = 1024; // Center horizontally player.y = 2632; // Always at the bottom (100px from bottom edge) // Hide player at start player.visible = false; // Show splash at start, hide on first tap and show player var splashActive = true; // Play splash music (ensure it loops) LK.playMusic('splashmusic', { loop: true }); game.down = function (x, y, obj) { if (splashActive) { splashActive = false; game._splashActive = false; if (splashContainer && splashContainer.parent) splashContainer.parent.removeChild(splashContainer); player.visible = true; // Stop splash music and start level 1 music LK.stopMusic(); LK.playMusic('Vertigo', { loop: true }); // Start level 1 (reset all gameplay state if needed) // Restore original game.down for controls 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; } }; } }; // While splashActive, do not allow any gameplay (player is hidden, no controls, no level running) // 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; var sbIntersecting = reducedCollision(superBonus, player, 0.7); 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; storage.record = record; } 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; var superBonusSpeedIncrease = typeof currentLevel !== "undefined" ? (currentLevel - 1) * 0.003 : 0; // 0.003 per level (was 0.006) superBonus.orbitSpeed = 0.18 + Math.random() * 0.04 + superBonusSpeedIncrease; } 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 --- if (player.lastWasIntersectingDeco === undefined) player.lastWasIntersectingDeco = []; if (player.lastWasIntersectingDeco[i] === undefined) player.lastWasIntersectingDeco[i] = false; var playerHitsDeco = reducedCollision(player, deco, 0.7); if (!player.lastWasIntersectingDeco[i] && playerHitsDeco) { // Player collides with deco: flash blue and handle lives/game over LK.effects.flashScreen(0x00e0ff, 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 at start position, restore visibility, reset radius/angle 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; } } player.lastWasIntersectingDeco[i] = playerHitsDeco; // --- Deco's own collision detection for legacy/compatibility --- if (deco.lastWasIntersecting === undefined) deco.lastWasIntersecting = false; var decoIntersecting = reducedCollision(deco, player, 0.7); if (!deco.lastWasIntersecting && decoIntersecting) { // Deco kills the player: flash blue and trigger game over LK.effects.flashScreen(0x00e0ff, 1000); // Play dead sound LK.getSound('Dead').play(); if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } 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; var decoHitsPlayerball = reducedCollision(deco, playerball, 0.7); if (!deco.lastWasIntersectingPlayerball && decoHitsPlayerball) { LK.effects.flashScreen(0x00e0ff, 1000); // Play dead sound LK.getSound('Dead').play(); if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } deco.lastWasIntersectingPlayerball = decoHitsPlayerball; } // --- Deco collides with playerball or player (combined logic) --- if (typeof playerball !== "undefined" && playerball) { if (deco.lastWasIntersectingPlayerOrBall === undefined) deco.lastWasIntersectingPlayerOrBall = false; var decoHitsPlayerOrBall = reducedCollision(deco, player, 0.7) || reducedCollision(deco, playerball, 0.7); if (!deco.lastWasIntersectingPlayerOrBall && decoHitsPlayerOrBall) { LK.effects.flashScreen(0x00e0ff, 1000); // Play dead sound LK.getSound('Dead').play(); if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } deco.lastWasIntersectingPlayerOrBall = decoHitsPlayerOrBall; } else { // Only player exists if (deco.lastWasIntersectingPlayerOrBall === undefined) deco.lastWasIntersectingPlayerOrBall = false; var decoHitsPlayer = reducedCollision(deco, player, 0.7); if (!deco.lastWasIntersectingPlayerOrBall && decoHitsPlayer) { LK.effects.flashScreen(0x00e0ff, 1000); // Play dead sound LK.getSound('Dead').play(); if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } 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 if (typeof currentLevel === "undefined" || currentLevel === null) { var currentLevel = 1; } var maxLevels = 30; 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 // Limit max enemy orbit to the outermost deco orbit var maxEnemyOrbitRadius = sharedDecoOuter3OrbitRadius; 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 = [0x7fff4f, // apple green 0xffa500, // orange 0xff5ef7, // pink 0xff3b3b, // red 0x00e0ff, // light blue 0x3b6cff, // blue 0xc54ce4, // purple 0xfff200 // yellow ]; 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); // Clamp to max deco orbit radius if (enemy.orbitRadius > maxEnemyOrbitRadius) enemy.orbitRadius = maxEnemyOrbitRadius; enemy.orbitAngle = Math.random() * Math.PI * 2; // Increase base orbit speed a little per level, but with diminishing increment as level increases var baseSpeed = 0.004 + Math.random() * 0.003; // Diminishing increment: increment = 0.001 * (1 / (1 + 0.18 * (level-1))) var diminishingFactor = 1 / (1 + 0.18 * Math.max(0, level - 1)); var speedIncrease = typeof level !== "undefined" ? (level - 1) * 0.001 * diminishingFactor : 0; enemy.orbitSpeed = baseSpeed + speedIncrease; // 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); // Vertigo music will be started after splash is dismissed // Update method for orbiting game.update = function () { // Prevent player movement until splash is dismissed if (typeof game !== "undefined" && (game._splashActive === true || typeof splashActive !== "undefined" && splashActive === true)) { playerMoveDirection = 0; return; } // Gravity: each frame, pull the player a bit toward the center if (typeof currentLevel === "undefined") { var gravityStrength = 2.2; } else { // Increase gravityStrength by 0.003 per level (much faster acceleration) var gravityStrength = 2.2 + (currentLevel - 1) * 0.003; } // Calculate vector from player to center var dx = centerX - player.x; var dy = centerY - player.y; var dist = Math.sqrt(dx * dx + dy * dy); // Only apply gravity if not already at center if (dist > 0.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 consistency with 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)); } else { // Snap to center if extremely close player.x = centerX; player.y = centerY; player.angle = 0; player.radius = 0; } // Smooth and continuous player movement (rotation/orbit) if (typeof playerMoveDirection !== "undefined" && playerMoveDirection !== 0) { // Player rotation speed increases with level, similar to enemy speed scaling // Base moveSpeed is 0.012, increase by 0.0007 per level (same as enemy speedIncrease) var moveSpeed = 0.012 + (typeof currentLevel !== "undefined" ? currentLevel - 1 : 0) * 0.0007; 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); } // --- LEVEL SYSTEM: Track and progress levels up to 20 --- if (typeof currentLevel === "undefined" || currentLevel === null) { currentLevel = 1; var maxLevels = 20; } if (typeof levelText !== "undefined" && levelText.setText) { levelText.setText('Nivel ' + currentLevel); } if (player.lastRadius === undefined) player.lastRadius = player.radius; // Check if player is within the center range (radius <= 30) and only advance when crossing into the center (from outside to inside) if (player.lastRadius === undefined) player.lastRadius = player.radius; if (!game._alreadyAdvancedLevel && player.lastRadius > 30 && player.radius <= 30) { // Player just reached the center, advance level game._alreadyAdvancedLevel = true; if (currentLevel < 30) { currentLevel++; // Colorize background with a random rainbow palette color for each level with smooth transition var rainbowPalette = [0x7fff4f, // apple green 0xffa500, // orange 0xff5ef7, // pink 0xff3b3b, // red 0x00e0ff, // light blue 0x3b6cff, // blue 0xc54ce4, // purple 0xfff200 // yellow ]; var prevBgLinesColor = bgLinesColor; bgLinesColor = rainbowPalette[Math.floor(Math.random() * rainbowPalette.length)]; if (typeof bgLines.tint !== "undefined") { // Animate color transition using tween plugin // Stronger effect: fade out, swap color, then fade in tween(bgLines, { alpha: 0.05 }, { duration: 250, easing: tween.cubicIn, onFinish: function onFinish() { // Instantly set new color at lowest alpha bgLines.color = bgLinesColor; bgLines.tint = bgLinesColor; // Fade in strongly tween(bgLines, { alpha: 0.32 }, { duration: 650, easing: tween.cubicOut }); } }); } else { bgLines.color = bgLinesColor; } // Do NOT reset lives on new level updateLivesText(); // Hide record display at the start of a new level if (typeof recordTopText !== "undefined") recordTopText.visible = false; if (typeof recordLabelText !== "undefined") recordLabelText.visible = false; // Update level number display if (typeof levelText !== "undefined" && levelText.setText) { levelText.setText('Nivel ' + currentLevel); } // Always set number of enemies to 3 + (currentLevel - 1), up to 22 at level 30 spawnEnemiesForLevel(currentLevel); // Add rotation/orbit variants: some reverse, some elliptical for (var k = 0; k < enemies.length; k++) { // Every 3rd enemy or at higher levels, make elliptical orbits 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; } // Alternate direction for more chaos if (currentLevel > 6 && k % 2 === 0) { enemies[k].orbitSpeed = -Math.abs(enemies[k].orbitSpeed); } else { enemies[k].orbitSpeed = Math.abs(enemies[k].orbitSpeed); } // Apply diminishing increment to enemy speed on level up as well var baseSpeed = Math.abs(enemies[k].orbitSpeed); var diminishingFactor = 1 / (1 + 0.18 * Math.max(0, currentLevel - 1)); var speedIncrease = (currentLevel - 1) * 0.001 * diminishingFactor; enemies[k].orbitSpeed = (enemies[k].orbitSpeed < 0 ? -1 : 1) * (baseSpeed + speedIncrease); } // Reset player to starting position for next level (center bottom of the screen) player.x = 1024; // Center horizontally player.y = 2632; // 100px from bottom edge 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); // Optionally, randomize enemy orbits a bit for variety for (var j = 0; j < enemies.length; j++) { enemies[j].orbitAngle = Math.random() * Math.PI * 2; } // --- Update bonuses and superBonus speed for new level --- for (var i = 0; i < bonuses.length; i++) { var bonusSpeedIncrease = (currentLevel - 1) * 0.002; // Make outer bonuses orbit more slowly, inner ones faster // REDUCED SPEED: Lowered all bonus orbit speeds for a much slower effect // For 3 orbits: 0=center, 1=extra inner, 2=outermost var baseSpeed = 0.025; // was 0.045, now even slower for innermost var minSpeed = 0.005; // was 0.01, now even slower for outermost var t = i / (bonuses.length - 1); // 0 for center, 0.5 for extra inner, 1 for outermost var speed = baseSpeed * (1 - t) + minSpeed * t; bonuses[i].orbitSpeed = speed + Math.random() * 0.007 + bonusSpeedIncrease * (0.5 + 0.5 * (1 - t)); // random range halved } var superBonusSpeedIncrease = (currentLevel - 1) * 0.003; // was 0.006 superBonus.orbitSpeed = 0.18 + Math.random() * 0.04 + superBonusSpeedIncrease; // --- End update bonuses and superBonus speed --- if (currentLevel === 30) { LK.showYouWin(); } } } // Allow level advance again only after player leaves the center if (player.radius > 30) { game._alreadyAdvancedLevel = false; } 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(); } } } 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; // Custom collision: reduce hitbox to 70% of asset size // Defined globally so it is available everywhere // This function is now defined globally at the top of Game Code for universal access function reducedCollision(a, b, scale) { if (!a || !b || !a.children || !b.children || !a.children[0] || !b.children[0]) return false; var aw = a.children[0].width * scale, ah = a.children[0].height * scale; var bw = b.children[0].width * scale, bh = b.children[0].height * scale; var dx = a.x - b.x, dy = a.y - b.y; var dist = Math.sqrt(dx * dx + dy * dy); var minDist = (Math.max(aw, ah) + Math.max(bw, bh)) * 0.5 * 0.5; return dist < minDist; } var isIntersecting = reducedCollision(enemy, player, 0.7); if (!enemy.lastWasIntersecting && isIntersecting) { // Collision just started, trigger miniparticle explosion and then handle lives/game over LK.effects.flashScreen(0xff0000, 1000); LK.getSound('Dead').play(); // 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; // After miniparticleLifetime, handle lives/game over LK.setTimeout(function () { lives--; updateLivesText(); if (lives <= 0) { if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } else { // Respawn player at start position, restore visibility, reset radius/angle 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 { lives--; updateLivesText(); if (lives <= 0) { if (typeof recordTopText !== "undefined") recordTopText.visible = true; if (typeof recordLabelText !== "undefined") recordLabelText.visible = true; LK.showGameOver(); } else { // Respawn player at start position, restore visibility, reset radius/angle 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) { for (var i = 0; i < closeEnemies.length; i++) { var cEnemy = closeEnemies[i]; if (cEnemy.lastWasIntersecting === undefined) cEnemy.lastWasIntersecting = false; var cEnemyIntersecting = reducedCollision(cEnemy, player, 0.7); if (!cEnemy.lastWasIntersecting && cEnemyIntersecting) { // enemy2 kills the player: flash red and handle lives/game over 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 at start position, restore visibility, reset radius/angle 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; } } cEnemy.lastWasIntersecting = cEnemyIntersecting; } } if (typeof orbitingEnemy !== "undefined" && orbitingEnemy) { if (orbitingEnemy.lastWasIntersecting === undefined) orbitingEnemy.lastWasIntersecting = false; var oEnemyIntersecting = reducedCollision(orbitingEnemy, player, 0.7); if (!orbitingEnemy.lastWasIntersecting && oEnemyIntersecting) { 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 at start position, restore visibility, reset radius/angle 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; } } orbitingEnemy.lastWasIntersecting = oEnemyIntersecting; } // --- Stage object update (orbiting) --- if (typeof stage !== "undefined" && stage) { stage.update(); } // --- Bonus objects update and collision (four bonuses, including superBonus) --- 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; var bIntersecting = reducedCollision(bonus, player, 0.7); if (bIntersecting) { // Player collects the bonus (always gives points, even if already collected recently) score += 150; if (typeof scoreText !== "undefined" && scoreText.setText) { scoreText.setText('' + score); } // Update record if needed if (score > record) { record = score; storage.record = record; } 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 this bonus to a new random angle on its own orbit (keep orbitIndex fixed) bonus.orbitAngle = Math.random() * Math.PI * 2; var bonusSpeedIncrease = typeof currentLevel !== "undefined" ? (currentLevel - 1) * 0.002 : 0; // 0.002 per level (was 0.004) // Make outer bonuses orbit more slowly, inner ones faster // REDUCED SPEED: Lowered all bonus orbit speeds for a much slower effect // For 3 orbits: 0=center, 1=extra inner, 2=outermost var baseSpeed = 0.025; // was 0.045, now even slower for innermost var minSpeed = 0.005; // was 0.01, now even slower for outermost var t = bonus.orbitIndex / 2; // 0 for center, 0.5 for extra inner, 1 for outermost var speed = baseSpeed * (1 - t) + minSpeed * t; bonus.orbitSpeed = speed + Math.random() * 0.007 + bonusSpeedIncrease * (0.5 + 0.5 * (1 - t)); // random range halved } bonus.lastWasIntersecting = bIntersecting; } } // --- Super Bonus (4th orbit) update and collision --- if (typeof superBonus !== "undefined" && superBonus) { superBonus.update(); if (superBonus.lastWasIntersecting === undefined) superBonus.lastWasIntersecting = false; var sbIntersecting = reducedCollision(superBonus, player, 0.7); if (!superBonus.lastWasIntersecting && sbIntersecting) { var _superBonusChainTick = function superBonusChainTick() { score += superBonusChainPoints; if (typeof scoreText !== "undefined" && scoreText.setText) { scoreText.setText('' + score); } // Update record if needed if (score > record) { record = score; storage.record = record; } 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); } superBonusChainIndex++; if (superBonusChainIndex < superBonusChainCount) { LK.setTimeout(_superBonusChainTick, 60); } }; // Player just collected the super bonus! // Superbonus: give a chain of points (e.g. 10 increments of 30 points, 1 every 60ms) var superBonusChainCount = 10; var superBonusChainPoints = 30; var superBonusChainIndex = 0; _superBonusChainTick(); // Move superBonus to a new random angle and randomize its speed (always fast) superBonus.orbitAngle = Math.random() * Math.PI * 2; var superBonusSpeedIncrease = typeof currentLevel !== "undefined" ? (currentLevel - 1) * 0.003 : 0; // 0.003 per level (was 0.006) superBonus.orbitSpeed = 0.18 + Math.random() * 0.04 + superBonusSpeedIncrease; } superBonus.lastWasIntersecting = sbIntersecting; } // --- Heart-in-orbit for extra life every 500 points --- if (typeof heartOrbits === "undefined") heartOrbits = []; if (typeof lastHeartScore === "undefined") lastHeartScore = 0; if (typeof heartInOrbitActive === "undefined") heartInOrbitActive = false; if (typeof heartInOrbitObj === "undefined") heartInOrbitObj = null; if (typeof heartInOrbitTimeout === "undefined") heartInOrbitTimeout = null; // Check if we crossed a new 500-point threshold and no heart is active if (!heartInOrbitActive && Math.floor(score / 500) > Math.floor(lastHeartScore / 500) && score >= 500) { // Spawn a heart in orbit // Make the heart appear in the inner orbits, away from the center, like the third deco // Use the third deco orbit as the base, plus a small random offset for variety var innerHeartOrbits = [sharedDecoInnerOrbitRadius, // inner deco orbit sharedDecoInnerOrbitRadius + 60, // slightly further out sharedDecoInnerOrbitRadius - 30 // slightly closer in, but not at center ]; var heartOrbitRadius = innerHeartOrbits[Math.floor(Math.random() * innerHeartOrbits.length)]; var heartOrbitSpeed = 0.025 + Math.random() * 0.025; var heartOrbitAngle = Math.random() * Math.PI * 2; heartInOrbitObj = new Container(); var heartAsset = heartInOrbitObj.attachAsset('heart8bit', { anchorX: 0.5, anchorY: 0.5, width: 64, height: 64 }); heartInOrbitObj.orbitRadius = heartOrbitRadius; heartInOrbitObj.orbitSpeed = heartOrbitSpeed; heartInOrbitObj.orbitAngle = heartOrbitAngle; heartInOrbitObj.update = function () { this.orbitAngle += this.orbitSpeed; this.x = centerX + this.orbitRadius * Math.cos(this.orbitAngle); this.y = centerY + this.orbitRadius * Math.sin(this.orbitAngle); }; game.addChild(heartInOrbitObj); heartInOrbitActive = true; lastHeartScore = score; // Set a timeout to remove the heart after 5 seconds if not collected if (heartInOrbitTimeout) { LK.clearTimeout(heartInOrbitTimeout); heartInOrbitTimeout = null; } heartInOrbitTimeout = LK.setTimeout(function () { if (heartInOrbitActive && heartInOrbitObj) { if (heartInOrbitObj.parent) heartInOrbitObj.parent.removeChild(heartInOrbitObj); heartInOrbitActive = false; heartInOrbitObj = null; } heartInOrbitTimeout = null; }, 20000); } // If heart is active, update and check collision if (heartInOrbitActive && heartInOrbitObj) { heartInOrbitObj.update(); if (heartInOrbitObj.lastWasIntersecting === undefined) heartInOrbitObj.lastWasIntersecting = false; var heartIntersecting = reducedCollision(heartInOrbitObj, player, 0.7); if (!heartInOrbitObj.lastWasIntersecting && heartIntersecting) { // Player collects the heart: gain a life (up to max) if (lives < maxLives) { lives++; updateLivesText(); } // Remove heart from game if (heartInOrbitObj.parent) heartInOrbitObj.parent.removeChild(heartInOrbitObj); heartInOrbitActive = false; heartInOrbitObj = null; // Cancel the timeout if still pending if (heartInOrbitTimeout) { LK.clearTimeout(heartInOrbitTimeout); heartInOrbitTimeout = null; } } if (heartInOrbitObj) { heartInOrbitObj.lastWasIntersecting = heartIntersecting; } } // Remove heart if player dies (game over handled elsewhere) if (heartInOrbitActive && lives <= 0 && heartInOrbitObj) { if (heartInOrbitObj.parent) heartInOrbitObj.parent.removeChild(heartInOrbitObj); heartInOrbitActive = false; heartInOrbitObj = null; // Cancel the timeout if still pending if (heartInOrbitTimeout) { LK.clearTimeout(heartInOrbitTimeout); heartInOrbitTimeout = null; } } };
===================================================================
--- original.js
+++ change.js
@@ -259,8 +259,31 @@
x: 1024,
y: 1366
});
splashContainer.addChild(splashTitle);
+// Add a rectangle as a JUGAR button below the title
+var jugarButtonY = 1366 + 420; // 420px below center (Titulo-rectangulo is 1062px tall, so this is ~half below)
+var jugarButton = LK.getAsset('bonus', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 500,
+ height: 160,
+ color: 0x00cfff,
+ x: 1024,
+ y: jugarButtonY
+});
+jugarButton.alpha = 0.92;
+splashContainer.addChild(jugarButton);
+// Add "JUGAR" text on top of the button
+var jugarText = new Text2('JUGAR', {
+ size: 110,
+ fill: 0xFFFFFF,
+ font: "'Impact','Arial Black',Tahoma"
+});
+jugarText.anchor.set(0.5, 0.5);
+jugarText.x = 1024;
+jugarText.y = jugarButtonY;
+splashContainer.addChild(jugarText);
game.addChild(splashContainer);
// Always keep splashContainer (and its title) above all other children
game.setChildIndex(splashContainer, game.children.length - 1);
// Defensive: ensure splashContainer stays on top after any addChild/addChildAt
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