User prompt
colores vivos y brillantes variados
User prompt
efecto multicolor a enemy
User prompt
varios colores a los enemigos
User prompt
solo colores brillantes en los enemigos, multicolores
User prompt
no deben haber colores oscuros en los enemigos
User prompt
colores mas brillantes a los enemigos
User prompt
la musica se para y da play de nievo siempre que inicie el primer nivel
User prompt
la musica solo se reinicia desde el inicio mientras este en el nivel1
User prompt
la musica vuelve a empezar si vuelve al nivel1
User prompt
add dead sound cuando jugador muere
User prompt
destruir al jugador en miniparticulas
User prompt
loop music
User prompt
play musica de los primeros 5 niveles
User prompt
ad vertigo music desde el nivel1 hasta el 5
User prompt
20 niveles, aumentan enemigos con cada nuevo level
User prompt
agranda un poco radio orbita mayor deco
User prompt
achica tamaño objeto deco orbita menor
User prompt
duplica orbita mayor deco
User prompt
crea una tercera orbita deco un poco mas grande
User prompt
reduce un poco velocidad deco
User prompt
duplica orbita deco
User prompt
aumenta velocidad deco
User prompt
crea una orbita deco de un radio la mitad menor
User prompt
duplica orbitas deco
User prompt
velocidad enemigo2 mas lenta
/**** * Plugins ****/ var tween = LK.import("@upit/tween.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 enemy2 asset var enemyGraphics = self.attachAsset('enemy2', { 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 () { // 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 ****/ // 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 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()); 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()); 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()); 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()); 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()); decoInner.orbitRadius = sharedDecoInnerOrbitRadius; decoInner.orbitAngle = Math.PI * 2 / decoCount * i + Math.PI / decoCount; // offset for visual separation decoInner.orbitSpeed = sharedDecoOrbitSpeed; // Reduce the size of the deco object for the inner orbit if (decoInner.children && decoInner.children.length > 0 && decoInner.children[0]) { decoInner.children[0].scaleX = 0.7; decoInner.children[0].scaleY = 0.7; } 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 = []; for (var i = 0; i < closeEnemyCount; i++) { var closeEnemy = game.addChild(new Enemy()); closeEnemy.orbitRadius = closeEnemyOrbitRadius; closeEnemy.orbitAngle = Math.PI * 2 / closeEnemyCount * i; closeEnemy.orbitSpeed = closeEnemyOrbitSpeed; closeEnemies.push(closeEnemy); } // 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 }); levelText.anchor.set(0.5, 0); // Center horizontally, top edge LK.gui.top.addChild(levelText); // Add score display at the top right var score = 0; var scoreText = new Text2('Puntos: 0', { size: 100, fill: 0xFFFF00 }); scoreText.anchor.set(1, 0); // Right aligned, top edge LK.gui.topRight.addChild(scoreText); // Set initial position of the player 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; var sbIntersecting = superBonus.intersects(player); if (!superBonus.lastWasIntersecting && sbIntersecting) { // Player just collected the super bonus! score += 200; if (typeof scoreText !== "undefined" && scoreText.setText) { scoreText.setText('Puntos: ' + score); } // 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 --- if (player.lastWasIntersectingDeco === undefined) player.lastWasIntersectingDeco = []; if (player.lastWasIntersectingDeco[i] === undefined) player.lastWasIntersectingDeco[i] = false; var playerHitsDeco = player.intersects(deco); if (!player.lastWasIntersectingDeco[i] && playerHitsDeco) { // Player collides with deco: flash blue and trigger game over LK.effects.flashScreen(0x00e0ff, 1000); // Play dead sound LK.getSound('Dead').play(); LK.showGameOver(); } player.lastWasIntersectingDeco[i] = playerHitsDeco; // --- Deco's own collision detection for legacy/compatibility --- if (deco.lastWasIntersecting === undefined) deco.lastWasIntersecting = false; var decoIntersecting = deco.intersects(player); 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(); 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 = deco.intersects(playerball); if (!deco.lastWasIntersectingPlayerball && decoHitsPlayerball) { LK.effects.flashScreen(0x00e0ff, 1000); // Play dead sound LK.getSound('Dead').play(); 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 = deco.intersects(player) || deco.intersects(playerball); if (!deco.lastWasIntersectingPlayerOrBall && decoHitsPlayerOrBall) { LK.effects.flashScreen(0x00e0ff, 1000); // Play dead sound LK.getSound('Dead').play(); LK.showGameOver(); } deco.lastWasIntersectingPlayerOrBall = decoHitsPlayerOrBall; } else { // Only player exists if (deco.lastWasIntersectingPlayerOrBall === undefined) deco.lastWasIntersectingPlayerOrBall = false; var decoHitsPlayer = deco.intersects(player); if (!deco.lastWasIntersectingPlayerOrBall && decoHitsPlayer) { LK.effects.flashScreen(0x00e0ff, 1000); // Play dead sound LK.getSound('Dead').play(); 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; // Add event listener for mouse click game.down = function (x, y, obj) { // Detect left or right click var isRightClick = false; if (obj && obj.event && obj.event.button !== undefined) { isRightClick = obj.event.button === 2; } if (isRightClick) { rightMouseDown = true; } else { leftMouseDown = true; } // Update player position based on new angle and current radius player.x = centerX + player.radius * Math.cos(player.angle); player.y = centerY + player.radius * Math.sin(player.angle); }; // Add event listener for mouse up to stop moving towards center game.up = function (x, y, obj) { var isRightClick = false; if (obj && obj.event && obj.event.button !== undefined) { isRightClick = obj.event.button === 2; } if (isRightClick) { rightMouseDown = false; } else { leftMouseDown = false; } }; // 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]; for (var i = 0; i < numEnemies; i++) { var enemy = game.addChild(new Enemy()); // Assign a much brighter, more vivid color to the enemy's graphics if (enemy.children && enemy.children.length > 0 && enemy.children[0]) { // Generate a bright color by maximizing at least two RGB channels var brightColors = [0xFF3B3B, // vivid red 0xFFF200, // yellow 0x00FF90, // bright green 0x00E0FF, // cyan 0x3B6CFF, // blue 0xC54CE4, // purple 0xFF5EF7, // pink 0xFFA500 // orange ]; var colorIdx = Math.floor(Math.random() * brightColors.length); var brightColor = brightColors[colorIdx]; enemy.children[0].color = brightColor; // If the asset supports .tint, set it as well for visual effect if (typeof enemy.children[0].tint !== "undefined") { enemy.children[0].tint = brightColor; } } enemy.x = 1024; enemy.y = 1366; // Distribute orbits and angles for variety var 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); } } // 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 = 1.1; } else { // Increase gravityStrength by 0.001 per level (in thousandths) var gravityStrength = 1.1 + (currentLevel - 1) * 0.001; } player.radius = Math.max(80, player.radius - gravityStrength); 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") { var currentLevel = 1; var maxLevels = 20; } if (player.lastRadius === undefined) player.lastRadius = player.radius; if (player.lastRadius > 80 && player.radius <= 80) { // Player just reached the center! // Give 100 points for reaching the center if (typeof score !== "undefined") { score += 100; if (typeof scoreText !== "undefined" && scoreText.setText) { scoreText.setText('Puntos: ' + score); } } if (currentLevel < maxLevels) { currentLevel++; // --- Vertigo music control: play from level 1 to 5, stop after level 5 --- // Always stop and play Vertigo music from the beginning if we are currently in level 1 if (currentLevel === 1) { LK.stopMusic(); LK.playMusic('Vertigo', { loop: true }); } if (currentLevel === 6) { LK.stopMusic(); } // Update level number display if (typeof levelText !== "undefined" && levelText.setText) { levelText.setText('Nivel ' + currentLevel); } // Intensify enemy orbits and speed for new level, but clamp to max for perception for (var i = 0; i < enemies.length; i++) { enemies[i].orbitSpeed = Math.min(enemies[i].orbitSpeed * 1.5, 0.045); // Clamp to max enemies[i].speed = Math.min(enemies[i].speed * 1.25, 7); // Clamp to max } // Always set number of enemies to 3 + (currentLevel - 1) 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); } } // 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; } } else { // Completed all levels, show win LK.showYouWin(); } } 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; var isIntersecting = enemy.intersects(player); if (!enemy.lastWasIntersecting && isIntersecting) { // Collision just started, trigger miniparticle explosion and then game over LK.effects.flashScreen(0xff0000, 1000); // Play dead sound 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, show game over LK.setTimeout(function () { LK.showGameOver(); }, miniparticleLifetime); } else { LK.showGameOver(); } } 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 = cEnemy.intersects(player); if (!cEnemy.lastWasIntersecting && cEnemyIntersecting) { // enemy2 kills the player: flash red and trigger game over LK.effects.flashScreen(0xff0000, 1000); // Play dead sound LK.getSound('Dead').play(); LK.showGameOver(); } cEnemy.lastWasIntersecting = cEnemyIntersecting; } } if (typeof orbitingEnemy !== "undefined" && orbitingEnemy) { if (orbitingEnemy.lastWasIntersecting === undefined) orbitingEnemy.lastWasIntersecting = false; var oEnemyIntersecting = orbitingEnemy.intersects(player); if (!orbitingEnemy.lastWasIntersecting && oEnemyIntersecting) { LK.effects.flashScreen(0xff0000, 1000); // Play dead sound LK.getSound('Dead').play(); LK.showGameOver(); } 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; var bIntersecting = bonus.intersects(player); if (!bonus.lastWasIntersecting && bIntersecting) { // Player just collected the bonus! score += 50; if (typeof scoreText !== "undefined" && scoreText.setText) { scoreText.setText('Puntos: ' + score); } // Move this bonus to a new random angle on its own orbit (keep orbitIndex fixed) bonus.orbitAngle = Math.random() * Math.PI * 2; bonus.orbitSpeed = 0.04 + Math.random() * 0.09; } bonus.lastWasIntersecting = bIntersecting; } } };
===================================================================
--- original.js
+++ change.js
@@ -463,16 +463,33 @@
// Amplified enemy orbits: increase all base radii for even wider orbits
var baseRadii = [370, 540, 710, 880, 1050, 1220, 1390, 1560];
for (var i = 0; i < numEnemies; i++) {
var enemy = game.addChild(new Enemy());
- // Assign a random color to the enemy's graphics
+ // Assign a much brighter, more vivid color to the enemy's graphics
if (enemy.children && enemy.children.length > 0 && enemy.children[0]) {
- // Generate a random color in 0xRRGGBB format
- var randomColor = Math.floor(Math.random() * 0xFFFFFF) | 0;
- enemy.children[0].color = randomColor;
+ // Generate a bright color by maximizing at least two RGB channels
+ var brightColors = [0xFF3B3B,
+ // vivid red
+ 0xFFF200,
+ // yellow
+ 0x00FF90,
+ // bright green
+ 0x00E0FF,
+ // cyan
+ 0x3B6CFF,
+ // blue
+ 0xC54CE4,
+ // purple
+ 0xFF5EF7,
+ // pink
+ 0xFFA500 // orange
+ ];
+ var colorIdx = Math.floor(Math.random() * brightColors.length);
+ var brightColor = brightColors[colorIdx];
+ enemy.children[0].color = brightColor;
// If the asset supports .tint, set it as well for visual effect
if (typeof enemy.children[0].tint !== "undefined") {
- enemy.children[0].tint = randomColor;
+ enemy.children[0].tint = brightColor;
}
}
enemy.x = 1024;
enemy.y = 1366;
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