User prompt
Has que los obstaculos caigan un poco mas luego desde que el jugador se le acerque ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que el jugador toque el piso y que los obstaculos esten alejados entre si y que esten en una posicion aleatoria ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos caigan un poco mas antes
User prompt
Has que los obstaculos caigan un poco mas antes
User prompt
Has que los obstaculos caigan un poco mas antes ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos caigan cuando el jugador estecsi por debajo de ellos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Un poco mas tarde ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Un poquito mas tarde ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos caigan un poquito mas tarde ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos caigan mucho antes de acercarse ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos caigan mas rapido ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Quita la animacion de los objetos antes de caer ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos caigan instantanea mente ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos caigan mas rapido ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos caigan muy rapido y que vuelvan a caer al volver a acercarse ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos actuen como los don pisoton de mario bros ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que el jugador solo pueda ir al lado derecho
User prompt
Has que los obstaculos suban lentamente despues de bajar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que los obstaculos suban lentamente despues de bajar, que maten al jugador al tocarlo y que el nivel sea mas dificil ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que el jugador tenga que atravesar un solo nivel muy largo en donde los obstaculos se quedan estaticos en el aire hasta que el jugador pase cerca de ellos y bajen bruscamente y suban lentamente ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Has que al apretar el lado izquuerdo de la pantalla el jugador valla hacia la izquierda, y que al presionar el lado derecho el jugador valla a la derecha, y que el jugador no pueda saltar por lo que el nivel no tiene que tener obstaculos imposibles sin saltar
User prompt
Try again
User prompt
Has los botones mas grandes y que uno lleve al jugador al lado izquierdo, otro al derecho y uno para saltar
User prompt
Arregla los botones
User prompt
Has que la camara siga al jugador y que hallan botones para caminar y saltar
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 1.0
});
self.speed = 2;
self.direction = 1;
self.patrolDistance = 200;
self.startX = 0;
self.setPatrol = function (startX, distance) {
self.startX = startX;
self.patrolDistance = distance;
};
self.update = function () {
self.x += self.speed * self.direction;
if (self.x > self.startX + self.patrolDistance || self.x < self.startX) {
self.direction *= -1;
enemyGraphics.scaleX = self.direction;
}
};
return self;
});
var Goal = Container.expand(function () {
var self = Container.call(this);
var goalGraphics = self.attachAsset('goal', {
anchorX: 0.5,
anchorY: 1.0
});
// Animate goal with gentle pulsing
tween(goalGraphics, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(goalGraphics, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Restart animation
tween(goalGraphics, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
}
});
return self;
});
var Platform = Container.expand(function (width, height) {
var self = Container.call(this);
var platformGraphics = self.attachAsset('ground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: width / 200,
scaleY: height / 40
});
self.width = width;
self.height = height;
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 = 8;
self.jumpPower = -20;
self.gravity = 1.2;
self.onGround = false;
self.facing = 1; // 1 for right, -1 for left
self.jump = function () {
if (self.onGround) {
self.velocityY = self.jumpPower;
self.onGround = false;
LK.getSound('jump').play();
}
};
self.moveLeft = function () {
self.velocityX = -self.speed;
self.facing = -1;
playerGraphics.scaleX = -1;
};
self.moveRight = function () {
self.velocityX = self.speed;
self.facing = 1;
playerGraphics.scaleX = 1;
};
self.stop = function () {
self.velocityX = 0;
};
self.update = function () {
// Apply gravity
self.velocityY += self.gravity;
// Apply velocity
self.x += self.velocityX;
self.y += self.velocityY;
// Check ground collision
self.onGround = false;
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (self.intersects(platform) && self.velocityY >= 0) {
self.y = platform.y - platform.height / 2;
self.velocityY = 0;
self.onGround = true;
break;
}
}
// Check boundaries
if (self.y > 2732) {
restartLevel();
}
// Apply friction when on ground
if (self.onGround) {
self.velocityX *= 0.8;
}
};
return self;
});
var Spike = Container.expand(function () {
var self = Container.call(this);
var spikeGraphics = self.attachAsset('spike', {
anchorX: 0.5,
anchorY: 1.0
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var player;
var platforms = [];
var enemies = [];
var spikes = [];
var goal;
var gameStarted = false;
var levelStartTime = 0;
var currentLevel = 1;
var maxLevel = storage.maxLevel || 1;
// UI Elements
var levelText = new Text2('Level 1', {
size: 80,
fill: 0xFFFFFF
});
levelText.anchor.set(0.5, 0);
LK.gui.top.addChild(levelText);
levelText.y = 50;
var instructionText = new Text2('Tap sides to move, top to jump', {
size: 60,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionText);
// Movement buttons
var leftButton = new Text2('◀', {
size: 120,
fill: 0xFFFFFF
});
leftButton.anchor.set(0.5, 0.5);
leftButton.alpha = 0.7;
LK.gui.bottomLeft.addChild(leftButton);
leftButton.x = 100;
leftButton.y = -100;
var rightButton = new Text2('▶', {
size: 120,
fill: 0xFFFFFF
});
rightButton.anchor.set(0.5, 0.5);
rightButton.alpha = 0.7;
LK.gui.bottomLeft.addChild(rightButton);
rightButton.x = 250;
rightButton.y = -100;
var jumpButton = new Text2('⬆', {
size: 120,
fill: 0xFFFFFF
});
jumpButton.anchor.set(0.5, 0.5);
jumpButton.alpha = 0.7;
LK.gui.bottomRight.addChild(jumpButton);
jumpButton.x = -100;
jumpButton.y = -100;
function createLevel(levelNum) {
// Clear existing level
for (var i = platforms.length - 1; i >= 0; i--) {
platforms[i].destroy();
}
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].destroy();
}
for (var i = spikes.length - 1; i >= 0; i--) {
spikes[i].destroy();
}
if (goal) {
goal.destroy();
}
platforms = [];
enemies = [];
spikes = [];
// Level 1 - Simple introduction
if (levelNum === 1) {
// Ground platforms
var platform1 = game.addChild(new Platform(400, 60));
platform1.x = 200;
platform1.y = 2500;
platforms.push(platform1);
var platform2 = game.addChild(new Platform(300, 60));
platform2.x = 700;
platform2.y = 2400;
platforms.push(platform2);
var platform3 = game.addChild(new Platform(300, 60));
platform3.x = 1100;
platform3.y = 2300;
platforms.push(platform3);
var platform4 = game.addChild(new Platform(400, 60));
platform4.x = 1600;
platform4.y = 2200;
platforms.push(platform4);
// Simple enemy
var enemy1 = game.addChild(new Enemy());
enemy1.x = 700;
enemy1.y = 2400;
enemy1.setPatrol(600, 200);
enemies.push(enemy1);
// Goal
goal = game.addChild(new Goal());
goal.x = 1600;
goal.y = 2200;
}
// Level 2 - More complex
else if (levelNum === 2) {
var platform1 = game.addChild(new Platform(300, 60));
platform1.x = 150;
platform1.y = 2500;
platforms.push(platform1);
var platform2 = game.addChild(new Platform(200, 60));
platform2.x = 500;
platform2.y = 2400;
platforms.push(platform2);
var platform3 = game.addChild(new Platform(200, 60));
platform3.x = 800;
platform3.y = 2300;
platforms.push(platform3);
var platform4 = game.addChild(new Platform(300, 60));
platform4.x = 1200;
platform4.y = 2400;
platforms.push(platform4);
var platform5 = game.addChild(new Platform(400, 60));
platform5.x = 1700;
platform5.y = 2200;
platforms.push(platform5);
// Enemies
var enemy1 = game.addChild(new Enemy());
enemy1.x = 500;
enemy1.y = 2400;
enemy1.setPatrol(450, 100);
enemies.push(enemy1);
var enemy2 = game.addChild(new Enemy());
enemy2.x = 1200;
enemy2.y = 2400;
enemy2.setPatrol(1100, 200);
enemies.push(enemy2);
// Spikes
var spike1 = game.addChild(new Spike());
spike1.x = 800;
spike1.y = 2300;
spikes.push(spike1);
goal = game.addChild(new Goal());
goal.x = 1700;
goal.y = 2200;
}
// Level 3 - Advanced
else {
var platform1 = game.addChild(new Platform(250, 60));
platform1.x = 125;
platform1.y = 2500;
platforms.push(platform1);
var platform2 = game.addChild(new Platform(150, 60));
platform2.x = 400;
platform2.y = 2350;
platforms.push(platform2);
var platform3 = game.addChild(new Platform(150, 60));
platform3.x = 650;
platform3.y = 2200;
platforms.push(platform3);
var platform4 = game.addChild(new Platform(200, 60));
platform4.x = 950;
platform4.y = 2350;
platforms.push(platform4);
var platform5 = game.addChild(new Platform(200, 60));
platform5.x = 1300;
platform5.y = 2250;
platforms.push(platform5);
var platform6 = game.addChild(new Platform(300, 60));
platform6.x = 1650;
platform6.y = 2150;
platforms.push(platform6);
// Multiple enemies
var enemy1 = game.addChild(new Enemy());
enemy1.x = 400;
enemy1.y = 2350;
enemy1.setPatrol(350, 100);
enemies.push(enemy1);
var enemy2 = game.addChild(new Enemy());
enemy2.x = 950;
enemy2.y = 2350;
enemy2.setPatrol(900, 100);
enemies.push(enemy2);
var enemy3 = game.addChild(new Enemy());
enemy3.x = 1300;
enemy3.y = 2250;
enemy3.setPatrol(1250, 100);
enemies.push(enemy3);
// More spikes
var spike1 = game.addChild(new Spike());
spike1.x = 650;
spike1.y = 2200;
spikes.push(spike1);
var spike2 = game.addChild(new Spike());
spike2.x = 1300;
spike2.y = 2250;
spikes.push(spike2);
goal = game.addChild(new Goal());
goal.x = 1650;
goal.y = 2150;
}
}
function startGame() {
if (gameStarted) return;
gameStarted = true;
levelStartTime = Date.now();
instructionText.visible = false;
// Create player
player = game.addChild(new Player());
player.x = 200;
player.y = 2400;
// Create level
createLevel(currentLevel);
levelText.setText('Level ' + currentLevel);
}
function restartLevel() {
LK.getSound('hit').play();
LK.effects.flashScreen(0xFF0000, 500);
if (player) {
player.destroy();
}
// Reset player
player = game.addChild(new Player());
player.x = 200;
player.y = 2400;
levelStartTime = Date.now();
}
function nextLevel() {
currentLevel++;
if (currentLevel > maxLevel) {
maxLevel = currentLevel;
storage.maxLevel = maxLevel;
}
if (currentLevel > 3) {
// Game completed
LK.showYouWin();
return;
}
// Destroy current player
if (player) {
player.destroy();
}
// Create new level
createLevel(currentLevel);
levelText.setText('Level ' + currentLevel);
// Reset player
player = game.addChild(new Player());
player.x = 200;
player.y = 2400;
levelStartTime = Date.now();
}
// Touch controls
var leftPressed = false;
var rightPressed = false;
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
return;
}
// Convert screen coordinates to GUI coordinates for button detection
var guiPos = LK.gui.toLocal({
x: x,
y: y
});
// Check if touching left button area
if (guiPos.x < 350 && guiPos.y > LK.gui.height - 200) {
if (guiPos.x < 175) {
leftPressed = true;
leftButton.alpha = 1.0;
} else {
rightPressed = true;
rightButton.alpha = 1.0;
}
}
// Check if touching jump button area
else if (guiPos.x > LK.gui.width - 200 && guiPos.y > LK.gui.height - 200) {
if (player) {
player.jump();
jumpButton.alpha = 1.0;
}
}
// Fallback to original touch areas for compatibility
else {
// Jump area (upper third of screen)
if (y < 2732 / 3) {
if (player) {
player.jump();
}
}
// Movement areas
else {
if (x < 2048 / 2) {
leftPressed = true;
} else {
rightPressed = true;
}
}
}
};
game.up = function (x, y, obj) {
leftPressed = false;
rightPressed = false;
// Reset button alphas
leftButton.alpha = 0.7;
rightButton.alpha = 0.7;
jumpButton.alpha = 0.7;
if (player) {
player.stop();
}
};
game.update = function () {
if (!gameStarted || !player) return;
// Handle continuous movement
if (leftPressed && !rightPressed) {
player.moveLeft();
} else if (rightPressed && !leftPressed) {
player.moveRight();
} else if (!leftPressed && !rightPressed) {
player.stop();
}
// Check enemy collisions
for (var i = 0; i < enemies.length; i++) {
if (player.intersects(enemies[i])) {
restartLevel();
return;
}
}
// Check spike collisions
for (var i = 0; i < spikes.length; i++) {
if (player.intersects(spikes[i])) {
restartLevel();
return;
}
}
// Check goal collision
if (goal && player.intersects(goal)) {
LK.getSound('collect').play();
var completionTime = Math.floor((Date.now() - levelStartTime) / 1000);
LK.setScore(LK.getScore() + Math.max(100 - completionTime, 10));
nextLevel();
}
// Camera follow player with smooth interpolation
var targetX = -(player.x - 1024); // Center player on screen
var targetY = -(player.y - 1366); // Center player vertically
game.x += (targetX - game.x) * 0.1;
game.y += (targetY - game.y) * 0.1;
}; ===================================================================
--- original.js
+++ change.js
@@ -187,28 +187,28 @@
});
leftButton.anchor.set(0.5, 0.5);
leftButton.alpha = 0.7;
LK.gui.bottomLeft.addChild(leftButton);
-leftButton.x = 150;
-leftButton.y = -150;
+leftButton.x = 100;
+leftButton.y = -100;
var rightButton = new Text2('▶', {
size: 120,
fill: 0xFFFFFF
});
rightButton.anchor.set(0.5, 0.5);
rightButton.alpha = 0.7;
LK.gui.bottomLeft.addChild(rightButton);
-rightButton.x = 350;
-rightButton.y = -150;
+rightButton.x = 250;
+rightButton.y = -100;
var jumpButton = new Text2('⬆', {
size: 120,
fill: 0xFFFFFF
});
jumpButton.anchor.set(0.5, 0.5);
jumpButton.alpha = 0.7;
LK.gui.bottomRight.addChild(jumpButton);
-jumpButton.x = -150;
-jumpButton.y = -150;
+jumpButton.x = -100;
+jumpButton.y = -100;
function createLevel(levelNum) {
// Clear existing level
for (var i = platforms.length - 1; i >= 0; i--) {
platforms[i].destroy();
@@ -415,19 +415,19 @@
x: x,
y: y
});
// Check if touching left button area
- if (guiPos.x < 300 && guiPos.y > LK.gui.height - 300) {
- if (guiPos.x < 200) {
+ if (guiPos.x < 350 && guiPos.y > LK.gui.height - 200) {
+ if (guiPos.x < 175) {
leftPressed = true;
leftButton.alpha = 1.0;
- } else if (guiPos.x < 400) {
+ } else {
rightPressed = true;
rightButton.alpha = 1.0;
}
}
// Check if touching jump button area
- else if (guiPos.x > LK.gui.width - 300 && guiPos.y > LK.gui.height - 300) {
+ else if (guiPos.x > LK.gui.width - 200 && guiPos.y > LK.gui.height - 200) {
if (player) {
player.jump();
jumpButton.alpha = 1.0;
}