User prompt
Crea una pantall de start antes de iniciar el juego, toma el mismo fondo para esa pantalla
User prompt
mira cuando entre a la ui de menu, quiero que el juego se pause, hasta que yo escoja una opcion
User prompt
Please fix the bug: 'Uncaught TypeError: LK.pauseGame is not a function' in or related to this line: 'LK.pauseGame();' Line Number: 1003
User prompt
Pero hace que cuando apriete menu, el juego se pause
User prompt
Please fix the bug: 'Uncaught TypeError: LK.restartGame is not a function' in or related to this line: 'LK.restartGame();' Line Number: 1029
User prompt
elimina todo ese menu que te dijo, y vuelve a crear uno desde cero
User prompt
no aparece el menu ahora, porfavor hace que aparezca
User prompt
mueve el boton a la parte izquierda inferior de la pantalla
User prompt
mueve de lugar el boton
User prompt
no mejor hace que esa ui aparezca con un boton aparte, por un boton en algun lado que se note y que diga menu, pero que no estorbe
User prompt
Crea que cuando una apriete el boton de pausa aparezca un pequeño menu con 3 opciones. reanudar, reiniciar, salir
User prompt
Mira ese poder de la katana hace que aparezca a las 5200 score y quiero que agregues una pequeña barra que te diga cuanto te falta para el poder katana-ninja, ponlo en una parte que se note pero que no estober ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mira pon atencion, borra el contador de score que hay y agrega uno completamente nuevo y que se note al lado derecho de la pantalla en la parte inferior
User prompt
agrega que cuando el jugador llegue a los 6000 de score se active un poder (agregale un efecto) y la katana se tripleque y que aparezcan 3 catanas en vez de 1 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agrega el otro sonido de ambiente, al juego, ese sonido sera para darle ambiente al juego
User prompt
agarra el sonido que agregue y ponlo para ea funcion que te dije
User prompt
Escucha bien, agrega un sonido para que cuando la katana corte una fruta suene un sonido de corte
User prompt
agregale sonidos para que cuando la katana corte una fruta suene un sonido de corte
User prompt
quitale la sombra a la luna y hace que el color del cielo no le afecte, agregale un aura de color amarillo para que brille ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
quitale el relieve a la luna
User prompt
cambia los colores del cielo, por los de un atardecer y una noche ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agregale al paisaje, quue vayan callendo particulas que son estrellas fugases ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agregale edificios al fondo del paisaje, y montañas con nieve en la punta ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
dale mas forma al paisaje, saca de ejemplo los paisajes de los animes japoneses ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
crea un fondo bonito animado para el juego, de un bosque con colores nitidos y con detalles ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Cloud = Container.expand(function (cloudX, cloudY, cloudScale) { var self = Container.call(this); // Create cloud with multiple overlapping circles var cloud1 = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); var cloud2 = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); cloud2.x = 40; cloud2.scaleX = 0.8; cloud2.scaleY = 0.8; var cloud3 = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); cloud3.x = -30; cloud3.scaleX = 0.9; cloud3.scaleY = 0.9; self.x = cloudX; self.y = cloudY; self.scaleX = cloudScale || 1; self.scaleY = cloudScale || 1; // Floating animation self.floatSpeed = Math.random() * 0.01 + 0.005; self.floatAmount = Math.random() * 20 + 10; self.driftSpeed = Math.random() * 0.5 + 0.2; self.originalX = cloudX; self.update = function () { // Gentle floating motion self.y = cloudY + Math.sin(LK.ticks * self.floatSpeed) * self.floatAmount; // Slow horizontal drift self.x += self.driftSpeed; // Reset position when off screen if (self.x > 2200) { self.x = -200; } }; return self; }); var Fruit = Container.expand(function (fruitType) { var self = Container.call(this); self.fruitType = fruitType; self.sliced = false; self.fallSpeed = Math.random() * 3 + (baseFallSpeed + currentDifficultyLevel * 0.3); var fruitGraphics = self.attachAsset(fruitType, { anchorX: 0.5, anchorY: 0.5 }); // Set initial random horizontal velocity self.velocityX = (Math.random() - 0.5) * 4; self.velocityY = self.fallSpeed; self.gravity = 0.1; self.update = function () { if (!self.sliced) { self.x += self.velocityX; self.y += self.velocityY; self.velocityY += self.gravity; } }; self.slice = function () { if (self.sliced) return; self.sliced = true; // Award points based on fruit type var points = 0; switch (self.fruitType) { case 'apple': points = 10; break; case 'orange': points = 15; break; case 'watermelon': points = 30; break; case 'pineapple': points = 25; break; case 'banana': points = 20; break; } LK.setScore(LK.getScore() + points); updateScoreDisplay(LK.getScore()); // Update difficulty progressively based on score var newScore = LK.getScore(); var newDifficultyLevel = Math.floor(newScore / 50); // Increase difficulty every 50 points if (newDifficultyLevel > currentDifficultyLevel) { currentDifficultyLevel = newDifficultyLevel; // Gradually decrease spawn rate (faster spawning) - minimum 20 frames spawnRate = Math.max(20, baseSpawnRate - currentDifficultyLevel * 8); } // Create slice effect self.createSliceEffect(); // Play slice sound LK.getSound('slice').play(); // Create floating score text var floatingScore = new Text2('+' + points, { size: 60, fill: 0xFFD700 }); floatingScore.anchor.set(0.5, 0.5); floatingScore.x = self.x; floatingScore.y = self.y; game.addChild(floatingScore); // Animate floating score tween(floatingScore, { y: floatingScore.y - 150, alpha: 0 }, { duration: 1000, onComplete: function onComplete() { floatingScore.destroy(); } }); // Animate fruit halves self.animateSlice(); }; self.createSliceEffect = function () { // Create particle explosion for (var i = 0; i < 8; i++) { var particle = new Particle(); particle.x = self.x; particle.y = self.y; particles.push(particle); game.addChild(particle); } }; self.animateSlice = function () { // Split fruit into two halves var leftHalf = self.attachAsset(self.fruitType, { anchorX: 0.5, anchorY: 0.5, x: -20 }); var rightHalf = self.attachAsset(self.fruitType, { anchorX: 0.5, anchorY: 0.5, x: 20 }); // Hide original fruit fruitGraphics.alpha = 0; // Animate halves falling tween(leftHalf, { x: leftHalf.x - 100, y: leftHalf.y + 200, rotation: -1 }, { duration: 1000 }); tween(rightHalf, { x: rightHalf.x + 100, y: rightHalf.y + 200, rotation: 1 }, { duration: 1000 }); tween(leftHalf, { alpha: 0 }, { duration: 800 }); tween(rightHalf, { alpha: 0 }, { duration: 800 }); }; return self; }); var GrassClump = Container.expand(function (grassX, grassY) { var self = Container.call(this); // Create multiple grass blades for (var i = 0; i < 5; i++) { var blade = self.attachAsset('grass_blade', { anchorX: 0.5, anchorY: 1 }); blade.x = (i - 2) * 8; blade.scaleY = Math.random() * 0.5 + 0.7; blade.rotation = (Math.random() - 0.5) * 0.3; // Vary grass color slightly var greenVariation = Math.random() * 0.2 + 0.9; blade.tint = 0x7CFC00 * greenVariation; } self.x = grassX; self.y = grassY; // Wind animation self.windSpeed = Math.random() * 0.03 + 0.02; self.windOffset = Math.random() * Math.PI * 2; self.update = function () { var wind = Math.sin(LK.ticks * self.windSpeed + self.windOffset) * 0.15; self.rotation = wind; }; return self; }); var Katana = Container.expand(function () { var self = Container.call(this); self.trailPoints = []; self.maxTrailLength = 10; var katanaGraphics = self.attachAsset('katana', { anchorX: 0.5, anchorY: 0.5 }); self.updatePosition = function (x, y) { // Add current position to trail self.trailPoints.push({ x: self.x, y: self.y }); if (self.trailPoints.length > self.maxTrailLength) { self.trailPoints.shift(); } // Calculate angle based on movement if (self.trailPoints.length > 1) { var lastPoint = self.trailPoints[self.trailPoints.length - 2]; var angle = Math.atan2(y - lastPoint.y, x - lastPoint.x); katanaGraphics.rotation = angle; } self.x = x; self.y = y; }; self.checkFruitCollisions = function () { for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; if (!fruit.sliced && self.intersects(fruit)) { fruit.slice(); } } }; return self; }); var Particle = Container.expand(function () { var self = Container.call(this); var particleGraphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = (Math.random() - 0.5) * 10; self.velocityY = (Math.random() - 0.5) * 10; self.life = 60; // 1 second at 60fps // Random color for juice effect var colors = [0xFF6B6B, 0xFFE66D, 0x4ECDC4, 0x45B7D1, 0x96CEB4]; particleGraphics.tint = colors[Math.floor(Math.random() * colors.length)]; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; self.velocityY += 0.2; // gravity self.life--; particleGraphics.alpha = self.life / 60; if (self.life <= 0) { self.destroy(); for (var i = particles.length - 1; i >= 0; i--) { if (particles[i] === self) { particles.splice(i, 1); break; } } } }; return self; }); var Tree = Container.expand(function (treeX, treeY, scale) { var self = Container.call(this); // Tree trunk var trunk = self.attachAsset('tree_trunk', { anchorX: 0.5, anchorY: 1 }); trunk.y = 0; // Multiple foliage layers for depth var foliageDark = self.attachAsset('tree_foliage_dark', { anchorX: 0.5, anchorY: 1 }); foliageDark.y = -200; foliageDark.x = 10; var foliageMain = self.attachAsset('tree_foliage', { anchorX: 0.5, anchorY: 1 }); foliageMain.y = -180; var foliageLight = self.attachAsset('tree_foliage_light', { anchorX: 0.5, anchorY: 1 }); foliageLight.y = -160; foliageLight.x = -15; // Set position and scale self.x = treeX; self.y = treeY; self.scaleX = scale || 1; self.scaleY = scale || 1; // Animation properties self.swaySpeed = Math.random() * 0.02 + 0.01; self.swayAmount = Math.random() * 0.1 + 0.05; self.animationOffset = Math.random() * Math.PI * 2; self.update = function () { // Gentle swaying animation var sway = Math.sin(LK.ticks * self.swaySpeed + self.animationOffset) * self.swayAmount; foliageMain.rotation = sway; foliageLight.rotation = sway * 0.8; foliageDark.rotation = sway * 1.2; trunk.rotation = sway * 0.3; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Create animated forest background var backgroundContainer = new Container(); game.addChild(backgroundContainer); // Create sky gradient effect with multiple colored rectangles var skyLayers = []; for (var s = 0; s < 8; s++) { var skyLayer = LK.getAsset('shape', { anchorX: 0, anchorY: 0, scaleX: 20.48, scaleY: 3.4 }); skyLayer.y = s * 340; // Gradient from light blue to deeper blue var blueIntensity = 0x87CEEB - s * 0x051020; skyLayer.tint = blueIntensity; skyLayer.alpha = 0.6; backgroundContainer.addChild(skyLayer); skyLayers.push(skyLayer); } // Create sun var sun = backgroundContainer.addChild(LK.getAsset('sun', { anchorX: 0.5, anchorY: 0.5 })); sun.x = 1600; sun.y = 300; // Animate sun with pulsing glow var sunGlow = backgroundContainer.addChild(LK.getAsset('sun', { anchorX: 0.5, anchorY: 0.5 })); sunGlow.x = 1600; sunGlow.y = 300; sunGlow.alpha = 0.3; sunGlow.scaleX = 1.5; sunGlow.scaleY = 1.5; // Create distant mountains var mountains = []; for (var m = 0; m < 6; m++) { var mountain = backgroundContainer.addChild(LK.getAsset('mountain', { anchorX: 0.5, anchorY: 1 })); mountain.x = m * 400 + 200; mountain.y = 2200; mountain.scaleY = Math.random() * 0.5 + 0.8; mountain.tint = 0x556B2F; mountain.alpha = 0.7; mountains.push(mountain); } // Create clouds var clouds = []; for (var c = 0; c < 8; c++) { var cloud = backgroundContainer.addChild(new Cloud(Math.random() * 2400 - 200, Math.random() * 600 + 200, Math.random() * 0.8 + 0.6)); clouds.push(cloud); } // Create background trees (larger, further back) var backgroundTrees = []; for (var bt = 0; bt < 15; bt++) { var bgTree = backgroundContainer.addChild(new Tree(Math.random() * 2400 - 200, 2200, Math.random() * 0.8 + 1.2)); bgTree.alpha = 0.7; bgTree.tint = 0x556B2F; backgroundTrees.push(bgTree); } // Create middle ground trees var middleTrees = []; for (var mt = 0; mt < 20; mt++) { var midTree = backgroundContainer.addChild(new Tree(Math.random() * 2600 - 300, 2400, Math.random() * 0.6 + 0.8)); midTree.alpha = 0.85; middleTrees.push(midTree); } // Create foreground trees var foregroundTrees = []; for (var ft = 0; ft < 12; ft++) { var fgTree = backgroundContainer.addChild(new Tree(Math.random() * 2800 - 400, 2600, Math.random() * 0.4 + 0.6)); foregroundTrees.push(fgTree); } // Create grass clumps across the ground var grassClumps = []; for (var g = 0; g < 50; g++) { var grass = backgroundContainer.addChild(new GrassClump(Math.random() * 2400, 2650 + Math.random() * 80)); grassClumps.push(grass); } // Create colorful flowers scattered around var flowers = []; var flowerColors = [0xFF69B4, 0xFF6347, 0x9370DB, 0x00CED1, 0xFFD700, 0xFF4500]; for (var f = 0; f < 30; f++) { var flower = backgroundContainer.addChild(LK.getAsset('flower', { anchorX: 0.5, anchorY: 0.5 })); flower.x = Math.random() * 2048; flower.y = 2600 + Math.random() * 100; flower.tint = flowerColors[Math.floor(Math.random() * flowerColors.length)]; flowers.push(flower); } // Animate sun glow tween(sunGlow, { scaleX: 2.0, scaleY: 2.0, alpha: 0.1 }, { duration: 3000, onComplete: function onComplete() { tween(sunGlow, { scaleX: 1.5, scaleY: 1.5, alpha: 0.3 }, { duration: 3000 }); } }); var fruits = []; var particles = []; var fruitTypes = ['apple', 'orange', 'watermelon', 'pineapple', 'banana']; var spawnTimer = 0; var spawnRate = 90; // frames between spawns var baseSpawnRate = 90; // original spawn rate var baseFallSpeed = 2; // base fall speed for fruits var currentDifficultyLevel = 0; // Katana health system variables var katanaHealth = 100; var maxKatanaHealth = 100; var katanaParalyzed = false; var paralyzeTimer = 0; var lastKatanaX = 0; var lastKatanaY = 0; var movementSamples = []; var maxMovementSamples = 10; // Create katana var katana = game.addChild(new Katana()); katana.x = 1024; katana.y = 1366; // Create 3D styled score display - numbers only var scoreContainer = new Container(); LK.gui.top.addChild(scoreContainer); // Create deep shadow layers for enhanced 3D effect var scoreShadow3 = new Text2('0', { size: 100, fill: 0x000000 }); scoreShadow3.anchor.set(0.5, 0.5); scoreShadow3.x = 8; scoreShadow3.y = 8; scoreShadow3.alpha = 0.3; scoreContainer.addChild(scoreShadow3); var scoreShadow2 = new Text2('0', { size: 100, fill: 0x2C3E50 }); scoreShadow2.anchor.set(0.5, 0.5); scoreShadow2.x = 5; scoreShadow2.y = 5; scoreShadow2.alpha = 0.6; scoreContainer.addChild(scoreShadow2); // Create primary shadow for 3D effect var scoreShadow = new Text2('0', { size: 100, fill: 0x34495E }); scoreShadow.anchor.set(0.5, 0.5); scoreShadow.x = 3; scoreShadow.y = 3; scoreShadow.alpha = 0.8; scoreContainer.addChild(scoreShadow); // Create main score text with gradient effect var scoreTxt = new Text2('0', { size: 100, fill: 0xF39C12 }); scoreTxt.anchor.set(0.5, 0.5); scoreContainer.addChild(scoreTxt); // Create bright highlight for 3D pop effect var scoreHighlight = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreHighlight.anchor.set(0.5, 0.5); scoreHighlight.x = -2; scoreHighlight.y = -2; scoreHighlight.alpha = 0.4; scoreContainer.addChild(scoreHighlight); // Create top highlight for extra dimension var scoreTopLight = new Text2('0', { size: 100, fill: 0xFFD700 }); scoreTopLight.anchor.set(0.5, 0.5); scoreTopLight.x = -1; scoreTopLight.y = -1; scoreTopLight.alpha = 0.6; scoreContainer.addChild(scoreTopLight); // Position the entire score container centered at top scoreContainer.x = 1024; // Center horizontally (2048/2) scoreContainer.y = 120; // Create katana health bar var healthBarContainer = new Container(); LK.gui.bottom.addChild(healthBarContainer); // Health bar background var healthBarBg = LK.getAsset('shape', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, scaleY: 0.3 }); healthBarBg.tint = 0x333333; healthBarContainer.addChild(healthBarBg); // Health bar fill var healthBarFill = LK.getAsset('shape', { anchorX: 0, anchorY: 0.5, scaleX: 3, scaleY: 0.25 }); healthBarFill.tint = 0x27AE60; healthBarFill.x = -150; // Start from left edge of background healthBarContainer.addChild(healthBarFill); // Health bar border var healthBarBorder = LK.getAsset('shape', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.1, scaleY: 0.35 }); healthBarBorder.tint = 0xFFFFFF; healthBarBorder.alpha = 0.8; healthBarContainer.addChild(healthBarBorder); // Position health bar at bottom center healthBarContainer.x = 1024; healthBarContainer.y = 2600; healthBarContainer.alpha = 0; // Initially hidden // Function to update all score texts and add animation function updateScoreDisplay(newScore) { var scoreText = newScore.toString(); scoreTxt.setText(scoreText); scoreShadow.setText(scoreText); scoreShadow2.setText(scoreText); scoreShadow3.setText(scoreText); scoreHighlight.setText(scoreText); scoreTopLight.setText(scoreText); // Add enhanced pulsing animation with 3D effect tween(scoreContainer, { scaleX: 1.3, scaleY: 1.3 }, { duration: 150, onComplete: function onComplete() { tween(scoreContainer, { scaleX: 1.0, scaleY: 1.0 }, { duration: 150 }); } }); // Add slight rotation for extra 3D effect tween(scoreContainer, { rotation: 0.1 }, { duration: 100, onComplete: function onComplete() { tween(scoreContainer, { rotation: 0 }, { duration: 100 }); } }); // Enhanced color change effect based on score with 3D layering if (newScore >= 500) { scoreTxt.fill = 0xE74C3C; // Red for high scores scoreTopLight.fill = 0xFF6B6B; scoreHighlight.fill = 0xFFAAAA; } else if (newScore >= 200) { scoreTxt.fill = 0x9B59B6; // Purple for medium scores scoreTopLight.fill = 0xBB6BD9; scoreHighlight.fill = 0xDDA0DD; } else if (newScore >= 100) { scoreTxt.fill = 0x3498DB; // Blue for decent scores scoreTopLight.fill = 0x5DADE2; scoreHighlight.fill = 0xADD8E6; } else { scoreTxt.fill = 0xF39C12; // Orange for starting scores scoreTopLight.fill = 0xFFD700; scoreHighlight.fill = 0xFFFFFF; } } // Track mouse movement var isSlicing = false; var lastMouseX = 0; var lastMouseY = 0; game.move = function (x, y, obj) { if (!katanaParalyzed) { katana.updatePosition(x, y); if (isSlicing) { katana.checkFruitCollisions(); } } // Track movement for katana health system var distance = Math.sqrt(Math.pow(x - lastKatanaX, 2) + Math.pow(y - lastKatanaY, 2)); movementSamples.push(distance); if (movementSamples.length > maxMovementSamples) { movementSamples.shift(); } // Calculate average movement in recent samples var totalMovement = 0; for (var i = 0; i < movementSamples.length; i++) { totalMovement += movementSamples[i]; } var avgMovement = totalMovement / movementSamples.length; // Only activate health system if katana is in upper 1.5cm (approximately 109 pixels) from top var isInUpperScreen = y < 109; // 1.5cm from top of screen (at 72 DPI: 1.5cm ≈ 109 pixels) // If movement is very rapid (increased threshold: 50+ pixels per frame on average) AND in upper screen if (avgMovement > 50 && movementSamples.length >= maxMovementSamples && isInUpperScreen) { katanaHealth -= 3; // Drain health faster for rapid movements // Show health bar when taking damage if (healthBarContainer.alpha < 1) { tween(healthBarContainer, { alpha: 1 }, { duration: 200 }); } // Update health bar fill var healthPercent = Math.max(0, katanaHealth / maxKatanaHealth); tween(healthBarFill, { scaleX: 3 * healthPercent }, { duration: 100 }); // Change color based on health level if (healthPercent < 0.3) { healthBarFill.tint = 0xE74C3C; // Red } else if (healthPercent < 0.6) { healthBarFill.tint = 0xF39C12; // Orange } else { healthBarFill.tint = 0x27AE60; // Green } // Check if health is depleted if (katanaHealth <= 0) { katanaHealth = 0; katanaParalyzed = true; paralyzeTimer = 66; // 1.1 seconds at 60fps // Flash katana red to indicate paralysis LK.effects.flashObject(katana, 0xFF0000, 1100); } } lastKatanaX = x; lastKatanaY = y; lastMouseX = x; lastMouseY = y; }; game.down = function (x, y, obj) { isSlicing = true; katana.updatePosition(x, y); }; game.up = function (x, y, obj) { isSlicing = false; }; game.update = function () { // Animate background elements // Animate flowers with gentle bobbing for (var f = 0; f < flowers.length; f++) { var flower = flowers[f]; flower.rotation = Math.sin(LK.ticks * 0.02 + f) * 0.2; flower.scaleX = 1 + Math.sin(LK.ticks * 0.015 + f) * 0.1; flower.scaleY = 1 + Math.sin(LK.ticks * 0.015 + f) * 0.1; } // Add subtle parallax effect to background layers for (var bt = 0; bt < backgroundTrees.length; bt++) { var bgTree = backgroundTrees[bt]; bgTree.x += Math.sin(LK.ticks * 0.001 + bt) * 0.1; } // Gentle sky color animation if (LK.ticks % 120 === 0) { for (var s = 0; s < skyLayers.length; s++) { var skyLayer = skyLayers[s]; var colorShift = Math.sin(LK.ticks * 0.001) * 0x020202; skyLayer.tint = 0x87CEEB - s * 0x051020 + colorShift; } } // Spawn fruits spawnTimer++; if (spawnTimer >= spawnRate) { spawnTimer = 0; var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)]; var fruit = new Fruit(fruitType); fruit.x = Math.random() * 1800 + 124; // Random x position within screen bounds fruit.y = -100; // Start above screen fruits.push(fruit); game.addChild(fruit); // Spawn rate is now controlled by difficulty level in slice function } // Update fruits and remove off-screen ones for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; // Check if fruit touched the ground (game over condition) if (fruit.y > 2732 && !fruit.sliced) { // Game over - fruit touched the ground LK.showGameOver(); return; // Stop game execution } // Remove fruits that fall off screen if (fruit.y > 2800) { fruit.destroy(); fruits.splice(i, 1); } } // Update particles for (var j = particles.length - 1; j >= 0; j--) { var particle = particles[j]; if (particle.life <= 0) { particles.splice(j, 1); } } // Update katana health system if (katanaParalyzed) { paralyzeTimer--; if (paralyzeTimer <= 0) { katanaParalyzed = false; katanaHealth = maxKatanaHealth; // Restore full health // Update health bar to full tween(healthBarFill, { scaleX: 3 }, { duration: 300 }); healthBarFill.tint = 0x27AE60; // Green // Hide health bar after recovery tween(healthBarContainer, { alpha: 0 }, { duration: 1000 }); } } else { // Gradually regenerate health when not making rapid movements if (katanaHealth < maxKatanaHealth) { katanaHealth += 0.5; // Slow regeneration if (katanaHealth > maxKatanaHealth) { katanaHealth = maxKatanaHealth; } // Update health bar fill var healthPercent = katanaHealth / maxKatanaHealth; healthBarFill.scaleX = 3 * healthPercent; // Update color if (healthPercent < 0.3) { healthBarFill.tint = 0xE74C3C; // Red } else if (healthPercent < 0.6) { healthBarFill.tint = 0xF39C12; // Orange } else { healthBarFill.tint = 0x27AE60; // Green } // Hide health bar when fully recovered and not being used if (katanaHealth >= maxKatanaHealth && healthBarContainer.alpha > 0) { tween(healthBarContainer, { alpha: 0 }, { duration: 2000 }); } } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Cloud = Container.expand(function (cloudX, cloudY, cloudScale) {
var self = Container.call(this);
// Create cloud with multiple overlapping circles
var cloud1 = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
var cloud2 = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
cloud2.x = 40;
cloud2.scaleX = 0.8;
cloud2.scaleY = 0.8;
var cloud3 = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
cloud3.x = -30;
cloud3.scaleX = 0.9;
cloud3.scaleY = 0.9;
self.x = cloudX;
self.y = cloudY;
self.scaleX = cloudScale || 1;
self.scaleY = cloudScale || 1;
// Floating animation
self.floatSpeed = Math.random() * 0.01 + 0.005;
self.floatAmount = Math.random() * 20 + 10;
self.driftSpeed = Math.random() * 0.5 + 0.2;
self.originalX = cloudX;
self.update = function () {
// Gentle floating motion
self.y = cloudY + Math.sin(LK.ticks * self.floatSpeed) * self.floatAmount;
// Slow horizontal drift
self.x += self.driftSpeed;
// Reset position when off screen
if (self.x > 2200) {
self.x = -200;
}
};
return self;
});
var Fruit = Container.expand(function (fruitType) {
var self = Container.call(this);
self.fruitType = fruitType;
self.sliced = false;
self.fallSpeed = Math.random() * 3 + (baseFallSpeed + currentDifficultyLevel * 0.3);
var fruitGraphics = self.attachAsset(fruitType, {
anchorX: 0.5,
anchorY: 0.5
});
// Set initial random horizontal velocity
self.velocityX = (Math.random() - 0.5) * 4;
self.velocityY = self.fallSpeed;
self.gravity = 0.1;
self.update = function () {
if (!self.sliced) {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
}
};
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
// Award points based on fruit type
var points = 0;
switch (self.fruitType) {
case 'apple':
points = 10;
break;
case 'orange':
points = 15;
break;
case 'watermelon':
points = 30;
break;
case 'pineapple':
points = 25;
break;
case 'banana':
points = 20;
break;
}
LK.setScore(LK.getScore() + points);
updateScoreDisplay(LK.getScore());
// Update difficulty progressively based on score
var newScore = LK.getScore();
var newDifficultyLevel = Math.floor(newScore / 50); // Increase difficulty every 50 points
if (newDifficultyLevel > currentDifficultyLevel) {
currentDifficultyLevel = newDifficultyLevel;
// Gradually decrease spawn rate (faster spawning) - minimum 20 frames
spawnRate = Math.max(20, baseSpawnRate - currentDifficultyLevel * 8);
}
// Create slice effect
self.createSliceEffect();
// Play slice sound
LK.getSound('slice').play();
// Create floating score text
var floatingScore = new Text2('+' + points, {
size: 60,
fill: 0xFFD700
});
floatingScore.anchor.set(0.5, 0.5);
floatingScore.x = self.x;
floatingScore.y = self.y;
game.addChild(floatingScore);
// Animate floating score
tween(floatingScore, {
y: floatingScore.y - 150,
alpha: 0
}, {
duration: 1000,
onComplete: function onComplete() {
floatingScore.destroy();
}
});
// Animate fruit halves
self.animateSlice();
};
self.createSliceEffect = function () {
// Create particle explosion
for (var i = 0; i < 8; i++) {
var particle = new Particle();
particle.x = self.x;
particle.y = self.y;
particles.push(particle);
game.addChild(particle);
}
};
self.animateSlice = function () {
// Split fruit into two halves
var leftHalf = self.attachAsset(self.fruitType, {
anchorX: 0.5,
anchorY: 0.5,
x: -20
});
var rightHalf = self.attachAsset(self.fruitType, {
anchorX: 0.5,
anchorY: 0.5,
x: 20
});
// Hide original fruit
fruitGraphics.alpha = 0;
// Animate halves falling
tween(leftHalf, {
x: leftHalf.x - 100,
y: leftHalf.y + 200,
rotation: -1
}, {
duration: 1000
});
tween(rightHalf, {
x: rightHalf.x + 100,
y: rightHalf.y + 200,
rotation: 1
}, {
duration: 1000
});
tween(leftHalf, {
alpha: 0
}, {
duration: 800
});
tween(rightHalf, {
alpha: 0
}, {
duration: 800
});
};
return self;
});
var GrassClump = Container.expand(function (grassX, grassY) {
var self = Container.call(this);
// Create multiple grass blades
for (var i = 0; i < 5; i++) {
var blade = self.attachAsset('grass_blade', {
anchorX: 0.5,
anchorY: 1
});
blade.x = (i - 2) * 8;
blade.scaleY = Math.random() * 0.5 + 0.7;
blade.rotation = (Math.random() - 0.5) * 0.3;
// Vary grass color slightly
var greenVariation = Math.random() * 0.2 + 0.9;
blade.tint = 0x7CFC00 * greenVariation;
}
self.x = grassX;
self.y = grassY;
// Wind animation
self.windSpeed = Math.random() * 0.03 + 0.02;
self.windOffset = Math.random() * Math.PI * 2;
self.update = function () {
var wind = Math.sin(LK.ticks * self.windSpeed + self.windOffset) * 0.15;
self.rotation = wind;
};
return self;
});
var Katana = Container.expand(function () {
var self = Container.call(this);
self.trailPoints = [];
self.maxTrailLength = 10;
var katanaGraphics = self.attachAsset('katana', {
anchorX: 0.5,
anchorY: 0.5
});
self.updatePosition = function (x, y) {
// Add current position to trail
self.trailPoints.push({
x: self.x,
y: self.y
});
if (self.trailPoints.length > self.maxTrailLength) {
self.trailPoints.shift();
}
// Calculate angle based on movement
if (self.trailPoints.length > 1) {
var lastPoint = self.trailPoints[self.trailPoints.length - 2];
var angle = Math.atan2(y - lastPoint.y, x - lastPoint.x);
katanaGraphics.rotation = angle;
}
self.x = x;
self.y = y;
};
self.checkFruitCollisions = function () {
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (!fruit.sliced && self.intersects(fruit)) {
fruit.slice();
}
}
};
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = (Math.random() - 0.5) * 10;
self.velocityY = (Math.random() - 0.5) * 10;
self.life = 60; // 1 second at 60fps
// Random color for juice effect
var colors = [0xFF6B6B, 0xFFE66D, 0x4ECDC4, 0x45B7D1, 0x96CEB4];
particleGraphics.tint = colors[Math.floor(Math.random() * colors.length)];
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += 0.2; // gravity
self.life--;
particleGraphics.alpha = self.life / 60;
if (self.life <= 0) {
self.destroy();
for (var i = particles.length - 1; i >= 0; i--) {
if (particles[i] === self) {
particles.splice(i, 1);
break;
}
}
}
};
return self;
});
var Tree = Container.expand(function (treeX, treeY, scale) {
var self = Container.call(this);
// Tree trunk
var trunk = self.attachAsset('tree_trunk', {
anchorX: 0.5,
anchorY: 1
});
trunk.y = 0;
// Multiple foliage layers for depth
var foliageDark = self.attachAsset('tree_foliage_dark', {
anchorX: 0.5,
anchorY: 1
});
foliageDark.y = -200;
foliageDark.x = 10;
var foliageMain = self.attachAsset('tree_foliage', {
anchorX: 0.5,
anchorY: 1
});
foliageMain.y = -180;
var foliageLight = self.attachAsset('tree_foliage_light', {
anchorX: 0.5,
anchorY: 1
});
foliageLight.y = -160;
foliageLight.x = -15;
// Set position and scale
self.x = treeX;
self.y = treeY;
self.scaleX = scale || 1;
self.scaleY = scale || 1;
// Animation properties
self.swaySpeed = Math.random() * 0.02 + 0.01;
self.swayAmount = Math.random() * 0.1 + 0.05;
self.animationOffset = Math.random() * Math.PI * 2;
self.update = function () {
// Gentle swaying animation
var sway = Math.sin(LK.ticks * self.swaySpeed + self.animationOffset) * self.swayAmount;
foliageMain.rotation = sway;
foliageLight.rotation = sway * 0.8;
foliageDark.rotation = sway * 1.2;
trunk.rotation = sway * 0.3;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Create animated forest background
var backgroundContainer = new Container();
game.addChild(backgroundContainer);
// Create sky gradient effect with multiple colored rectangles
var skyLayers = [];
for (var s = 0; s < 8; s++) {
var skyLayer = LK.getAsset('shape', {
anchorX: 0,
anchorY: 0,
scaleX: 20.48,
scaleY: 3.4
});
skyLayer.y = s * 340;
// Gradient from light blue to deeper blue
var blueIntensity = 0x87CEEB - s * 0x051020;
skyLayer.tint = blueIntensity;
skyLayer.alpha = 0.6;
backgroundContainer.addChild(skyLayer);
skyLayers.push(skyLayer);
}
// Create sun
var sun = backgroundContainer.addChild(LK.getAsset('sun', {
anchorX: 0.5,
anchorY: 0.5
}));
sun.x = 1600;
sun.y = 300;
// Animate sun with pulsing glow
var sunGlow = backgroundContainer.addChild(LK.getAsset('sun', {
anchorX: 0.5,
anchorY: 0.5
}));
sunGlow.x = 1600;
sunGlow.y = 300;
sunGlow.alpha = 0.3;
sunGlow.scaleX = 1.5;
sunGlow.scaleY = 1.5;
// Create distant mountains
var mountains = [];
for (var m = 0; m < 6; m++) {
var mountain = backgroundContainer.addChild(LK.getAsset('mountain', {
anchorX: 0.5,
anchorY: 1
}));
mountain.x = m * 400 + 200;
mountain.y = 2200;
mountain.scaleY = Math.random() * 0.5 + 0.8;
mountain.tint = 0x556B2F;
mountain.alpha = 0.7;
mountains.push(mountain);
}
// Create clouds
var clouds = [];
for (var c = 0; c < 8; c++) {
var cloud = backgroundContainer.addChild(new Cloud(Math.random() * 2400 - 200, Math.random() * 600 + 200, Math.random() * 0.8 + 0.6));
clouds.push(cloud);
}
// Create background trees (larger, further back)
var backgroundTrees = [];
for (var bt = 0; bt < 15; bt++) {
var bgTree = backgroundContainer.addChild(new Tree(Math.random() * 2400 - 200, 2200, Math.random() * 0.8 + 1.2));
bgTree.alpha = 0.7;
bgTree.tint = 0x556B2F;
backgroundTrees.push(bgTree);
}
// Create middle ground trees
var middleTrees = [];
for (var mt = 0; mt < 20; mt++) {
var midTree = backgroundContainer.addChild(new Tree(Math.random() * 2600 - 300, 2400, Math.random() * 0.6 + 0.8));
midTree.alpha = 0.85;
middleTrees.push(midTree);
}
// Create foreground trees
var foregroundTrees = [];
for (var ft = 0; ft < 12; ft++) {
var fgTree = backgroundContainer.addChild(new Tree(Math.random() * 2800 - 400, 2600, Math.random() * 0.4 + 0.6));
foregroundTrees.push(fgTree);
}
// Create grass clumps across the ground
var grassClumps = [];
for (var g = 0; g < 50; g++) {
var grass = backgroundContainer.addChild(new GrassClump(Math.random() * 2400, 2650 + Math.random() * 80));
grassClumps.push(grass);
}
// Create colorful flowers scattered around
var flowers = [];
var flowerColors = [0xFF69B4, 0xFF6347, 0x9370DB, 0x00CED1, 0xFFD700, 0xFF4500];
for (var f = 0; f < 30; f++) {
var flower = backgroundContainer.addChild(LK.getAsset('flower', {
anchorX: 0.5,
anchorY: 0.5
}));
flower.x = Math.random() * 2048;
flower.y = 2600 + Math.random() * 100;
flower.tint = flowerColors[Math.floor(Math.random() * flowerColors.length)];
flowers.push(flower);
}
// Animate sun glow
tween(sunGlow, {
scaleX: 2.0,
scaleY: 2.0,
alpha: 0.1
}, {
duration: 3000,
onComplete: function onComplete() {
tween(sunGlow, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0.3
}, {
duration: 3000
});
}
});
var fruits = [];
var particles = [];
var fruitTypes = ['apple', 'orange', 'watermelon', 'pineapple', 'banana'];
var spawnTimer = 0;
var spawnRate = 90; // frames between spawns
var baseSpawnRate = 90; // original spawn rate
var baseFallSpeed = 2; // base fall speed for fruits
var currentDifficultyLevel = 0;
// Katana health system variables
var katanaHealth = 100;
var maxKatanaHealth = 100;
var katanaParalyzed = false;
var paralyzeTimer = 0;
var lastKatanaX = 0;
var lastKatanaY = 0;
var movementSamples = [];
var maxMovementSamples = 10;
// Create katana
var katana = game.addChild(new Katana());
katana.x = 1024;
katana.y = 1366;
// Create 3D styled score display - numbers only
var scoreContainer = new Container();
LK.gui.top.addChild(scoreContainer);
// Create deep shadow layers for enhanced 3D effect
var scoreShadow3 = new Text2('0', {
size: 100,
fill: 0x000000
});
scoreShadow3.anchor.set(0.5, 0.5);
scoreShadow3.x = 8;
scoreShadow3.y = 8;
scoreShadow3.alpha = 0.3;
scoreContainer.addChild(scoreShadow3);
var scoreShadow2 = new Text2('0', {
size: 100,
fill: 0x2C3E50
});
scoreShadow2.anchor.set(0.5, 0.5);
scoreShadow2.x = 5;
scoreShadow2.y = 5;
scoreShadow2.alpha = 0.6;
scoreContainer.addChild(scoreShadow2);
// Create primary shadow for 3D effect
var scoreShadow = new Text2('0', {
size: 100,
fill: 0x34495E
});
scoreShadow.anchor.set(0.5, 0.5);
scoreShadow.x = 3;
scoreShadow.y = 3;
scoreShadow.alpha = 0.8;
scoreContainer.addChild(scoreShadow);
// Create main score text with gradient effect
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xF39C12
});
scoreTxt.anchor.set(0.5, 0.5);
scoreContainer.addChild(scoreTxt);
// Create bright highlight for 3D pop effect
var scoreHighlight = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreHighlight.anchor.set(0.5, 0.5);
scoreHighlight.x = -2;
scoreHighlight.y = -2;
scoreHighlight.alpha = 0.4;
scoreContainer.addChild(scoreHighlight);
// Create top highlight for extra dimension
var scoreTopLight = new Text2('0', {
size: 100,
fill: 0xFFD700
});
scoreTopLight.anchor.set(0.5, 0.5);
scoreTopLight.x = -1;
scoreTopLight.y = -1;
scoreTopLight.alpha = 0.6;
scoreContainer.addChild(scoreTopLight);
// Position the entire score container centered at top
scoreContainer.x = 1024; // Center horizontally (2048/2)
scoreContainer.y = 120;
// Create katana health bar
var healthBarContainer = new Container();
LK.gui.bottom.addChild(healthBarContainer);
// Health bar background
var healthBarBg = LK.getAsset('shape', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 0.3
});
healthBarBg.tint = 0x333333;
healthBarContainer.addChild(healthBarBg);
// Health bar fill
var healthBarFill = LK.getAsset('shape', {
anchorX: 0,
anchorY: 0.5,
scaleX: 3,
scaleY: 0.25
});
healthBarFill.tint = 0x27AE60;
healthBarFill.x = -150; // Start from left edge of background
healthBarContainer.addChild(healthBarFill);
// Health bar border
var healthBarBorder = LK.getAsset('shape', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3.1,
scaleY: 0.35
});
healthBarBorder.tint = 0xFFFFFF;
healthBarBorder.alpha = 0.8;
healthBarContainer.addChild(healthBarBorder);
// Position health bar at bottom center
healthBarContainer.x = 1024;
healthBarContainer.y = 2600;
healthBarContainer.alpha = 0; // Initially hidden
// Function to update all score texts and add animation
function updateScoreDisplay(newScore) {
var scoreText = newScore.toString();
scoreTxt.setText(scoreText);
scoreShadow.setText(scoreText);
scoreShadow2.setText(scoreText);
scoreShadow3.setText(scoreText);
scoreHighlight.setText(scoreText);
scoreTopLight.setText(scoreText);
// Add enhanced pulsing animation with 3D effect
tween(scoreContainer, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 150,
onComplete: function onComplete() {
tween(scoreContainer, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 150
});
}
});
// Add slight rotation for extra 3D effect
tween(scoreContainer, {
rotation: 0.1
}, {
duration: 100,
onComplete: function onComplete() {
tween(scoreContainer, {
rotation: 0
}, {
duration: 100
});
}
});
// Enhanced color change effect based on score with 3D layering
if (newScore >= 500) {
scoreTxt.fill = 0xE74C3C; // Red for high scores
scoreTopLight.fill = 0xFF6B6B;
scoreHighlight.fill = 0xFFAAAA;
} else if (newScore >= 200) {
scoreTxt.fill = 0x9B59B6; // Purple for medium scores
scoreTopLight.fill = 0xBB6BD9;
scoreHighlight.fill = 0xDDA0DD;
} else if (newScore >= 100) {
scoreTxt.fill = 0x3498DB; // Blue for decent scores
scoreTopLight.fill = 0x5DADE2;
scoreHighlight.fill = 0xADD8E6;
} else {
scoreTxt.fill = 0xF39C12; // Orange for starting scores
scoreTopLight.fill = 0xFFD700;
scoreHighlight.fill = 0xFFFFFF;
}
}
// Track mouse movement
var isSlicing = false;
var lastMouseX = 0;
var lastMouseY = 0;
game.move = function (x, y, obj) {
if (!katanaParalyzed) {
katana.updatePosition(x, y);
if (isSlicing) {
katana.checkFruitCollisions();
}
}
// Track movement for katana health system
var distance = Math.sqrt(Math.pow(x - lastKatanaX, 2) + Math.pow(y - lastKatanaY, 2));
movementSamples.push(distance);
if (movementSamples.length > maxMovementSamples) {
movementSamples.shift();
}
// Calculate average movement in recent samples
var totalMovement = 0;
for (var i = 0; i < movementSamples.length; i++) {
totalMovement += movementSamples[i];
}
var avgMovement = totalMovement / movementSamples.length;
// Only activate health system if katana is in upper 1.5cm (approximately 109 pixels) from top
var isInUpperScreen = y < 109; // 1.5cm from top of screen (at 72 DPI: 1.5cm ≈ 109 pixels)
// If movement is very rapid (increased threshold: 50+ pixels per frame on average) AND in upper screen
if (avgMovement > 50 && movementSamples.length >= maxMovementSamples && isInUpperScreen) {
katanaHealth -= 3; // Drain health faster for rapid movements
// Show health bar when taking damage
if (healthBarContainer.alpha < 1) {
tween(healthBarContainer, {
alpha: 1
}, {
duration: 200
});
}
// Update health bar fill
var healthPercent = Math.max(0, katanaHealth / maxKatanaHealth);
tween(healthBarFill, {
scaleX: 3 * healthPercent
}, {
duration: 100
});
// Change color based on health level
if (healthPercent < 0.3) {
healthBarFill.tint = 0xE74C3C; // Red
} else if (healthPercent < 0.6) {
healthBarFill.tint = 0xF39C12; // Orange
} else {
healthBarFill.tint = 0x27AE60; // Green
}
// Check if health is depleted
if (katanaHealth <= 0) {
katanaHealth = 0;
katanaParalyzed = true;
paralyzeTimer = 66; // 1.1 seconds at 60fps
// Flash katana red to indicate paralysis
LK.effects.flashObject(katana, 0xFF0000, 1100);
}
}
lastKatanaX = x;
lastKatanaY = y;
lastMouseX = x;
lastMouseY = y;
};
game.down = function (x, y, obj) {
isSlicing = true;
katana.updatePosition(x, y);
};
game.up = function (x, y, obj) {
isSlicing = false;
};
game.update = function () {
// Animate background elements
// Animate flowers with gentle bobbing
for (var f = 0; f < flowers.length; f++) {
var flower = flowers[f];
flower.rotation = Math.sin(LK.ticks * 0.02 + f) * 0.2;
flower.scaleX = 1 + Math.sin(LK.ticks * 0.015 + f) * 0.1;
flower.scaleY = 1 + Math.sin(LK.ticks * 0.015 + f) * 0.1;
}
// Add subtle parallax effect to background layers
for (var bt = 0; bt < backgroundTrees.length; bt++) {
var bgTree = backgroundTrees[bt];
bgTree.x += Math.sin(LK.ticks * 0.001 + bt) * 0.1;
}
// Gentle sky color animation
if (LK.ticks % 120 === 0) {
for (var s = 0; s < skyLayers.length; s++) {
var skyLayer = skyLayers[s];
var colorShift = Math.sin(LK.ticks * 0.001) * 0x020202;
skyLayer.tint = 0x87CEEB - s * 0x051020 + colorShift;
}
}
// Spawn fruits
spawnTimer++;
if (spawnTimer >= spawnRate) {
spawnTimer = 0;
var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(fruitType);
fruit.x = Math.random() * 1800 + 124; // Random x position within screen bounds
fruit.y = -100; // Start above screen
fruits.push(fruit);
game.addChild(fruit);
// Spawn rate is now controlled by difficulty level in slice function
}
// Update fruits and remove off-screen ones
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Check if fruit touched the ground (game over condition)
if (fruit.y > 2732 && !fruit.sliced) {
// Game over - fruit touched the ground
LK.showGameOver();
return; // Stop game execution
}
// Remove fruits that fall off screen
if (fruit.y > 2800) {
fruit.destroy();
fruits.splice(i, 1);
}
}
// Update particles
for (var j = particles.length - 1; j >= 0; j--) {
var particle = particles[j];
if (particle.life <= 0) {
particles.splice(j, 1);
}
}
// Update katana health system
if (katanaParalyzed) {
paralyzeTimer--;
if (paralyzeTimer <= 0) {
katanaParalyzed = false;
katanaHealth = maxKatanaHealth; // Restore full health
// Update health bar to full
tween(healthBarFill, {
scaleX: 3
}, {
duration: 300
});
healthBarFill.tint = 0x27AE60; // Green
// Hide health bar after recovery
tween(healthBarContainer, {
alpha: 0
}, {
duration: 1000
});
}
} else {
// Gradually regenerate health when not making rapid movements
if (katanaHealth < maxKatanaHealth) {
katanaHealth += 0.5; // Slow regeneration
if (katanaHealth > maxKatanaHealth) {
katanaHealth = maxKatanaHealth;
}
// Update health bar fill
var healthPercent = katanaHealth / maxKatanaHealth;
healthBarFill.scaleX = 3 * healthPercent;
// Update color
if (healthPercent < 0.3) {
healthBarFill.tint = 0xE74C3C; // Red
} else if (healthPercent < 0.6) {
healthBarFill.tint = 0xF39C12; // Orange
} else {
healthBarFill.tint = 0x27AE60; // Green
}
// Hide health bar when fully recovered and not being used
if (katanaHealth >= maxKatanaHealth && healthBarContainer.alpha > 0) {
tween(healthBarContainer, {
alpha: 0
}, {
duration: 2000
});
}
}
}
};
katana animada. In-Game asset. 2d. High contrast. No shadows
manzana animada. In-Game asset. 2d. High contrast. No shadows
melon animado. In-Game asset. 2d. High contrast. No shadows
Naranja animada. In-Game asset. 2d. High contrast. No shadows
platano animado. In-Game asset. 2d. High contrast. No shadows
piña animada. In-Game asset. 2d. High contrast. No shadows
Tronco completo de un arbol animado. In-Game asset. 2d. High contrast. No shadows
montañas con nieve en la punta animadas. In-Game asset. 2d. High contrast. No shadows
LUna animada. In-Game asset. 2d. High contrast. No shadows
nubes animada. In-Game asset. 2d. High contrast. No shadows
Pasto animado. In-Game asset. 2d. High contrast. No shadows
Flower animada. In-Game asset. 2d. High contrast. No shadows