User prompt
cada vez que el personaje destruya un enemigo escribe el siguiente mensaje "CRASHH", que permanezca visible por 1 segundo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
crea un sonido cuando el personaje muere
User prompt
quita la ultima orden
User prompt
cuando el personaje muere, crea una animacion de desaparicion ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
crea un sonido cuando el personaje destruye a un enemigo
User prompt
suma 100 puntos cada vez que el personaje destruya un enemigo
User prompt
crea un sonido cuando el personaje toca a un enemigo volador
User prompt
los enemigos voladores no matan al personaje solo lo hacen retroceder un poco ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
los enemigos voladores aparecen de forma aleatoria
User prompt
agregar un nuevo enemigo al pasar de nivel
User prompt
a medida que pasa de nivel aumenta el numero de enemigo
User prompt
el salto del personaje es un poco mas alto
User prompt
si el personaje toca de lado al enemigo este muere
User prompt
si el personaje cae sobre el enemigo, este lo destruye y no muere
User prompt
el numero de enemigos y su velocidad deben ir aumentando a medida que se pasa al siguiente nivel
User prompt
los enemigos deben aparecer de la derecha y avanzar
User prompt
la altura entre plataformas debe ser menor
User prompt
las plataformas se deben encontrar mas cerca una de otras
User prompt
el saltodel personaje no es automatico, su salto es controlado por el jugador
User prompt
quiero que el personaje se mueva a la meta de forma automatica ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
quiero que los enemigos busquen con sus ojos al personaje y se se muevan buscando a este ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
quiero que las plataformas se muevan de arriba a abajo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
quiero que el mensaje "bien echo" desaparezca al comenzar el nivel
User prompt
cuando el personaje llega a la meta quiero el siguiente mensaje "Bien echo"
User prompt
quiero que las plataformas cambien de lugar a medida que pasa de nivel
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 2;
self.velocityY = 0;
self.gravity = 0.8;
self.isAlive = true;
self.direction = -1; // Always move left initially
self.patrolDistance = 300;
self.startX = 0;
self.isTracking = false;
self.update = function () {
if (!self.isAlive) return;
// Apply gravity
self.velocityY += self.gravity;
// Seek player behavior
if (player) {
var distanceToPlayer = Math.abs(player.x - self.x);
var verticalDistance = Math.abs(player.y - self.y);
// Only seek if player is within detection range
if (distanceToPlayer < 400 && verticalDistance < 200) {
// Make enemy look at player and move towards them
if (player.x < self.x) {
self.direction = -1;
self.velocityX = Math.min(self.velocityX + 0.2, self.maxSpeed || 3);
} else {
self.direction = 1;
self.velocityX = Math.min(self.velocityX + 0.2, self.maxSpeed || 3);
}
// Eye tracking effect - tween enemy slightly towards player
if (!self.isTracking) {
self.isTracking = true;
var targetTint = 0xFF4444; // Red tint when tracking
tween(enemyGraphics, {
tint: targetTint
}, {
duration: 300
});
}
} else {
// Return to normal advancing behavior (move left)
if (self.isTracking) {
self.isTracking = false;
tween(enemyGraphics, {
tint: 0xFFFFFF
}, {
duration: 500
});
}
// Use the enemy's set velocity or default to 2
self.velocityX = self.velocityX || 2;
self.direction = -1; // Always move left when not tracking
}
}
// Move horizontally
self.x += self.velocityX * self.direction;
self.y += self.velocityY;
// Ground collision
if (self.y >= groundLevel - 30) {
self.y = groundLevel - 30;
self.velocityY = 0;
}
// Platform collision
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (self.intersects(platform) && self.velocityY > 0) {
var enemyBottom = self.y + 30;
var platformTop = platform.y - 20;
if (enemyBottom - self.velocityY <= platformTop) {
self.y = platformTop - 30;
self.velocityY = 0;
}
}
}
// Remove enemies that go off screen (left side)
if (self.x < -100) {
self.isAlive = false;
self.visible = false;
}
// Keep enemy in bounds (right side only)
if (self.x > 2018) {
self.x = 2018;
self.direction = -1;
}
};
self.defeat = function () {
self.isAlive = false;
self.visible = false;
LK.getSound('enemyDefeat').play();
LK.setScore(LK.getScore() + 100);
scoreTxt.setText(LK.getScore());
};
return self;
});
var Goal = Container.expand(function () {
var self = Container.call(this);
var goalGraphics = self.attachAsset('goal', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Platform = Container.expand(function () {
var self = Container.call(this);
var platformGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.speed = 8;
self.jumpPower = 20;
self.gravity = 0.8;
self.isGrounded = false;
self.isJumping = false;
self.update = function () {
// Apply gravity
self.velocityY += self.gravity;
// Apply velocities
self.x += self.velocityX;
self.y += self.velocityY;
// Ground collision
if (self.y >= groundLevel - 40) {
self.y = groundLevel - 40;
self.velocityY = 0;
self.isGrounded = true;
self.isJumping = false;
}
// Platform collision
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (self.intersects(platform) && self.velocityY > 0) {
var playerBottom = self.y + 40;
var platformTop = platform.y - 20;
if (playerBottom - self.velocityY <= platformTop) {
self.y = platformTop - 40;
self.velocityY = 0;
self.isGrounded = true;
self.isJumping = false;
}
}
}
// Keep player in bounds
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
// Apply friction
self.velocityX *= 0.85;
// Auto-movement logic
if (autoMovementEnabled && goal) {
// Calculate direction to goal
var distanceToGoal = goal.x - self.x;
var verticalDistance = goal.y - self.y;
// Move towards goal horizontally
if (Math.abs(distanceToGoal) > 50) {
if (distanceToGoal > 0) {
self.velocityX = autoMovementSpeed;
} else {
self.velocityX = -autoMovementSpeed;
}
}
// Update last position for tracking (but no auto-jump)
lastPlayerX = self.x;
}
};
self.jump = function () {
if (self.isGrounded) {
self.velocityY = -self.jumpPower;
self.isGrounded = false;
self.isJumping = true;
LK.getSound('jump').play();
}
};
self.moveLeft = function () {
self.velocityX = -self.speed;
};
self.moveRight = function () {
self.velocityX = self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var player;
var enemies = [];
var platforms = [];
var goal;
var currentLevel = 1;
var lives = 3;
var groundLevel = 2600;
var leftPressed = false;
var rightPressed = false;
var lastTouchX = 0;
var lastTouchY = 0;
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
scoreTxt.x = 120;
scoreTxt.y = 50;
LK.gui.topLeft.addChild(scoreTxt);
var levelTxt = new Text2('Level: 1', {
size: 60,
fill: 0xFFFFFF
});
levelTxt.anchor.set(0.5, 0);
levelTxt.x = 0;
levelTxt.y = 50;
LK.gui.top.addChild(levelTxt);
var livesTxt = new Text2('Lives: 3', {
size: 60,
fill: 0xFFFFFF
});
livesTxt.anchor.set(1, 0);
livesTxt.x = -50;
livesTxt.y = 50;
LK.gui.topRight.addChild(livesTxt);
function createLevel(levelNum) {
// Clear existing level
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].destroy();
enemies.splice(i, 1);
}
for (var i = platforms.length - 1; i >= 0; i--) {
platforms[i].destroy();
platforms.splice(i, 1);
}
if (goal) {
goal.destroy();
goal = null;
}
// Hide any existing "Bien echo" message
var existingMessage = LK.gui.center.children.find(function (child) {
return child.text === 'Bien echo';
});
if (existingMessage) {
existingMessage.destroy();
}
// Create player if not exists
if (!player) {
player = game.addChild(new Player());
}
// Reset player position
player.x = 200;
player.y = groundLevel - 100;
player.velocityX = 0;
player.velocityY = 0;
// Reset auto-movement variables
lastPlayerX = player.x;
// Create platforms based on level - different layouts for each level
var platformConfigs = [
// Level 1 - Simple staircase
[{
x: 500,
y: 2450
}, {
x: 750,
y: 2350
}, {
x: 1000,
y: 2250
}, {
x: 1250,
y: 2150
}],
// Level 2 - Zigzag pattern
[{
x: 400,
y: 2450
}, {
x: 650,
y: 2350
}, {
x: 900,
y: 2400
}, {
x: 1150,
y: 2250
}, {
x: 1400,
y: 2150
}],
// Level 3 - Dense low platforms
[{
x: 350,
y: 2400
}, {
x: 550,
y: 2300
}, {
x: 750,
y: 2450
}, {
x: 950,
y: 2250
}, {
x: 1150,
y: 2150
}, {
x: 1350,
y: 2050
}],
// Level 4 - High platforms with gaps
[{
x: 450,
y: 2400
}, {
x: 700,
y: 2300
}, {
x: 950,
y: 2450
}, {
x: 1200,
y: 2200
}],
// Level 5 - Vertical tower
[{
x: 650,
y: 2450
}, {
x: 650,
y: 2350
}, {
x: 900,
y: 2250
}, {
x: 1150,
y: 2300
}, {
x: 1400,
y: 2200
}],
// Level 6 - Scattered platforms
[{
x: 400,
y: 2400
}, {
x: 600,
y: 2300
}, {
x: 800,
y: 2450
}, {
x: 1000,
y: 2250
}, {
x: 1200,
y: 2150
}, {
x: 1400,
y: 2050
}],
// Level 7 - Long jumps
[{
x: 550,
y: 2350
}, {
x: 850,
y: 2250
}, {
x: 1150,
y: 2150
}],
// Level 8 - Complex maze
[{
x: 450,
y: 2450
}, {
x: 650,
y: 2350
}, {
x: 850,
y: 2450
}, {
x: 1050,
y: 2250
}, {
x: 1250,
y: 2400
}, {
x: 1450,
y: 2150
}],
// Level 9 - Pyramid structure
[{
x: 900,
y: 2450
}, {
x: 750,
y: 2350
}, {
x: 1050,
y: 2350
}, {
x: 600,
y: 2250
}, {
x: 1200,
y: 2250
}, {
x: 900,
y: 2150
}],
// Level 10 - Final challenge
[{
x: 350,
y: 2400
}, {
x: 550,
y: 2300
}, {
x: 750,
y: 2350
}, {
x: 950,
y: 2250
}, {
x: 1150,
y: 2300
}, {
x: 1350,
y: 2200
}, {
x: 1550,
y: 2100
}]];
var levelPlatforms = platformConfigs[Math.min(levelNum - 1, platformConfigs.length - 1)];
var _loop = function _loop() {
platform = game.addChild(new Platform());
platform.x = levelPlatforms[i].x;
platform.y = levelPlatforms[i].y;
platforms.push(platform);
// Add vertical movement to each platform
moveDistance = 150; // How far up/down to move
moveDuration = 2000 + i * 300; // Different speeds for each platform
initialY = platform.y; // Create alternating movement - some go up first, others down first
targetY = i % 2 === 0 ? initialY - moveDistance : initialY + moveDistance; // Start the movement animation
function animatePlatform(plat, startY, endY, duration) {
tween(plat, {
y: endY
}, {
duration: duration,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Reverse the movement when finished
animatePlatform(plat, endY, startY, duration);
}
});
}
animatePlatform(platform, initialY, targetY, moveDuration);
},
platform,
moveDistance,
moveDuration,
initialY,
targetY;
for (var i = 0; i < levelPlatforms.length; i++) {
_loop();
}
// Create enemies - spawn from right side
var enemyCount = Math.min(levelNum + 2, 8); // Increase max enemies to 8
var enemySpeed = 2 + (levelNum - 1) * 0.5; // Speed increases by 0.5 per level
for (var i = 0; i < enemyCount; i++) {
var enemy = game.addChild(new Enemy());
enemy.x = 2048 + i * 200; // Start from right side of screen
enemy.y = groundLevel - 100;
enemy.startX = enemy.x;
enemy.velocityX = enemySpeed; // Set speed based on level
enemy.maxSpeed = enemySpeed + 1; // Set max speed for tracking
enemies.push(enemy);
}
// Create goal
goal = game.addChild(new Goal());
goal.x = 1900;
goal.y = groundLevel - 75;
// Update level display
levelTxt.setText('Level: ' + levelNum);
}
function nextLevel() {
currentLevel++;
LK.setScore(LK.getScore() + 500);
scoreTxt.setText(LK.getScore());
LK.getSound('levelComplete').play();
// Display "Bien echo" message
var congratsText = new Text2('Bien echo', {
size: 120,
fill: 0xFFD700
});
congratsText.anchor.set(0.5, 0.5);
congratsText.x = 0;
congratsText.y = 0;
LK.gui.center.addChild(congratsText);
// Remove the message after 2 seconds
LK.setTimeout(function () {
congratsText.destroy();
}, 2000);
if (currentLevel > 10) {
LK.showYouWin();
} else {
createLevel(currentLevel);
}
}
function loseLife() {
lives--;
livesTxt.setText('Lives: ' + lives);
if (lives <= 0) {
LK.showGameOver();
} else {
// Reset player position
player.x = 200;
player.y = groundLevel - 100;
player.velocityX = 0;
player.velocityY = 0;
}
}
// Touch controls
game.down = function (x, y, obj) {
lastTouchX = x;
lastTouchY = y;
// Jump on tap
if (player) {
player.jump();
}
};
game.move = function (x, y, obj) {
if (!player) return;
var deltaX = x - lastTouchX;
// Movement based on drag direction
if (Math.abs(deltaX) > 20) {
if (deltaX > 0) {
rightPressed = true;
leftPressed = false;
} else {
leftPressed = true;
rightPressed = false;
}
}
lastTouchX = x;
lastTouchY = y;
};
game.up = function (x, y, obj) {
leftPressed = false;
rightPressed = false;
};
game.update = function () {
if (!player) return;
// Handle movement (only if auto-movement is disabled)
if (!autoMovementEnabled) {
if (leftPressed) {
player.moveLeft();
}
if (rightPressed) {
player.moveRight();
}
}
// Enemy collision detection
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
if (!enemy.isAlive) continue;
if (player.intersects(enemy)) {
// Check if player is falling on enemy from above
if (player.velocityY > 0 && player.y < enemy.y - 10) {
enemy.defeat();
player.velocityY = -10; // Bounce effect
} else {
// Player touched enemy from side - destroy enemy instead of losing life
enemy.defeat();
player.velocityY = -5; // Small bounce effect
}
}
}
// Goal collision
if (goal && player.intersects(goal)) {
nextLevel();
}
// Fall off screen
if (player.y > 2800) {
loseLife();
}
};
// Auto-movement variables
var autoMovementEnabled = true;
var autoMovementSpeed = 4;
var lastPlayerX = 0;
// Initialize first level
createLevel(1);
; ===================================================================
--- original.js
+++ change.js
@@ -587,17 +587,16 @@
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
if (!enemy.isAlive) continue;
if (player.intersects(enemy)) {
- // Check if player is jumping on enemy from above
+ // Check if player is falling on enemy from above
if (player.velocityY > 0 && player.y < enemy.y - 10) {
enemy.defeat();
player.velocityY = -10; // Bounce effect
} else {
- // Player touched enemy from side - lose life
- LK.getSound('enemyHit').play();
- loseLife();
- return;
+ // Player touched enemy from side - destroy enemy instead of losing life
+ enemy.defeat();
+ player.velocityY = -5; // Small bounce effect
}
}
}
// Goal collision
un fuego. In-Game asset. 2d. High contrast. No shadows. un fuego. un fuego
un fuego con ojos y boca, de expresion enojado. In-Game asset. 2d. High contrast. No shadows
un castillo simple. In-Game asset. 2d. High contrast. No shadows. castillo simple
una nube. In-Game asset. 2d. High contrast. No shadows
fuego con alas, ojo y boca. In-Game asset. 2d. High contrast. No shadows
camino de tierra. In-Game asset. 2d. High contrast. No shadows
cielo con castillos y nubes de fondo, que se vea borroso. In-Game asset. 2d. High contrast. No shadows
un oyo de tierra con estacas puntiagudas, de aspecto amenazador. In-Game asset. 2d. High contrast. No shadows
un sol con la leyenda "1 UP". In-Game asset. 2d. High contrast. No shadows
un huevo de colores. In-Game asset. 2d. High contrast. No shadows. un huevo de colores
humo gris. In-Game asset. 2d. High contrast. No shadows
un muñeco con gorra y pantalones. In-Game asset. 2d. High contrast. No shadows