User prompt
Haz que cuando el personaje lo toque, el personaje haga un sonido y una animación diferente. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que el menú de poderes solo se pueda abrir una sola vez en todo el juego
User prompt
Has que los poderes del menú solo duren 10 segundos y los de las plataformas 5 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Has que en el menú de poderes solo tengas una sola vez para usar los dos poderes
User prompt
Has otro menú para tener super salto y el modo caida lenta ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que cuando toques el slime el slime aga una animación y ruido ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que cuando el jugador aparezca aparezca en la plataforma 1
User prompt
Has que el suelo no se vea vacío llénalo hacia abajo un 70% más
User prompt
Has que el cielo pueda cambiar de color en el menú ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que el cielo del juego se pueda modificar
User prompt
Has que cuando pases del nivel 5 los niveles esten mas difíciles
User prompt
Has la última plataforma brille ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Añade unas botas al personaje cuando recoja el power up de super salto ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Añade el poder de doble salto
User prompt
Añade puntos
User prompt
Añade un sistema de puntos cada punto recolectado 10 puntos al final te dice cuánto puntos conseguiste tu record y el de ahora ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Añade la opción de bajar y subir la música ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Añade la opción de menú ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que el sonido voz suene cuando el personaje salte
User prompt
Hasle una animación a los botones ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var ControlButton = Container.expand(function (type) { var self = Container.call(this); self.buttonType = type; self.isPressed = false; var buttonGraphics; if (type === 'jump') { buttonGraphics = self.attachAsset('jumpButton', { anchorX: 0.5, anchorY: 0.5 }); } else if (type === 'run') { buttonGraphics = self.attachAsset('runButton', { anchorX: 0.5, anchorY: 0.5 }); } else { buttonGraphics = self.attachAsset(type === 'left' ? 'leftButton' : 'rightButton', { anchorX: 0.5, anchorY: 0.5 }); } // Add larger transparent hitbox for easier touch detection var hitboxSize = 240; // Larger than visual button (180px) var hitbox = LK.getAsset('jumpButton', { anchorX: 0.5, anchorY: 0.5, width: hitboxSize, height: hitboxSize, alpha: 0 // Invisible }); self.addChild(hitbox); self.down = function (x, y, obj) { self.isPressed = true; // Scale down and change alpha for press effect tween(buttonGraphics, { scaleX: 0.85, scaleY: 0.85, alpha: 0.7 }, { duration: 100, easing: tween.easeOut }); }; self.up = function (x, y, obj) { self.isPressed = false; // Scale back up and restore alpha for release effect tween(buttonGraphics, { scaleX: 1.0, scaleY: 1.0, alpha: 1.0 }, { duration: 150, easing: tween.easeOut }); }; // Add idle floating animation self.animationTimer = Math.random() * 100; // Random start offset self.update = function () { if (!self.isPressed) { // Gentle floating animation when not pressed self.animationTimer += 0.05; var floatOffset = Math.sin(self.animationTimer) * 3; buttonGraphics.y = floatOffset; // Subtle breathing scale effect var breathingScale = 1.0 + Math.sin(self.animationTimer * 2) * 0.02; if (!buttonGraphics._tweening) { buttonGraphics.scaleX = breathingScale; buttonGraphics.scaleY = breathingScale; } } }; return self; }); var Platform = Container.expand(function (width, height, number) { var self = Container.call(this); self.platformWidth = width || 300; self.platformHeight = height || 40; self.platformNumber = number || 0; var platformGraphics = self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.5, scaleX: self.platformWidth / 300, scaleY: self.platformHeight / 40 }); // Add number text if platform has a number if (self.platformNumber > 0) { var numberText = new Text2(self.platformNumber.toString(), { size: 30, fill: 0x000000 }); numberText.anchor.set(0.5, 0.5); self.addChild(numberText); } return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 1.0 }); self.velocityX = 0; self.velocityY = 0; self.speed = 12; self.runSpeed = 20; self.isRunning = false; self.jumpPower = 30; self.baseJumpPower = 30; self.powerUpJumpPower = 45; self.powerUpActive = false; self.powerUpTimer = 0; self.slowFallActive = false; self.slowFallTimer = 0; self.gravity = 0.8; self.baseGravity = 0.8; self.slowFallGravity = 0.25; self.onGround = false; self.parachute = null; self.maxFallSpeed = 15; // Animation states self.animationState = 'idle'; // 'idle', 'falling', 'jumping' self.lastOnGround = true; self.animationTimer = 0; self.moveLeft = function () { self.velocityX = self.isRunning ? -self.runSpeed : -self.speed; }; self.moveRight = function () { self.velocityX = self.isRunning ? self.runSpeed : self.speed; }; self.setRunning = function (running) { self.isRunning = running; }; self.jump = function () { if (self.onGround) { self.velocityY = -self.jumpPower; self.onGround = false; } }; self.stopHorizontalMovement = function () { self.velocityX = 0; }; self.collectPowerUp = function () { self.powerUpActive = true; self.powerUpTimer = 600; // 10 seconds at 60fps self.jumpPower = self.powerUpJumpPower; // Flash player green to show power-up is active LK.effects.flashObject(self, 0x00ff00, 300); }; self.collectSlowFallPowerUp = function () { self.slowFallActive = true; self.slowFallTimer = 480; // 8 seconds at 60fps self.gravity = self.slowFallGravity; // Flash player blue to show slow fall is active LK.effects.flashObject(self, 0x3498db, 300); // Add gentle blue tint while active tween(playerGraphics, { tint: 0xadd8e6 }, { duration: 300, easing: tween.easeOut }); // Create parachute self.parachute = LK.getAsset('parachute', { anchorX: 0.5, anchorY: 1.0, alpha: 0 }); self.addChild(self.parachute); self.parachute.x = 0; self.parachute.y = -200; // Position above player // Animate parachute appearing tween(self.parachute, { alpha: 0.8, y: -180 }, { duration: 500, easing: tween.easeOut }); }; self.update = function () { // Apply gravity self.velocityY += self.gravity; // Limit fall speed if (self.velocityY > self.maxFallSpeed) { self.velocityY = self.maxFallSpeed; } // Update position self.x += self.velocityX; self.y += self.velocityY; // Flip sprite based on movement direction if (self.velocityX > 0) { // Moving right - face right (normal) playerGraphics.scaleX = Math.abs(playerGraphics.scaleX); } else if (self.velocityX < 0) { // Moving left - face left (flipped) playerGraphics.scaleX = -Math.abs(playerGraphics.scaleX); } // Update animation timer self.animationTimer += 0.1; // Determine animation state var newAnimationState = 'idle'; if (!self.onGround && self.velocityY < -5) { newAnimationState = 'jumping'; } else if (!self.onGround && self.velocityY > 5) { newAnimationState = 'falling'; } else if (self.onGround && self.velocityX !== 0) { newAnimationState = 'walking'; } else if (self.onGround) { newAnimationState = 'idle'; } // Apply animations based on state transitions if (self.animationState !== newAnimationState) { // State changed, apply new animation if (newAnimationState === 'jumping') { // Jump animation - stretch upward tween(playerGraphics, { scaleY: 1.3, scaleX: 0.8, rotation: self.velocityX > 0 ? 0.1 : self.velocityX < 0 ? -0.1 : 0 }, { duration: 200, easing: tween.easeOut }); } else if (newAnimationState === 'falling') { // Fall animation - compress and tilt tween(playerGraphics, { scaleY: 0.7, scaleX: 1.2, rotation: self.velocityX > 0 ? 0.2 : self.velocityX < 0 ? -0.2 : 0 }, { duration: 300, easing: tween.easeOut }); } else if (newAnimationState === 'idle' && !self.lastOnGround && self.onGround) { // Landing animation - squash and recover tween(playerGraphics, { scaleY: 0.6, scaleX: 1.4, rotation: 0 }, { duration: 150, easing: tween.easeOut, onFinish: function onFinish() { tween(playerGraphics, { scaleY: 1.0, scaleX: 1.0, rotation: 0 }, { duration: 200, easing: tween.easeOut }); } }); } else if (newAnimationState === 'walking') { // Walking animation - return to normal scale for bouncing tween(playerGraphics, { scaleY: 1.0, scaleX: 1.0, rotation: 0 }, { duration: 200, easing: tween.easeOut }); } else if (newAnimationState === 'idle') { // Return to idle animation tween(playerGraphics, { scaleY: 1.0, scaleX: 1.0, rotation: 0 }, { duration: 300, easing: tween.easeOut }); } } // Continuous animations based on state if (newAnimationState === 'idle' && self.onGround) { // Gentle breathing effect var breathingScale = 1.0 + Math.sin(self.animationTimer * 2) * 0.02; if (!playerGraphics._tweening) { // Only apply if not currently tweening playerGraphics.scaleY = breathingScale; } } else if (newAnimationState === 'walking' && self.onGround) { // Walking animation - bouncing effect (slower) var walkingBounce = 1.0 + Math.sin(self.animationTimer * 4) * 0.15; var walkingTilt = Math.sin(self.animationTimer * 4) * 0.05; if (!playerGraphics._tweening) { // Only apply if not currently tweening playerGraphics.scaleY = walkingBounce; playerGraphics.rotation = walkingTilt * (self.velocityX > 0 ? 1 : -1); } } // Update states for next frame self.animationState = newAnimationState; self.lastOnGround = self.onGround; // Keep player within screen bounds horizontally if (self.x < 90) { self.x = 90; } if (self.x > 1958) { self.x = 1958; } // Handle power-up timer if (self.powerUpActive) { self.powerUpTimer--; if (self.powerUpTimer <= 0) { self.powerUpActive = false; self.jumpPower = self.baseJumpPower; // Flash player red to show power-up expired LK.effects.flashObject(self, 0xff0000, 200); } } // Handle slow fall timer if (self.slowFallActive) { self.slowFallTimer--; // Animate parachute swaying if (self.parachute) { var swayAmount = Math.sin(self.animationTimer * 3) * 15; self.parachute.x = swayAmount; self.parachute.rotation = Math.sin(self.animationTimer * 2) * 0.1; } if (self.slowFallTimer <= 0) { self.slowFallActive = false; self.gravity = self.baseGravity; // Flash player red to show slow fall expired and remove tint LK.effects.flashObject(self, 0xff0000, 200); tween(playerGraphics, { tint: 0xffffff }, { duration: 300, easing: tween.easeOut }); // Remove parachute with animation if (self.parachute) { tween(self.parachute, { alpha: 0, y: -220 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { if (self.parachute) { self.removeChild(self.parachute); self.parachute = null; } } }); } } } // Reset onGround flag self.onGround = false; }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); self.collected = false; var powerupGraphics = self.attachAsset('powerup', { anchorX: 0.5, anchorY: 0.5 }); // Add visual indicator (star symbol) var starText = new Text2('★', { size: 30, fill: 0xFFFFFF }); starText.anchor.set(0.5, 0.5); self.addChild(starText); // Floating animation self.floatOffset = 0; self.update = function () { // Create floating effect self.floatOffset += 0.1; powerupGraphics.y = Math.sin(self.floatOffset) * 10; starText.y = Math.sin(self.floatOffset) * 10; // Rotate the star starText.rotation += 0.05; }; return self; }); var SlowFallPowerUp = Container.expand(function () { var self = Container.call(this); self.collected = false; var powerupGraphics = self.attachAsset('slowfallpowerup', { anchorX: 0.5, anchorY: 0.5 }); // Tint it blue to distinguish from jump power-up powerupGraphics.tint = 0x3498db; // Add visual indicator (feather symbol) var featherText = new Text2('🪶', { size: 30, fill: 0xFFFFFF }); featherText.anchor.set(0.5, 0.5); self.addChild(featherText); // Floating animation with slower movement self.floatOffset = 0; self.update = function () { // Create gentle floating effect self.floatOffset += 0.05; var floatY = Math.sin(self.floatOffset) * 15; powerupGraphics.y = floatY; featherText.y = floatY; // Gentle rotation featherText.rotation += 0.02; // Subtle pulsing effect using tween if (LK.ticks % 120 === 0) { tween(powerupGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 600, easing: tween.easeInOut }); tween(powerupGraphics, { scaleX: 1.0, scaleY: 1.0 }, { duration: 600, easing: tween.easeInOut }); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ var currentLevel = 1; var player = game.addChild(new Player()); player.x = 1024; player.y = 2500; var platforms = []; var powerUps = []; var slowFallPowerUps = []; var ground = game.addChild(LK.getAsset('ground', { anchorX: 0.5, anchorY: 1.0 })); ground.x = 1024; ground.y = 2732; // Create platforms with numbers 1-15 var platformData = [{ x: 400, y: 2400, width: 200, number: 1 }, { x: 800, y: 2200, width: 250, number: 2 }, { x: 1200, y: 2000, width: 200, number: 3 }, { x: 600, y: 1800, width: 300, number: 4 }, { x: 1400, y: 1600, width: 200, number: 5 }, { x: 300, y: 1400, width: 250, number: 6 }, { x: 1000, y: 1200, width: 300, number: 7 }, { x: 1600, y: 1000, width: 200, number: 8 }, { x: 400, y: 800, width: 250, number: 9 }, { x: 1200, y: 600, width: 200, number: 10 }, { x: 800, y: 400, width: 300, number: 11 }, { x: 500, y: 200, width: 180, number: 12 }, { x: 1400, y: 100, width: 220, number: 13 }, { x: 200, y: -100, width: 250, number: 14 }, { x: 1000, y: -300, width: 200, number: 15 }]; function createLevel(levelNumber) { // Clear existing platforms for (var i = platforms.length - 1; i >= 0; i--) { platforms[i].destroy(); } platforms = []; // Clear existing power-ups for (var i = powerUps.length - 1; i >= 0; i--) { powerUps[i].destroy(); } powerUps = []; // Clear existing slow fall power-ups for (var i = slowFallPowerUps.length - 1; i >= 0; i--) { slowFallPowerUps[i].destroy(); } slowFallPowerUps = []; // Generate new platform layout for each level var baseY = 2400; var yStep = 200; for (var i = 0; i < 15; i++) { var platformNumber = i + 1; var platform = game.addChild(new Platform(Math.max(150, 250 - (levelNumber - 1) * 10), 40, platformNumber)); // Completely randomize platform positions var minX = 200; // Minimum distance from left edge var maxX = 1848; // Maximum distance from right edge (accounting for platform width) var randomX = minX + Math.random() * (maxX - minX); platform.x = randomX; platform.y = baseY - i * yStep; platforms.push(platform); // Spawn power-up randomly on some platforms (7% chance) if (Math.random() < 0.07 && platformNumber !== 1 && platformNumber !== 15) { var powerUp = game.addChild(new PowerUp()); powerUp.x = platform.x; powerUp.y = platform.y - 60; // Position above platform powerUps.push(powerUp); } // Spawn slow fall power-up randomly on some platforms (7% chance) if (Math.random() < 0.07 && platformNumber !== 1 && platformNumber !== 15) { var slowFallPowerUp = game.addChild(new SlowFallPowerUp()); slowFallPowerUp.x = platform.x + 50; // Offset slightly to avoid overlap slowFallPowerUp.y = platform.y - 60; // Position above platform slowFallPowerUps.push(slowFallPowerUp); } } } // Create initial level createLevel(currentLevel); // Control buttons var leftButton = LK.gui.bottomLeft.addChild(new ControlButton('left')); leftButton.x = 110; leftButton.y = -110; var rightButton = LK.gui.bottomLeft.addChild(new ControlButton('right')); rightButton.x = 310; rightButton.y = -110; var runButton = LK.gui.bottomLeft.addChild(new ControlButton('run')); runButton.x = 510; runButton.y = -110; var jumpButton = LK.gui.bottomRight.addChild(new ControlButton('jump')); jumpButton.x = -110; jumpButton.y = -110; // Control button labels var leftLabel = new Text2('←', { size: 60, fill: 0xFFFFFF }); leftLabel.anchor.set(0.5, 0.5); leftButton.addChild(leftLabel); var rightLabel = new Text2('→', { size: 60, fill: 0xFFFFFF }); rightLabel.anchor.set(0.5, 0.5); rightButton.addChild(rightLabel); var runLabel = new Text2('RUN', { size: 30, fill: 0xFFFFFF }); runLabel.anchor.set(0.5, 0.5); runButton.addChild(runLabel); var jumpLabel = new Text2('↑', { size: 60, fill: 0xFFFFFF }); jumpLabel.anchor.set(0.5, 0.5); jumpButton.addChild(jumpLabel); // Level display var levelText = new Text2('Level ' + currentLevel, { size: 80, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0); LK.gui.top.addChild(levelText); levelText.y = 120; // Position below the top menu // Power-up status display var powerUpText = new Text2('', { size: 40, fill: 0xf39c12 }); powerUpText.anchor.set(0.5, 0); LK.gui.top.addChild(powerUpText); powerUpText.y = 200; // Slow fall status display var slowFallText = new Text2('', { size: 40, fill: 0x3498db }); slowFallText.anchor.set(0.5, 0); LK.gui.top.addChild(slowFallText); slowFallText.y = 250; function checkCollisions() { var playerBottom = player.y; var playerTop = player.y - 180; var playerLeft = player.x - 90; var playerRight = player.x + 90; // Check ground collision if (playerBottom >= ground.y - 50) { if (player.velocityY > 0) { player.y = ground.y - 50; player.velocityY = 0; player.onGround = true; } } // Check platform collisions for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; var platformLeft = platform.x - platform.platformWidth / 2; var platformRight = platform.x + platform.platformWidth / 2; var platformTop = platform.y - platform.platformHeight / 2; var platformBottom = platform.y + platform.platformHeight / 2; // Check if player is horizontally aligned with platform if (playerRight > platformLeft && playerLeft < platformRight) { // Check if player is falling onto platform from above if (player.velocityY > 0 && playerBottom >= platformTop && playerTop < platformTop) { player.y = platformTop; player.velocityY = 0; player.onGround = true; } } } // Check power-up collisions for (var i = powerUps.length - 1; i >= 0; i--) { var powerUp = powerUps[i]; if (!powerUp.collected) { var powerUpLeft = powerUp.x - 20; var powerUpRight = powerUp.x + 20; var powerUpTop = powerUp.y - 20; var powerUpBottom = powerUp.y + 20; // Check if player intersects with power-up if (playerRight > powerUpLeft && playerLeft < powerUpRight && playerBottom > powerUpTop && playerTop < powerUpBottom) { powerUp.collected = true; player.collectPowerUp(); powerUp.destroy(); powerUps.splice(i, 1); } } } // Check slow fall power-up collisions for (var i = slowFallPowerUps.length - 1; i >= 0; i--) { var slowFallPowerUp = slowFallPowerUps[i]; if (!slowFallPowerUp.collected) { var slowFallLeft = slowFallPowerUp.x - 20; var slowFallRight = slowFallPowerUp.x + 20; var slowFallTop = slowFallPowerUp.y - 20; var slowFallBottom = slowFallPowerUp.y + 20; // Check if player intersects with slow fall power-up if (playerRight > slowFallLeft && playerLeft < slowFallRight && playerBottom > slowFallTop && playerTop < slowFallBottom) { slowFallPowerUp.collected = true; player.collectSlowFallPowerUp(); slowFallPowerUp.destroy(); slowFallPowerUps.splice(i, 1); } } } } game.update = function () { // Check collisions first to set onGround flag checkCollisions(); // Handle input player.setRunning(runButton.isPressed); if (leftButton.isPressed) { player.moveLeft(); } else if (rightButton.isPressed) { player.moveRight(); } else { player.stopHorizontalMovement(); } if (jumpButton.isPressed) { player.jump(); } // Update power-up display if (player.powerUpActive) { var secondsLeft = Math.ceil(player.powerUpTimer / 60); powerUpText.setText('★ Super Jump: ' + secondsLeft + 's'); } else { powerUpText.setText(''); } // Update slow fall display if (player.slowFallActive) { var secondsLeft = Math.ceil(player.slowFallTimer / 60); slowFallText.setText('🪶 Slow Fall: ' + secondsLeft + 's'); } else { slowFallText.setText(''); } // Camera follows player var targetY = -player.y + 1366; // Center player vertically on screen game.y = targetY; // Check if player reached platform 15 var platform15 = null; for (var i = 0; i < platforms.length; i++) { if (platforms[i].platformNumber === 15) { platform15 = platforms[i]; break; } } if (platform15) { var playerBottom = player.y; var playerLeft = player.x - 90; var playerRight = player.x + 90; var platform15Left = platform15.x - platform15.platformWidth / 2; var platform15Right = platform15.x + platform15.platformWidth / 2; var platform15Top = platform15.y - platform15.platformHeight / 2; // Check if player is on platform 15 if (playerRight > platform15Left && playerLeft < platform15Right && playerBottom >= platform15Top && playerBottom <= platform15Top + 50) { // Player reached platform 15 - advance to next level currentLevel++; if (currentLevel > 10) { // After 10 levels, show you win LK.showYouWin(); } else { // Create next level createLevel(currentLevel); levelText.setText('Level ' + currentLevel); // Reset player position for new level player.x = 1024; player.y = 2500; player.velocityX = 0; player.velocityY = 0; // Flash screen green to indicate level completion LK.effects.flashScreen(0x00ff00, 500); } } } // Check if player fell off screen if (player.y > 2800) { // Reset player position player.x = 1024; player.y = 2500; player.velocityX = 0; player.velocityY = 0; } }; // Play background music LK.playMusic('Musica');
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ControlButton = Container.expand(function (type) {
var self = Container.call(this);
self.buttonType = type;
self.isPressed = false;
var buttonGraphics;
if (type === 'jump') {
buttonGraphics = self.attachAsset('jumpButton', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (type === 'run') {
buttonGraphics = self.attachAsset('runButton', {
anchorX: 0.5,
anchorY: 0.5
});
} else {
buttonGraphics = self.attachAsset(type === 'left' ? 'leftButton' : 'rightButton', {
anchorX: 0.5,
anchorY: 0.5
});
}
// Add larger transparent hitbox for easier touch detection
var hitboxSize = 240; // Larger than visual button (180px)
var hitbox = LK.getAsset('jumpButton', {
anchorX: 0.5,
anchorY: 0.5,
width: hitboxSize,
height: hitboxSize,
alpha: 0 // Invisible
});
self.addChild(hitbox);
self.down = function (x, y, obj) {
self.isPressed = true;
// Scale down and change alpha for press effect
tween(buttonGraphics, {
scaleX: 0.85,
scaleY: 0.85,
alpha: 0.7
}, {
duration: 100,
easing: tween.easeOut
});
};
self.up = function (x, y, obj) {
self.isPressed = false;
// Scale back up and restore alpha for release effect
tween(buttonGraphics, {
scaleX: 1.0,
scaleY: 1.0,
alpha: 1.0
}, {
duration: 150,
easing: tween.easeOut
});
};
// Add idle floating animation
self.animationTimer = Math.random() * 100; // Random start offset
self.update = function () {
if (!self.isPressed) {
// Gentle floating animation when not pressed
self.animationTimer += 0.05;
var floatOffset = Math.sin(self.animationTimer) * 3;
buttonGraphics.y = floatOffset;
// Subtle breathing scale effect
var breathingScale = 1.0 + Math.sin(self.animationTimer * 2) * 0.02;
if (!buttonGraphics._tweening) {
buttonGraphics.scaleX = breathingScale;
buttonGraphics.scaleY = breathingScale;
}
}
};
return self;
});
var Platform = Container.expand(function (width, height, number) {
var self = Container.call(this);
self.platformWidth = width || 300;
self.platformHeight = height || 40;
self.platformNumber = number || 0;
var platformGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.platformWidth / 300,
scaleY: self.platformHeight / 40
});
// Add number text if platform has a number
if (self.platformNumber > 0) {
var numberText = new Text2(self.platformNumber.toString(), {
size: 30,
fill: 0x000000
});
numberText.anchor.set(0.5, 0.5);
self.addChild(numberText);
}
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1.0
});
self.velocityX = 0;
self.velocityY = 0;
self.speed = 12;
self.runSpeed = 20;
self.isRunning = false;
self.jumpPower = 30;
self.baseJumpPower = 30;
self.powerUpJumpPower = 45;
self.powerUpActive = false;
self.powerUpTimer = 0;
self.slowFallActive = false;
self.slowFallTimer = 0;
self.gravity = 0.8;
self.baseGravity = 0.8;
self.slowFallGravity = 0.25;
self.onGround = false;
self.parachute = null;
self.maxFallSpeed = 15;
// Animation states
self.animationState = 'idle'; // 'idle', 'falling', 'jumping'
self.lastOnGround = true;
self.animationTimer = 0;
self.moveLeft = function () {
self.velocityX = self.isRunning ? -self.runSpeed : -self.speed;
};
self.moveRight = function () {
self.velocityX = self.isRunning ? self.runSpeed : self.speed;
};
self.setRunning = function (running) {
self.isRunning = running;
};
self.jump = function () {
if (self.onGround) {
self.velocityY = -self.jumpPower;
self.onGround = false;
}
};
self.stopHorizontalMovement = function () {
self.velocityX = 0;
};
self.collectPowerUp = function () {
self.powerUpActive = true;
self.powerUpTimer = 600; // 10 seconds at 60fps
self.jumpPower = self.powerUpJumpPower;
// Flash player green to show power-up is active
LK.effects.flashObject(self, 0x00ff00, 300);
};
self.collectSlowFallPowerUp = function () {
self.slowFallActive = true;
self.slowFallTimer = 480; // 8 seconds at 60fps
self.gravity = self.slowFallGravity;
// Flash player blue to show slow fall is active
LK.effects.flashObject(self, 0x3498db, 300);
// Add gentle blue tint while active
tween(playerGraphics, {
tint: 0xadd8e6
}, {
duration: 300,
easing: tween.easeOut
});
// Create parachute
self.parachute = LK.getAsset('parachute', {
anchorX: 0.5,
anchorY: 1.0,
alpha: 0
});
self.addChild(self.parachute);
self.parachute.x = 0;
self.parachute.y = -200; // Position above player
// Animate parachute appearing
tween(self.parachute, {
alpha: 0.8,
y: -180
}, {
duration: 500,
easing: tween.easeOut
});
};
self.update = function () {
// Apply gravity
self.velocityY += self.gravity;
// Limit fall speed
if (self.velocityY > self.maxFallSpeed) {
self.velocityY = self.maxFallSpeed;
}
// Update position
self.x += self.velocityX;
self.y += self.velocityY;
// Flip sprite based on movement direction
if (self.velocityX > 0) {
// Moving right - face right (normal)
playerGraphics.scaleX = Math.abs(playerGraphics.scaleX);
} else if (self.velocityX < 0) {
// Moving left - face left (flipped)
playerGraphics.scaleX = -Math.abs(playerGraphics.scaleX);
}
// Update animation timer
self.animationTimer += 0.1;
// Determine animation state
var newAnimationState = 'idle';
if (!self.onGround && self.velocityY < -5) {
newAnimationState = 'jumping';
} else if (!self.onGround && self.velocityY > 5) {
newAnimationState = 'falling';
} else if (self.onGround && self.velocityX !== 0) {
newAnimationState = 'walking';
} else if (self.onGround) {
newAnimationState = 'idle';
}
// Apply animations based on state transitions
if (self.animationState !== newAnimationState) {
// State changed, apply new animation
if (newAnimationState === 'jumping') {
// Jump animation - stretch upward
tween(playerGraphics, {
scaleY: 1.3,
scaleX: 0.8,
rotation: self.velocityX > 0 ? 0.1 : self.velocityX < 0 ? -0.1 : 0
}, {
duration: 200,
easing: tween.easeOut
});
} else if (newAnimationState === 'falling') {
// Fall animation - compress and tilt
tween(playerGraphics, {
scaleY: 0.7,
scaleX: 1.2,
rotation: self.velocityX > 0 ? 0.2 : self.velocityX < 0 ? -0.2 : 0
}, {
duration: 300,
easing: tween.easeOut
});
} else if (newAnimationState === 'idle' && !self.lastOnGround && self.onGround) {
// Landing animation - squash and recover
tween(playerGraphics, {
scaleY: 0.6,
scaleX: 1.4,
rotation: 0
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(playerGraphics, {
scaleY: 1.0,
scaleX: 1.0,
rotation: 0
}, {
duration: 200,
easing: tween.easeOut
});
}
});
} else if (newAnimationState === 'walking') {
// Walking animation - return to normal scale for bouncing
tween(playerGraphics, {
scaleY: 1.0,
scaleX: 1.0,
rotation: 0
}, {
duration: 200,
easing: tween.easeOut
});
} else if (newAnimationState === 'idle') {
// Return to idle animation
tween(playerGraphics, {
scaleY: 1.0,
scaleX: 1.0,
rotation: 0
}, {
duration: 300,
easing: tween.easeOut
});
}
}
// Continuous animations based on state
if (newAnimationState === 'idle' && self.onGround) {
// Gentle breathing effect
var breathingScale = 1.0 + Math.sin(self.animationTimer * 2) * 0.02;
if (!playerGraphics._tweening) {
// Only apply if not currently tweening
playerGraphics.scaleY = breathingScale;
}
} else if (newAnimationState === 'walking' && self.onGround) {
// Walking animation - bouncing effect (slower)
var walkingBounce = 1.0 + Math.sin(self.animationTimer * 4) * 0.15;
var walkingTilt = Math.sin(self.animationTimer * 4) * 0.05;
if (!playerGraphics._tweening) {
// Only apply if not currently tweening
playerGraphics.scaleY = walkingBounce;
playerGraphics.rotation = walkingTilt * (self.velocityX > 0 ? 1 : -1);
}
}
// Update states for next frame
self.animationState = newAnimationState;
self.lastOnGround = self.onGround;
// Keep player within screen bounds horizontally
if (self.x < 90) {
self.x = 90;
}
if (self.x > 1958) {
self.x = 1958;
}
// Handle power-up timer
if (self.powerUpActive) {
self.powerUpTimer--;
if (self.powerUpTimer <= 0) {
self.powerUpActive = false;
self.jumpPower = self.baseJumpPower;
// Flash player red to show power-up expired
LK.effects.flashObject(self, 0xff0000, 200);
}
}
// Handle slow fall timer
if (self.slowFallActive) {
self.slowFallTimer--;
// Animate parachute swaying
if (self.parachute) {
var swayAmount = Math.sin(self.animationTimer * 3) * 15;
self.parachute.x = swayAmount;
self.parachute.rotation = Math.sin(self.animationTimer * 2) * 0.1;
}
if (self.slowFallTimer <= 0) {
self.slowFallActive = false;
self.gravity = self.baseGravity;
// Flash player red to show slow fall expired and remove tint
LK.effects.flashObject(self, 0xff0000, 200);
tween(playerGraphics, {
tint: 0xffffff
}, {
duration: 300,
easing: tween.easeOut
});
// Remove parachute with animation
if (self.parachute) {
tween(self.parachute, {
alpha: 0,
y: -220
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
if (self.parachute) {
self.removeChild(self.parachute);
self.parachute = null;
}
}
});
}
}
}
// Reset onGround flag
self.onGround = false;
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
self.collected = false;
var powerupGraphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
// Add visual indicator (star symbol)
var starText = new Text2('★', {
size: 30,
fill: 0xFFFFFF
});
starText.anchor.set(0.5, 0.5);
self.addChild(starText);
// Floating animation
self.floatOffset = 0;
self.update = function () {
// Create floating effect
self.floatOffset += 0.1;
powerupGraphics.y = Math.sin(self.floatOffset) * 10;
starText.y = Math.sin(self.floatOffset) * 10;
// Rotate the star
starText.rotation += 0.05;
};
return self;
});
var SlowFallPowerUp = Container.expand(function () {
var self = Container.call(this);
self.collected = false;
var powerupGraphics = self.attachAsset('slowfallpowerup', {
anchorX: 0.5,
anchorY: 0.5
});
// Tint it blue to distinguish from jump power-up
powerupGraphics.tint = 0x3498db;
// Add visual indicator (feather symbol)
var featherText = new Text2('🪶', {
size: 30,
fill: 0xFFFFFF
});
featherText.anchor.set(0.5, 0.5);
self.addChild(featherText);
// Floating animation with slower movement
self.floatOffset = 0;
self.update = function () {
// Create gentle floating effect
self.floatOffset += 0.05;
var floatY = Math.sin(self.floatOffset) * 15;
powerupGraphics.y = floatY;
featherText.y = floatY;
// Gentle rotation
featherText.rotation += 0.02;
// Subtle pulsing effect using tween
if (LK.ticks % 120 === 0) {
tween(powerupGraphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 600,
easing: tween.easeInOut
});
tween(powerupGraphics, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 600,
easing: tween.easeInOut
});
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var currentLevel = 1;
var player = game.addChild(new Player());
player.x = 1024;
player.y = 2500;
var platforms = [];
var powerUps = [];
var slowFallPowerUps = [];
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0.5,
anchorY: 1.0
}));
ground.x = 1024;
ground.y = 2732;
// Create platforms with numbers 1-15
var platformData = [{
x: 400,
y: 2400,
width: 200,
number: 1
}, {
x: 800,
y: 2200,
width: 250,
number: 2
}, {
x: 1200,
y: 2000,
width: 200,
number: 3
}, {
x: 600,
y: 1800,
width: 300,
number: 4
}, {
x: 1400,
y: 1600,
width: 200,
number: 5
}, {
x: 300,
y: 1400,
width: 250,
number: 6
}, {
x: 1000,
y: 1200,
width: 300,
number: 7
}, {
x: 1600,
y: 1000,
width: 200,
number: 8
}, {
x: 400,
y: 800,
width: 250,
number: 9
}, {
x: 1200,
y: 600,
width: 200,
number: 10
}, {
x: 800,
y: 400,
width: 300,
number: 11
}, {
x: 500,
y: 200,
width: 180,
number: 12
}, {
x: 1400,
y: 100,
width: 220,
number: 13
}, {
x: 200,
y: -100,
width: 250,
number: 14
}, {
x: 1000,
y: -300,
width: 200,
number: 15
}];
function createLevel(levelNumber) {
// Clear existing platforms
for (var i = platforms.length - 1; i >= 0; i--) {
platforms[i].destroy();
}
platforms = [];
// Clear existing power-ups
for (var i = powerUps.length - 1; i >= 0; i--) {
powerUps[i].destroy();
}
powerUps = [];
// Clear existing slow fall power-ups
for (var i = slowFallPowerUps.length - 1; i >= 0; i--) {
slowFallPowerUps[i].destroy();
}
slowFallPowerUps = [];
// Generate new platform layout for each level
var baseY = 2400;
var yStep = 200;
for (var i = 0; i < 15; i++) {
var platformNumber = i + 1;
var platform = game.addChild(new Platform(Math.max(150, 250 - (levelNumber - 1) * 10), 40, platformNumber));
// Completely randomize platform positions
var minX = 200; // Minimum distance from left edge
var maxX = 1848; // Maximum distance from right edge (accounting for platform width)
var randomX = minX + Math.random() * (maxX - minX);
platform.x = randomX;
platform.y = baseY - i * yStep;
platforms.push(platform);
// Spawn power-up randomly on some platforms (7% chance)
if (Math.random() < 0.07 && platformNumber !== 1 && platformNumber !== 15) {
var powerUp = game.addChild(new PowerUp());
powerUp.x = platform.x;
powerUp.y = platform.y - 60; // Position above platform
powerUps.push(powerUp);
}
// Spawn slow fall power-up randomly on some platforms (7% chance)
if (Math.random() < 0.07 && platformNumber !== 1 && platformNumber !== 15) {
var slowFallPowerUp = game.addChild(new SlowFallPowerUp());
slowFallPowerUp.x = platform.x + 50; // Offset slightly to avoid overlap
slowFallPowerUp.y = platform.y - 60; // Position above platform
slowFallPowerUps.push(slowFallPowerUp);
}
}
}
// Create initial level
createLevel(currentLevel);
// Control buttons
var leftButton = LK.gui.bottomLeft.addChild(new ControlButton('left'));
leftButton.x = 110;
leftButton.y = -110;
var rightButton = LK.gui.bottomLeft.addChild(new ControlButton('right'));
rightButton.x = 310;
rightButton.y = -110;
var runButton = LK.gui.bottomLeft.addChild(new ControlButton('run'));
runButton.x = 510;
runButton.y = -110;
var jumpButton = LK.gui.bottomRight.addChild(new ControlButton('jump'));
jumpButton.x = -110;
jumpButton.y = -110;
// Control button labels
var leftLabel = new Text2('←', {
size: 60,
fill: 0xFFFFFF
});
leftLabel.anchor.set(0.5, 0.5);
leftButton.addChild(leftLabel);
var rightLabel = new Text2('→', {
size: 60,
fill: 0xFFFFFF
});
rightLabel.anchor.set(0.5, 0.5);
rightButton.addChild(rightLabel);
var runLabel = new Text2('RUN', {
size: 30,
fill: 0xFFFFFF
});
runLabel.anchor.set(0.5, 0.5);
runButton.addChild(runLabel);
var jumpLabel = new Text2('↑', {
size: 60,
fill: 0xFFFFFF
});
jumpLabel.anchor.set(0.5, 0.5);
jumpButton.addChild(jumpLabel);
// Level display
var levelText = new Text2('Level ' + currentLevel, {
size: 80,
fill: 0xFFFFFF
});
levelText.anchor.set(0.5, 0);
LK.gui.top.addChild(levelText);
levelText.y = 120; // Position below the top menu
// Power-up status display
var powerUpText = new Text2('', {
size: 40,
fill: 0xf39c12
});
powerUpText.anchor.set(0.5, 0);
LK.gui.top.addChild(powerUpText);
powerUpText.y = 200;
// Slow fall status display
var slowFallText = new Text2('', {
size: 40,
fill: 0x3498db
});
slowFallText.anchor.set(0.5, 0);
LK.gui.top.addChild(slowFallText);
slowFallText.y = 250;
function checkCollisions() {
var playerBottom = player.y;
var playerTop = player.y - 180;
var playerLeft = player.x - 90;
var playerRight = player.x + 90;
// Check ground collision
if (playerBottom >= ground.y - 50) {
if (player.velocityY > 0) {
player.y = ground.y - 50;
player.velocityY = 0;
player.onGround = true;
}
}
// Check platform collisions
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
var platformLeft = platform.x - platform.platformWidth / 2;
var platformRight = platform.x + platform.platformWidth / 2;
var platformTop = platform.y - platform.platformHeight / 2;
var platformBottom = platform.y + platform.platformHeight / 2;
// Check if player is horizontally aligned with platform
if (playerRight > platformLeft && playerLeft < platformRight) {
// Check if player is falling onto platform from above
if (player.velocityY > 0 && playerBottom >= platformTop && playerTop < platformTop) {
player.y = platformTop;
player.velocityY = 0;
player.onGround = true;
}
}
}
// Check power-up collisions
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
if (!powerUp.collected) {
var powerUpLeft = powerUp.x - 20;
var powerUpRight = powerUp.x + 20;
var powerUpTop = powerUp.y - 20;
var powerUpBottom = powerUp.y + 20;
// Check if player intersects with power-up
if (playerRight > powerUpLeft && playerLeft < powerUpRight && playerBottom > powerUpTop && playerTop < powerUpBottom) {
powerUp.collected = true;
player.collectPowerUp();
powerUp.destroy();
powerUps.splice(i, 1);
}
}
}
// Check slow fall power-up collisions
for (var i = slowFallPowerUps.length - 1; i >= 0; i--) {
var slowFallPowerUp = slowFallPowerUps[i];
if (!slowFallPowerUp.collected) {
var slowFallLeft = slowFallPowerUp.x - 20;
var slowFallRight = slowFallPowerUp.x + 20;
var slowFallTop = slowFallPowerUp.y - 20;
var slowFallBottom = slowFallPowerUp.y + 20;
// Check if player intersects with slow fall power-up
if (playerRight > slowFallLeft && playerLeft < slowFallRight && playerBottom > slowFallTop && playerTop < slowFallBottom) {
slowFallPowerUp.collected = true;
player.collectSlowFallPowerUp();
slowFallPowerUp.destroy();
slowFallPowerUps.splice(i, 1);
}
}
}
}
game.update = function () {
// Check collisions first to set onGround flag
checkCollisions();
// Handle input
player.setRunning(runButton.isPressed);
if (leftButton.isPressed) {
player.moveLeft();
} else if (rightButton.isPressed) {
player.moveRight();
} else {
player.stopHorizontalMovement();
}
if (jumpButton.isPressed) {
player.jump();
}
// Update power-up display
if (player.powerUpActive) {
var secondsLeft = Math.ceil(player.powerUpTimer / 60);
powerUpText.setText('★ Super Jump: ' + secondsLeft + 's');
} else {
powerUpText.setText('');
}
// Update slow fall display
if (player.slowFallActive) {
var secondsLeft = Math.ceil(player.slowFallTimer / 60);
slowFallText.setText('🪶 Slow Fall: ' + secondsLeft + 's');
} else {
slowFallText.setText('');
}
// Camera follows player
var targetY = -player.y + 1366; // Center player vertically on screen
game.y = targetY;
// Check if player reached platform 15
var platform15 = null;
for (var i = 0; i < platforms.length; i++) {
if (platforms[i].platformNumber === 15) {
platform15 = platforms[i];
break;
}
}
if (platform15) {
var playerBottom = player.y;
var playerLeft = player.x - 90;
var playerRight = player.x + 90;
var platform15Left = platform15.x - platform15.platformWidth / 2;
var platform15Right = platform15.x + platform15.platformWidth / 2;
var platform15Top = platform15.y - platform15.platformHeight / 2;
// Check if player is on platform 15
if (playerRight > platform15Left && playerLeft < platform15Right && playerBottom >= platform15Top && playerBottom <= platform15Top + 50) {
// Player reached platform 15 - advance to next level
currentLevel++;
if (currentLevel > 10) {
// After 10 levels, show you win
LK.showYouWin();
} else {
// Create next level
createLevel(currentLevel);
levelText.setText('Level ' + currentLevel);
// Reset player position for new level
player.x = 1024;
player.y = 2500;
player.velocityX = 0;
player.velocityY = 0;
// Flash screen green to indicate level completion
LK.effects.flashScreen(0x00ff00, 500);
}
}
}
// Check if player fell off screen
if (player.y > 2800) {
// Reset player position
player.x = 1024;
player.y = 2500;
player.velocityX = 0;
player.velocityY = 0;
}
};
// Play background music
LK.playMusic('Musica');
Poder de saltó. In-Game asset. 2d. High contrast. No shadows
Slow fall. In-Game asset. 2d. High contrast. No shadows
Paracaídas. In-Game asset. 2d. High contrast. No shadows
Flecha hacia la derecha. In-Game asset. 2d. High contrast. No shadows
Botas de super salto. In-Game asset. 2d. High contrast. No shadows
Cubo de slime con cara feliz. In-Game asset. 2d. High contrast. No shadows