User prompt
Que el boton de jugar de nuevo sea rectangular
User prompt
Cuando se acaben las vidas, que se detenga el juego y cuando se le presione el boton de jugar de nuevo que se reinicien las vidas y la barra de energía
User prompt
Cuando se acaben las vidas:
User prompt
Elimina los codigos repetidos y la barra de progreso profavor
User prompt
Pantalla final ‐ Muestra: Puntuación (Energía alcanzada), tiempo jugado, tabla de mensajes:
▸ ≥25 pts → “¡NutriMáster!”
▸ 15‐24 pts → “¡Buen cazador de nutrientes!”
▸ <15 pts → “Sigue practicando, revisa tus elecciones”.
Reintento Botón “Jugar de nuevo”; re‐inicia variables y anima contador regresivo 3‐2‐1.
↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que las vida vayan bajando cuando el jugador toque comida chatarra
User prompt
Cuando las vidas lleguen a 0 que se reinicie todo
User prompt
Marcador Barra de Energía (0‐30). Empieza en 15.
‐ A 0 → pantalla “Fatiga” (fin).
Vida = 3 corazones; sin corazones → pantalla “Colapso” (fin).
User prompt
Haz qje la barra de Energía regrese a como estaba antes
User prompt
Cuando comienze el reto de experto que la velocidad de los alimentos baje más rapido. Y el texto en la pantalla que ocupe toda la pantalla y cambia las fuentes del juego a unas más llamativas ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que la barra de Energía vaya avanzando progresivamente según los alimentos saludable que consiga el jugador ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Podrias agrandar la barra de energía
User prompt
Marcador Barra de Energía (agrandalo) (0‐30). Empieza en 15.
‐ A 0 → pantalla “Fatiga” (fin).
Vida = 3 corazones; sin corazones → pantalla “Colapso” (fin).
Niveles–tiempo El juego es endless; a los 30 segundos aparece mensaje “¡Reto experto!” y se agregan bombas de ansiedad (objeto negro) → –5 Energía si se atrapa.
Power‐ups 1 cada 20 alimentos: Botella de agua → restaura +3 Energía.
Duración sprite en pantalla igual a alimentos
↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agranda el tamño del jugador y de la comida
User prompt
Clasificación 1 Saludables → +1 punto «Energía».
2 Ultraprocesados → –1 vida.
3 Falsos sanos (p. ej. “cereal azucarado”) → –2 puntos «Energía».
Marcador Barra de Energía (0‐30). Empieza en 15.
‐ A 0 → pantalla “Fatiga” (fin).
Vida = 3 corazones; sin corazones → pantalla “Colapso” (fin).
Niveles–tiempo El juego es endless; al minuto 2 aparece mensaje “¡Reto experto!” y se agregan bombas de ansiedad (objeto negro) → –5 Energía si se atrapa.
Power‐ups 1 cada 20 alimentos: Botella de agua → restaura +3 Energía.
Duración sprite en pantalla igual a alimentos.
Feedback inmediato Acierto → sonido “ping”, destello verde en avatar.
Error → sonido “buzz”, destello rojo, vibra (API Vibration) 100 ms en móvil.
Pantalla final ‐ Muestra: Puntuación (Energía alcanzada), tiempo jugado, tabla de mensajes:
▸ ≥25 pts → “¡NutriMáster!”
▸ 15‐24 pts → “¡Buen cazador de nutrientes!”
▸ <15 pts → “Sigue practicando, revisa tus elecciones”.
Reintento Botón “Jugar de nuevo”; re‐inicia variables y anima contador regresivo 3‐2‐1.
↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Que la bola de ansiedad aparezca cada 40 segundos, que la comida caiga en diferentes velocidades ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Clasificación 1 Saludables → +1 punto «Energía».
2 Ultraprocesados → –1 vida.
3 Falsos sanos (p. ej. “cereal azucarado”) → –2 puntos «Energía».
Marcador Barra de Energía (0‐30). Empieza en 15.
‐ A 0 → pantalla “Fatiga” (fin).
Vida = 3 corazones; sin corazones → pantalla “Colapso” (fin).
Niveles–tiempo El juego es endless; al minuto 2 aparece mensaje “¡Reto experto!” y se agregan bombas de ansiedad (objeto negro) → –5 Energía si se atrapa.
Power‐ups 1 cada 20 alimentos: Botella de agua → restaura +3 Energía.
Duración sprite en pantalla igual a alimentos.
Feedback inmediato Acierto → sonido “ping”, destello verde en avatar.
Error → sonido “buzz”, destello rojo, vibra (API Vibration) 100 ms en móvil.
Pantalla final ‐ Muestra: Puntuación (Energía alcanzada), tiempo jugado, tabla de mensajes:
▸ ≥25 pts → “¡NutriMáster!”
▸ 15‐24 pts → “¡Buen cazador de nutrientes!”
▸ <15 pts → “Sigue practicando, revisa tus elecciones”.
Reintento Botón “Jugar de nuevo”; re‐inicia variables y anima contador regresivo 3‐2‐1.
↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Lista mínima de sprites saludables (PNG, fondo transparente): plátano, manzana, zanahoria, brócoli, pan integral, huevo duro. Sprites ultraprocesados: gaseosa, papas fritas de bolsa, caramelo, hamburguesa fast‐food. Sprites falsos sanos: barra “cereal” con azúcar, yogur saborizado azucarado.
User prompt
que la comida sea el doble de grance, que no caiga tanta a la vez y que caiga más rapido
User prompt
que caiga menos fruta y que sea más grande
User prompt
que la fruta sea más grande y rapida, Alimentos que caen ‐ Sprites PNG 96×96 px. ‐ Velocidad inicial 100 px/s; aumenta 10 px/s cada 15 seg. ‐ Cada 0,7 s se instancia 1 alimento en posición X aleatoria arriba del canvas. Clasificación 1 Saludables → +1 punto «Energía». 2 Ultraprocesados → –1 vida. 3 Falsos sanos (p. ej. “cereal azucarado”) → –2 puntos «Energía». Marcador Barra de Energía (0‐30). Empieza en 15. ‐ A 0 → pantalla “Fatiga” (fin). Vida = 3 corazones; sin corazones → pantalla “Colapso” (fin). Niveles–tiempo El juego es endless; al minuto 2 aparece mensaje “¡Reto experto!” y se agregan bombas de ansiedad (objeto negro) → –5 Energía si se atrapa. Power‐ups 1 cada 20 alimentos: Botella de agua → restaura +3 Energía. Duración sprite en pantalla igual a alimentos. Feedback inmediato Acierto → sonido “ping”, destello verde en avatar. Error → sonido “buzz”, destello rojo, vibra (API Vibration) 100 ms en móvil. Pantalla final ‐ Muestra: Puntuación (Energía alcanzada), tiempo jugado, tabla de mensajes: ▸ ≥25 pts → “¡NutriMáster!” ▸ 15‐24 pts → “¡Buen cazador de nutrientes!” ▸ <15 pts → “Sigue practicando, revisa tus elecciones”. Reintento Botón “Jugar de nuevo”; re‐inicia variables y anima contador regresivo 3‐2‐1. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
que solamente haya 10 tipos de comida, y aumentales el tamaño un poco más
User prompt
agrega más variedad de comida
User prompt
haz la comida más grande y que caiga más rapido
User prompt
podrías hacer que la fruta caiga más rápido
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var FallingItem = Container.expand(function (type, specificFood) { var self = Container.call(this); self.type = type; self.specificFood = specificFood; // Set different speeds based on type and add randomness if (type === 'anxiety') { self.speed = fallSpeed * 1.5; // Anxiety bombs fall faster } else if (type === 'water') { self.speed = fallSpeed * 0.8; // Water bottles fall slower } else { // Food items have variable speeds between 0.7x and 1.3x base speed var speedMultiplier = 0.7 + Math.random() * 0.6; // Increase speed significantly during expert mode if (anxietyBombsActive) { speedMultiplier *= 1.8; // Make items fall 80% faster in expert mode } self.speed = fallSpeed * speedMultiplier; } var assetName = specificFood || 'waterBottle'; if (type === 'water') assetName = 'waterBottle';else if (type === 'anxiety') assetName = 'anxietyBomb'; var graphic = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += self.speed; }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerBody = self.attachAsset('player', { anchorX: 0.5, anchorY: 1.0 }); var basket = self.attachAsset('basket', { anchorX: 0.5, anchorY: 0.5, y: -110 }); self.speed = 8; self.targetX = self.x; self.update = function () { var dx = self.targetX - self.x; if (Math.abs(dx) > 5) { self.x += dx * 0.15; } else { self.x = self.targetX; } // Keep player within bounds if (self.x < 150) self.x = 150; if (self.x > 2048 - 150) self.x = 2048 - 150; }; self.moveTo = function (targetX) { self.targetX = targetX; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Fake Healthy Foods // Junk Foods // Healthy Foods - Proteins & Grains // Healthy Foods - Vegetables // Healthy Foods - Fruits // Game variables // Healthy foods // Junk foods // Fake healthy foods // Game elements var player; var fallingItems = []; var energy = 15; var lives = 3; var fallSpeed = 200 / 60; // 200px/s converted to pixels per frame (doubled speed) var lastSpeedIncrease = 0; var lastWaterSpawn = 0; var gameStartTime = 0; var foodsCaught = 0; var anxietyBombsActive = false; var lastSpawnTime = 0; var lastAnxietySpawnTime = 0; var expertMessageShown = false; // UI elements var livesText; var scoreText; var energyText; // Initialize UI function initializeUI() { // Energy text energyText = new Text2('Energía: 15/30', { size: 36, fill: 0xFFFFFF, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); energyText.anchor.set(0, 0); LK.gui.topLeft.addChild(energyText); energyText.x = 150; energyText.y = 20; // Lives text livesText = new Text2('Vidas: 3', { size: 48, fill: 0xFF0000, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); livesText.anchor.set(1, 0); LK.gui.topRight.addChild(livesText); livesText.x = -20; livesText.y = 20; // Score text scoreText = new Text2('Puntuación: 0', { size: 42, fill: 0xFFFFFF, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); scoreText.y = 60; } // Update UI function updateUI() { energyText.setText('Energía: ' + energy + '/30'); livesText.setText('Vidas: ' + lives); scoreText.setText('Puntuación: ' + LK.getScore()); } // Flash effect function flashScreen(color) { LK.effects.flashScreen(color, 300); } // Food arrays for variety - exactly 10 sprite types + 2 fake healthy var healthyFoods = ['banana', 'apple', 'carrot', 'broccoli', 'wholeBread', 'hardEgg']; var junkFoods = ['soda', 'chips', 'candy', 'burger']; var fakeFoods = ['cerealBar', 'flavoredYogurt']; // Spawn falling item function spawnFallingItem() { var type = 'healthy'; var specificFood = null; var rand = Math.random(); if (foodsCaught > 0 && foodsCaught % 20 === 0 && lastWaterSpawn !== foodsCaught) { type = 'water'; lastWaterSpawn = foodsCaught; } else if (rand < 0.3) { type = 'junk'; specificFood = junkFoods[Math.floor(Math.random() * junkFoods.length)]; } else if (rand < 0.5) { type = 'fake'; specificFood = fakeFoods[Math.floor(Math.random() * fakeFoods.length)]; } else { type = 'healthy'; specificFood = healthyFoods[Math.floor(Math.random() * healthyFoods.length)]; } var item = new FallingItem(type, specificFood); item.x = Math.random() * (2048 - 350) + 175; item.y = -175; fallingItems.push(item); game.addChild(item); } // Spawn anxiety bomb function spawnAnxietyBomb() { var item = new FallingItem('anxiety', null); item.x = Math.random() * (2048 - 350) + 175; item.y = -175; fallingItems.push(item); game.addChild(item); } // Helper function for player visual feedback function playerFeedback(color, duration, scaleEffect) { if (scaleEffect) { tween(player, { scaleX: 1.2, scaleY: 1.2 }, { duration: duration, onFinish: function onFinish() { tween(player, { scaleX: 1.0, scaleY: 1.0 }, { duration: duration }); } }); } else { tween(player, { tint: color }, { duration: duration, onFinish: function onFinish() { tween(player, { tint: 0xFFFFFF }, { duration: duration }); } }); } } // Helper function for vibration feedback function vibrateDevice() { if (navigator && navigator.vibrate) { navigator.vibrate(100); } } // Handle item collision function handleItemCollision(item) { switch (item.type) { case 'healthy': energy = Math.min(30, energy + 1); LK.getSound('ping').play(); flashScreen(0x32CD32); playerFeedback(0x32CD32, 100, false); foodsCaught++; break; case 'junk': lives--; LK.getSound('buzz').play(); vibrateDevice(); flashScreen(0xFF4500); playerFeedback(0xFF4500, 100, false); break; case 'fake': energy = Math.max(0, energy - 2); LK.getSound('buzz').play(); vibrateDevice(); flashScreen(0xFFD700); playerFeedback(0xFFD700, 100, false); break; case 'water': energy = Math.min(30, energy + 3); LK.getSound('powerup').play(); flashScreen(0x00BFFF); playerFeedback(0x00BFFF, 150, true); break; case 'anxiety': energy = Math.max(0, energy - 5); LK.getSound('explosion').play(); vibrateDevice(); flashScreen(0x8B008B); playerFeedback(0x8B008B, 300, false); break; } } // Initialize game function initializeGame() { gameStartTime = LK.ticks; // Create player player = new Player(); player.x = 2048 / 2; player.y = 2732 - 100; game.addChild(player); // Initialize UI initializeUI(); updateUI(); } // Game input handling game.down = function (x, y, obj) { var gamePos = game.toLocal({ x: x, y: y }); player.moveTo(gamePos.x); }; game.move = function (x, y, obj) { var gamePos = game.toLocal({ x: x, y: y }); player.moveTo(gamePos.x); }; // Main game update loop game.update = function () { var currentTime = LK.ticks; var gameTime = (currentTime - gameStartTime) / 60; // Convert to seconds // Increase speed every 15 seconds if (gameTime - lastSpeedIncrease >= 15) { fallSpeed += 10 / 60; // Increase by 10px/s lastSpeedIncrease = gameTime; } // Activate anxiety bombs after 30 seconds if (gameTime >= 30 && !anxietyBombsActive) { anxietyBombsActive = true; expertMessageShown = true; lastAnxietySpawnTime = currentTime; // Create full screen overlay for expert message var expertOverlay = LK.getAsset('basket', { width: 2048, height: 2732, anchorX: 0, anchorY: 0 }); expertOverlay.tint = 0x000000; expertOverlay.alpha = 0.9; game.addChild(expertOverlay); // Show expert challenge message with attractive styling var expertText = new Text2('¡RETO EXPERTO!', { size: 120, fill: 0xFFD700, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); expertText.anchor.set(0.5, 0.5); expertText.x = 2048 / 2; expertText.y = 2732 / 2 - 100; game.addChild(expertText); // Add subtitle text var subtitleText = new Text2('¡Los alimentos caen más rápido!', { size: 60, fill: 0xFF4500, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); subtitleText.anchor.set(0.5, 0.5); subtitleText.x = 2048 / 2; subtitleText.y = 2732 / 2 + 50; game.addChild(subtitleText); // Animate expert message with pulsing effect tween(expertText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { tween(expertText, { scaleX: 1.0, scaleY: 1.0 }, { duration: 500, easing: tween.easeInOut }); } }); // Animate and remove message after 4 seconds tween(expertOverlay, { alpha: 0 }, { duration: 4000, onFinish: function onFinish() { expertOverlay.destroy(); } }); tween(expertText, { alpha: 0 }, { duration: 4000, onFinish: function onFinish() { expertText.destroy(); } }); tween(subtitleText, { alpha: 0 }, { duration: 4000, onFinish: function onFinish() { subtitleText.destroy(); } }); } // Spawn items every 2 seconds if (currentTime - lastSpawnTime >= 120) { // 2.0 * 60 = 120 frames spawnFallingItem(); lastSpawnTime = currentTime; } // Spawn anxiety bombs every 40 seconds after activation if (anxietyBombsActive && currentTime - lastAnxietySpawnTime >= 2400) { // 40 * 60 = 2400 frames spawnAnxietyBomb(); lastAnxietySpawnTime = currentTime; } // Update falling items for (var i = fallingItems.length - 1; i >= 0; i--) { var item = fallingItems[i]; // Check collision with player if (item.intersects(player)) { handleItemCollision(item); item.destroy(); fallingItems.splice(i, 1); continue; } // Remove items that fall off screen if (item.y > 2732 + 350) { item.destroy(); fallingItems.splice(i, 1); } } // Update UI updateUI(); // Check game over conditions if (energy <= 0) { // Store final stats storage.finalEnergy = energy; storage.finalTime = Math.floor(gameTime); storage.gameEndReason = 'fatiga'; LK.setScore(energy); showCustomGameOver(); } else if (lives <= 0) { // When lives reach 0, restart the entire game startCountdown(); } }; // Show custom game over message function showCustomGameOver() { var finalEnergy = storage.finalEnergy || energy; var finalTime = storage.finalTime || Math.floor((LK.ticks - gameStartTime) / 60); var reason = storage.gameEndReason || 'fatiga'; var message = ''; if (finalEnergy >= 25) { message = '¡NutriMáster!'; } else if (finalEnergy >= 15) { message = '¡Buen cazador de nutrientes!'; } else { message = 'Sigue practicando, revisa tus elecciones'; } // Create full screen overlay var overlay = LK.getAsset('basket', { width: 2048, height: 2732, anchorX: 0, anchorY: 0 }); overlay.tint = 0x000000; overlay.alpha = 0.9; game.addChild(overlay); // Title var titleText = new Text2('PANTALLA FINAL', { size: 80, fill: 0xFFD700, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 400; game.addChild(titleText); // Score section var scoreText = new Text2('Puntuación (Energía alcanzada): ' + finalEnergy, { size: 56, fill: 0x32CD32, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); scoreText.anchor.set(0.5, 0.5); scoreText.x = 2048 / 2; scoreText.y = 600; game.addChild(scoreText); // Time played section var timeText = new Text2('Tiempo jugado: ' + finalTime + ' segundos', { size: 56, fill: 0x00BFFF, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); timeText.anchor.set(0.5, 0.5); timeText.x = 2048 / 2; timeText.y = 750; game.addChild(timeText); // Message section with color based on performance var messageColor = 0xFFFFFF; if (finalEnergy >= 25) { messageColor = 0xFFD700; // Gold for NutriMaster } else if (finalEnergy >= 15) { messageColor = 0x32CD32; // Green for good hunter } else { messageColor = 0xFF4500; // Orange for keep practicing } var messageText = new Text2(message, { size: 64, fill: messageColor, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); messageText.anchor.set(0.5, 0.5); messageText.x = 2048 / 2; messageText.y = 950; game.addChild(messageText); // Create animated restart button var restartButton = LK.getAsset('basket', { width: 500, height: 100, anchorX: 0.5, anchorY: 0.5 }); restartButton.tint = 0x32CD32; restartButton.x = 2048 / 2; restartButton.y = 1300; game.addChild(restartButton); var restartText = new Text2('Jugar de nuevo', { size: 52, fill: 0xFFFFFF, font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif" }); restartText.anchor.set(0.5, 0.5); restartText.x = 2048 / 2; restartText.y = 1300; game.addChild(restartText); // Animate button with pulsing effect function animateRestartButton() { tween(restartButton, { scaleX: 1.1, scaleY: 1.1 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(restartButton, { scaleX: 1.0, scaleY: 1.0 }, { duration: 800, easing: tween.easeInOut, onFinish: animateRestartButton }); } }); tween(restartText, { scaleX: 1.1, scaleY: 1.1 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(restartText, { scaleX: 1.0, scaleY: 1.0 }, { duration: 800, easing: tween.easeInOut }); } }); } animateRestartButton(); // Add click handler for restart restartButton.down = function () { startCountdown(); }; restartText.down = function () { startCountdown(); }; } // Start countdown and restart game function startCountdown() { // Clear all game objects for (var i = fallingItems.length - 1; i >= 0; i--) { fallingItems[i].destroy(); } fallingItems = []; game.removeChildren(); // Reset all game variables energy = 15; lives = 3; fallSpeed = 200 / 60; lastSpeedIncrease = 0; lastWaterSpawn = 0; gameStartTime = 0; foodsCaught = 0; anxietyBombsActive = false; lastSpawnTime = 0; lastAnxietySpawnTime = 0; expertMessageShown = false; LK.setScore(0); // Show countdown var countdownNumbers = [3, 2, 1]; var currentCount = 0; function showCountdownNumber() { if (currentCount < countdownNumbers.length) { var countText = new Text2(countdownNumbers[currentCount].toString(), { size: 200, fill: 0xFFFF00, font: "'Impact', 'Arial Black', sans-serif" }); countText.anchor.set(0.5, 0.5); countText.x = 2048 / 2; countText.y = 2732 / 2; game.addChild(countText); // Animate countdown number tween(countText, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 1000, onFinish: function onFinish() { countText.destroy(); currentCount++; if (currentCount < countdownNumbers.length) { showCountdownNumber(); } else { // Start new game initializeGame(); } } }); } } showCountdownNumber(); } // Initialize the game initializeGame(); ;
===================================================================
--- original.js
+++ change.js
@@ -75,18 +75,18 @@
/****
* Game Code
****/
-// Game elements
-// Fake healthy foods
-// Junk foods
-// Healthy foods
-// Game variables
-// Healthy Foods - Fruits
-// Healthy Foods - Vegetables
-// Healthy Foods - Proteins & Grains
-// Junk Foods
// Fake Healthy Foods
+// Junk Foods
+// Healthy Foods - Proteins & Grains
+// Healthy Foods - Vegetables
+// Healthy Foods - Fruits
+// Game variables
+// Healthy foods
+// Junk foods
+// Fake healthy foods
+// Game elements
var player;
var fallingItems = [];
var energy = 15;
var lives = 3;
@@ -99,36 +99,13 @@
var lastSpawnTime = 0;
var lastAnxietySpawnTime = 0;
var expertMessageShown = false;
// UI elements
-var energyBar;
var livesText;
var scoreText;
var energyText;
// Initialize UI
function initializeUI() {
- // Energy bar background
- var energyBarBg = LK.getAsset('basket', {
- width: 400,
- height: 30,
- anchorX: 0,
- anchorY: 0
- });
- energyBarBg.tint = 0x444444;
- LK.gui.topLeft.addChild(energyBarBg);
- energyBarBg.x = 150;
- energyBarBg.y = 20;
- // Energy bar fill
- energyBar = LK.getAsset('basket', {
- width: 300,
- height: 26,
- anchorX: 0,
- anchorY: 0
- });
- energyBar.tint = 0x32CD32;
- LK.gui.topLeft.addChild(energyBar);
- energyBar.x = 152;
- energyBar.y = 22;
// Energy text
energyText = new Text2('Energía: 15/30', {
size: 36,
fill: 0xFFFFFF,
@@ -136,9 +113,9 @@
});
energyText.anchor.set(0, 0);
LK.gui.topLeft.addChild(energyText);
energyText.x = 150;
- energyText.y = 60;
+ energyText.y = 20;
// Lives text
livesText = new Text2('Vidas: 3', {
size: 48,
fill: 0xFF0000,
@@ -155,17 +132,12 @@
font: "'Impact', 'Bebas Neue', 'Anton', 'Oswald', 'Arial Black', sans-serif"
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
- scoreText.y = 120;
+ scoreText.y = 60;
}
// Update UI
function updateUI() {
- var energyPercent = Math.max(0, energy / 30);
- energyBar.width = 396 * energyPercent;
- if (energy > 20) energyBar.tint = 0x32CD32; // Green
- else if (energy > 10) energyBar.tint = 0xFFD700; // Yellow
- else energyBar.tint = 0xFF4500; // Red
energyText.setText('Energía: ' + energy + '/30');
livesText.setText('Vidas: ' + lives);
scoreText.setText('Puntuación: ' + LK.getScore());
}
@@ -208,110 +180,82 @@
item.y = -175;
fallingItems.push(item);
game.addChild(item);
}
+// Helper function for player visual feedback
+function playerFeedback(color, duration, scaleEffect) {
+ if (scaleEffect) {
+ tween(player, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: duration,
+ onFinish: function onFinish() {
+ tween(player, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: duration
+ });
+ }
+ });
+ } else {
+ tween(player, {
+ tint: color
+ }, {
+ duration: duration,
+ onFinish: function onFinish() {
+ tween(player, {
+ tint: 0xFFFFFF
+ }, {
+ duration: duration
+ });
+ }
+ });
+ }
+}
+// Helper function for vibration feedback
+function vibrateDevice() {
+ if (navigator && navigator.vibrate) {
+ navigator.vibrate(100);
+ }
+}
// Handle item collision
function handleItemCollision(item) {
switch (item.type) {
case 'healthy':
energy = Math.min(30, energy + 1);
LK.getSound('ping').play();
flashScreen(0x32CD32);
- tween(player, {
- tint: 0x32CD32
- }, {
- duration: 100,
- onFinish: function onFinish() {
- tween(player, {
- tint: 0xFFFFFF
- }, {
- duration: 100
- });
- }
- });
+ playerFeedback(0x32CD32, 100, false);
foodsCaught++;
break;
case 'junk':
lives--;
LK.getSound('buzz').play();
- // Vibration feedback for mobile
- if (navigator && navigator.vibrate) {
- navigator.vibrate(100);
- }
+ vibrateDevice();
flashScreen(0xFF4500);
- tween(player, {
- tint: 0xFF4500
- }, {
- duration: 100,
- onFinish: function onFinish() {
- tween(player, {
- tint: 0xFFFFFF
- }, {
- duration: 100
- });
- }
- });
+ playerFeedback(0xFF4500, 100, false);
break;
case 'fake':
energy = Math.max(0, energy - 2);
LK.getSound('buzz').play();
- // Vibration feedback for mobile
- if (navigator && navigator.vibrate) {
- navigator.vibrate(100);
- }
+ vibrateDevice();
flashScreen(0xFFD700);
- tween(player, {
- tint: 0xFFD700
- }, {
- duration: 100,
- onFinish: function onFinish() {
- tween(player, {
- tint: 0xFFFFFF
- }, {
- duration: 100
- });
- }
- });
+ playerFeedback(0xFFD700, 100, false);
break;
case 'water':
energy = Math.min(30, energy + 3);
LK.getSound('powerup').play();
flashScreen(0x00BFFF);
- tween(player, {
- scaleX: 1.2,
- scaleY: 1.2
- }, {
- duration: 150,
- onFinish: function onFinish() {
- tween(player, {
- scaleX: 1.0,
- scaleY: 1.0
- }, {
- duration: 150
- });
- }
- });
+ playerFeedback(0x00BFFF, 150, true);
break;
case 'anxiety':
energy = Math.max(0, energy - 5);
LK.getSound('explosion').play();
- // Vibration feedback for mobile
- if (navigator && navigator.vibrate) {
- navigator.vibrate(100);
- }
+ vibrateDevice();
flashScreen(0x8B008B);
- tween(player, {
- tint: 0x8B008B
- }, {
- duration: 300,
- onFinish: function onFinish() {
- tween(player, {
- tint: 0xFFFFFF
- }, {
- duration: 300
- });
- }
- });
+ playerFeedback(0x8B008B, 300, false);
break;
}
}
// Initialize game