User prompt
haz que cuando toques correctamente la linea blanca con la barra verde le hagas 15 de daño al enemigo, solo se puede hacer 0 de daño si fallas al precionar fuera de la barra verde
User prompt
haz que si precionas en la barrita verde hagas 15 de daño
User prompt
elimina la barrita del centro de la barra verde, solo haz que mientras mas al centro de la barra verde preciones bien hagas mas daño y mientras mas alejado del centro menos daño haras, solo se puede hacer 0 de daño si fallas al no precionar en la barra verde
User prompt
haz que el maximo de daño que se pueda hacer en la barra de ataque sea de 25, y que el minimo sea de 10, y si no precionas en la barrita verde solamente fallaras
User prompt
haz que al precionar la linea en la barrita verde, mientras mas al centro de la barra preciones correctamente, mas daño haras
User prompt
haz que si precionas justo cuando la linea toca la barrita del medio en vez de hacer 10 de daño haces 15 de daño
User prompt
haz que la barrita verde tenga otra barrita en el centro, si precionas cuando este en la barrita del centro en vez de hacer 10 de daño haras 15
User prompt
haz que cuando sea momento de elegir una opcion en la battlecard el corazon se posicione automaticamente en el centro de la battlebox ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que el corazon se pueda mover hasta que todos los proyectiles dentro de la battle box salgan de la battlebox, y cuando ya no hayan proyectiles en la battlebox si puedas elegir una opcion en la battlecard ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que el momento de elegir una opcion en la targeta de batalla solo empieze cuando todos los proyectiles dentro de la battlebox hayan salido de ahi
User prompt
haz que cuando es momento de elegir una opcion en la targeta de batalla, el corazon no se mueva hasta que sea momento de que el enemigo ataque denuevo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que la barrita verde en la que hay que precionar en el momento justo, cada ronda en la que vas a atacar cambie de posicion y de tamaño para que no sea tan repetitivo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que al precionar el boton de atacar, salga una barrita en medio de la pantalla en la que tebas precionar la pantalla en el momento exacto en que una linea toque una parte verde de la barra, al precionarlo correctamente le haras 10 de daño al enemigo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que al precionar el boton de atacar, salga una barrita en medio de la pantalla en la que tebas precionar la pantalla en el momento exacto en que una linea toque una parte verde de la barra, al precionarlo correctamente le haras 10 de daño al enemigo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que la interfaz de la targeta de batalla sea mucho mas grande, que tape toda la zona de abajo para que se vean bien los botones
User prompt
haz que en las targetas de batalla solo haya una, elimina la otra
User prompt
ahora haz que el enemigo solo pueda atacar si es su turno de hacerlo, su turno de atacar es cuando el jugador elije que accion tomar, si atacar, defenderse o curarse
User prompt
haz que los rombos aparezcan mas rapido
User prompt
haz que los rombos sean mas rapidos y aparezcan un poco mas rapido
User prompt
haz que los rombos sean un poco mas grandes y un poco mas rapidos
User prompt
haz que los rombos sean rectos, y que al momento de ser lanzados hacia ti, esten con la punta en direccion a donde son lanzados, pero que una vez que son lanzados no cambien su direccion
User prompt
haz que el rombo este recto
User prompt
haz que las puntas de los rombos segun la imagen que les puse, al ser lanzadas en direccion al corazon estos rombos tengan su punta mirando al corazon al ser lanzadas
User prompt
haz que los proyectiles de rombo de el enemigo, tengan su punta dirigida hacia el lugar en el que se encuentre el corazon (para que no se vea duro y en una sola direccion)
User prompt
haz que la velocidad de los rombos del enemigo sean de 3,5 y que los rombos tengan su punta dirigida al lugar al que son lanzados para que no se vean tan estaticos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1"); var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Circle = Container.expand(function (circleType) { var self = Container.call(this); var circleGraphics = self.attachAsset('circle' + circleType, { anchorX: 0.5, anchorY: 0.5 }); self.circleType = circleType; self.size = circleType; self.velocityX = 0; self.velocityY = 0; self.radius = [90, 120, 150, 180, 210, 240, 270, 320, 370][circleType - 1]; self.lastY = 0; self.lastIntersecting = false; self.spawnImmunity = false; self.spawnTime = 0; self.isSelected = false; self.originalTint = 0xFFFFFF; // Add selection handler self.down = function (x, y, obj) { if (selectionMode && gameState === 'playing') { if (self.isSelected) { // Deselect circle self.isSelected = false; circleGraphics.tint = self.originalTint; var index = selectedCircles.indexOf(self); if (index > -1) { selectedCircles.splice(index, 1); } } else if (selectedCircles.length < maxSelectableCircles) { // Select circle self.isSelected = true; circleGraphics.tint = 0xFF0000; // Red tint for selection selectedCircles.push(self); // If we have selected enough circles, remove them if (selectedCircles.length >= maxSelectableCircles) { // Deduct cost for using button1 score -= 750; scoreText.setText('Score: ' + score); scoreCounter.setText('Puntos: ' + score); // Remove selected circles for (var i = selectedCircles.length - 1; i >= 0; i--) { var circle = selectedCircles[i]; game.removeChild(circle); var circleIndex = circles.indexOf(circle); if (circleIndex > -1) { circles.splice(circleIndex, 1); } } // Reset selection state selectedCircles = []; selectionMode = false; } } } }; self.update = function () { // Apply gravity with slight variation based on size (heavier objects fall slightly faster) var gravityForce = 0.4 + self.radius / 1000; // Larger circles have slightly more gravity self.velocityY += gravityForce; // Apply velocity self.x += self.velocityX; self.y += self.velocityY; // Apply air resistance (less friction for more realistic movement) self.velocityX *= 0.995; // Very slight air resistance self.velocityY *= 0.999; // Even less resistance on Y axis // Add rotation based on horizontal velocity to make circles look more natural circleGraphics.rotation += self.velocityX * 0.01; // Container collision detection var containerLeft = containerX + 20; var containerRight = containerX + containerWidth - 20; var containerBottom = containerY + containerHeight - 20; var containerTop = containerY; // Side walls collision with improved bouncing if (self.x - self.radius < containerLeft) { self.x = containerLeft + self.radius; self.velocityX = Math.abs(self.velocityX) * 0.7; // More bounce } if (self.x + self.radius > containerRight) { self.x = containerRight - self.radius; self.velocityX = -Math.abs(self.velocityX) * 0.7; // More bounce } // Allow circles to move above the container when spawning, no collision with top // Bottom collision with better restitution if (self.y + self.radius > containerBottom) { self.y = containerBottom - self.radius; // Add some bounce to vertical velocity instead of stopping completely self.velocityY = -Math.abs(self.velocityY) * 0.3; // Small bounce self.velocityX *= 0.85; // Less friction loss } // Circle-to-circle collision with other circles for (var i = 0; i < circles.length; i++) { var other = circles[i]; if (other !== self) { var dx = self.x - other.x; var dy = self.y - other.y; var distance = Math.sqrt(dx * dx + dy * dy); // Use consistent radius for collision detection var minDistance = self.radius + other.radius; if (distance < minDistance && distance > 0) { // Same size circles merge if (self.circleType === other.circleType && self.circleType < 9) { // Prevent multiple merges of the same circles if (self.shouldMerge || other.shouldMerge) { return; } // Create new larger circle var newCircle = new Circle(self.circleType + 1); newCircle.x = (self.x + other.x) / 2; newCircle.y = (self.y + other.y) / 2; newCircle.velocityX = (self.velocityX + other.velocityX) / 2; newCircle.velocityY = (self.velocityY + other.velocityY) / 2; // Start small and animate to full size newCircle.scaleX = 0.3; newCircle.scaleY = 0.3; tween(newCircle, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.bounceOut }); // Play fusion sound LK.getSound('circleFusion').play(); // Mark both circles for merging into the same new circle self.shouldMerge = true; other.shouldMerge = true; self.mergeInto = newCircle; other.mergeInto = newCircle; score += self.circleType * 10; scoreText.setText('Score: ' + score); scoreCounter.setText('Puntos: ' + score); return; } // Simple and consistent collision response var overlap = minDistance - distance; var normalX = dx / distance; var normalY = dy / distance; // Calculate mass based on radius var mass1 = self.radius; var mass2 = other.radius; var totalMass = mass1 + mass2; // Separate circles proportionally to their masses var pushForce = overlap * 0.5; // Split the overlap correction var ratio1 = mass2 / totalMass; // Lighter objects move more var ratio2 = mass1 / totalMass; // Apply position correction with small buffer var buffer = 2; // Small buffer to prevent immediate re-collision var correctionX = normalX * (pushForce + buffer); var correctionY = normalY * (pushForce + buffer); self.x += correctionX * ratio1; self.y += correctionY * ratio1; other.x -= correctionX * ratio2; other.y -= correctionY * ratio2; // Keep circles within container bounds after collision var containerLeft = containerX + 20; var containerRight = containerX + containerWidth - 20; var containerBottom = containerY + containerHeight - 20; if (self.x - self.radius < containerLeft) { self.x = containerLeft + self.radius; } if (self.x + self.radius > containerRight) { self.x = containerRight - self.radius; } if (self.y + self.radius > containerBottom) { self.y = containerBottom - self.radius; } if (other.x - other.radius < containerLeft) { other.x = containerLeft + other.radius; } if (other.x + other.radius > containerRight) { other.x = containerRight - other.radius; } if (other.y + other.radius > containerBottom) { other.y = containerBottom - other.radius; } // Simple velocity exchange for realistic bouncing var relativeVelocityX = self.velocityX - other.velocityX; var relativeVelocityY = self.velocityY - other.velocityY; var separatingVelocity = relativeVelocityX * normalX + relativeVelocityY * normalY; // Only resolve if objects are moving towards each other if (separatingVelocity < 0) { var restitution = 0.6; // Moderate bounciness var impulse = -(1 + restitution) * separatingVelocity / (1 / mass1 + 1 / mass2); var impulseX = impulse * normalX; var impulseY = impulse * normalY; self.velocityX += impulseX / mass1; self.velocityY += impulseY / mass1; other.velocityX -= impulseX / mass2; other.velocityY -= impulseY / mass2; } } } } }; return self; }); var EnemyDiamond = Container.expand(function () { var self = Container.call(this); var diamondGraphics = self.attachAsset('enemyDiamond', { anchorX: 0.5, anchorY: 0.5 }); // Rotate diamond 45 degrees to make it look like a diamond diamondGraphics.rotation = Math.PI / 4; self.speed = 3.5; self.velocityX = 0; self.velocityY = 0; self.lastY = 0; self.lastX = 0; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000011 }); /**** * Game Code ****/ // Keep menu assets // Suika Game assets // Game state management var gameState = 'menu'; // 'menu', 'playing', 'paused', or 'settings' var sensitivity = storage.sensitivity || 0.5; // Default sensitivity // Suika Game variables var containerX = (2048 - 1600) / 2; var containerY = 200; var containerWidth = 1600; var containerHeight = 2000; var circles = []; var score = 0; var nextCircleType = 1; var currentCircle = null; var dropLine = null; var gameStarted = false; // Individual circle immunity will be handled per circle // Create container walls var leftWall = LK.getAsset('containerWall', { anchorX: 0, anchorY: 0 }); leftWall.x = containerX; leftWall.y = containerY; var rightWall = LK.getAsset('containerWall', { anchorX: 0, anchorY: 0 }); rightWall.x = containerX + containerWidth - 20; rightWall.y = containerY; var bottomWall = LK.getAsset('containerBottom', { anchorX: 0, anchorY: 0 }); bottomWall.x = containerX; bottomWall.y = containerY + containerHeight - 20; var topWall = LK.getAsset('containerTop', { anchorX: 0, anchorY: 0 }); topWall.x = containerX; topWall.y = containerY - 20; // Score display var scoreText = new Text2('Score: 0', { size: 60, fill: 0x000000 }); scoreText.anchor.set(0.5, 0); scoreText.x = containerX + containerWidth / 2; scoreText.y = containerY - 80; // Position above the red line // Additional score counter above red line var scoreCounter = new Text2('Puntos: 0', { size: 50, fill: 0xFFFFFF }); scoreCounter.anchor.set(0.5, 0.5); scoreCounter.x = containerX + containerWidth / 2; scoreCounter.y = containerY - 40; // Just above the red line // Next circle preview var nextCirclePreview = LK.getAsset('nextCirclePreview', { anchorX: 0.5, anchorY: 0.5 }); nextCirclePreview.x = containerX + containerWidth + 100; nextCirclePreview.y = 400; var nextCircleText = new Text2('Next:', { size: 40, fill: 0x000000 }); nextCircleText.anchor.set(0.5, 0.5); nextCircleText.x = nextCirclePreview.x; nextCircleText.y = nextCirclePreview.y - 60; // Create city background elements var cityElements = []; // Create starry night background for (var i = 0; i < 100; i++) { var star = LK.getAsset('nextCirclePreview', { anchorX: 0.5, anchorY: 0.5 }); star.x = Math.random() * 2048; star.y = Math.random() * 1500; // Only in upper portion of screen star.scaleX = 0.05 + Math.random() * 0.1; star.scaleY = star.scaleX; star.tint = 0xffffff; star.alpha = 0.3 + Math.random() * 0.7; game.addChild(star); cityElements.push(star); } // Create buildings for (var i = 0; i < 8; i++) { var building = LK.getAsset('building', { anchorX: 0.5, anchorY: 1 }); building.x = i * 280 + 140; building.y = 2732; building.scaleX = 1 + Math.random() * 0.5; building.scaleY = 1 + Math.random() * 1.2; building.tint = 0x333333 + Math.random() * 0x333333; // Random dark colors game.addChild(building); cityElements.push(building); } // Create city fog/smog effects var fogElements = []; for (var i = 0; i < 6; i++) { var fog = LK.getAsset('cityFog', { anchorX: 0.5, anchorY: 0.5 }); fog.x = Math.random() * 2048; fog.y = 1800 + Math.random() * 400; fog.tint = 0x666666; // Gray city smog fog.alpha = 0.15 + Math.random() * 0.25; fog.scaleX = 1 + Math.random() * 2; fog.scaleY = 0.6 + Math.random() * 0.8; fog.fogSpeed = 0.3 + Math.random() * 0.7; fog.fogDirection = Math.random() * Math.PI * 2; game.addChild(fog); fogElements.push(fog); } // Create moon var moon = LK.getAsset('moon', { anchorX: 0.5, anchorY: 0.5 }); moon.x = -100; // Start off-screen left moon.y = 400; // Upper portion of screen moon.scaleX = 1.2; moon.scaleY = 1.2; moon.alpha = 0.9; moon.tint = 0xFFFFDD; // Slight cream color // Moon click counter for easter egg var moonClickCount = 0; var moonClickTimeout = null; // Chaos screen elements var chaosScreenElements = []; // Battle screen elements var battleScreenElements = []; var battleScreenActive = false; var enemyDiamonds = []; var lastEnemyShootTime = 0; // Battle card elements var battleCardElements = []; // Character data for DELTARUNE-style cards var characterData = [{ name: "KRIS", hp: 90, attack: 10, defense: 2, magic: 1, portrait: 0x4a4a8a }, { name: "SUSIE", hp: 110, attack: 14, defense: 0, magic: 1, portrait: 0x8a4a8a }]; // Add click handler to moon moon.down = function (x, y, obj) { LK.getSound('moonClick').play(); // Create and display moon click image var moonClickImage = LK.getAsset('moonClickImage', { anchorX: 0.5, anchorY: 0.5 }); moonClickImage.x = moon.x; moonClickImage.y = moon.y; moonClickImage.alpha = 0.8; game.addChild(moonClickImage); // Animate image to fade out and remove after 1.5 seconds tween(moonClickImage, { alpha: 0, scaleX: 1.5, scaleY: 1.5 }, { duration: 1500, easing: tween.easeOut, onFinish: function onFinish() { game.removeChild(moonClickImage); } }); // Easter egg: count moon clicks moonClickCount++; if (moonClickTimeout) { LK.clearTimeout(moonClickTimeout); } // Reset counter after 3 seconds if no more clicks moonClickTimeout = LK.setTimeout(function () { moonClickCount = 0; }, 3000); // Check if clicked 3 times in a row if (moonClickCount >= 3) { moonClickCount = 0; if (moonClickTimeout) { LK.clearTimeout(moonClickTimeout); moonClickTimeout = null; } showChaosScreen(); } }; game.addChild(moon); cityElements.push(moon); // Animate moon movement across screen with arc trajectory moon.y = 800; // Start much lower var moonStartY = 800; var moonMidY = 250; // Higher point at middle var moonEndY = 800; // End at same height as start // Function to create complete moon cycle function startMoonCycle() { // First half: move right and up to middle tween(moon, { x: 1024, // Middle of screen (2048/2) y: moonMidY }, { duration: 18000, // 18 seconds to reach middle (slower) easing: tween.easeOut, onFinish: function onFinish() { // Second half: move right and down to end tween(moon, { x: 2148, y: moonEndY }, { duration: 18000, // 18 seconds to reach end (slower) easing: tween.easeIn, onFinish: function onFinish() { // Reset moon and start cycle again moon.x = -100; moon.y = moonStartY; startMoonCycle(); } }); } }); } // Start the moon cycle startMoonCycle(); // Create start screen elements var titleText = new Text2('The amazing digital chaos!', { size: 120, fill: 0xFFD700 }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 2732 / 3; var playButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); playButton.x = 2048 / 2; playButton.y = 2732 / 2 - 100; // Move play button up playButton.scaleX = 2.5; // Much larger playButton.scaleY = 1.8; // Taller // Add border effect with second button behind var playButtonBorder = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); playButtonBorder.x = playButton.x; playButtonBorder.y = playButton.y; playButtonBorder.tint = 0x000000; // Black border playButtonBorder.scaleX = 2.6; // Slightly larger for border playButtonBorder.scaleY = 1.9; game.addChild(playButtonBorder); game.addChild(playButton); // Add main button after border var playButtonText = new Text2('JUGAR', { size: 100, // Larger text fill: 0x000000 // Black color }); playButtonText.anchor.set(0.5, 0.5); playButtonText.x = playButton.x; playButtonText.y = playButton.y; // Add start screen elements game.addChild(titleText); game.addChild(playButton); game.addChild(playButtonText); // Store references for easy removal (including city elements) var menuElements = [titleText, playButtonBorder, playButton, playButtonText].concat(cityElements).concat(fogElements); // Create pause button (only visible during gameplay) var pauseButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); pauseButton.x = 2048 - 100; pauseButton.y = 150; pauseButton.tint = 0x666666; pauseButton.scaleX = 0.8; pauseButton.scaleY = 0.8; var pauseButtonText = new Text2('||', { size: 60, fill: 0xFFFFFF }); pauseButtonText.anchor.set(0.5, 0.5); pauseButtonText.x = pauseButton.x; pauseButtonText.y = pauseButton.y; // Pause menu elements var pauseMenuElements = []; var pauseTitle = new Text2('PAUSA', { size: 120, fill: 0xFFD700 }); pauseTitle.anchor.set(0.5, 0.5); pauseTitle.x = 2048 / 2; pauseTitle.y = 800; var resumeButton = LK.getAsset('continueButton', { anchorX: 0.5, anchorY: 0.5 }); resumeButton.x = 2048 / 2; resumeButton.y = 1200; resumeButton.scaleX = 2; resumeButton.scaleY = 1.2; var resumeButtonText = new Text2('CONTINUAR', { size: 80, fill: 0x000000 }); resumeButtonText.anchor.set(0.5, 0.5); resumeButtonText.x = resumeButton.x; resumeButtonText.y = resumeButton.y; var menuButton = LK.getAsset('mainMenuButton', { anchorX: 0.5, anchorY: 0.5 }); menuButton.x = 2048 / 2; menuButton.y = 1400; menuButton.scaleX = 2; menuButton.scaleY = 1.2; var menuButtonText = new Text2('MENU PRINCIPAL', { size: 70, fill: 0x000000 }); menuButtonText.anchor.set(0.5, 0.5); menuButtonText.x = menuButton.x; menuButtonText.y = menuButton.y; var restartButton = LK.getAsset('sensitivityButton', { anchorX: 0.5, anchorY: 0.5 }); restartButton.x = 2048 / 2; restartButton.y = 1600; restartButton.scaleX = 2; restartButton.scaleY = 1.2; var restartButtonText = new Text2('REINICIAR', { size: 70, fill: 0x000000 }); restartButtonText.anchor.set(0.5, 0.5); restartButtonText.x = restartButton.x; restartButtonText.y = restartButton.y; var volumeButton = LK.getAsset('sensitivityButton', { anchorX: 0.5, anchorY: 0.5 }); volumeButton.x = 2048 / 2; volumeButton.y = 1800; volumeButton.scaleX = 2; volumeButton.scaleY = 1.2; var volumeButtonText = new Text2('VOLUMEN', { size: 70, fill: 0x000000 }); volumeButtonText.anchor.set(0.5, 0.5); volumeButtonText.x = volumeButton.x; volumeButtonText.y = volumeButton.y; pauseMenuElements = [pauseTitle, resumeButton, resumeButtonText, menuButton, menuButtonText, restartButton, restartButtonText, volumeButton, volumeButtonText]; // Settings screen elements var settingsScreenElements = []; var settingsTitle = new Text2('AJUSTAR SENSIBILIDAD', { size: 100, fill: 0xFFD700 }); settingsTitle.anchor.set(0.5, 0.5); settingsTitle.x = 2048 / 2; settingsTitle.y = 800; var sensitivityText = new Text2('Sensibilidad: ' + Math.round(sensitivity * 100) + '%', { size: 80, fill: 0xFFFFFF }); sensitivityText.anchor.set(0.5, 0.5); sensitivityText.x = 2048 / 2; sensitivityText.y = 1200; var decreaseButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); decreaseButton.x = 2048 / 2 - 200; decreaseButton.y = 1400; decreaseButton.tint = 0xFF4444; decreaseButton.scaleX = 1.5; decreaseButton.scaleY = 1.2; var decreaseButtonText = new Text2('-', { size: 100, fill: 0xFFFFFF }); decreaseButtonText.anchor.set(0.5, 0.5); decreaseButtonText.x = decreaseButton.x; decreaseButtonText.y = decreaseButton.y; var increaseButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); increaseButton.x = 2048 / 2 + 200; increaseButton.y = 1400; increaseButton.tint = 0x44FF44; increaseButton.scaleX = 1.5; increaseButton.scaleY = 1.2; var increaseButtonText = new Text2('+', { size: 100, fill: 0xFFFFFF }); increaseButtonText.anchor.set(0.5, 0.5); increaseButtonText.x = increaseButton.x; increaseButtonText.y = increaseButton.y; var backFromSettingsButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); backFromSettingsButton.x = 2048 / 2; backFromSettingsButton.y = 1700; backFromSettingsButton.tint = 0x888888; backFromSettingsButton.scaleX = 1.8; backFromSettingsButton.scaleY = 1.2; var backFromSettingsButtonText = new Text2('VOLVER', { size: 70, fill: 0xFFFFFF }); backFromSettingsButtonText.anchor.set(0.5, 0.5); backFromSettingsButtonText.x = backFromSettingsButton.x; backFromSettingsButtonText.y = backFromSettingsButton.y; settingsScreenElements = [settingsTitle, sensitivityText, decreaseButton, decreaseButtonText, increaseButton, increaseButtonText, backFromSettingsButton, backFromSettingsButtonText]; // Volume control screen elements var volumeScreenElements = []; var volumeTitle = new Text2('AJUSTAR VOLUMEN', { size: 100, fill: 0xFFD700 }); volumeTitle.anchor.set(0.5, 0.5); volumeTitle.x = 2048 / 2; volumeTitle.y = 800; var musicVolume = 0.5; // Default volume var volumeText = new Text2('Volumen: ' + Math.round(musicVolume * 100) + '%', { size: 80, fill: 0xFFFFFF }); volumeText.anchor.set(0.5, 0.5); volumeText.x = 2048 / 2; volumeText.y = 1200; var volumeDecreaseButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); volumeDecreaseButton.x = 2048 / 2 - 200; volumeDecreaseButton.y = 1400; volumeDecreaseButton.tint = 0xFF4444; volumeDecreaseButton.scaleX = 1.5; volumeDecreaseButton.scaleY = 1.2; var volumeDecreaseButtonText = new Text2('-', { size: 100, fill: 0xFFFFFF }); volumeDecreaseButtonText.anchor.set(0.5, 0.5); volumeDecreaseButtonText.x = volumeDecreaseButton.x; volumeDecreaseButtonText.y = volumeDecreaseButton.y; var volumeIncreaseButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); volumeIncreaseButton.x = 2048 / 2 + 200; volumeIncreaseButton.y = 1400; volumeIncreaseButton.tint = 0x44FF44; volumeIncreaseButton.scaleX = 1.5; volumeIncreaseButton.scaleY = 1.2; var volumeIncreaseButtonText = new Text2('+', { size: 100, fill: 0xFFFFFF }); volumeIncreaseButtonText.anchor.set(0.5, 0.5); volumeIncreaseButtonText.x = volumeIncreaseButton.x; volumeIncreaseButtonText.y = volumeIncreaseButton.y; var backFromVolumeButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); backFromVolumeButton.x = 2048 / 2; backFromVolumeButton.y = 1700; backFromVolumeButton.tint = 0x888888; backFromVolumeButton.scaleX = 1.8; backFromVolumeButton.scaleY = 1.2; var backFromVolumeButtonText = new Text2('VOLVER', { size: 70, fill: 0xFFFFFF }); backFromVolumeButtonText.anchor.set(0.5, 0.5); backFromVolumeButtonText.x = backFromVolumeButton.x; backFromVolumeButtonText.y = backFromVolumeButton.y; volumeScreenElements = [volumeTitle, volumeText, volumeDecreaseButton, volumeDecreaseButtonText, volumeIncreaseButton, volumeIncreaseButtonText, backFromVolumeButton, backFromVolumeButtonText]; // Function to show chaos screen (easter egg) function showChaosScreen() { gameState = 'chaos'; // Remove menu elements for (var i = 0; i < menuElements.length; i++) { game.removeChild(menuElements[i]); } // Create chaos screen elements var chaosTitle = new Text2('EASTER EGG FOUND!', { size: 100, fill: 0xFF0000 }); chaosTitle.anchor.set(0.5, 0.5); chaosTitle.x = 2048 / 2; chaosTitle.y = 800; var chaosSubtitle = new Text2('Welcome to the secret screen', { size: 60, fill: 0xFFFFFF }); chaosSubtitle.anchor.set(0.5, 0.5); chaosSubtitle.x = 2048 / 2; chaosSubtitle.y = 1000; var chaosButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); chaosButton.x = 2048 / 2; chaosButton.y = 1400; chaosButton.tint = 0x8B0000; // Dark red chaosButton.scaleX = 2.5; chaosButton.scaleY = 1.8; var chaosButtonText = new Text2('CHAOS', { size: 100, fill: 0xFFFFFF }); chaosButtonText.anchor.set(0.5, 0.5); chaosButtonText.x = chaosButton.x; chaosButtonText.y = chaosButton.y; var backToChaosMenuButton = LK.getAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); backToChaosMenuButton.x = 2048 / 2; backToChaosMenuButton.y = 1700; backToChaosMenuButton.tint = 0x888888; backToChaosMenuButton.scaleX = 1.8; backToChaosMenuButton.scaleY = 1.2; var backToChaosMenuButtonText = new Text2('VOLVER', { size: 70, fill: 0xFFFFFF }); backToChaosMenuButtonText.anchor.set(0.5, 0.5); backToChaosMenuButtonText.x = backToChaosMenuButton.x; backToChaosMenuButtonText.y = backToChaosMenuButton.y; chaosScreenElements = [chaosTitle, chaosSubtitle, chaosButton, chaosButtonText, backToChaosMenuButton, backToChaosMenuButtonText]; // Add chaos screen elements for (var i = 0; i < chaosScreenElements.length; i++) { game.addChild(chaosScreenElements[i]); } } // Function to return to main menu from chaos screen function returnToMainMenuFromChaos() { gameState = 'menu'; // Remove chaos screen elements for (var i = 0; i < chaosScreenElements.length; i++) { game.removeChild(chaosScreenElements[i]); } // Add menu elements back for (var i = 0; i < menuElements.length; i++) { game.addChild(menuElements[i]); } } // Function to create character battle cards function createBattleCards() { battleCardElements = []; for (var i = 0; i < characterData.length; i++) { var character = characterData[i]; var cardX = 512 + i * 1024; // Position cards to occupy full width var cardY = 2400; // Position cards at bottom of screen // Resize cards to be wider and fit screen width var cardWidth = 950; // Wider cards var cardHeight = 300; // Shorter cards for bottom positioning // Create card border (white background) var cardBorder = LK.getAsset('characterCardBorder', { anchorX: 0.5, anchorY: 0.5, scaleX: cardWidth / 310, scaleY: cardHeight / 410 }); cardBorder.x = cardX; cardBorder.y = cardY; // Create main card background var cardBg = LK.getAsset('characterCard', { anchorX: 0.5, anchorY: 0.5, scaleX: cardWidth / 300, scaleY: cardHeight / 400 }); cardBg.x = cardX; cardBg.y = cardY; // Create character portrait (smaller and positioned to the left) var portrait = LK.getAsset('characterPortrait', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 0.6 }); portrait.x = cardX - 300; portrait.y = cardY - 20; portrait.tint = character.portrait; // Create character name text (positioned above portrait) var nameText = new Text2(character.name, { size: 45, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = cardX - 300; nameText.y = cardY - 100; // Create HP text (positioned to the right of portrait) var hpText = new Text2('HP: ' + character.hp, { size: 32, fill: 0xFF4444 }); hpText.anchor.set(0.5, 0.5); hpText.x = cardX - 100; hpText.y = cardY - 60; // Create Attack text var attackText = new Text2('ATK: ' + character.attack, { size: 32, fill: 0xFFAA44 }); attackText.anchor.set(0.5, 0.5); attackText.x = cardX - 100; attackText.y = cardY - 20; // Create Defense text var defenseText = new Text2('DEF: ' + character.defense, { size: 32, fill: 0x44AAFF }); defenseText.anchor.set(0.5, 0.5); defenseText.x = cardX - 100; defenseText.y = cardY + 20; // Create action buttons for each character var buttonSize = 80; var buttonSpacing = 90; var startX = cardX + 80; var buttonY = cardY; // ATACAR button var attackButton = LK.getAsset('characterNameBg', { anchorX: 0.5, anchorY: 0.5, scaleX: buttonSize / 280, scaleY: buttonSize / 60 }); attackButton.x = startX; attackButton.y = buttonY - 40; attackButton.tint = 0xFF4444; var attackButtonText = new Text2('ATACAR', { size: 20, fill: 0xFFFFFF }); attackButtonText.anchor.set(0.5, 0.5); attackButtonText.x = attackButton.x; attackButtonText.y = attackButton.y; // ACTUAR button var actButton = LK.getAsset('characterNameBg', { anchorX: 0.5, anchorY: 0.5, scaleX: buttonSize / 280, scaleY: buttonSize / 60 }); actButton.x = startX + buttonSpacing; actButton.y = buttonY - 40; actButton.tint = 0x44AA44; var actButtonText = new Text2('ACTUAR', { size: 20, fill: 0xFFFFFF }); actButtonText.anchor.set(0.5, 0.5); actButtonText.x = actButton.x; actButtonText.y = actButton.y; // COMIDA button var foodButton = LK.getAsset('characterNameBg', { anchorX: 0.5, anchorY: 0.5, scaleX: buttonSize / 280, scaleY: buttonSize / 60 }); foodButton.x = startX; foodButton.y = buttonY + 40; foodButton.tint = 0xFFAA44; var foodButtonText = new Text2('COMIDA', { size: 20, fill: 0xFFFFFF }); foodButtonText.anchor.set(0.5, 0.5); foodButtonText.x = foodButton.x; foodButtonText.y = foodButton.y; // DEFENSA button var defenseButton = LK.getAsset('characterNameBg', { anchorX: 0.5, anchorY: 0.5, scaleX: buttonSize / 280, scaleY: buttonSize / 60 }); defenseButton.x = startX + buttonSpacing; defenseButton.y = buttonY + 40; defenseButton.tint = 0x4444FF; var defenseButtonText = new Text2('DEFENSA', { size: 20, fill: 0xFFFFFF }); defenseButtonText.anchor.set(0.5, 0.5); defenseButtonText.x = defenseButton.x; defenseButtonText.y = defenseButton.y; // Store all card elements including action buttons battleCardElements.push(cardBorder, cardBg, portrait, nameText, hpText, attackText, defenseText, attackButton, attackButtonText, actButton, actButtonText, foodButton, foodButtonText, defenseButton, defenseButtonText); } } // Function to show DELTARUNE-style battle screen function showBattleScreen() { gameState = 'battle'; battleScreenActive = true; // Remove chaos screen elements for (var i = 0; i < chaosScreenElements.length; i++) { game.removeChild(chaosScreenElements[i]); } // Create battle screen background var battleBackground = LK.getAsset('battleBackground', { anchorX: 0, anchorY: 0 }); battleBackground.x = 0; battleBackground.y = 0; // Create battle dialogue box var battleBox = LK.getAsset('battleBox', { anchorX: 0.5, anchorY: 0.5, scaleX: 4.2, scaleY: 8.0 }); battleBox.x = 2048 / 2; battleBox.y = 2732 / 2; // Create enemy character above battle box var enemyCharacter = LK.getAsset('characterPortrait', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); enemyCharacter.x = battleBox.x; enemyCharacter.y = battleBox.y - 700; // Position higher above battle box (3-4 cm more separation) // enemyCharacter.tint = 0x8B0080; // Purple alien color - removed to show original image // Add levitation animation to make enemy look powerful var enemyBaseY = enemyCharacter.y; var enemyBaseX = enemyCharacter.x; function startEnemyLevitation() { // Generate random offsets for movement var randomXOffset = (Math.random() - 0.5) * 80; // Random X between -40 and 40 var randomYOffset = (Math.random() - 0.5) * 60; // Random Y between -30 and 30 var randomDuration = 800 + Math.random() * 600; // Random duration between 0.8-1.4 seconds (faster) // Determine direction based on X movement and flip enemy accordingly if (randomXOffset > 0) { // Moving right - show normal image (not flipped) enemyCharacter.scaleX = Math.abs(enemyCharacter.scaleX); } else if (randomXOffset < 0) { // Moving left - flip image horizontally enemyCharacter.scaleX = -Math.abs(enemyCharacter.scaleX); } // Move to random position around base location tween(enemyCharacter, { y: enemyBaseY + randomYOffset, x: enemyBaseX + randomXOffset }, { duration: randomDuration, easing: tween.easeInOut, onFinish: function onFinish() { // Continue the cycle with new random movement startEnemyLevitation(); } }); } // Start the levitation animation startEnemyLevitation(); // Create battle text var battleText = new Text2('* Choose your fighters for battle!', { size: 50, fill: 0x000000 }); battleText.anchor.set(0.5, 0.5); battleText.x = battleBox.x; battleText.y = battleBox.y; // Create pause button in top right corner var battlePauseButton = LK.getAsset('battlePauseButton', { anchorX: 0.5, anchorY: 0.5 }); battlePauseButton.x = 2048 - 80; battlePauseButton.y = 80; var battlePauseButtonText = new Text2('EXIT', { size: 30, fill: 0xFFFFFF }); battlePauseButtonText.anchor.set(0.5, 0.5); battlePauseButtonText.x = battlePauseButton.x; battlePauseButtonText.y = battlePauseButton.y; // Create heart cursor (player soul) var heartCursor = LK.getAsset('heartCursor', { anchorX: 0.5, anchorY: 0.5 }); heartCursor.x = battleBox.x; heartCursor.y = battleBox.y; heartCursor.scaleX = 1.2; heartCursor.scaleY = 1.2; battleScreenElements = [battleBackground, battleBox, battleText, battlePauseButton, battlePauseButtonText, heartCursor, enemyCharacter]; // Add battle screen elements for (var i = 0; i < battleScreenElements.length; i++) { game.addChild(battleScreenElements[i]); } // Create and add character cards createBattleCards(); for (var i = 0; i < battleCardElements.length; i++) { game.addChild(battleCardElements[i]); } } // Function to exit battle screen function exitBattleScreen() { gameState = 'chaos'; battleScreenActive = false; // Remove battle screen elements for (var i = 0; i < battleScreenElements.length; i++) { game.removeChild(battleScreenElements[i]); } // Remove battle card elements for (var i = 0; i < battleCardElements.length; i++) { game.removeChild(battleCardElements[i]); } battleCardElements = []; // Remove all enemy diamonds for (var i = 0; i < enemyDiamonds.length; i++) { game.removeChild(enemyDiamonds[i]); } enemyDiamonds = []; // Return to chaos screen for (var i = 0; i < chaosScreenElements.length; i++) { game.addChild(chaosScreenElements[i]); } } // Function to start the game function startGame() { gameState = 'playing'; // Remove menu elements for (var i = 0; i < menuElements.length; i++) { game.removeChild(menuElements[i]); } // Add game elements game.addChild(leftWall); game.addChild(rightWall); game.addChild(bottomWall); game.addChild(topWall); game.addChild(scoreText); game.addChild(scoreCounter); game.addChild(nextCirclePreview); game.addChild(nextCircleText); // Add pause button game.addChild(pauseButton); game.addChild(pauseButtonText); // Create wooden board below container woodenBoard = LK.getAsset('woodenBoard', { anchorX: 0.5, anchorY: 0 }); woodenBoard.x = containerX + containerWidth / 2; woodenBoard.y = containerY + containerHeight + 50; game.addChild(woodenBoard); // Create 3 buttons on the wooden board button1 = LK.getAsset('button1', { anchorX: 0.5, anchorY: 0.5 }); button1.x = woodenBoard.x - 400; button1.y = woodenBoard.y + 100; game.addChild(button1); button1CostText = new Text2('750 puntos', { size: 60, fill: 0xFFD700 }); button1CostText.anchor.set(0.5, 0.5); button1CostText.x = button1.x; button1CostText.y = button1.y + 140; game.addChild(button1CostText); button2 = LK.getAsset('button2', { anchorX: 0.5, anchorY: 0.5 }); button2.x = woodenBoard.x; button2.y = woodenBoard.y + 100; game.addChild(button2); button2CostText = new Text2('650 puntos', { size: 60, fill: 0xFFD700 }); button2CostText.anchor.set(0.5, 0.5); button2CostText.x = button2.x; button2CostText.y = button2.y + 140; game.addChild(button2CostText); button3 = LK.getAsset('button3', { anchorX: 0.5, anchorY: 0.5 }); button3.x = woodenBoard.x + 400; button3.y = woodenBoard.y + 100; game.addChild(button3); button3CostText = new Text2('9,999 puntos', { size: 60, fill: 0xFFD700 }); button3CostText.anchor.set(0.5, 0.5); button3CostText.x = button3.x; button3CostText.y = button3.y + 140; game.addChild(button3CostText); // Initialize first circle generateNextCircle(); gameStarted = true; // Start playing background music LK.playMusic('NightChaos'); } // Function to show pause menu function showPauseMenu() { gameState = 'paused'; // Add pause menu elements for (var i = 0; i < pauseMenuElements.length; i++) { game.addChild(pauseMenuElements[i]); } } // Function to resume game function resumeGame() { gameState = 'playing'; // Remove pause menu elements for (var i = 0; i < pauseMenuElements.length; i++) { game.removeChild(pauseMenuElements[i]); } } // Function to show settings screen function showSettings() { gameState = 'settings'; // Remove pause menu elements for (var i = 0; i < pauseMenuElements.length; i++) { game.removeChild(pauseMenuElements[i]); } // Add settings elements for (var i = 0; i < settingsScreenElements.length; i++) { game.addChild(settingsScreenElements[i]); } } // Function to go back to pause menu from settings function backToPauseMenu() { gameState = 'paused'; // Remove settings elements for (var i = 0; i < settingsScreenElements.length; i++) { game.removeChild(settingsScreenElements[i]); } // Add pause menu elements for (var i = 0; i < pauseMenuElements.length; i++) { game.addChild(pauseMenuElements[i]); } } // Function to show volume control screen function showVolumeControl() { gameState = 'volume'; // Remove pause menu elements for (var i = 0; i < pauseMenuElements.length; i++) { game.removeChild(pauseMenuElements[i]); } // Add volume control elements for (var i = 0; i < volumeScreenElements.length; i++) { game.addChild(volumeScreenElements[i]); } } // Function to go back to pause menu from volume control function backToPauseMenuFromVolume() { gameState = 'paused'; // Remove volume control elements for (var i = 0; i < volumeScreenElements.length; i++) { game.removeChild(volumeScreenElements[i]); } // Add pause menu elements for (var i = 0; i < pauseMenuElements.length; i++) { game.addChild(pauseMenuElements[i]); } } // Function to restart game function restartGame() { gameState = 'playing'; // Remove pause menu elements for (var i = 0; i < pauseMenuElements.length; i++) { game.removeChild(pauseMenuElements[i]); } // Remove all circles for (var i = 0; i < circles.length; i++) { game.removeChild(circles[i]); } circles = []; if (currentCircle) { game.removeChild(currentCircle); currentCircle = null; } if (dropLine) { game.removeChild(dropLine); dropLine = null; } // Reset game state score = 0; nextCircleType = 1; scoreText.setText('Score: 0'); scoreCounter.setText('Puntos: 0'); // Generate new next circle generateNextCircle(); gameStarted = true; } // Function to return to main menu from pause function returnToMainMenu() { gameState = 'menu'; // Remove pause menu elements for (var i = 0; i < pauseMenuElements.length; i++) { game.removeChild(pauseMenuElements[i]); } // Remove game elements game.removeChild(leftWall); game.removeChild(rightWall); game.removeChild(bottomWall); game.removeChild(topWall); game.removeChild(scoreText); game.removeChild(scoreCounter); game.removeChild(nextCirclePreview); game.removeChild(nextCircleText); if (currentCircle) { game.removeChild(currentCircle); currentCircle = null; } if (dropLine) { game.removeChild(dropLine); dropLine = null; } // Remove all circles for (var i = 0; i < circles.length; i++) { game.removeChild(circles[i]); } circles = []; game.removeChild(pauseButton); game.removeChild(pauseButtonText); // Remove wooden board and buttons if (woodenBoard) { game.removeChild(woodenBoard); } if (button1) { game.removeChild(button1); if (button1CostText) { game.removeChild(button1CostText); } } if (button2) { game.removeChild(button2); if (button2CostText) { game.removeChild(button2CostText); } } if (button3) { game.removeChild(button3); if (button3CostText) { game.removeChild(button3CostText); } } // Reset game state score = 0; nextCircleType = 1; gameStarted = false; // Add menu elements back for (var i = 0; i < menuElements.length; i++) { game.addChild(menuElements[i]); } } // Movement controls var keys = { up: false, down: false, left: false, right: false }; // Touch/mouse controls var isDragging = false; var lastTouchX = 0; var lastTouchY = 0; // Wooden board and buttons var woodenBoard = null; var button1 = null; var button1CostText = null; var button2 = null; var button2Text = null; var button2CostText = null; var button3 = null; var button3Text = null; var button3CostText = null; // Circle selection system var selectionMode = false; var selectedCircles = []; var maxSelectableCircles = 2; function generateNextCircle() { nextCircleType = Math.floor(Math.random() * 3) + 1; // Random circle type 1-3 only // Update preview game.removeChild(nextCirclePreview); nextCirclePreview = LK.getAsset('circle' + nextCircleType, { anchorX: 0.5, anchorY: 0.5 }); nextCirclePreview.x = containerX + containerWidth + 100; nextCirclePreview.y = 400; nextCirclePreview.scaleX = 0.6; nextCirclePreview.scaleY = 0.6; game.addChild(nextCirclePreview); } game.down = function (x, y, obj) { if (gameState === 'menu') { // Check if play button was clicked var playButtonBounds = { left: playButton.x - playButton.width * playButton.scaleX / 2, right: playButton.x + playButton.width * playButton.scaleX / 2, top: playButton.y - playButton.height * playButton.scaleY / 2, bottom: playButton.y + playButton.height * playButton.scaleY / 2 }; if (x >= playButtonBounds.left && x <= playButtonBounds.right && y >= playButtonBounds.top && y <= playButtonBounds.bottom) { startGame(); } } else if (gameState === 'playing') { // Check if pause button was clicked var pauseButtonBounds = { left: pauseButton.x - pauseButton.width * pauseButton.scaleX / 2, right: pauseButton.x + pauseButton.width * pauseButton.scaleX / 2, top: pauseButton.y - pauseButton.height * pauseButton.scaleY / 2, bottom: pauseButton.y + pauseButton.height * pauseButton.scaleY / 2 }; if (x >= pauseButtonBounds.left && x <= pauseButtonBounds.right && y >= pauseButtonBounds.top && y <= pauseButtonBounds.bottom) { showPauseMenu(); } else { // Check if button1 was clicked (only if button1 exists) if (button1) { var button1Bounds = { left: button1.x - button1.width * button1.scaleX / 2, right: button1.x + button1.width * button1.scaleX / 2, top: button1.y - button1.height * button1.scaleY / 2, bottom: button1.y + button1.height * button1.scaleY / 2 }; if (x >= button1Bounds.left && x <= button1Bounds.right && y >= button1Bounds.top && y <= button1Bounds.bottom) { // Check if player has enough points to use button1 if (score < 750) { // Show feedback that player doesn't have enough points // Could add visual/audio feedback here in the future return; } // Play exchange sound when button1 is pressed LK.getSound('button1Exchange').play(); // Enable selection mode if (!selectionMode) { selectionMode = true; selectedCircles = []; } else { // Cancel selection mode selectionMode = false; // Reset all selected circles for (var i = 0; i < selectedCircles.length; i++) { var circle = selectedCircles[i]; circle.isSelected = false; var circleGraphics = circle.children[0]; if (circleGraphics) { circleGraphics.tint = circle.originalTint; } } selectedCircles = []; } } } // Check if button2 was clicked (only if button2 exists) if (button2) { var button2Bounds = { left: button2.x - button2.width * button2.scaleX / 2, right: button2.x + button2.width * button2.scaleX / 2, top: button2.y - button2.height * button2.scaleY / 2, bottom: button2.y + button2.height * button2.scaleY / 2 }; if (x >= button2Bounds.left && x <= button2Bounds.right && y >= button2Bounds.top && y <= button2Bounds.bottom) { // Check if player has enough points to use button2 if (score < 650) { // Show feedback that player doesn't have enough points return; } // Deduct cost for using button2 score -= 650; scoreText.setText('Score: ' + score); scoreCounter.setText('Puntos: ' + score); // Only swap positions if there are at least 2 circles in the container if (circles.length >= 2) { // Create array of current positions var positions = []; for (var i = 0; i < circles.length; i++) { positions.push({ x: circles[i].x, y: circles[i].y }); } // Shuffle the positions array for (var i = positions.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = positions[i]; positions[i] = positions[j]; positions[j] = temp; } // Instantly set each circle to its new position for (var i = 0; i < circles.length; i++) { var circle = circles[i]; var newPos = positions[i]; // Set position instantly without animation circle.x = newPos.x; circle.y = newPos.y; } } } } // Check if button3 was clicked (only if button3 exists) if (button3) { var button3Bounds = { left: button3.x - button3.width * button3.scaleX / 2, right: button3.x + button3.width * button3.scaleX / 2, top: button3.y - button3.height * button3.scaleY / 2, bottom: button3.y + button3.height * button3.scaleY / 2 }; if (x >= button3Bounds.left && x <= button3Bounds.right && y >= button3Bounds.top && y <= button3Bounds.bottom) { // Check if player has enough points to use button3 if (score < 9999) { // Show feedback that player doesn't have enough points return; } // Deduct cost for using button3 score -= 9999; scoreText.setText('Score: ' + score); scoreCounter.setText('Puntos: ' + score); // Show victory screen LK.showYouWin(); } } // Check if click is inside the container (frasco) boundaries and not in selection mode if (!selectionMode && x >= containerX + 20 && x <= containerX + containerWidth - 20 && y >= containerY && y <= containerY + containerHeight - 20) { // Create and drop a circle var newCircle = new Circle(nextCircleType); newCircle.x = Math.max(containerX + 50, Math.min(x, containerX + containerWidth - 50)); newCircle.y = containerY - 100; // Spawn above the red line newCircle.velocityY = 2; newCircle.velocityX = 0; newCircle.lastY = newCircle.y; newCircle.lastIntersecting = false; // Set individual spawn immunity for this circle newCircle.spawnImmunity = true; newCircle.spawnTime = LK.ticks; game.addChild(newCircle); circles.push(newCircle); // Use tween to disable immunity after 3 seconds for this specific circle var immunityObj = { immunity: 1 }; tween(immunityObj, { immunity: 0 }, { duration: 3000, onFinish: function onFinish() { newCircle.spawnImmunity = false; } }); generateNextCircle(); } } } else if (gameState === 'paused') { // Handle pause menu interactions var resumeButtonBounds = { left: resumeButton.x - resumeButton.width * resumeButton.scaleX / 2, right: resumeButton.x + resumeButton.width * resumeButton.scaleX / 2, top: resumeButton.y - resumeButton.height * resumeButton.scaleY / 2, bottom: resumeButton.y + resumeButton.height * resumeButton.scaleY / 2 }; var menuButtonBounds = { left: menuButton.x - menuButton.width * menuButton.scaleX / 2, right: menuButton.x + menuButton.width * menuButton.scaleX / 2, top: menuButton.y - menuButton.height * menuButton.scaleY / 2, bottom: menuButton.y + menuButton.height * menuButton.scaleY / 2 }; var restartButtonBounds = { left: restartButton.x - restartButton.width * restartButton.scaleX / 2, right: restartButton.x + restartButton.width * restartButton.scaleX / 2, top: restartButton.y - restartButton.height * restartButton.scaleY / 2, bottom: restartButton.y + restartButton.height * restartButton.scaleY / 2 }; var volumeButtonBounds = { left: volumeButton.x - volumeButton.width * volumeButton.scaleX / 2, right: volumeButton.x + volumeButton.width * volumeButton.scaleX / 2, top: volumeButton.y - volumeButton.height * volumeButton.scaleY / 2, bottom: volumeButton.y + volumeButton.height * volumeButton.scaleY / 2 }; if (x >= resumeButtonBounds.left && x <= resumeButtonBounds.right && y >= resumeButtonBounds.top && y <= resumeButtonBounds.bottom) { resumeGame(); } else if (x >= menuButtonBounds.left && x <= menuButtonBounds.right && y >= menuButtonBounds.top && y <= menuButtonBounds.bottom) { returnToMainMenu(); } else if (x >= restartButtonBounds.left && x <= restartButtonBounds.right && y >= restartButtonBounds.top && y <= restartButtonBounds.bottom) { restartGame(); } else if (x >= volumeButtonBounds.left && x <= volumeButtonBounds.right && y >= volumeButtonBounds.top && y <= volumeButtonBounds.bottom) { showVolumeControl(); } } else if (gameState === 'settings') { // Handle settings interactions var decreaseButtonBounds = { left: decreaseButton.x - decreaseButton.width * decreaseButton.scaleX / 2, right: decreaseButton.x + decreaseButton.width * decreaseButton.scaleX / 2, top: decreaseButton.y - decreaseButton.height * decreaseButton.scaleY / 2, bottom: decreaseButton.y + decreaseButton.height * decreaseButton.scaleY / 2 }; var increaseButtonBounds = { left: increaseButton.x - increaseButton.width * increaseButton.scaleX / 2, right: increaseButton.x + increaseButton.width * increaseButton.scaleX / 2, top: increaseButton.y - increaseButton.height * increaseButton.scaleY / 2, bottom: increaseButton.y + increaseButton.height * increaseButton.scaleY / 2 }; var backFromSettingsButtonBounds = { left: backFromSettingsButton.x - backFromSettingsButton.width * backFromSettingsButton.scaleX / 2, right: backFromSettingsButton.x + backFromSettingsButton.width * backFromSettingsButton.scaleX / 2, top: backFromSettingsButton.y - backFromSettingsButton.height * backFromSettingsButton.scaleY / 2, bottom: backFromSettingsButton.y + backFromSettingsButton.height * backFromSettingsButton.scaleY / 2 }; if (x >= decreaseButtonBounds.left && x <= decreaseButtonBounds.right && y >= decreaseButtonBounds.top && y <= decreaseButtonBounds.bottom) { sensitivity = Math.max(0.1, sensitivity - 0.1); storage.sensitivity = sensitivity; sensitivityText.setText('Sensibilidad: ' + Math.round(sensitivity * 100) + '%'); } else if (x >= increaseButtonBounds.left && x <= increaseButtonBounds.right && y >= increaseButtonBounds.top && y <= increaseButtonBounds.bottom) { sensitivity = Math.min(1.0, sensitivity + 0.1); storage.sensitivity = sensitivity; sensitivityText.setText('Sensibilidad: ' + Math.round(sensitivity * 100) + '%'); } else if (x >= backFromSettingsButtonBounds.left && x <= backFromSettingsButtonBounds.right && y >= backFromSettingsButtonBounds.top && y <= backFromSettingsButtonBounds.bottom) { backToPauseMenu(); } } else if (gameState === 'volume') { // Handle volume control interactions var volumeDecreaseButtonBounds = { left: volumeDecreaseButton.x - volumeDecreaseButton.width * volumeDecreaseButton.scaleX / 2, right: volumeDecreaseButton.x + volumeDecreaseButton.width * volumeDecreaseButton.scaleX / 2, top: volumeDecreaseButton.y - volumeDecreaseButton.height * volumeDecreaseButton.scaleY / 2, bottom: volumeDecreaseButton.y + volumeDecreaseButton.height * volumeDecreaseButton.scaleY / 2 }; var volumeIncreaseButtonBounds = { left: volumeIncreaseButton.x - volumeIncreaseButton.width * volumeIncreaseButton.scaleX / 2, right: volumeIncreaseButton.x + volumeIncreaseButton.width * volumeIncreaseButton.scaleX / 2, top: volumeIncreaseButton.y - volumeIncreaseButton.height * volumeIncreaseButton.scaleY / 2, bottom: volumeIncreaseButton.y + volumeIncreaseButton.height * volumeIncreaseButton.scaleY / 2 }; var backFromVolumeButtonBounds = { left: backFromVolumeButton.x - backFromVolumeButton.width * backFromVolumeButton.scaleX / 2, right: backFromVolumeButton.x + backFromVolumeButton.width * backFromVolumeButton.scaleX / 2, top: backFromVolumeButton.y - backFromVolumeButton.height * backFromVolumeButton.scaleY / 2, bottom: backFromVolumeButton.y + backFromVolumeButton.height * backFromVolumeButton.scaleY / 2 }; if (x >= volumeDecreaseButtonBounds.left && x <= volumeDecreaseButtonBounds.right && y >= volumeDecreaseButtonBounds.top && y <= volumeDecreaseButtonBounds.bottom) { musicVolume = Math.max(0.0, musicVolume - 0.1); volumeText.setText('Volumen: ' + Math.round(musicVolume * 100) + '%'); // Update music volume by restarting it with new volume LK.stopMusic(); if (musicVolume > 0) { LK.playMusic('NightChaos', { fade: { start: 0, end: musicVolume, duration: 500 } }); } } else if (x >= volumeIncreaseButtonBounds.left && x <= volumeIncreaseButtonBounds.right && y >= volumeIncreaseButtonBounds.top && y <= volumeIncreaseButtonBounds.bottom) { musicVolume = Math.min(1.0, musicVolume + 0.1); volumeText.setText('Volumen: ' + Math.round(musicVolume * 100) + '%'); // Update music volume by restarting it with new volume LK.stopMusic(); if (musicVolume > 0) { LK.playMusic('NightChaos', { fade: { start: 0, end: musicVolume, duration: 500 } }); } } else if (x >= backFromVolumeButtonBounds.left && x <= backFromVolumeButtonBounds.right && y >= backFromVolumeButtonBounds.top && y <= backFromVolumeButtonBounds.bottom) { backToPauseMenuFromVolume(); } } else if (gameState === 'chaos') { // Handle chaos screen interactions var chaosButtonBounds = { left: chaosScreenElements[2].x - chaosScreenElements[2].width * chaosScreenElements[2].scaleX / 2, right: chaosScreenElements[2].x + chaosScreenElements[2].width * chaosScreenElements[2].scaleX / 2, top: chaosScreenElements[2].y - chaosScreenElements[2].height * chaosScreenElements[2].scaleY / 2, bottom: chaosScreenElements[2].y + chaosScreenElements[2].height * chaosScreenElements[2].scaleY / 2 }; var backToChaosMenuButtonBounds = { left: chaosScreenElements[4].x - chaosScreenElements[4].width * chaosScreenElements[4].scaleX / 2, right: chaosScreenElements[4].x + chaosScreenElements[4].width * chaosScreenElements[4].scaleX / 2, top: chaosScreenElements[4].y - chaosScreenElements[4].height * chaosScreenElements[4].scaleY / 2, bottom: chaosScreenElements[4].y + chaosScreenElements[4].height * chaosScreenElements[4].scaleY / 2 }; if (x >= chaosButtonBounds.left && x <= chaosButtonBounds.right && y >= chaosButtonBounds.top && y <= chaosButtonBounds.bottom) { // CHAOS button clicked - open battle screen showBattleScreen(); } else if (x >= backToChaosMenuButtonBounds.left && x <= backToChaosMenuButtonBounds.right && y >= backToChaosMenuButtonBounds.top && y <= backToChaosMenuButtonBounds.bottom) { returnToMainMenuFromChaos(); } } else if (gameState === 'battle') { // Handle battle screen interactions if (battleScreenElements.length >= 5) { var battlePauseButton = battleScreenElements[3]; var battlePauseButtonBounds = { left: battlePauseButton.x - battlePauseButton.width * battlePauseButton.scaleX / 2, right: battlePauseButton.x + battlePauseButton.width * battlePauseButton.scaleX / 2, top: battlePauseButton.y - battlePauseButton.height * battlePauseButton.scaleY / 2, bottom: battlePauseButton.y + battlePauseButton.height * battlePauseButton.scaleY / 2 }; if (x >= battlePauseButtonBounds.left && x <= battlePauseButtonBounds.right && y >= battlePauseButtonBounds.top && y <= battlePauseButtonBounds.bottom) { exitBattleScreen(); } } } }; game.move = function (x, y, obj) { // Handle heart cursor movement in battle screen if (gameState === 'battle' && battleScreenElements.length >= 6) { var heartCursor = battleScreenElements[5]; var battleBox = battleScreenElements[1]; if (heartCursor && battleBox) { // Calculate the green rectangle boundaries within the battleBox // Make the heart movement area 2.2 times smaller (larger than before) var battleBoxWidth = battleBox.width * battleBox.scaleX; var battleBoxHeight = battleBox.height * battleBox.scaleY; var smallerWidth = battleBoxWidth / 2.2; var smallerHeight = battleBoxHeight / 1.8; // Make height area larger (1.8 instead of 2.2) var battleBoxLeft = battleBox.x - smallerWidth / 2; var battleBoxRight = battleBox.x + smallerWidth / 2; var battleBoxTop = battleBox.y - smallerHeight / 2; var battleBoxBottom = battleBox.y + smallerHeight / 2; // Constrain heart cursor within the adjusted green rectangle boundaries heartCursor.x = Math.max(battleBoxLeft, Math.min(x, battleBoxRight)); heartCursor.y = Math.max(battleBoxTop, Math.min(y, battleBoxBottom)); } } }; game.up = function (x, y, obj) { if (gameState === 'playing') { isDragging = false; } }; // Suika Game helper functions can be added here if needed // Main game update game.update = function () { // Animate fog elements in menu if (gameState === 'menu') { for (var i = 0; i < fogElements.length; i++) { var fog = fogElements[i]; fog.x += Math.cos(fog.fogDirection) * fog.fogSpeed; fog.y += Math.sin(fog.fogDirection) * fog.fogSpeed * 0.3; fog.alpha += Math.sin(LK.ticks * 0.02 + i) * 0.01; // Keep fog within bounds and wrap around if (fog.x < -100) fog.x = 2148; if (fog.x > 2148) fog.x = -100; if (fog.y < 1000) fog.y = 2200; if (fog.y > 2200) fog.y = 1000; } } if (gameState === 'playing') { // Handle circle merging var mergedCircles = []; var circlesToRemove = []; for (var i = circles.length - 1; i >= 0; i--) { var circle = circles[i]; if (circle.shouldMerge && circle.mergeInto) { // Only add the merged circle once if (mergedCircles.indexOf(circle.mergeInto) === -1) { game.addChild(circle.mergeInto); mergedCircles.push(circle.mergeInto); circles.push(circle.mergeInto); circle.mergeInto.lastY = circle.mergeInto.y; circle.mergeInto.lastIntersecting = false; // Set spawn immunity for merged circles circle.mergeInto.spawnImmunity = true; circle.mergeInto.spawnTime = LK.ticks; // Use tween to disable immunity after 3 seconds for merged circle var mergedImmunityObj = { immunity: 1 }; var mergedCircle = circle.mergeInto; // Capture reference before tween tween(mergedImmunityObj, { immunity: 0 }, { duration: 3000, onFinish: function onFinish() { if (mergedCircle) { mergedCircle.spawnImmunity = false; } } }); } // Mark circle for removal circlesToRemove.push(circle); } } // Remove all circles that merged for (var j = 0; j < circlesToRemove.length; j++) { var circleToRemove = circlesToRemove[j]; game.removeChild(circleToRemove); var index = circles.indexOf(circleToRemove); if (index > -1) { circles.splice(index, 1); } } // Check for game over (circle rises and touches the red line) for (var i = 0; i < circles.length; i++) { var circle = circles[i]; // Only trigger game over if circle touches the red line and this specific circle's immunity is not active if (circle.y - circle.radius <= containerY && !circle.spawnImmunity) { // Game over condition - circle touched the red line LK.showGameOver(); return; } } } if (gameState === 'battle' && battleScreenActive) { // Enemy shooting logic - shoot diamonds every 1.5 seconds (90 ticks) if (LK.ticks - lastEnemyShootTime >= 90) { lastEnemyShootTime = LK.ticks; // Get enemy position from battleScreenElements if (battleScreenElements.length >= 7) { var enemyCharacter = battleScreenElements[6]; var heartCursor = battleScreenElements[5]; // Get heart cursor reference // Create new diamond projectile var newDiamond = new EnemyDiamond(); newDiamond.x = enemyCharacter.x; newDiamond.y = enemyCharacter.y; newDiamond.lastX = newDiamond.x; newDiamond.lastY = newDiamond.y; // Calculate direction towards heart cursor var deltaX = heartCursor.x - enemyCharacter.x; var deltaY = heartCursor.y - enemyCharacter.y; var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); // Normalize direction and apply speed if (distance > 0) { newDiamond.velocityX = deltaX / distance * newDiamond.speed; newDiamond.velocityY = deltaY / distance * newDiamond.speed; // Calculate rotation angle to point diamond tip towards target var angle = Math.atan2(deltaY, deltaX); // Access the diamond graphics and set rotation var diamondGraphics = newDiamond.children[0]; if (diamondGraphics) { diamondGraphics.rotation = angle + Math.PI / 4; // Add base 45-degree rotation } } else { // Fallback to downward movement if positions are identical newDiamond.velocityX = 0; newDiamond.velocityY = newDiamond.speed; } game.addChild(newDiamond); enemyDiamonds.push(newDiamond); } } // Update and manage enemy diamonds for (var i = enemyDiamonds.length - 1; i >= 0; i--) { var diamond = enemyDiamonds[i]; // Check if diamond is off screen if (diamond.x < -50 || diamond.x > 2098 || diamond.y < -50 || diamond.y > 2782) { game.removeChild(diamond); enemyDiamonds.splice(i, 1); } } } };
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Circle = Container.expand(function (circleType) {
var self = Container.call(this);
var circleGraphics = self.attachAsset('circle' + circleType, {
anchorX: 0.5,
anchorY: 0.5
});
self.circleType = circleType;
self.size = circleType;
self.velocityX = 0;
self.velocityY = 0;
self.radius = [90, 120, 150, 180, 210, 240, 270, 320, 370][circleType - 1];
self.lastY = 0;
self.lastIntersecting = false;
self.spawnImmunity = false;
self.spawnTime = 0;
self.isSelected = false;
self.originalTint = 0xFFFFFF;
// Add selection handler
self.down = function (x, y, obj) {
if (selectionMode && gameState === 'playing') {
if (self.isSelected) {
// Deselect circle
self.isSelected = false;
circleGraphics.tint = self.originalTint;
var index = selectedCircles.indexOf(self);
if (index > -1) {
selectedCircles.splice(index, 1);
}
} else if (selectedCircles.length < maxSelectableCircles) {
// Select circle
self.isSelected = true;
circleGraphics.tint = 0xFF0000; // Red tint for selection
selectedCircles.push(self);
// If we have selected enough circles, remove them
if (selectedCircles.length >= maxSelectableCircles) {
// Deduct cost for using button1
score -= 750;
scoreText.setText('Score: ' + score);
scoreCounter.setText('Puntos: ' + score);
// Remove selected circles
for (var i = selectedCircles.length - 1; i >= 0; i--) {
var circle = selectedCircles[i];
game.removeChild(circle);
var circleIndex = circles.indexOf(circle);
if (circleIndex > -1) {
circles.splice(circleIndex, 1);
}
}
// Reset selection state
selectedCircles = [];
selectionMode = false;
}
}
}
};
self.update = function () {
// Apply gravity with slight variation based on size (heavier objects fall slightly faster)
var gravityForce = 0.4 + self.radius / 1000; // Larger circles have slightly more gravity
self.velocityY += gravityForce;
// Apply velocity
self.x += self.velocityX;
self.y += self.velocityY;
// Apply air resistance (less friction for more realistic movement)
self.velocityX *= 0.995; // Very slight air resistance
self.velocityY *= 0.999; // Even less resistance on Y axis
// Add rotation based on horizontal velocity to make circles look more natural
circleGraphics.rotation += self.velocityX * 0.01;
// Container collision detection
var containerLeft = containerX + 20;
var containerRight = containerX + containerWidth - 20;
var containerBottom = containerY + containerHeight - 20;
var containerTop = containerY;
// Side walls collision with improved bouncing
if (self.x - self.radius < containerLeft) {
self.x = containerLeft + self.radius;
self.velocityX = Math.abs(self.velocityX) * 0.7; // More bounce
}
if (self.x + self.radius > containerRight) {
self.x = containerRight - self.radius;
self.velocityX = -Math.abs(self.velocityX) * 0.7; // More bounce
}
// Allow circles to move above the container when spawning, no collision with top
// Bottom collision with better restitution
if (self.y + self.radius > containerBottom) {
self.y = containerBottom - self.radius;
// Add some bounce to vertical velocity instead of stopping completely
self.velocityY = -Math.abs(self.velocityY) * 0.3; // Small bounce
self.velocityX *= 0.85; // Less friction loss
}
// Circle-to-circle collision with other circles
for (var i = 0; i < circles.length; i++) {
var other = circles[i];
if (other !== self) {
var dx = self.x - other.x;
var dy = self.y - other.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Use consistent radius for collision detection
var minDistance = self.radius + other.radius;
if (distance < minDistance && distance > 0) {
// Same size circles merge
if (self.circleType === other.circleType && self.circleType < 9) {
// Prevent multiple merges of the same circles
if (self.shouldMerge || other.shouldMerge) {
return;
}
// Create new larger circle
var newCircle = new Circle(self.circleType + 1);
newCircle.x = (self.x + other.x) / 2;
newCircle.y = (self.y + other.y) / 2;
newCircle.velocityX = (self.velocityX + other.velocityX) / 2;
newCircle.velocityY = (self.velocityY + other.velocityY) / 2;
// Start small and animate to full size
newCircle.scaleX = 0.3;
newCircle.scaleY = 0.3;
tween(newCircle, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut
});
// Play fusion sound
LK.getSound('circleFusion').play();
// Mark both circles for merging into the same new circle
self.shouldMerge = true;
other.shouldMerge = true;
self.mergeInto = newCircle;
other.mergeInto = newCircle;
score += self.circleType * 10;
scoreText.setText('Score: ' + score);
scoreCounter.setText('Puntos: ' + score);
return;
}
// Simple and consistent collision response
var overlap = minDistance - distance;
var normalX = dx / distance;
var normalY = dy / distance;
// Calculate mass based on radius
var mass1 = self.radius;
var mass2 = other.radius;
var totalMass = mass1 + mass2;
// Separate circles proportionally to their masses
var pushForce = overlap * 0.5; // Split the overlap correction
var ratio1 = mass2 / totalMass; // Lighter objects move more
var ratio2 = mass1 / totalMass;
// Apply position correction with small buffer
var buffer = 2; // Small buffer to prevent immediate re-collision
var correctionX = normalX * (pushForce + buffer);
var correctionY = normalY * (pushForce + buffer);
self.x += correctionX * ratio1;
self.y += correctionY * ratio1;
other.x -= correctionX * ratio2;
other.y -= correctionY * ratio2;
// Keep circles within container bounds after collision
var containerLeft = containerX + 20;
var containerRight = containerX + containerWidth - 20;
var containerBottom = containerY + containerHeight - 20;
if (self.x - self.radius < containerLeft) {
self.x = containerLeft + self.radius;
}
if (self.x + self.radius > containerRight) {
self.x = containerRight - self.radius;
}
if (self.y + self.radius > containerBottom) {
self.y = containerBottom - self.radius;
}
if (other.x - other.radius < containerLeft) {
other.x = containerLeft + other.radius;
}
if (other.x + other.radius > containerRight) {
other.x = containerRight - other.radius;
}
if (other.y + other.radius > containerBottom) {
other.y = containerBottom - other.radius;
}
// Simple velocity exchange for realistic bouncing
var relativeVelocityX = self.velocityX - other.velocityX;
var relativeVelocityY = self.velocityY - other.velocityY;
var separatingVelocity = relativeVelocityX * normalX + relativeVelocityY * normalY;
// Only resolve if objects are moving towards each other
if (separatingVelocity < 0) {
var restitution = 0.6; // Moderate bounciness
var impulse = -(1 + restitution) * separatingVelocity / (1 / mass1 + 1 / mass2);
var impulseX = impulse * normalX;
var impulseY = impulse * normalY;
self.velocityX += impulseX / mass1;
self.velocityY += impulseY / mass1;
other.velocityX -= impulseX / mass2;
other.velocityY -= impulseY / mass2;
}
}
}
}
};
return self;
});
var EnemyDiamond = Container.expand(function () {
var self = Container.call(this);
var diamondGraphics = self.attachAsset('enemyDiamond', {
anchorX: 0.5,
anchorY: 0.5
});
// Rotate diamond 45 degrees to make it look like a diamond
diamondGraphics.rotation = Math.PI / 4;
self.speed = 3.5;
self.velocityX = 0;
self.velocityY = 0;
self.lastY = 0;
self.lastX = 0;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000011
});
/****
* Game Code
****/
// Keep menu assets
// Suika Game assets
// Game state management
var gameState = 'menu'; // 'menu', 'playing', 'paused', or 'settings'
var sensitivity = storage.sensitivity || 0.5; // Default sensitivity
// Suika Game variables
var containerX = (2048 - 1600) / 2;
var containerY = 200;
var containerWidth = 1600;
var containerHeight = 2000;
var circles = [];
var score = 0;
var nextCircleType = 1;
var currentCircle = null;
var dropLine = null;
var gameStarted = false;
// Individual circle immunity will be handled per circle
// Create container walls
var leftWall = LK.getAsset('containerWall', {
anchorX: 0,
anchorY: 0
});
leftWall.x = containerX;
leftWall.y = containerY;
var rightWall = LK.getAsset('containerWall', {
anchorX: 0,
anchorY: 0
});
rightWall.x = containerX + containerWidth - 20;
rightWall.y = containerY;
var bottomWall = LK.getAsset('containerBottom', {
anchorX: 0,
anchorY: 0
});
bottomWall.x = containerX;
bottomWall.y = containerY + containerHeight - 20;
var topWall = LK.getAsset('containerTop', {
anchorX: 0,
anchorY: 0
});
topWall.x = containerX;
topWall.y = containerY - 20;
// Score display
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0x000000
});
scoreText.anchor.set(0.5, 0);
scoreText.x = containerX + containerWidth / 2;
scoreText.y = containerY - 80; // Position above the red line
// Additional score counter above red line
var scoreCounter = new Text2('Puntos: 0', {
size: 50,
fill: 0xFFFFFF
});
scoreCounter.anchor.set(0.5, 0.5);
scoreCounter.x = containerX + containerWidth / 2;
scoreCounter.y = containerY - 40; // Just above the red line
// Next circle preview
var nextCirclePreview = LK.getAsset('nextCirclePreview', {
anchorX: 0.5,
anchorY: 0.5
});
nextCirclePreview.x = containerX + containerWidth + 100;
nextCirclePreview.y = 400;
var nextCircleText = new Text2('Next:', {
size: 40,
fill: 0x000000
});
nextCircleText.anchor.set(0.5, 0.5);
nextCircleText.x = nextCirclePreview.x;
nextCircleText.y = nextCirclePreview.y - 60;
// Create city background elements
var cityElements = [];
// Create starry night background
for (var i = 0; i < 100; i++) {
var star = LK.getAsset('nextCirclePreview', {
anchorX: 0.5,
anchorY: 0.5
});
star.x = Math.random() * 2048;
star.y = Math.random() * 1500; // Only in upper portion of screen
star.scaleX = 0.05 + Math.random() * 0.1;
star.scaleY = star.scaleX;
star.tint = 0xffffff;
star.alpha = 0.3 + Math.random() * 0.7;
game.addChild(star);
cityElements.push(star);
}
// Create buildings
for (var i = 0; i < 8; i++) {
var building = LK.getAsset('building', {
anchorX: 0.5,
anchorY: 1
});
building.x = i * 280 + 140;
building.y = 2732;
building.scaleX = 1 + Math.random() * 0.5;
building.scaleY = 1 + Math.random() * 1.2;
building.tint = 0x333333 + Math.random() * 0x333333; // Random dark colors
game.addChild(building);
cityElements.push(building);
}
// Create city fog/smog effects
var fogElements = [];
for (var i = 0; i < 6; i++) {
var fog = LK.getAsset('cityFog', {
anchorX: 0.5,
anchorY: 0.5
});
fog.x = Math.random() * 2048;
fog.y = 1800 + Math.random() * 400;
fog.tint = 0x666666; // Gray city smog
fog.alpha = 0.15 + Math.random() * 0.25;
fog.scaleX = 1 + Math.random() * 2;
fog.scaleY = 0.6 + Math.random() * 0.8;
fog.fogSpeed = 0.3 + Math.random() * 0.7;
fog.fogDirection = Math.random() * Math.PI * 2;
game.addChild(fog);
fogElements.push(fog);
}
// Create moon
var moon = LK.getAsset('moon', {
anchorX: 0.5,
anchorY: 0.5
});
moon.x = -100; // Start off-screen left
moon.y = 400; // Upper portion of screen
moon.scaleX = 1.2;
moon.scaleY = 1.2;
moon.alpha = 0.9;
moon.tint = 0xFFFFDD; // Slight cream color
// Moon click counter for easter egg
var moonClickCount = 0;
var moonClickTimeout = null;
// Chaos screen elements
var chaosScreenElements = [];
// Battle screen elements
var battleScreenElements = [];
var battleScreenActive = false;
var enemyDiamonds = [];
var lastEnemyShootTime = 0;
// Battle card elements
var battleCardElements = [];
// Character data for DELTARUNE-style cards
var characterData = [{
name: "KRIS",
hp: 90,
attack: 10,
defense: 2,
magic: 1,
portrait: 0x4a4a8a
}, {
name: "SUSIE",
hp: 110,
attack: 14,
defense: 0,
magic: 1,
portrait: 0x8a4a8a
}];
// Add click handler to moon
moon.down = function (x, y, obj) {
LK.getSound('moonClick').play();
// Create and display moon click image
var moonClickImage = LK.getAsset('moonClickImage', {
anchorX: 0.5,
anchorY: 0.5
});
moonClickImage.x = moon.x;
moonClickImage.y = moon.y;
moonClickImage.alpha = 0.8;
game.addChild(moonClickImage);
// Animate image to fade out and remove after 1.5 seconds
tween(moonClickImage, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
game.removeChild(moonClickImage);
}
});
// Easter egg: count moon clicks
moonClickCount++;
if (moonClickTimeout) {
LK.clearTimeout(moonClickTimeout);
}
// Reset counter after 3 seconds if no more clicks
moonClickTimeout = LK.setTimeout(function () {
moonClickCount = 0;
}, 3000);
// Check if clicked 3 times in a row
if (moonClickCount >= 3) {
moonClickCount = 0;
if (moonClickTimeout) {
LK.clearTimeout(moonClickTimeout);
moonClickTimeout = null;
}
showChaosScreen();
}
};
game.addChild(moon);
cityElements.push(moon);
// Animate moon movement across screen with arc trajectory
moon.y = 800; // Start much lower
var moonStartY = 800;
var moonMidY = 250; // Higher point at middle
var moonEndY = 800; // End at same height as start
// Function to create complete moon cycle
function startMoonCycle() {
// First half: move right and up to middle
tween(moon, {
x: 1024,
// Middle of screen (2048/2)
y: moonMidY
}, {
duration: 18000,
// 18 seconds to reach middle (slower)
easing: tween.easeOut,
onFinish: function onFinish() {
// Second half: move right and down to end
tween(moon, {
x: 2148,
y: moonEndY
}, {
duration: 18000,
// 18 seconds to reach end (slower)
easing: tween.easeIn,
onFinish: function onFinish() {
// Reset moon and start cycle again
moon.x = -100;
moon.y = moonStartY;
startMoonCycle();
}
});
}
});
}
// Start the moon cycle
startMoonCycle();
// Create start screen elements
var titleText = new Text2('The amazing digital chaos!', {
size: 120,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 2732 / 3;
var playButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
playButton.x = 2048 / 2;
playButton.y = 2732 / 2 - 100; // Move play button up
playButton.scaleX = 2.5; // Much larger
playButton.scaleY = 1.8; // Taller
// Add border effect with second button behind
var playButtonBorder = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
playButtonBorder.x = playButton.x;
playButtonBorder.y = playButton.y;
playButtonBorder.tint = 0x000000; // Black border
playButtonBorder.scaleX = 2.6; // Slightly larger for border
playButtonBorder.scaleY = 1.9;
game.addChild(playButtonBorder);
game.addChild(playButton); // Add main button after border
var playButtonText = new Text2('JUGAR', {
size: 100,
// Larger text
fill: 0x000000 // Black color
});
playButtonText.anchor.set(0.5, 0.5);
playButtonText.x = playButton.x;
playButtonText.y = playButton.y;
// Add start screen elements
game.addChild(titleText);
game.addChild(playButton);
game.addChild(playButtonText);
// Store references for easy removal (including city elements)
var menuElements = [titleText, playButtonBorder, playButton, playButtonText].concat(cityElements).concat(fogElements);
// Create pause button (only visible during gameplay)
var pauseButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
pauseButton.x = 2048 - 100;
pauseButton.y = 150;
pauseButton.tint = 0x666666;
pauseButton.scaleX = 0.8;
pauseButton.scaleY = 0.8;
var pauseButtonText = new Text2('||', {
size: 60,
fill: 0xFFFFFF
});
pauseButtonText.anchor.set(0.5, 0.5);
pauseButtonText.x = pauseButton.x;
pauseButtonText.y = pauseButton.y;
// Pause menu elements
var pauseMenuElements = [];
var pauseTitle = new Text2('PAUSA', {
size: 120,
fill: 0xFFD700
});
pauseTitle.anchor.set(0.5, 0.5);
pauseTitle.x = 2048 / 2;
pauseTitle.y = 800;
var resumeButton = LK.getAsset('continueButton', {
anchorX: 0.5,
anchorY: 0.5
});
resumeButton.x = 2048 / 2;
resumeButton.y = 1200;
resumeButton.scaleX = 2;
resumeButton.scaleY = 1.2;
var resumeButtonText = new Text2('CONTINUAR', {
size: 80,
fill: 0x000000
});
resumeButtonText.anchor.set(0.5, 0.5);
resumeButtonText.x = resumeButton.x;
resumeButtonText.y = resumeButton.y;
var menuButton = LK.getAsset('mainMenuButton', {
anchorX: 0.5,
anchorY: 0.5
});
menuButton.x = 2048 / 2;
menuButton.y = 1400;
menuButton.scaleX = 2;
menuButton.scaleY = 1.2;
var menuButtonText = new Text2('MENU PRINCIPAL', {
size: 70,
fill: 0x000000
});
menuButtonText.anchor.set(0.5, 0.5);
menuButtonText.x = menuButton.x;
menuButtonText.y = menuButton.y;
var restartButton = LK.getAsset('sensitivityButton', {
anchorX: 0.5,
anchorY: 0.5
});
restartButton.x = 2048 / 2;
restartButton.y = 1600;
restartButton.scaleX = 2;
restartButton.scaleY = 1.2;
var restartButtonText = new Text2('REINICIAR', {
size: 70,
fill: 0x000000
});
restartButtonText.anchor.set(0.5, 0.5);
restartButtonText.x = restartButton.x;
restartButtonText.y = restartButton.y;
var volumeButton = LK.getAsset('sensitivityButton', {
anchorX: 0.5,
anchorY: 0.5
});
volumeButton.x = 2048 / 2;
volumeButton.y = 1800;
volumeButton.scaleX = 2;
volumeButton.scaleY = 1.2;
var volumeButtonText = new Text2('VOLUMEN', {
size: 70,
fill: 0x000000
});
volumeButtonText.anchor.set(0.5, 0.5);
volumeButtonText.x = volumeButton.x;
volumeButtonText.y = volumeButton.y;
pauseMenuElements = [pauseTitle, resumeButton, resumeButtonText, menuButton, menuButtonText, restartButton, restartButtonText, volumeButton, volumeButtonText];
// Settings screen elements
var settingsScreenElements = [];
var settingsTitle = new Text2('AJUSTAR SENSIBILIDAD', {
size: 100,
fill: 0xFFD700
});
settingsTitle.anchor.set(0.5, 0.5);
settingsTitle.x = 2048 / 2;
settingsTitle.y = 800;
var sensitivityText = new Text2('Sensibilidad: ' + Math.round(sensitivity * 100) + '%', {
size: 80,
fill: 0xFFFFFF
});
sensitivityText.anchor.set(0.5, 0.5);
sensitivityText.x = 2048 / 2;
sensitivityText.y = 1200;
var decreaseButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
decreaseButton.x = 2048 / 2 - 200;
decreaseButton.y = 1400;
decreaseButton.tint = 0xFF4444;
decreaseButton.scaleX = 1.5;
decreaseButton.scaleY = 1.2;
var decreaseButtonText = new Text2('-', {
size: 100,
fill: 0xFFFFFF
});
decreaseButtonText.anchor.set(0.5, 0.5);
decreaseButtonText.x = decreaseButton.x;
decreaseButtonText.y = decreaseButton.y;
var increaseButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
increaseButton.x = 2048 / 2 + 200;
increaseButton.y = 1400;
increaseButton.tint = 0x44FF44;
increaseButton.scaleX = 1.5;
increaseButton.scaleY = 1.2;
var increaseButtonText = new Text2('+', {
size: 100,
fill: 0xFFFFFF
});
increaseButtonText.anchor.set(0.5, 0.5);
increaseButtonText.x = increaseButton.x;
increaseButtonText.y = increaseButton.y;
var backFromSettingsButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
backFromSettingsButton.x = 2048 / 2;
backFromSettingsButton.y = 1700;
backFromSettingsButton.tint = 0x888888;
backFromSettingsButton.scaleX = 1.8;
backFromSettingsButton.scaleY = 1.2;
var backFromSettingsButtonText = new Text2('VOLVER', {
size: 70,
fill: 0xFFFFFF
});
backFromSettingsButtonText.anchor.set(0.5, 0.5);
backFromSettingsButtonText.x = backFromSettingsButton.x;
backFromSettingsButtonText.y = backFromSettingsButton.y;
settingsScreenElements = [settingsTitle, sensitivityText, decreaseButton, decreaseButtonText, increaseButton, increaseButtonText, backFromSettingsButton, backFromSettingsButtonText];
// Volume control screen elements
var volumeScreenElements = [];
var volumeTitle = new Text2('AJUSTAR VOLUMEN', {
size: 100,
fill: 0xFFD700
});
volumeTitle.anchor.set(0.5, 0.5);
volumeTitle.x = 2048 / 2;
volumeTitle.y = 800;
var musicVolume = 0.5; // Default volume
var volumeText = new Text2('Volumen: ' + Math.round(musicVolume * 100) + '%', {
size: 80,
fill: 0xFFFFFF
});
volumeText.anchor.set(0.5, 0.5);
volumeText.x = 2048 / 2;
volumeText.y = 1200;
var volumeDecreaseButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
volumeDecreaseButton.x = 2048 / 2 - 200;
volumeDecreaseButton.y = 1400;
volumeDecreaseButton.tint = 0xFF4444;
volumeDecreaseButton.scaleX = 1.5;
volumeDecreaseButton.scaleY = 1.2;
var volumeDecreaseButtonText = new Text2('-', {
size: 100,
fill: 0xFFFFFF
});
volumeDecreaseButtonText.anchor.set(0.5, 0.5);
volumeDecreaseButtonText.x = volumeDecreaseButton.x;
volumeDecreaseButtonText.y = volumeDecreaseButton.y;
var volumeIncreaseButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
volumeIncreaseButton.x = 2048 / 2 + 200;
volumeIncreaseButton.y = 1400;
volumeIncreaseButton.tint = 0x44FF44;
volumeIncreaseButton.scaleX = 1.5;
volumeIncreaseButton.scaleY = 1.2;
var volumeIncreaseButtonText = new Text2('+', {
size: 100,
fill: 0xFFFFFF
});
volumeIncreaseButtonText.anchor.set(0.5, 0.5);
volumeIncreaseButtonText.x = volumeIncreaseButton.x;
volumeIncreaseButtonText.y = volumeIncreaseButton.y;
var backFromVolumeButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
backFromVolumeButton.x = 2048 / 2;
backFromVolumeButton.y = 1700;
backFromVolumeButton.tint = 0x888888;
backFromVolumeButton.scaleX = 1.8;
backFromVolumeButton.scaleY = 1.2;
var backFromVolumeButtonText = new Text2('VOLVER', {
size: 70,
fill: 0xFFFFFF
});
backFromVolumeButtonText.anchor.set(0.5, 0.5);
backFromVolumeButtonText.x = backFromVolumeButton.x;
backFromVolumeButtonText.y = backFromVolumeButton.y;
volumeScreenElements = [volumeTitle, volumeText, volumeDecreaseButton, volumeDecreaseButtonText, volumeIncreaseButton, volumeIncreaseButtonText, backFromVolumeButton, backFromVolumeButtonText];
// Function to show chaos screen (easter egg)
function showChaosScreen() {
gameState = 'chaos';
// Remove menu elements
for (var i = 0; i < menuElements.length; i++) {
game.removeChild(menuElements[i]);
}
// Create chaos screen elements
var chaosTitle = new Text2('EASTER EGG FOUND!', {
size: 100,
fill: 0xFF0000
});
chaosTitle.anchor.set(0.5, 0.5);
chaosTitle.x = 2048 / 2;
chaosTitle.y = 800;
var chaosSubtitle = new Text2('Welcome to the secret screen', {
size: 60,
fill: 0xFFFFFF
});
chaosSubtitle.anchor.set(0.5, 0.5);
chaosSubtitle.x = 2048 / 2;
chaosSubtitle.y = 1000;
var chaosButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
chaosButton.x = 2048 / 2;
chaosButton.y = 1400;
chaosButton.tint = 0x8B0000; // Dark red
chaosButton.scaleX = 2.5;
chaosButton.scaleY = 1.8;
var chaosButtonText = new Text2('CHAOS', {
size: 100,
fill: 0xFFFFFF
});
chaosButtonText.anchor.set(0.5, 0.5);
chaosButtonText.x = chaosButton.x;
chaosButtonText.y = chaosButton.y;
var backToChaosMenuButton = LK.getAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
backToChaosMenuButton.x = 2048 / 2;
backToChaosMenuButton.y = 1700;
backToChaosMenuButton.tint = 0x888888;
backToChaosMenuButton.scaleX = 1.8;
backToChaosMenuButton.scaleY = 1.2;
var backToChaosMenuButtonText = new Text2('VOLVER', {
size: 70,
fill: 0xFFFFFF
});
backToChaosMenuButtonText.anchor.set(0.5, 0.5);
backToChaosMenuButtonText.x = backToChaosMenuButton.x;
backToChaosMenuButtonText.y = backToChaosMenuButton.y;
chaosScreenElements = [chaosTitle, chaosSubtitle, chaosButton, chaosButtonText, backToChaosMenuButton, backToChaosMenuButtonText];
// Add chaos screen elements
for (var i = 0; i < chaosScreenElements.length; i++) {
game.addChild(chaosScreenElements[i]);
}
}
// Function to return to main menu from chaos screen
function returnToMainMenuFromChaos() {
gameState = 'menu';
// Remove chaos screen elements
for (var i = 0; i < chaosScreenElements.length; i++) {
game.removeChild(chaosScreenElements[i]);
}
// Add menu elements back
for (var i = 0; i < menuElements.length; i++) {
game.addChild(menuElements[i]);
}
}
// Function to create character battle cards
function createBattleCards() {
battleCardElements = [];
for (var i = 0; i < characterData.length; i++) {
var character = characterData[i];
var cardX = 512 + i * 1024; // Position cards to occupy full width
var cardY = 2400; // Position cards at bottom of screen
// Resize cards to be wider and fit screen width
var cardWidth = 950; // Wider cards
var cardHeight = 300; // Shorter cards for bottom positioning
// Create card border (white background)
var cardBorder = LK.getAsset('characterCardBorder', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: cardWidth / 310,
scaleY: cardHeight / 410
});
cardBorder.x = cardX;
cardBorder.y = cardY;
// Create main card background
var cardBg = LK.getAsset('characterCard', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: cardWidth / 300,
scaleY: cardHeight / 400
});
cardBg.x = cardX;
cardBg.y = cardY;
// Create character portrait (smaller and positioned to the left)
var portrait = LK.getAsset('characterPortrait', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
portrait.x = cardX - 300;
portrait.y = cardY - 20;
portrait.tint = character.portrait;
// Create character name text (positioned above portrait)
var nameText = new Text2(character.name, {
size: 45,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameText.x = cardX - 300;
nameText.y = cardY - 100;
// Create HP text (positioned to the right of portrait)
var hpText = new Text2('HP: ' + character.hp, {
size: 32,
fill: 0xFF4444
});
hpText.anchor.set(0.5, 0.5);
hpText.x = cardX - 100;
hpText.y = cardY - 60;
// Create Attack text
var attackText = new Text2('ATK: ' + character.attack, {
size: 32,
fill: 0xFFAA44
});
attackText.anchor.set(0.5, 0.5);
attackText.x = cardX - 100;
attackText.y = cardY - 20;
// Create Defense text
var defenseText = new Text2('DEF: ' + character.defense, {
size: 32,
fill: 0x44AAFF
});
defenseText.anchor.set(0.5, 0.5);
defenseText.x = cardX - 100;
defenseText.y = cardY + 20;
// Create action buttons for each character
var buttonSize = 80;
var buttonSpacing = 90;
var startX = cardX + 80;
var buttonY = cardY;
// ATACAR button
var attackButton = LK.getAsset('characterNameBg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: buttonSize / 280,
scaleY: buttonSize / 60
});
attackButton.x = startX;
attackButton.y = buttonY - 40;
attackButton.tint = 0xFF4444;
var attackButtonText = new Text2('ATACAR', {
size: 20,
fill: 0xFFFFFF
});
attackButtonText.anchor.set(0.5, 0.5);
attackButtonText.x = attackButton.x;
attackButtonText.y = attackButton.y;
// ACTUAR button
var actButton = LK.getAsset('characterNameBg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: buttonSize / 280,
scaleY: buttonSize / 60
});
actButton.x = startX + buttonSpacing;
actButton.y = buttonY - 40;
actButton.tint = 0x44AA44;
var actButtonText = new Text2('ACTUAR', {
size: 20,
fill: 0xFFFFFF
});
actButtonText.anchor.set(0.5, 0.5);
actButtonText.x = actButton.x;
actButtonText.y = actButton.y;
// COMIDA button
var foodButton = LK.getAsset('characterNameBg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: buttonSize / 280,
scaleY: buttonSize / 60
});
foodButton.x = startX;
foodButton.y = buttonY + 40;
foodButton.tint = 0xFFAA44;
var foodButtonText = new Text2('COMIDA', {
size: 20,
fill: 0xFFFFFF
});
foodButtonText.anchor.set(0.5, 0.5);
foodButtonText.x = foodButton.x;
foodButtonText.y = foodButton.y;
// DEFENSA button
var defenseButton = LK.getAsset('characterNameBg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: buttonSize / 280,
scaleY: buttonSize / 60
});
defenseButton.x = startX + buttonSpacing;
defenseButton.y = buttonY + 40;
defenseButton.tint = 0x4444FF;
var defenseButtonText = new Text2('DEFENSA', {
size: 20,
fill: 0xFFFFFF
});
defenseButtonText.anchor.set(0.5, 0.5);
defenseButtonText.x = defenseButton.x;
defenseButtonText.y = defenseButton.y;
// Store all card elements including action buttons
battleCardElements.push(cardBorder, cardBg, portrait, nameText, hpText, attackText, defenseText, attackButton, attackButtonText, actButton, actButtonText, foodButton, foodButtonText, defenseButton, defenseButtonText);
}
}
// Function to show DELTARUNE-style battle screen
function showBattleScreen() {
gameState = 'battle';
battleScreenActive = true;
// Remove chaos screen elements
for (var i = 0; i < chaosScreenElements.length; i++) {
game.removeChild(chaosScreenElements[i]);
}
// Create battle screen background
var battleBackground = LK.getAsset('battleBackground', {
anchorX: 0,
anchorY: 0
});
battleBackground.x = 0;
battleBackground.y = 0;
// Create battle dialogue box
var battleBox = LK.getAsset('battleBox', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4.2,
scaleY: 8.0
});
battleBox.x = 2048 / 2;
battleBox.y = 2732 / 2;
// Create enemy character above battle box
var enemyCharacter = LK.getAsset('characterPortrait', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
enemyCharacter.x = battleBox.x;
enemyCharacter.y = battleBox.y - 700; // Position higher above battle box (3-4 cm more separation)
// enemyCharacter.tint = 0x8B0080; // Purple alien color - removed to show original image
// Add levitation animation to make enemy look powerful
var enemyBaseY = enemyCharacter.y;
var enemyBaseX = enemyCharacter.x;
function startEnemyLevitation() {
// Generate random offsets for movement
var randomXOffset = (Math.random() - 0.5) * 80; // Random X between -40 and 40
var randomYOffset = (Math.random() - 0.5) * 60; // Random Y between -30 and 30
var randomDuration = 800 + Math.random() * 600; // Random duration between 0.8-1.4 seconds (faster)
// Determine direction based on X movement and flip enemy accordingly
if (randomXOffset > 0) {
// Moving right - show normal image (not flipped)
enemyCharacter.scaleX = Math.abs(enemyCharacter.scaleX);
} else if (randomXOffset < 0) {
// Moving left - flip image horizontally
enemyCharacter.scaleX = -Math.abs(enemyCharacter.scaleX);
}
// Move to random position around base location
tween(enemyCharacter, {
y: enemyBaseY + randomYOffset,
x: enemyBaseX + randomXOffset
}, {
duration: randomDuration,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Continue the cycle with new random movement
startEnemyLevitation();
}
});
}
// Start the levitation animation
startEnemyLevitation();
// Create battle text
var battleText = new Text2('* Choose your fighters for battle!', {
size: 50,
fill: 0x000000
});
battleText.anchor.set(0.5, 0.5);
battleText.x = battleBox.x;
battleText.y = battleBox.y;
// Create pause button in top right corner
var battlePauseButton = LK.getAsset('battlePauseButton', {
anchorX: 0.5,
anchorY: 0.5
});
battlePauseButton.x = 2048 - 80;
battlePauseButton.y = 80;
var battlePauseButtonText = new Text2('EXIT', {
size: 30,
fill: 0xFFFFFF
});
battlePauseButtonText.anchor.set(0.5, 0.5);
battlePauseButtonText.x = battlePauseButton.x;
battlePauseButtonText.y = battlePauseButton.y;
// Create heart cursor (player soul)
var heartCursor = LK.getAsset('heartCursor', {
anchorX: 0.5,
anchorY: 0.5
});
heartCursor.x = battleBox.x;
heartCursor.y = battleBox.y;
heartCursor.scaleX = 1.2;
heartCursor.scaleY = 1.2;
battleScreenElements = [battleBackground, battleBox, battleText, battlePauseButton, battlePauseButtonText, heartCursor, enemyCharacter];
// Add battle screen elements
for (var i = 0; i < battleScreenElements.length; i++) {
game.addChild(battleScreenElements[i]);
}
// Create and add character cards
createBattleCards();
for (var i = 0; i < battleCardElements.length; i++) {
game.addChild(battleCardElements[i]);
}
}
// Function to exit battle screen
function exitBattleScreen() {
gameState = 'chaos';
battleScreenActive = false;
// Remove battle screen elements
for (var i = 0; i < battleScreenElements.length; i++) {
game.removeChild(battleScreenElements[i]);
}
// Remove battle card elements
for (var i = 0; i < battleCardElements.length; i++) {
game.removeChild(battleCardElements[i]);
}
battleCardElements = [];
// Remove all enemy diamonds
for (var i = 0; i < enemyDiamonds.length; i++) {
game.removeChild(enemyDiamonds[i]);
}
enemyDiamonds = [];
// Return to chaos screen
for (var i = 0; i < chaosScreenElements.length; i++) {
game.addChild(chaosScreenElements[i]);
}
}
// Function to start the game
function startGame() {
gameState = 'playing';
// Remove menu elements
for (var i = 0; i < menuElements.length; i++) {
game.removeChild(menuElements[i]);
}
// Add game elements
game.addChild(leftWall);
game.addChild(rightWall);
game.addChild(bottomWall);
game.addChild(topWall);
game.addChild(scoreText);
game.addChild(scoreCounter);
game.addChild(nextCirclePreview);
game.addChild(nextCircleText);
// Add pause button
game.addChild(pauseButton);
game.addChild(pauseButtonText);
// Create wooden board below container
woodenBoard = LK.getAsset('woodenBoard', {
anchorX: 0.5,
anchorY: 0
});
woodenBoard.x = containerX + containerWidth / 2;
woodenBoard.y = containerY + containerHeight + 50;
game.addChild(woodenBoard);
// Create 3 buttons on the wooden board
button1 = LK.getAsset('button1', {
anchorX: 0.5,
anchorY: 0.5
});
button1.x = woodenBoard.x - 400;
button1.y = woodenBoard.y + 100;
game.addChild(button1);
button1CostText = new Text2('750 puntos', {
size: 60,
fill: 0xFFD700
});
button1CostText.anchor.set(0.5, 0.5);
button1CostText.x = button1.x;
button1CostText.y = button1.y + 140;
game.addChild(button1CostText);
button2 = LK.getAsset('button2', {
anchorX: 0.5,
anchorY: 0.5
});
button2.x = woodenBoard.x;
button2.y = woodenBoard.y + 100;
game.addChild(button2);
button2CostText = new Text2('650 puntos', {
size: 60,
fill: 0xFFD700
});
button2CostText.anchor.set(0.5, 0.5);
button2CostText.x = button2.x;
button2CostText.y = button2.y + 140;
game.addChild(button2CostText);
button3 = LK.getAsset('button3', {
anchorX: 0.5,
anchorY: 0.5
});
button3.x = woodenBoard.x + 400;
button3.y = woodenBoard.y + 100;
game.addChild(button3);
button3CostText = new Text2('9,999 puntos', {
size: 60,
fill: 0xFFD700
});
button3CostText.anchor.set(0.5, 0.5);
button3CostText.x = button3.x;
button3CostText.y = button3.y + 140;
game.addChild(button3CostText);
// Initialize first circle
generateNextCircle();
gameStarted = true;
// Start playing background music
LK.playMusic('NightChaos');
}
// Function to show pause menu
function showPauseMenu() {
gameState = 'paused';
// Add pause menu elements
for (var i = 0; i < pauseMenuElements.length; i++) {
game.addChild(pauseMenuElements[i]);
}
}
// Function to resume game
function resumeGame() {
gameState = 'playing';
// Remove pause menu elements
for (var i = 0; i < pauseMenuElements.length; i++) {
game.removeChild(pauseMenuElements[i]);
}
}
// Function to show settings screen
function showSettings() {
gameState = 'settings';
// Remove pause menu elements
for (var i = 0; i < pauseMenuElements.length; i++) {
game.removeChild(pauseMenuElements[i]);
}
// Add settings elements
for (var i = 0; i < settingsScreenElements.length; i++) {
game.addChild(settingsScreenElements[i]);
}
}
// Function to go back to pause menu from settings
function backToPauseMenu() {
gameState = 'paused';
// Remove settings elements
for (var i = 0; i < settingsScreenElements.length; i++) {
game.removeChild(settingsScreenElements[i]);
}
// Add pause menu elements
for (var i = 0; i < pauseMenuElements.length; i++) {
game.addChild(pauseMenuElements[i]);
}
}
// Function to show volume control screen
function showVolumeControl() {
gameState = 'volume';
// Remove pause menu elements
for (var i = 0; i < pauseMenuElements.length; i++) {
game.removeChild(pauseMenuElements[i]);
}
// Add volume control elements
for (var i = 0; i < volumeScreenElements.length; i++) {
game.addChild(volumeScreenElements[i]);
}
}
// Function to go back to pause menu from volume control
function backToPauseMenuFromVolume() {
gameState = 'paused';
// Remove volume control elements
for (var i = 0; i < volumeScreenElements.length; i++) {
game.removeChild(volumeScreenElements[i]);
}
// Add pause menu elements
for (var i = 0; i < pauseMenuElements.length; i++) {
game.addChild(pauseMenuElements[i]);
}
}
// Function to restart game
function restartGame() {
gameState = 'playing';
// Remove pause menu elements
for (var i = 0; i < pauseMenuElements.length; i++) {
game.removeChild(pauseMenuElements[i]);
}
// Remove all circles
for (var i = 0; i < circles.length; i++) {
game.removeChild(circles[i]);
}
circles = [];
if (currentCircle) {
game.removeChild(currentCircle);
currentCircle = null;
}
if (dropLine) {
game.removeChild(dropLine);
dropLine = null;
}
// Reset game state
score = 0;
nextCircleType = 1;
scoreText.setText('Score: 0');
scoreCounter.setText('Puntos: 0');
// Generate new next circle
generateNextCircle();
gameStarted = true;
}
// Function to return to main menu from pause
function returnToMainMenu() {
gameState = 'menu';
// Remove pause menu elements
for (var i = 0; i < pauseMenuElements.length; i++) {
game.removeChild(pauseMenuElements[i]);
}
// Remove game elements
game.removeChild(leftWall);
game.removeChild(rightWall);
game.removeChild(bottomWall);
game.removeChild(topWall);
game.removeChild(scoreText);
game.removeChild(scoreCounter);
game.removeChild(nextCirclePreview);
game.removeChild(nextCircleText);
if (currentCircle) {
game.removeChild(currentCircle);
currentCircle = null;
}
if (dropLine) {
game.removeChild(dropLine);
dropLine = null;
}
// Remove all circles
for (var i = 0; i < circles.length; i++) {
game.removeChild(circles[i]);
}
circles = [];
game.removeChild(pauseButton);
game.removeChild(pauseButtonText);
// Remove wooden board and buttons
if (woodenBoard) {
game.removeChild(woodenBoard);
}
if (button1) {
game.removeChild(button1);
if (button1CostText) {
game.removeChild(button1CostText);
}
}
if (button2) {
game.removeChild(button2);
if (button2CostText) {
game.removeChild(button2CostText);
}
}
if (button3) {
game.removeChild(button3);
if (button3CostText) {
game.removeChild(button3CostText);
}
}
// Reset game state
score = 0;
nextCircleType = 1;
gameStarted = false;
// Add menu elements back
for (var i = 0; i < menuElements.length; i++) {
game.addChild(menuElements[i]);
}
}
// Movement controls
var keys = {
up: false,
down: false,
left: false,
right: false
};
// Touch/mouse controls
var isDragging = false;
var lastTouchX = 0;
var lastTouchY = 0;
// Wooden board and buttons
var woodenBoard = null;
var button1 = null;
var button1CostText = null;
var button2 = null;
var button2Text = null;
var button2CostText = null;
var button3 = null;
var button3Text = null;
var button3CostText = null;
// Circle selection system
var selectionMode = false;
var selectedCircles = [];
var maxSelectableCircles = 2;
function generateNextCircle() {
nextCircleType = Math.floor(Math.random() * 3) + 1; // Random circle type 1-3 only
// Update preview
game.removeChild(nextCirclePreview);
nextCirclePreview = LK.getAsset('circle' + nextCircleType, {
anchorX: 0.5,
anchorY: 0.5
});
nextCirclePreview.x = containerX + containerWidth + 100;
nextCirclePreview.y = 400;
nextCirclePreview.scaleX = 0.6;
nextCirclePreview.scaleY = 0.6;
game.addChild(nextCirclePreview);
}
game.down = function (x, y, obj) {
if (gameState === 'menu') {
// Check if play button was clicked
var playButtonBounds = {
left: playButton.x - playButton.width * playButton.scaleX / 2,
right: playButton.x + playButton.width * playButton.scaleX / 2,
top: playButton.y - playButton.height * playButton.scaleY / 2,
bottom: playButton.y + playButton.height * playButton.scaleY / 2
};
if (x >= playButtonBounds.left && x <= playButtonBounds.right && y >= playButtonBounds.top && y <= playButtonBounds.bottom) {
startGame();
}
} else if (gameState === 'playing') {
// Check if pause button was clicked
var pauseButtonBounds = {
left: pauseButton.x - pauseButton.width * pauseButton.scaleX / 2,
right: pauseButton.x + pauseButton.width * pauseButton.scaleX / 2,
top: pauseButton.y - pauseButton.height * pauseButton.scaleY / 2,
bottom: pauseButton.y + pauseButton.height * pauseButton.scaleY / 2
};
if (x >= pauseButtonBounds.left && x <= pauseButtonBounds.right && y >= pauseButtonBounds.top && y <= pauseButtonBounds.bottom) {
showPauseMenu();
} else {
// Check if button1 was clicked (only if button1 exists)
if (button1) {
var button1Bounds = {
left: button1.x - button1.width * button1.scaleX / 2,
right: button1.x + button1.width * button1.scaleX / 2,
top: button1.y - button1.height * button1.scaleY / 2,
bottom: button1.y + button1.height * button1.scaleY / 2
};
if (x >= button1Bounds.left && x <= button1Bounds.right && y >= button1Bounds.top && y <= button1Bounds.bottom) {
// Check if player has enough points to use button1
if (score < 750) {
// Show feedback that player doesn't have enough points
// Could add visual/audio feedback here in the future
return;
}
// Play exchange sound when button1 is pressed
LK.getSound('button1Exchange').play();
// Enable selection mode
if (!selectionMode) {
selectionMode = true;
selectedCircles = [];
} else {
// Cancel selection mode
selectionMode = false;
// Reset all selected circles
for (var i = 0; i < selectedCircles.length; i++) {
var circle = selectedCircles[i];
circle.isSelected = false;
var circleGraphics = circle.children[0];
if (circleGraphics) {
circleGraphics.tint = circle.originalTint;
}
}
selectedCircles = [];
}
}
}
// Check if button2 was clicked (only if button2 exists)
if (button2) {
var button2Bounds = {
left: button2.x - button2.width * button2.scaleX / 2,
right: button2.x + button2.width * button2.scaleX / 2,
top: button2.y - button2.height * button2.scaleY / 2,
bottom: button2.y + button2.height * button2.scaleY / 2
};
if (x >= button2Bounds.left && x <= button2Bounds.right && y >= button2Bounds.top && y <= button2Bounds.bottom) {
// Check if player has enough points to use button2
if (score < 650) {
// Show feedback that player doesn't have enough points
return;
}
// Deduct cost for using button2
score -= 650;
scoreText.setText('Score: ' + score);
scoreCounter.setText('Puntos: ' + score);
// Only swap positions if there are at least 2 circles in the container
if (circles.length >= 2) {
// Create array of current positions
var positions = [];
for (var i = 0; i < circles.length; i++) {
positions.push({
x: circles[i].x,
y: circles[i].y
});
}
// Shuffle the positions array
for (var i = positions.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = positions[i];
positions[i] = positions[j];
positions[j] = temp;
}
// Instantly set each circle to its new position
for (var i = 0; i < circles.length; i++) {
var circle = circles[i];
var newPos = positions[i];
// Set position instantly without animation
circle.x = newPos.x;
circle.y = newPos.y;
}
}
}
}
// Check if button3 was clicked (only if button3 exists)
if (button3) {
var button3Bounds = {
left: button3.x - button3.width * button3.scaleX / 2,
right: button3.x + button3.width * button3.scaleX / 2,
top: button3.y - button3.height * button3.scaleY / 2,
bottom: button3.y + button3.height * button3.scaleY / 2
};
if (x >= button3Bounds.left && x <= button3Bounds.right && y >= button3Bounds.top && y <= button3Bounds.bottom) {
// Check if player has enough points to use button3
if (score < 9999) {
// Show feedback that player doesn't have enough points
return;
}
// Deduct cost for using button3
score -= 9999;
scoreText.setText('Score: ' + score);
scoreCounter.setText('Puntos: ' + score);
// Show victory screen
LK.showYouWin();
}
}
// Check if click is inside the container (frasco) boundaries and not in selection mode
if (!selectionMode && x >= containerX + 20 && x <= containerX + containerWidth - 20 && y >= containerY && y <= containerY + containerHeight - 20) {
// Create and drop a circle
var newCircle = new Circle(nextCircleType);
newCircle.x = Math.max(containerX + 50, Math.min(x, containerX + containerWidth - 50));
newCircle.y = containerY - 100; // Spawn above the red line
newCircle.velocityY = 2;
newCircle.velocityX = 0;
newCircle.lastY = newCircle.y;
newCircle.lastIntersecting = false;
// Set individual spawn immunity for this circle
newCircle.spawnImmunity = true;
newCircle.spawnTime = LK.ticks;
game.addChild(newCircle);
circles.push(newCircle);
// Use tween to disable immunity after 3 seconds for this specific circle
var immunityObj = {
immunity: 1
};
tween(immunityObj, {
immunity: 0
}, {
duration: 3000,
onFinish: function onFinish() {
newCircle.spawnImmunity = false;
}
});
generateNextCircle();
}
}
} else if (gameState === 'paused') {
// Handle pause menu interactions
var resumeButtonBounds = {
left: resumeButton.x - resumeButton.width * resumeButton.scaleX / 2,
right: resumeButton.x + resumeButton.width * resumeButton.scaleX / 2,
top: resumeButton.y - resumeButton.height * resumeButton.scaleY / 2,
bottom: resumeButton.y + resumeButton.height * resumeButton.scaleY / 2
};
var menuButtonBounds = {
left: menuButton.x - menuButton.width * menuButton.scaleX / 2,
right: menuButton.x + menuButton.width * menuButton.scaleX / 2,
top: menuButton.y - menuButton.height * menuButton.scaleY / 2,
bottom: menuButton.y + menuButton.height * menuButton.scaleY / 2
};
var restartButtonBounds = {
left: restartButton.x - restartButton.width * restartButton.scaleX / 2,
right: restartButton.x + restartButton.width * restartButton.scaleX / 2,
top: restartButton.y - restartButton.height * restartButton.scaleY / 2,
bottom: restartButton.y + restartButton.height * restartButton.scaleY / 2
};
var volumeButtonBounds = {
left: volumeButton.x - volumeButton.width * volumeButton.scaleX / 2,
right: volumeButton.x + volumeButton.width * volumeButton.scaleX / 2,
top: volumeButton.y - volumeButton.height * volumeButton.scaleY / 2,
bottom: volumeButton.y + volumeButton.height * volumeButton.scaleY / 2
};
if (x >= resumeButtonBounds.left && x <= resumeButtonBounds.right && y >= resumeButtonBounds.top && y <= resumeButtonBounds.bottom) {
resumeGame();
} else if (x >= menuButtonBounds.left && x <= menuButtonBounds.right && y >= menuButtonBounds.top && y <= menuButtonBounds.bottom) {
returnToMainMenu();
} else if (x >= restartButtonBounds.left && x <= restartButtonBounds.right && y >= restartButtonBounds.top && y <= restartButtonBounds.bottom) {
restartGame();
} else if (x >= volumeButtonBounds.left && x <= volumeButtonBounds.right && y >= volumeButtonBounds.top && y <= volumeButtonBounds.bottom) {
showVolumeControl();
}
} else if (gameState === 'settings') {
// Handle settings interactions
var decreaseButtonBounds = {
left: decreaseButton.x - decreaseButton.width * decreaseButton.scaleX / 2,
right: decreaseButton.x + decreaseButton.width * decreaseButton.scaleX / 2,
top: decreaseButton.y - decreaseButton.height * decreaseButton.scaleY / 2,
bottom: decreaseButton.y + decreaseButton.height * decreaseButton.scaleY / 2
};
var increaseButtonBounds = {
left: increaseButton.x - increaseButton.width * increaseButton.scaleX / 2,
right: increaseButton.x + increaseButton.width * increaseButton.scaleX / 2,
top: increaseButton.y - increaseButton.height * increaseButton.scaleY / 2,
bottom: increaseButton.y + increaseButton.height * increaseButton.scaleY / 2
};
var backFromSettingsButtonBounds = {
left: backFromSettingsButton.x - backFromSettingsButton.width * backFromSettingsButton.scaleX / 2,
right: backFromSettingsButton.x + backFromSettingsButton.width * backFromSettingsButton.scaleX / 2,
top: backFromSettingsButton.y - backFromSettingsButton.height * backFromSettingsButton.scaleY / 2,
bottom: backFromSettingsButton.y + backFromSettingsButton.height * backFromSettingsButton.scaleY / 2
};
if (x >= decreaseButtonBounds.left && x <= decreaseButtonBounds.right && y >= decreaseButtonBounds.top && y <= decreaseButtonBounds.bottom) {
sensitivity = Math.max(0.1, sensitivity - 0.1);
storage.sensitivity = sensitivity;
sensitivityText.setText('Sensibilidad: ' + Math.round(sensitivity * 100) + '%');
} else if (x >= increaseButtonBounds.left && x <= increaseButtonBounds.right && y >= increaseButtonBounds.top && y <= increaseButtonBounds.bottom) {
sensitivity = Math.min(1.0, sensitivity + 0.1);
storage.sensitivity = sensitivity;
sensitivityText.setText('Sensibilidad: ' + Math.round(sensitivity * 100) + '%');
} else if (x >= backFromSettingsButtonBounds.left && x <= backFromSettingsButtonBounds.right && y >= backFromSettingsButtonBounds.top && y <= backFromSettingsButtonBounds.bottom) {
backToPauseMenu();
}
} else if (gameState === 'volume') {
// Handle volume control interactions
var volumeDecreaseButtonBounds = {
left: volumeDecreaseButton.x - volumeDecreaseButton.width * volumeDecreaseButton.scaleX / 2,
right: volumeDecreaseButton.x + volumeDecreaseButton.width * volumeDecreaseButton.scaleX / 2,
top: volumeDecreaseButton.y - volumeDecreaseButton.height * volumeDecreaseButton.scaleY / 2,
bottom: volumeDecreaseButton.y + volumeDecreaseButton.height * volumeDecreaseButton.scaleY / 2
};
var volumeIncreaseButtonBounds = {
left: volumeIncreaseButton.x - volumeIncreaseButton.width * volumeIncreaseButton.scaleX / 2,
right: volumeIncreaseButton.x + volumeIncreaseButton.width * volumeIncreaseButton.scaleX / 2,
top: volumeIncreaseButton.y - volumeIncreaseButton.height * volumeIncreaseButton.scaleY / 2,
bottom: volumeIncreaseButton.y + volumeIncreaseButton.height * volumeIncreaseButton.scaleY / 2
};
var backFromVolumeButtonBounds = {
left: backFromVolumeButton.x - backFromVolumeButton.width * backFromVolumeButton.scaleX / 2,
right: backFromVolumeButton.x + backFromVolumeButton.width * backFromVolumeButton.scaleX / 2,
top: backFromVolumeButton.y - backFromVolumeButton.height * backFromVolumeButton.scaleY / 2,
bottom: backFromVolumeButton.y + backFromVolumeButton.height * backFromVolumeButton.scaleY / 2
};
if (x >= volumeDecreaseButtonBounds.left && x <= volumeDecreaseButtonBounds.right && y >= volumeDecreaseButtonBounds.top && y <= volumeDecreaseButtonBounds.bottom) {
musicVolume = Math.max(0.0, musicVolume - 0.1);
volumeText.setText('Volumen: ' + Math.round(musicVolume * 100) + '%');
// Update music volume by restarting it with new volume
LK.stopMusic();
if (musicVolume > 0) {
LK.playMusic('NightChaos', {
fade: {
start: 0,
end: musicVolume,
duration: 500
}
});
}
} else if (x >= volumeIncreaseButtonBounds.left && x <= volumeIncreaseButtonBounds.right && y >= volumeIncreaseButtonBounds.top && y <= volumeIncreaseButtonBounds.bottom) {
musicVolume = Math.min(1.0, musicVolume + 0.1);
volumeText.setText('Volumen: ' + Math.round(musicVolume * 100) + '%');
// Update music volume by restarting it with new volume
LK.stopMusic();
if (musicVolume > 0) {
LK.playMusic('NightChaos', {
fade: {
start: 0,
end: musicVolume,
duration: 500
}
});
}
} else if (x >= backFromVolumeButtonBounds.left && x <= backFromVolumeButtonBounds.right && y >= backFromVolumeButtonBounds.top && y <= backFromVolumeButtonBounds.bottom) {
backToPauseMenuFromVolume();
}
} else if (gameState === 'chaos') {
// Handle chaos screen interactions
var chaosButtonBounds = {
left: chaosScreenElements[2].x - chaosScreenElements[2].width * chaosScreenElements[2].scaleX / 2,
right: chaosScreenElements[2].x + chaosScreenElements[2].width * chaosScreenElements[2].scaleX / 2,
top: chaosScreenElements[2].y - chaosScreenElements[2].height * chaosScreenElements[2].scaleY / 2,
bottom: chaosScreenElements[2].y + chaosScreenElements[2].height * chaosScreenElements[2].scaleY / 2
};
var backToChaosMenuButtonBounds = {
left: chaosScreenElements[4].x - chaosScreenElements[4].width * chaosScreenElements[4].scaleX / 2,
right: chaosScreenElements[4].x + chaosScreenElements[4].width * chaosScreenElements[4].scaleX / 2,
top: chaosScreenElements[4].y - chaosScreenElements[4].height * chaosScreenElements[4].scaleY / 2,
bottom: chaosScreenElements[4].y + chaosScreenElements[4].height * chaosScreenElements[4].scaleY / 2
};
if (x >= chaosButtonBounds.left && x <= chaosButtonBounds.right && y >= chaosButtonBounds.top && y <= chaosButtonBounds.bottom) {
// CHAOS button clicked - open battle screen
showBattleScreen();
} else if (x >= backToChaosMenuButtonBounds.left && x <= backToChaosMenuButtonBounds.right && y >= backToChaosMenuButtonBounds.top && y <= backToChaosMenuButtonBounds.bottom) {
returnToMainMenuFromChaos();
}
} else if (gameState === 'battle') {
// Handle battle screen interactions
if (battleScreenElements.length >= 5) {
var battlePauseButton = battleScreenElements[3];
var battlePauseButtonBounds = {
left: battlePauseButton.x - battlePauseButton.width * battlePauseButton.scaleX / 2,
right: battlePauseButton.x + battlePauseButton.width * battlePauseButton.scaleX / 2,
top: battlePauseButton.y - battlePauseButton.height * battlePauseButton.scaleY / 2,
bottom: battlePauseButton.y + battlePauseButton.height * battlePauseButton.scaleY / 2
};
if (x >= battlePauseButtonBounds.left && x <= battlePauseButtonBounds.right && y >= battlePauseButtonBounds.top && y <= battlePauseButtonBounds.bottom) {
exitBattleScreen();
}
}
}
};
game.move = function (x, y, obj) {
// Handle heart cursor movement in battle screen
if (gameState === 'battle' && battleScreenElements.length >= 6) {
var heartCursor = battleScreenElements[5];
var battleBox = battleScreenElements[1];
if (heartCursor && battleBox) {
// Calculate the green rectangle boundaries within the battleBox
// Make the heart movement area 2.2 times smaller (larger than before)
var battleBoxWidth = battleBox.width * battleBox.scaleX;
var battleBoxHeight = battleBox.height * battleBox.scaleY;
var smallerWidth = battleBoxWidth / 2.2;
var smallerHeight = battleBoxHeight / 1.8; // Make height area larger (1.8 instead of 2.2)
var battleBoxLeft = battleBox.x - smallerWidth / 2;
var battleBoxRight = battleBox.x + smallerWidth / 2;
var battleBoxTop = battleBox.y - smallerHeight / 2;
var battleBoxBottom = battleBox.y + smallerHeight / 2;
// Constrain heart cursor within the adjusted green rectangle boundaries
heartCursor.x = Math.max(battleBoxLeft, Math.min(x, battleBoxRight));
heartCursor.y = Math.max(battleBoxTop, Math.min(y, battleBoxBottom));
}
}
};
game.up = function (x, y, obj) {
if (gameState === 'playing') {
isDragging = false;
}
};
// Suika Game helper functions can be added here if needed
// Main game update
game.update = function () {
// Animate fog elements in menu
if (gameState === 'menu') {
for (var i = 0; i < fogElements.length; i++) {
var fog = fogElements[i];
fog.x += Math.cos(fog.fogDirection) * fog.fogSpeed;
fog.y += Math.sin(fog.fogDirection) * fog.fogSpeed * 0.3;
fog.alpha += Math.sin(LK.ticks * 0.02 + i) * 0.01;
// Keep fog within bounds and wrap around
if (fog.x < -100) fog.x = 2148;
if (fog.x > 2148) fog.x = -100;
if (fog.y < 1000) fog.y = 2200;
if (fog.y > 2200) fog.y = 1000;
}
}
if (gameState === 'playing') {
// Handle circle merging
var mergedCircles = [];
var circlesToRemove = [];
for (var i = circles.length - 1; i >= 0; i--) {
var circle = circles[i];
if (circle.shouldMerge && circle.mergeInto) {
// Only add the merged circle once
if (mergedCircles.indexOf(circle.mergeInto) === -1) {
game.addChild(circle.mergeInto);
mergedCircles.push(circle.mergeInto);
circles.push(circle.mergeInto);
circle.mergeInto.lastY = circle.mergeInto.y;
circle.mergeInto.lastIntersecting = false;
// Set spawn immunity for merged circles
circle.mergeInto.spawnImmunity = true;
circle.mergeInto.spawnTime = LK.ticks;
// Use tween to disable immunity after 3 seconds for merged circle
var mergedImmunityObj = {
immunity: 1
};
var mergedCircle = circle.mergeInto; // Capture reference before tween
tween(mergedImmunityObj, {
immunity: 0
}, {
duration: 3000,
onFinish: function onFinish() {
if (mergedCircle) {
mergedCircle.spawnImmunity = false;
}
}
});
}
// Mark circle for removal
circlesToRemove.push(circle);
}
}
// Remove all circles that merged
for (var j = 0; j < circlesToRemove.length; j++) {
var circleToRemove = circlesToRemove[j];
game.removeChild(circleToRemove);
var index = circles.indexOf(circleToRemove);
if (index > -1) {
circles.splice(index, 1);
}
}
// Check for game over (circle rises and touches the red line)
for (var i = 0; i < circles.length; i++) {
var circle = circles[i];
// Only trigger game over if circle touches the red line and this specific circle's immunity is not active
if (circle.y - circle.radius <= containerY && !circle.spawnImmunity) {
// Game over condition - circle touched the red line
LK.showGameOver();
return;
}
}
}
if (gameState === 'battle' && battleScreenActive) {
// Enemy shooting logic - shoot diamonds every 1.5 seconds (90 ticks)
if (LK.ticks - lastEnemyShootTime >= 90) {
lastEnemyShootTime = LK.ticks;
// Get enemy position from battleScreenElements
if (battleScreenElements.length >= 7) {
var enemyCharacter = battleScreenElements[6];
var heartCursor = battleScreenElements[5]; // Get heart cursor reference
// Create new diamond projectile
var newDiamond = new EnemyDiamond();
newDiamond.x = enemyCharacter.x;
newDiamond.y = enemyCharacter.y;
newDiamond.lastX = newDiamond.x;
newDiamond.lastY = newDiamond.y;
// Calculate direction towards heart cursor
var deltaX = heartCursor.x - enemyCharacter.x;
var deltaY = heartCursor.y - enemyCharacter.y;
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
// Normalize direction and apply speed
if (distance > 0) {
newDiamond.velocityX = deltaX / distance * newDiamond.speed;
newDiamond.velocityY = deltaY / distance * newDiamond.speed;
// Calculate rotation angle to point diamond tip towards target
var angle = Math.atan2(deltaY, deltaX);
// Access the diamond graphics and set rotation
var diamondGraphics = newDiamond.children[0];
if (diamondGraphics) {
diamondGraphics.rotation = angle + Math.PI / 4; // Add base 45-degree rotation
}
} else {
// Fallback to downward movement if positions are identical
newDiamond.velocityX = 0;
newDiamond.velocityY = newDiamond.speed;
}
game.addChild(newDiamond);
enemyDiamonds.push(newDiamond);
}
}
// Update and manage enemy diamonds
for (var i = enemyDiamonds.length - 1; i >= 0; i--) {
var diamond = enemyDiamonds[i];
// Check if diamond is off screen
if (diamond.x < -50 || diamond.x > 2098 || diamond.y < -50 || diamond.y > 2782) {
game.removeChild(diamond);
enemyDiamonds.splice(i, 1);
}
}
}
};
Niebla terrorifica. In-Game asset. 2d. High contrast. No shadows
marco de boton de inicio sin palabras en el. In-Game asset. 2d. High contrast. No shadows
una estrella hermosa con cara kawai que en su frente diga Dazai. In-Game asset. 2d. High contrast. No shadows
una luna redondita kawai con lentes de sol, en su frente lleva una sinta que dice STAR. In-Game asset. 2d. High contrast. No shadows
sacale el fondo de color negro, dejando solo al personaje con el redondeado rojo
un oso redondo. In-Game asset. 2d. High contrast. No shadows
un monito en una imagen redonda, el monito lleva gafas de sol, es de plastico y tiene una sonrisa. In-Game asset. 2d. High contrast. No shadows
un oso redondito, con una aureola, cara kawai y con los brazitos juntitos como rezando y cantando. In-Game asset. 2d. High contrast. No shadows
Nube realista de noche. In-Game asset. 2d. High contrast. No shadows
un edificio pixel art por la noche. In-Game asset. 2d. High contrast. No shadows
un boton color rojo, dentro de el hay un dibujo de dos flechas como indicando que se mezcla algo. In-Game asset. 2d. High contrast. No shadows
un boton redondo color amarillo, dentro de el hay un dinujo de una corona brillante. In-Game asset. 2d. High contrast. No shadows
una tabla de madera alargada como si fuese de una cocina. In-Game asset. 2d. High contrast. No shadows
Una luna brillante. In-Game asset. 2d. High contrast. No shadows
un corazon pixeleado al estilo de DELTARUNE u Undertale. In-Game asset. 2d. High contrast. No shadows
Jevil, un jefe del capitulo 1 de deltarune, es pixleado y el fondo detras de este es color blanco. In-Game asset. 2d. High contrast. No shadows
un diamante, es pixeleado, solo mejora su calidad, no cambies su forma
haz que este trebol blanco, sea pixeleado de 16x16
Jevil de deltarune capitulo uno siendo golpeado en el estomago echandose un poco para atras aunque con una risa loca en su rostro (pixeleado con fondo blanco). In-Game asset. 2d. High contrast. No shadows
Una caja sorpresa cerrada en blanco y negro pixeleado en 16x16 pixeles, en la caja hay un dibujo de unos ojos y sonrisa de Jevil de deltarune. el fondo de la imagen es de color rojo
un corazon de color blanco con bordes negros, el mismo que lanza Jevil en deltarune capitulo 1, el corazon es pixeleado 16x16 (el fondo de la imagen sea roja). In-Game asset. 2d. High contrast. No shadows
una bomba redonda, color blanco con bordes de color negro, es pixeleada de 16x16 (la imagen tiene fondo rojo). In-Game asset. 2d. High contrast. No shadows