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 FallingObstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('spike', {
anchorX: 0.5,
anchorY: 1.0
});
// Thwomp-like behavior states
self.state = 'waiting'; // waiting, detecting, falling, rising
self.originalY = 0;
self.fallY = 0;
self.triggerDistance = 200;
self.detectionTimer = 0;
self.detectionDelay = 500; // Half second before falling
self.lastPlayerInRange = false;
self.update = function () {
if (!player) return;
var distanceToPlayer = Math.abs(player.x - self.x);
var playerInRange = distanceToPlayer < self.triggerDistance && player.y > self.originalY - 200;
// State machine for Thwomp behavior
if (self.state === 'waiting') {
// Check if player enters detection range
if (!self.lastPlayerInRange && playerInRange) {
self.state = 'detecting';
self.detectionTimer = 0;
// Visual warning - shake slightly
tween(obstacleGraphics, {
rotation: 0.1
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(obstacleGraphics, {
rotation: -0.1
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(obstacleGraphics, {
rotation: 0
}, {
duration: 100,
easing: tween.easeInOut
});
}
});
}
});
}
} else if (self.state === 'detecting') {
self.detectionTimer += 1000 / 60; // Add frame time
if (self.detectionTimer >= self.detectionDelay) {
self.state = 'falling';
// Fall instantly like a Thwomp
tween(self, {
y: self.fallY
}, {
duration: 0,
easing: tween.easeIn,
onFinish: function onFinish() {
// Stay down briefly, then rise slowly
LK.setTimeout(function () {
self.state = 'rising';
tween(self, {
y: self.originalY
}, {
duration: 3000,
easing: tween.easeOut,
onFinish: function onFinish() {
self.state = 'waiting';
// Reset last player range to allow re-triggering
self.lastPlayerInRange = false;
}
});
}, 800);
}
});
}
} else if (self.state === 'rising') {
// Don't detect player while rising
self.lastPlayerInRange = true;
}
self.lastPlayerInRange = playerInRange;
};
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.facing = 1; // 1 for right, -1 for left
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 velocity
self.x += self.velocityX;
// Apply friction
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 to move right', {
size: 60,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionText);
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 = [];
// Create one very long level
// Ground platform - very long continuous ground
var platform1 = game.addChild(new Platform(8000, 60));
platform1.x = 4000;
platform1.y = 2500;
platforms.push(platform1);
// Create Thwomp-like falling obstacles
var obstaclePositions = [400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 3600, 3800, 4000, 4200, 4400, 4600, 4800, 5000, 5200, 5400, 5600, 5800, 6000, 6200, 6400, 6600, 6800, 7000, 7200];
for (var i = 0; i < obstaclePositions.length; i++) {
var obstacle = game.addChild(new FallingObstacle());
obstacle.x = obstaclePositions[i];
obstacle.y = 2100; // Start position in air
obstacle.originalY = 2100;
obstacle.fallY = 2420; // Where it falls to (just above ground)
obstacle.triggerDistance = 200;
spikes.push(obstacle); // Add to spikes array since they kill the player
}
// Goal at the end
goal = game.addChild(new Goal());
goal.x = 7500;
goal.y = 2500;
}
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('The Long Journey');
}
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() {
// Game completed - single long level
LK.showYouWin();
}
// Touch controls
var rightPressed = false;
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
return;
}
// Only allow right movement
rightPressed = true;
};
game.up = function (x, y, obj) {
rightPressed = false;
if (player) {
player.stop();
}
};
game.update = function () {
if (!gameStarted || !player) return;
// Handle continuous movement - only right
if (rightPressed) {
player.moveRight();
} else {
player.stop();
}
// Thwomp obstacles handle their own behavior in their update methods
// 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
@@ -81,13 +81,13 @@
} else if (self.state === 'detecting') {
self.detectionTimer += 1000 / 60; // Add frame time
if (self.detectionTimer >= self.detectionDelay) {
self.state = 'falling';
- // Fall very quickly like a Thwomp
+ // Fall instantly like a Thwomp
tween(self, {
y: self.fallY
}, {
- duration: 100,
+ duration: 0,
easing: tween.easeIn,
onFinish: function onFinish() {
// Stay down briefly, then rise slowly
LK.setTimeout(function () {