User prompt
Haz que el texto "TAP TO START" sea más alegre y colorido ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que el botón "TAP TO START" tenga un estilo cartoon
User prompt
Haz que el botón de jugar "TAP TO START" se note más ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que cuando aparezca la pantalla de inicio no aparezca el juego y sólo el botón de jugar se podrá ver
User prompt
Agrega una pantalla de inicio con un menú
User prompt
Haz que el activo "zona de luz" tenga un cielo azul de fondo
User prompt
Haz un pasto verde desde arriba realista
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'transformText.style.fill = "#FFFF99";' Line Number: 322
Code edit (1 edits merged)
Please save this source code
User prompt
Luz y Sombra
Initial prompt
¡Claro! Aquí tienes una idea original para un juego: --- 🎮 Título: “Luz y Sombra” 📜 Género: Aventura / Puzzles / Plataformas 🧠 Concepto General: Eres un joven guardián que despierta en un mundo dividido entre la luz eterna y la oscuridad perpetua. Cada zona del mundo está corrompida por un exceso de uno de los dos elementos: luz o sombra. Tu misión es restaurar el equilibrio, manipulando ambos poderes a tu favor. --- 🕹️ Mecánicas principales: Cambio de forma: Puedes alternar entre forma de luz y forma de sombra. Cada una tiene habilidades distintas: Luz: Puede iluminar áreas oscuras, activar mecanismos solares, moverse más rápido. Sombra: Puede volverse intangible, absorber energía, colarse en grietas. Puzzles ambientales: Algunos caminos solo se abren combinando ambas formas, usando reflejos, sombras proyectadas y plataformas que reaccionan a la luz o la oscuridad. Narrativa ambiental: No hay diálogo. La historia se cuenta a través del entorno: ruinas, pinturas antiguas, espíritus atrapados. Exploración no lineal: Cada región del mapa tiene distintos niveles de desequilibrio. Puedes elegir a qué zona ir primero, desbloqueando nuevas habilidades que afectan otras zonas (tipo Metroidvania). --- 🎨 Estilo visual: Arte en 2.5D con estética minimalista, usando una paleta de colores dual (blanco brillante y negro profundo) con acentos de color en momentos clave. --- 🎵 Sonido: Una banda sonora ambiental que cambia según el dominio (más etérea en luz, más disonante y grave en sombra). --- ¿Quieres que te ayude a desarrollarlo más? Puedo crear personajes, historia, enemigos, niveles o incluso un prototipo básico en código si lo necesitas.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var MainMenu = Container.expand(function () { var self = Container.call(this); // Dark overlay background self.overlay = self.attachAsset('shadowZone', { anchorX: 0.5, anchorY: 0.5, scaleX: 6, scaleY: 8, alpha: 0.9 }); self.overlay.x = 1024; self.overlay.y = 1366; // Title text self.titleText = new Text2('LUZ Y SOMBRA', { size: 120, fill: 0xFFFFFF }); self.titleText.anchor.set(0.5, 0.5); self.titleText.x = 1024; self.titleText.y = 800; self.addChild(self.titleText); // Subtitle self.subtitleText = new Text2('Transform between light and shadow\nto restore balance to the world', { size: 50, fill: 0xCCCCCC }); self.subtitleText.anchor.set(0.5, 0.5); self.subtitleText.x = 1024; self.subtitleText.y = 1000; self.addChild(self.subtitleText); // Start button background with cartoon styling self.startButton = self.attachAsset('lightZone', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 0.6, tint: 0x00FF88 }); self.startButton.x = 1024; self.startButton.y = 1400; // Add cartoon border effect self.buttonBorder = self.attachAsset('shadowZone', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.25, scaleY: 0.65, tint: 0x004433, alpha: 0.8 }); self.buttonBorder.x = 1024; self.buttonBorder.y = 1405; // Add shadow effect self.buttonShadow = self.attachAsset('shadowZone', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.22, scaleY: 0.62, tint: 0x000000, alpha: 0.4 }); self.buttonShadow.x = 1024; self.buttonShadow.y = 1410; // Start button text with cartoon styling self.startText = new Text2('TAP TO START', { size: 64, fill: 0x003322 }); self.startText.anchor.set(0.5, 0.5); self.startText.x = 1024; self.startText.y = 1400; self.addChild(self.startText); // Add text outline effect self.startTextOutline = new Text2('TAP TO START', { size: 66, fill: 0xFFFFFF }); self.startTextOutline.anchor.set(0.5, 0.5); self.startTextOutline.x = 1022; self.startTextOutline.y = 1398; self.addChild(self.startTextOutline); // Ensure text is on top of outline self.removeChild(self.startText); self.addChild(self.startText); // Enhanced pulsing animation using tween self.startPulse = function () { // Scale up animation for button tween(self.startButton, { scaleX: 1.4, scaleY: 0.7 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { // Scale down animation tween(self.startButton, { scaleX: 1.2, scaleY: 0.6 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { self.startPulse(); // Loop the animation } }); } }); // Animate border with slight delay tween(self.buttonBorder, { scaleX: 1.45, scaleY: 0.75 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(self.buttonBorder, { scaleX: 1.25, scaleY: 0.65 }, { duration: 800, easing: tween.easeInOut }); } }); // Animate shadow tween(self.buttonShadow, { scaleX: 1.42, scaleY: 0.72 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(self.buttonShadow, { scaleX: 1.22, scaleY: 0.62 }, { duration: 800, easing: tween.easeInOut }); } }); // Joyful bouncing text animation tween(self.startText, { scaleX: 1.3, scaleY: 1.4, rotation: 0.1 }, { duration: 500, easing: tween.bounceOut, onFinish: function onFinish() { tween(self.startText, { scaleX: 1.0, scaleY: 1.0, rotation: -0.05 }, { duration: 700, easing: tween.elasticOut, onFinish: function onFinish() { tween(self.startText, { rotation: 0 }, { duration: 300, easing: tween.easeInOut }); } }); } }); // Outline bouncing animation with slight offset tween(self.startTextOutline, { scaleX: 1.25, scaleY: 1.35, rotation: 0.08 }, { duration: 500, easing: tween.bounceOut, onFinish: function onFinish() { tween(self.startTextOutline, { scaleX: 1.0, scaleY: 1.0, rotation: -0.03 }, { duration: 700, easing: tween.elasticOut, onFinish: function onFinish() { tween(self.startTextOutline, { rotation: 0 }, { duration: 300, easing: tween.easeInOut }); } }); } }); }; // Start the pulsing animation self.startPulse(); // Rainbow color animation for the text self.colorIndex = 0; self.rainbowColors = [0xFF0080, // Hot pink 0xFF4000, // Orange red 0xFFFF00, // Bright yellow 0x00FF40, // Lime green 0x0080FF, // Sky blue 0x8000FF, // Purple 0xFF0080 // Back to hot pink ]; self.colorPulse = function () { var currentColor = self.rainbowColors[self.colorIndex]; var nextIndex = (self.colorIndex + 1) % self.rainbowColors.length; var nextColor = self.rainbowColors[nextIndex]; tween(self.startText, { tint: currentColor }, { duration: 600, easing: tween.easeInOut, onFinish: function onFinish() { self.colorIndex = nextIndex; self.colorPulse(); // Loop the color animation } }); // Outline with complementary colors var outlineColor = self.colorIndex % 2 === 0 ? 0xFFFFFF : 0x000000; tween(self.startTextOutline, { tint: outlineColor }, { duration: 600, easing: tween.easeInOut }); }; // Start the rainbow color animation self.colorPulse(); self.update = function () { // Remove old simple pulsing - now using tween animations }; self.down = function (x, y, obj) { // Check if click is on start button area var buttonDistance = Math.sqrt(Math.pow(x - 1024, 2) + Math.pow(y - 1400, 2)); if (buttonDistance < 200) { self.startGame(); } }; self.startGame = function () { // Remove menu and start game self.parent.removeChild(self); gameStarted = true; // Show all game elements grassBackground.visible = true; player.visible = true; zone1.visible = true; zone2.visible = true; zone3.visible = true; zone4.visible = true; platform1.visible = true; platform2.visible = true; platform3.visible = true; platform4.visible = true; instructionText.visible = true; scoreText.visible = true; transformText.visible = true; }; return self; }); var Platform = Container.expand(function (platformType, platformX, platformY) { var self = Container.call(this); self.platformType = platformType; self.isActive = false; var assetType = platformType === 'light' ? 'lightPlatform' : 'shadowPlatform'; self.graphics = self.attachAsset(assetType, { anchorX: 0.5, anchorY: 0.5, alpha: 0.3 }); self.x = platformX; self.y = platformY; self.activate = function () { if (!self.isActive) { self.isActive = true; LK.getSound('activate').play(); tween(self.graphics, { alpha: 1 }, { duration: 500 }); } }; self.deactivate = function () { if (self.isActive) { self.isActive = false; tween(self.graphics, { alpha: 0.3 }, { duration: 500 }); } }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); self.isLightForm = true; self.speed = 8; self.transformCooldown = 0; self.lightGraphics = self.attachAsset('lightForm', { anchorX: 0.5, anchorY: 0.5 }); self.shadowGraphics = self.attachAsset('shadowForm', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); self.transform = function () { if (self.transformCooldown > 0) return; self.isLightForm = !self.isLightForm; self.transformCooldown = 30; LK.getSound('transform').play(); if (self.isLightForm) { tween(self.lightGraphics, { alpha: 1 }, { duration: 300 }); tween(self.shadowGraphics, { alpha: 0 }, { duration: 300 }); } else { tween(self.lightGraphics, { alpha: 0 }, { duration: 300 }); tween(self.shadowGraphics, { alpha: 1 }, { duration: 300 }); } }; self.update = function () { if (self.transformCooldown > 0) { self.transformCooldown--; } }; return self; }); var Zone = Container.expand(function (zoneType, zoneX, zoneY) { var self = Container.call(this); self.zoneType = zoneType; self.isCorrupted = true; self.healingProgress = 0; self.particles = []; var assetType = zoneType === 'light' ? 'lightZone' : 'shadowZone'; if (zoneType === 'light') { self.skyBackground = self.attachAsset('skyBlue', { anchorX: 0.5, anchorY: 0.5 }); } self.background = self.attachAsset(assetType, { anchorX: 0.5, anchorY: 0.5 }); self.x = zoneX; self.y = zoneY; self.createCorruptionParticles = function () { for (var i = 0; i < 8; i++) { var particle = self.addChild(LK.getAsset('corruptionParticle', { anchorX: 0.5, anchorY: 0.5 })); particle.x = (Math.random() - 0.5) * 300; particle.y = (Math.random() - 0.5) * 300; particle.floatSpeed = Math.random() * 2 + 1; particle.floatDirection = Math.random() * Math.PI * 2; self.particles.push(particle); } }; self.heal = function () { if (!self.isCorrupted) return; self.healingProgress += 2; if (self.healingProgress >= 100) { self.isCorrupted = false; LK.getSound('heal').play(); for (var i = self.particles.length - 1; i >= 0; i--) { var particle = self.particles[i]; tween(particle, { alpha: 0, scaleX: 0, scaleY: 0 }, { duration: 1000, onFinish: function onFinish() { if (particle.parent) { particle.parent.removeChild(particle); } } }); } self.particles = []; tween(self.background, { tint: 0x99CC99 }, { duration: 2000 }); for (var j = 0; j < 12; j++) { var healParticle = self.addChild(LK.getAsset('healingParticle', { anchorX: 0.5, anchorY: 0.5 })); healParticle.x = (Math.random() - 0.5) * 400; healParticle.y = (Math.random() - 0.5) * 400; tween(healParticle, { y: healParticle.y - 200, alpha: 0, scaleX: 2, scaleY: 2 }, { duration: 2000, onFinish: function onFinish() { if (healParticle.parent) { healParticle.parent.removeChild(healParticle); } } }); } zonesHealed++; scoreText.setText('Zones Healed: ' + zonesHealed + '/4'); if (zonesHealed >= 4) { LK.setTimeout(function () { LK.showYouWin(); }, 2000); } } }; self.update = function () { for (var i = 0; i < self.particles.length; i++) { var particle = self.particles[i]; particle.x += Math.cos(particle.floatDirection) * particle.floatSpeed; particle.y += Math.sin(particle.floatDirection) * particle.floatSpeed; if (Math.abs(particle.x) > 200) { particle.floatDirection = Math.PI - particle.floatDirection; } if (Math.abs(particle.y) > 200) { particle.floatDirection = -particle.floatDirection; } } }; self.createCorruptionParticles(); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x006400 }); /**** * Game Code ****/ var gameStarted = false; var grassBackground = game.addChild(LK.getAsset('grass', { anchorX: 0, anchorY: 0 })); grassBackground.x = 0; grassBackground.y = 0; grassBackground.visible = false; // Create and show main menu var mainMenu = game.addChild(new MainMenu()); var player = game.addChild(new Player()); player.x = 1024; player.y = 1366; player.visible = false; var zones = []; var platforms = []; var zonesHealed = 0; var zone1 = game.addChild(new Zone('light', 512, 600)); var zone2 = game.addChild(new Zone('shadow', 1536, 600)); var zone3 = game.addChild(new Zone('light', 512, 1800)); var zone4 = game.addChild(new Zone('shadow', 1536, 1800)); zones.push(zone1, zone2, zone3, zone4); zone1.visible = false; zone2.visible = false; zone3.visible = false; zone4.visible = false; var platform1 = game.addChild(new Platform('light', 800, 900)); var platform2 = game.addChild(new Platform('shadow', 1248, 900)); var platform3 = game.addChild(new Platform('light', 800, 1500)); var platform4 = game.addChild(new Platform('shadow', 1248, 1500)); platforms.push(platform1, platform2, platform3, platform4); platform1.visible = false; platform2.visible = false; platform3.visible = false; platform4.visible = false; var instructionText = new Text2('Tap to move player\nDouble tap to transform\nStand on matching platforms to heal zones', { size: 40, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 0); LK.gui.top.addChild(instructionText); instructionText.y = 100; instructionText.visible = false; var scoreText = new Text2('Zones Healed: 0/4', { size: 50, fill: 0xFFFF99 }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); scoreText.y = 200; scoreText.visible = false; var transformText = new Text2('', { size: 45, fill: 0xFF99FF }); transformText.anchor.set(0.5, 1); LK.gui.bottom.addChild(transformText); transformText.visible = false; var lastTapTime = 0; var targetX = player.x; var targetY = player.y; game.down = function (x, y, obj) { if (!gameStarted) { return; // Menu will handle its own input } var currentTime = Date.now(); if (currentTime - lastTapTime < 300) { player.transform(); } else { targetX = x; targetY = y; } lastTapTime = currentTime; }; game.update = function () { if (!gameStarted) { return; // Don't update game logic until started } var dx = targetX - player.x; var dy = targetY - player.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 10) { var moveX = dx / distance * player.speed; var moveY = dy / distance * player.speed; player.x += moveX; player.y += moveY; } for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; var platformDistance = Math.sqrt(Math.pow(player.x - platform.x, 2) + Math.pow(player.y - platform.y, 2)); if (platformDistance < 120) { if (player.isLightForm && platform.platformType === 'light' || !player.isLightForm && platform.platformType === 'shadow') { platform.activate(); } else { platform.deactivate(); } } else { platform.deactivate(); } } for (var j = 0; j < zones.length; j++) { var zone = zones[j]; if (!zone.isCorrupted) continue; var zoneDistance = Math.sqrt(Math.pow(player.x - zone.x, 2) + Math.pow(player.y - zone.y, 2)); if (zoneDistance < 220) { var nearbyPlatform = null; for (var k = 0; k < platforms.length; k++) { var checkPlatform = platforms[k]; var platZoneDistance = Math.sqrt(Math.pow(zone.x - checkPlatform.x, 2) + Math.pow(zone.y - checkPlatform.y, 2)); if (platZoneDistance < 400 && checkPlatform.isActive) { var correctForm = zone.zoneType === 'light' && !player.isLightForm || zone.zoneType === 'shadow' && player.isLightForm; if (correctForm) { nearbyPlatform = checkPlatform; break; } } } if (nearbyPlatform) { zone.heal(); } } } if (player.isLightForm) { transformText.setText('Light Form - Fast Movement'); transformText.fill = "#FFFF99"; } else { transformText.setText('Shadow Form - Energy Absorption'); transformText.fill = "#9966FF"; } if (player.transformCooldown > 0) { transformText.setText(transformText.text + ' (Cooldown: ' + Math.ceil(player.transformCooldown / 60) + 's)'); } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var MainMenu = Container.expand(function () {
var self = Container.call(this);
// Dark overlay background
self.overlay = self.attachAsset('shadowZone', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 6,
scaleY: 8,
alpha: 0.9
});
self.overlay.x = 1024;
self.overlay.y = 1366;
// Title text
self.titleText = new Text2('LUZ Y SOMBRA', {
size: 120,
fill: 0xFFFFFF
});
self.titleText.anchor.set(0.5, 0.5);
self.titleText.x = 1024;
self.titleText.y = 800;
self.addChild(self.titleText);
// Subtitle
self.subtitleText = new Text2('Transform between light and shadow\nto restore balance to the world', {
size: 50,
fill: 0xCCCCCC
});
self.subtitleText.anchor.set(0.5, 0.5);
self.subtitleText.x = 1024;
self.subtitleText.y = 1000;
self.addChild(self.subtitleText);
// Start button background with cartoon styling
self.startButton = self.attachAsset('lightZone', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 0.6,
tint: 0x00FF88
});
self.startButton.x = 1024;
self.startButton.y = 1400;
// Add cartoon border effect
self.buttonBorder = self.attachAsset('shadowZone', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.25,
scaleY: 0.65,
tint: 0x004433,
alpha: 0.8
});
self.buttonBorder.x = 1024;
self.buttonBorder.y = 1405;
// Add shadow effect
self.buttonShadow = self.attachAsset('shadowZone', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.22,
scaleY: 0.62,
tint: 0x000000,
alpha: 0.4
});
self.buttonShadow.x = 1024;
self.buttonShadow.y = 1410;
// Start button text with cartoon styling
self.startText = new Text2('TAP TO START', {
size: 64,
fill: 0x003322
});
self.startText.anchor.set(0.5, 0.5);
self.startText.x = 1024;
self.startText.y = 1400;
self.addChild(self.startText);
// Add text outline effect
self.startTextOutline = new Text2('TAP TO START', {
size: 66,
fill: 0xFFFFFF
});
self.startTextOutline.anchor.set(0.5, 0.5);
self.startTextOutline.x = 1022;
self.startTextOutline.y = 1398;
self.addChild(self.startTextOutline);
// Ensure text is on top of outline
self.removeChild(self.startText);
self.addChild(self.startText);
// Enhanced pulsing animation using tween
self.startPulse = function () {
// Scale up animation for button
tween(self.startButton, {
scaleX: 1.4,
scaleY: 0.7
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Scale down animation
tween(self.startButton, {
scaleX: 1.2,
scaleY: 0.6
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.startPulse(); // Loop the animation
}
});
}
});
// Animate border with slight delay
tween(self.buttonBorder, {
scaleX: 1.45,
scaleY: 0.75
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self.buttonBorder, {
scaleX: 1.25,
scaleY: 0.65
}, {
duration: 800,
easing: tween.easeInOut
});
}
});
// Animate shadow
tween(self.buttonShadow, {
scaleX: 1.42,
scaleY: 0.72
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self.buttonShadow, {
scaleX: 1.22,
scaleY: 0.62
}, {
duration: 800,
easing: tween.easeInOut
});
}
});
// Joyful bouncing text animation
tween(self.startText, {
scaleX: 1.3,
scaleY: 1.4,
rotation: 0.1
}, {
duration: 500,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(self.startText, {
scaleX: 1.0,
scaleY: 1.0,
rotation: -0.05
}, {
duration: 700,
easing: tween.elasticOut,
onFinish: function onFinish() {
tween(self.startText, {
rotation: 0
}, {
duration: 300,
easing: tween.easeInOut
});
}
});
}
});
// Outline bouncing animation with slight offset
tween(self.startTextOutline, {
scaleX: 1.25,
scaleY: 1.35,
rotation: 0.08
}, {
duration: 500,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(self.startTextOutline, {
scaleX: 1.0,
scaleY: 1.0,
rotation: -0.03
}, {
duration: 700,
easing: tween.elasticOut,
onFinish: function onFinish() {
tween(self.startTextOutline, {
rotation: 0
}, {
duration: 300,
easing: tween.easeInOut
});
}
});
}
});
};
// Start the pulsing animation
self.startPulse();
// Rainbow color animation for the text
self.colorIndex = 0;
self.rainbowColors = [0xFF0080,
// Hot pink
0xFF4000,
// Orange red
0xFFFF00,
// Bright yellow
0x00FF40,
// Lime green
0x0080FF,
// Sky blue
0x8000FF,
// Purple
0xFF0080 // Back to hot pink
];
self.colorPulse = function () {
var currentColor = self.rainbowColors[self.colorIndex];
var nextIndex = (self.colorIndex + 1) % self.rainbowColors.length;
var nextColor = self.rainbowColors[nextIndex];
tween(self.startText, {
tint: currentColor
}, {
duration: 600,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.colorIndex = nextIndex;
self.colorPulse(); // Loop the color animation
}
});
// Outline with complementary colors
var outlineColor = self.colorIndex % 2 === 0 ? 0xFFFFFF : 0x000000;
tween(self.startTextOutline, {
tint: outlineColor
}, {
duration: 600,
easing: tween.easeInOut
});
};
// Start the rainbow color animation
self.colorPulse();
self.update = function () {
// Remove old simple pulsing - now using tween animations
};
self.down = function (x, y, obj) {
// Check if click is on start button area
var buttonDistance = Math.sqrt(Math.pow(x - 1024, 2) + Math.pow(y - 1400, 2));
if (buttonDistance < 200) {
self.startGame();
}
};
self.startGame = function () {
// Remove menu and start game
self.parent.removeChild(self);
gameStarted = true;
// Show all game elements
grassBackground.visible = true;
player.visible = true;
zone1.visible = true;
zone2.visible = true;
zone3.visible = true;
zone4.visible = true;
platform1.visible = true;
platform2.visible = true;
platform3.visible = true;
platform4.visible = true;
instructionText.visible = true;
scoreText.visible = true;
transformText.visible = true;
};
return self;
});
var Platform = Container.expand(function (platformType, platformX, platformY) {
var self = Container.call(this);
self.platformType = platformType;
self.isActive = false;
var assetType = platformType === 'light' ? 'lightPlatform' : 'shadowPlatform';
self.graphics = self.attachAsset(assetType, {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3
});
self.x = platformX;
self.y = platformY;
self.activate = function () {
if (!self.isActive) {
self.isActive = true;
LK.getSound('activate').play();
tween(self.graphics, {
alpha: 1
}, {
duration: 500
});
}
};
self.deactivate = function () {
if (self.isActive) {
self.isActive = false;
tween(self.graphics, {
alpha: 0.3
}, {
duration: 500
});
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
self.isLightForm = true;
self.speed = 8;
self.transformCooldown = 0;
self.lightGraphics = self.attachAsset('lightForm', {
anchorX: 0.5,
anchorY: 0.5
});
self.shadowGraphics = self.attachAsset('shadowForm', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
});
self.transform = function () {
if (self.transformCooldown > 0) return;
self.isLightForm = !self.isLightForm;
self.transformCooldown = 30;
LK.getSound('transform').play();
if (self.isLightForm) {
tween(self.lightGraphics, {
alpha: 1
}, {
duration: 300
});
tween(self.shadowGraphics, {
alpha: 0
}, {
duration: 300
});
} else {
tween(self.lightGraphics, {
alpha: 0
}, {
duration: 300
});
tween(self.shadowGraphics, {
alpha: 1
}, {
duration: 300
});
}
};
self.update = function () {
if (self.transformCooldown > 0) {
self.transformCooldown--;
}
};
return self;
});
var Zone = Container.expand(function (zoneType, zoneX, zoneY) {
var self = Container.call(this);
self.zoneType = zoneType;
self.isCorrupted = true;
self.healingProgress = 0;
self.particles = [];
var assetType = zoneType === 'light' ? 'lightZone' : 'shadowZone';
if (zoneType === 'light') {
self.skyBackground = self.attachAsset('skyBlue', {
anchorX: 0.5,
anchorY: 0.5
});
}
self.background = self.attachAsset(assetType, {
anchorX: 0.5,
anchorY: 0.5
});
self.x = zoneX;
self.y = zoneY;
self.createCorruptionParticles = function () {
for (var i = 0; i < 8; i++) {
var particle = self.addChild(LK.getAsset('corruptionParticle', {
anchorX: 0.5,
anchorY: 0.5
}));
particle.x = (Math.random() - 0.5) * 300;
particle.y = (Math.random() - 0.5) * 300;
particle.floatSpeed = Math.random() * 2 + 1;
particle.floatDirection = Math.random() * Math.PI * 2;
self.particles.push(particle);
}
};
self.heal = function () {
if (!self.isCorrupted) return;
self.healingProgress += 2;
if (self.healingProgress >= 100) {
self.isCorrupted = false;
LK.getSound('heal').play();
for (var i = self.particles.length - 1; i >= 0; i--) {
var particle = self.particles[i];
tween(particle, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 1000,
onFinish: function onFinish() {
if (particle.parent) {
particle.parent.removeChild(particle);
}
}
});
}
self.particles = [];
tween(self.background, {
tint: 0x99CC99
}, {
duration: 2000
});
for (var j = 0; j < 12; j++) {
var healParticle = self.addChild(LK.getAsset('healingParticle', {
anchorX: 0.5,
anchorY: 0.5
}));
healParticle.x = (Math.random() - 0.5) * 400;
healParticle.y = (Math.random() - 0.5) * 400;
tween(healParticle, {
y: healParticle.y - 200,
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 2000,
onFinish: function onFinish() {
if (healParticle.parent) {
healParticle.parent.removeChild(healParticle);
}
}
});
}
zonesHealed++;
scoreText.setText('Zones Healed: ' + zonesHealed + '/4');
if (zonesHealed >= 4) {
LK.setTimeout(function () {
LK.showYouWin();
}, 2000);
}
}
};
self.update = function () {
for (var i = 0; i < self.particles.length; i++) {
var particle = self.particles[i];
particle.x += Math.cos(particle.floatDirection) * particle.floatSpeed;
particle.y += Math.sin(particle.floatDirection) * particle.floatSpeed;
if (Math.abs(particle.x) > 200) {
particle.floatDirection = Math.PI - particle.floatDirection;
}
if (Math.abs(particle.y) > 200) {
particle.floatDirection = -particle.floatDirection;
}
}
};
self.createCorruptionParticles();
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x006400
});
/****
* Game Code
****/
var gameStarted = false;
var grassBackground = game.addChild(LK.getAsset('grass', {
anchorX: 0,
anchorY: 0
}));
grassBackground.x = 0;
grassBackground.y = 0;
grassBackground.visible = false;
// Create and show main menu
var mainMenu = game.addChild(new MainMenu());
var player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
player.visible = false;
var zones = [];
var platforms = [];
var zonesHealed = 0;
var zone1 = game.addChild(new Zone('light', 512, 600));
var zone2 = game.addChild(new Zone('shadow', 1536, 600));
var zone3 = game.addChild(new Zone('light', 512, 1800));
var zone4 = game.addChild(new Zone('shadow', 1536, 1800));
zones.push(zone1, zone2, zone3, zone4);
zone1.visible = false;
zone2.visible = false;
zone3.visible = false;
zone4.visible = false;
var platform1 = game.addChild(new Platform('light', 800, 900));
var platform2 = game.addChild(new Platform('shadow', 1248, 900));
var platform3 = game.addChild(new Platform('light', 800, 1500));
var platform4 = game.addChild(new Platform('shadow', 1248, 1500));
platforms.push(platform1, platform2, platform3, platform4);
platform1.visible = false;
platform2.visible = false;
platform3.visible = false;
platform4.visible = false;
var instructionText = new Text2('Tap to move player\nDouble tap to transform\nStand on matching platforms to heal zones', {
size: 40,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
instructionText.y = 100;
instructionText.visible = false;
var scoreText = new Text2('Zones Healed: 0/4', {
size: 50,
fill: 0xFFFF99
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
scoreText.y = 200;
scoreText.visible = false;
var transformText = new Text2('', {
size: 45,
fill: 0xFF99FF
});
transformText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(transformText);
transformText.visible = false;
var lastTapTime = 0;
var targetX = player.x;
var targetY = player.y;
game.down = function (x, y, obj) {
if (!gameStarted) {
return; // Menu will handle its own input
}
var currentTime = Date.now();
if (currentTime - lastTapTime < 300) {
player.transform();
} else {
targetX = x;
targetY = y;
}
lastTapTime = currentTime;
};
game.update = function () {
if (!gameStarted) {
return; // Don't update game logic until started
}
var dx = targetX - player.x;
var dy = targetY - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 10) {
var moveX = dx / distance * player.speed;
var moveY = dy / distance * player.speed;
player.x += moveX;
player.y += moveY;
}
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
var platformDistance = Math.sqrt(Math.pow(player.x - platform.x, 2) + Math.pow(player.y - platform.y, 2));
if (platformDistance < 120) {
if (player.isLightForm && platform.platformType === 'light' || !player.isLightForm && platform.platformType === 'shadow') {
platform.activate();
} else {
platform.deactivate();
}
} else {
platform.deactivate();
}
}
for (var j = 0; j < zones.length; j++) {
var zone = zones[j];
if (!zone.isCorrupted) continue;
var zoneDistance = Math.sqrt(Math.pow(player.x - zone.x, 2) + Math.pow(player.y - zone.y, 2));
if (zoneDistance < 220) {
var nearbyPlatform = null;
for (var k = 0; k < platforms.length; k++) {
var checkPlatform = platforms[k];
var platZoneDistance = Math.sqrt(Math.pow(zone.x - checkPlatform.x, 2) + Math.pow(zone.y - checkPlatform.y, 2));
if (platZoneDistance < 400 && checkPlatform.isActive) {
var correctForm = zone.zoneType === 'light' && !player.isLightForm || zone.zoneType === 'shadow' && player.isLightForm;
if (correctForm) {
nearbyPlatform = checkPlatform;
break;
}
}
}
if (nearbyPlatform) {
zone.heal();
}
}
}
if (player.isLightForm) {
transformText.setText('Light Form - Fast Movement');
transformText.fill = "#FFFF99";
} else {
transformText.setText('Shadow Form - Energy Absorption');
transformText.fill = "#9966FF";
}
if (player.transformCooldown > 0) {
transformText.setText(transformText.text + ' (Cooldown: ' + Math.ceil(player.transformCooldown / 60) + 's)');
}
};
Un campo soleado. In-Game asset. 2d. High contrast. No shadows. Cartoon
Un bosque oscuro. In-Game asset. 2d. High contrast. No shadows. Cartoon
Un círculo negro realista. In-Game asset. 2d. High contrast. No shadows. Realista
Un glitch negro. In-Game asset. 2d. High contrast. No shadows. Píxel art
Un círculo amarillo claro realista. In-Game asset. 2d. High contrast. No shadows. Realista
Un ladrillo realista. In-Game asset. 2d. High contrast. No shadows. Realista
Una pluma realista. In-Game asset. 2d. High contrast. No shadows. Realista
un corazón con un "+" verde al lado del corazon. In-Game asset. 2d. High contrast. No shadows. Cartoon
Un pasto desde arriba realista. In-Game asset. 2d. High contrast. No shadows. Realista
Un cielo azul. In-Game asset. 2d. High contrast. No shadows