User prompt
cada bono debe ocupar una orbita pero solo seran 3 bonos
User prompt
un solo objet bono en 3 orbitas aisladas
User prompt
Please fix the bug: 'orbits is undefined' in or related to this line: 'for (var i = 0; i < orbits.length; i++) {' Line Number: 89
User prompt
un bono por orbita
User prompt
diferentes velocidades al bonus
User prompt
mas
User prompt
amplia el radio de la orbita del bonus
User prompt
agrega colores rambom a los enemigos
User prompt
agrega un objeto bonus que orbita cerca del centro algo rapido
User prompt
llegar al centro da 100 puntos
User prompt
pon una puntuacion
User prompt
pon el numero de nivel arriba
User prompt
fija siempre el inici en el centro de abajo de la pantalla en todos los stages
User prompt
el jugador siempre aparecera en la parte inferior de la pantalla
User prompt
los enemigos se deben multiplicar uno mas por stage
User prompt
aunque cambien su orbita de direccion deben completar al menos 3 vueltas en un sentido
User prompt
deven ir sumandose enemigos segun se avanza hasta el nivel 20, un mas cada nivel, y algunos rotan contrario a las manesillas del reloj y otros aleatoreamene cambian su orbita de direccion
User prompt
los enemigos se deben ir sumando, nivel 1 con 3 enemigos, nivel2 cuatro enemigos y asi se siguen sumando
User prompt
cada nivel agrega un enemigo
User prompt
los enemigo se deven ir multiplicando a medidas se pasa de nivel
User prompt
los objetos aumentan en numero gradualmente mientras se pasan los niveles, la rotacion del jugador acelera la gravedad y va mas rapido al centro
User prompt
segun avanzan los stages aumentan los objetos que rotan en orbita
User prompt
la velocidad de atracion aumentala con cada nivel en milesimas
User prompt
todos los objetos colisional al jugador
User prompt
los niveles aumentan la cantidad de objetos y obstaculos y variantes de rotacion
/**** * 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 = 350; // Farther from center (increased radius) 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; }); // Position near the top // Define Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); // Attach enemy asset var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); // Set initial position and movement properties self.speed = 1.2; // Lowered for better perception self.direction = 1; // 1 for right, -1 for left // Update method for enemy movement self.update = function () { self.x += self.speed * self.direction; // Reverse direction if enemy hits screen bounds if (self.x < 0 || self.x > 2048) { self.direction *= -1; } }; }); // 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 ****/ // Add a player to the game var player = game.addChild(new Player()); // Define orbits var orbits = [200, 400, 800]; // 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; b.orbitAngle = Math.random() * Math.PI * 2; bonuses.push(b); } // 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 = [200, 400, 800]; // 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]; } } // Add a new orbit to the end of the array to create an infinite loop var newOrbit = orbits[orbits.length - 1] + 200; 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 var currentLevel = 1; 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 = []; var numEnemies = 3 * level; var baseRadii = [200, 400, 800, 600, 1000, 300, 500, 900]; for (var i = 0; i < numEnemies; i++) { var enemy = game.addChild(new Enemy()); // Assign a random 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; // 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.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); // 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++; // 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); } 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 game over LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } enemy.lastWasIntersecting = isIntersecting; }); // --- 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
@@ -78,14 +78,18 @@
// Add a player to the game
var player = game.addChild(new Player());
// Define orbits
var orbits = [200, 400, 800];
-// Create a single bonus object that can move between three isolated orbits
-var bonus = game.addChild(new Bonus());
-bonus.orbitIndex = Math.floor(Math.random() * orbits.length);
-bonus.orbitRadius = orbits[bonus.orbitIndex];
-bonus.orbitSpeed = 0.04 + Math.random() * 0.09;
-bonus.orbitAngle = Math.random() * Math.PI * 2;
+// 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;
+ b.orbitAngle = Math.random() * Math.PI * 2;
+ bonuses.push(b);
+}
// Add level number display at the top center of the screen
var levelText = new Text2('Nivel 1', {
size: 100,
fill: 0xFFFFFF
@@ -343,32 +347,25 @@
LK.showGameOver();
}
enemy.lastWasIntersecting = isIntersecting;
});
- // --- Bonus object update and collision (single bonus, jumps between orbits) ---
- if (bonus && bonus.update) {
- 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 bonus to a new random orbit and angle (different from current)
- var prevIndex = bonus.orbitIndex;
- var newIndex = prevIndex;
- // Ensure new orbit is different from current
- if (orbits.length > 1) {
- while (newIndex === prevIndex) {
- newIndex = Math.floor(Math.random() * orbits.length);
+ // --- 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.orbitIndex = newIndex;
- bonus.orbitRadius = orbits[bonus.orbitIndex];
- bonus.orbitAngle = Math.random() * Math.PI * 2;
- bonus.orbitSpeed = 0.04 + Math.random() * 0.09;
+ bonus.lastWasIntersecting = bIntersecting;
}
- bonus.lastWasIntersecting = bIntersecting;
}
};
\ 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