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.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;
// Check boundaries
if (self.x < 0) {
self.x = 0;
}
// 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 left side to move left, right side 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 floating obstacles that will fall when player approaches
var obstaclePositions = [600, 900, 1200, 1600, 2000, 2400, 2800, 3200, 3600, 4000, 4400, 4800, 5200, 5600, 6000, 6400, 6800, 7200];
for (var i = 0; i < obstaclePositions.length; i++) {
var obstacle = game.addChild(new Platform(120, 80));
obstacle.x = obstaclePositions[i];
obstacle.y = 2200; // Start floating in air
obstacle.originalY = 2200;
obstacle.fallY = 2420; // Where it falls to (just above ground)
obstacle.isActive = false;
obstacle.triggerDistance = 200; // Distance to trigger fall
platforms.push(obstacle);
}
// 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 leftPressed = false;
var rightPressed = false;
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
return;
}
// Simple left/right screen tap detection
if (x < 2048 / 2) {
leftPressed = true;
} else {
rightPressed = true;
}
};
game.up = function (x, y, obj) {
leftPressed = false;
rightPressed = false;
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 proximity to floating obstacles and trigger falling
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
// Skip the ground platform (first one)
if (i === 0) continue;
// Check if player is within trigger distance
var distanceToPlayer = Math.abs(player.x - platform.x);
// If player gets close and obstacle hasn't been activated yet
if (distanceToPlayer < platform.triggerDistance && !platform.isActive) {
platform.isActive = true;
// Fall quickly
tween(platform, {
y: platform.fallY
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
// After falling, wait a moment then rise slowly
LK.setTimeout(function () {
tween(platform, {
y: platform.originalY
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
platform.isActive = false;
}
});
}, 1000);
}
});
}
}
// 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
@@ -170,75 +170,30 @@
}
platforms = [];
enemies = [];
spikes = [];
- // Level 1 - Simple introduction
- if (levelNum === 1) {
- // Ground platform - continuous ground
- var platform1 = game.addChild(new Platform(2000, 60));
- platform1.x = 1000;
- platform1.y = 2500;
- platforms.push(platform1);
- // Simple enemy
- var enemy1 = game.addChild(new Enemy());
- enemy1.x = 700;
- enemy1.y = 2500;
- enemy1.setPatrol(600, 200);
- enemies.push(enemy1);
- // Goal
- goal = game.addChild(new Goal());
- goal.x = 1600;
- goal.y = 2500;
+ // 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 floating obstacles that will fall when player approaches
+ var obstaclePositions = [600, 900, 1200, 1600, 2000, 2400, 2800, 3200, 3600, 4000, 4400, 4800, 5200, 5600, 6000, 6400, 6800, 7200];
+ for (var i = 0; i < obstaclePositions.length; i++) {
+ var obstacle = game.addChild(new Platform(120, 80));
+ obstacle.x = obstaclePositions[i];
+ obstacle.y = 2200; // Start floating in air
+ obstacle.originalY = 2200;
+ obstacle.fallY = 2420; // Where it falls to (just above ground)
+ obstacle.isActive = false;
+ obstacle.triggerDistance = 200; // Distance to trigger fall
+ platforms.push(obstacle);
}
- // Level 2 - More complex
- else if (levelNum === 2) {
- // Continuous ground
- var platform1 = game.addChild(new Platform(2000, 60));
- platform1.x = 1000;
- platform1.y = 2500;
- platforms.push(platform1);
- // Enemies
- var enemy1 = game.addChild(new Enemy());
- enemy1.x = 500;
- enemy1.y = 2500;
- enemy1.setPatrol(450, 100);
- enemies.push(enemy1);
- var enemy2 = game.addChild(new Enemy());
- enemy2.x = 1200;
- enemy2.y = 2500;
- enemy2.setPatrol(1100, 200);
- enemies.push(enemy2);
- goal = game.addChild(new Goal());
- goal.x = 1700;
- goal.y = 2500;
- }
- // Level 3 - Advanced
- else {
- // Continuous ground
- var platform1 = game.addChild(new Platform(2000, 60));
- platform1.x = 1000;
- platform1.y = 2500;
- platforms.push(platform1);
- // Multiple enemies
- var enemy1 = game.addChild(new Enemy());
- enemy1.x = 400;
- enemy1.y = 2500;
- enemy1.setPatrol(350, 100);
- enemies.push(enemy1);
- var enemy2 = game.addChild(new Enemy());
- enemy2.x = 950;
- enemy2.y = 2500;
- enemy2.setPatrol(900, 100);
- enemies.push(enemy2);
- var enemy3 = game.addChild(new Enemy());
- enemy3.x = 1300;
- enemy3.y = 2500;
- enemy3.setPatrol(1250, 100);
- enemies.push(enemy3);
- goal = game.addChild(new Goal());
- goal.x = 1650;
- goal.y = 2500;
- }
+ // Goal at the end
+ goal = game.addChild(new Goal());
+ goal.x = 7500;
+ goal.y = 2500;
}
function startGame() {
if (gameStarted) return;
gameStarted = true;
@@ -249,9 +204,9 @@
player.x = 200;
player.y = 2400;
// Create level
createLevel(currentLevel);
- levelText.setText('Level ' + currentLevel);
+ levelText.setText('The Long Journey');
}
function restartLevel() {
LK.getSound('hit').play();
LK.effects.flashScreen(0xFF0000, 500);
@@ -264,30 +219,10 @@
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();
+ // Game completed - single long level
+ LK.showYouWin();
}
// Touch controls
var leftPressed = false;
var rightPressed = false;
@@ -319,8 +254,41 @@
player.moveRight();
} else if (!leftPressed && !rightPressed) {
player.stop();
}
+ // Check proximity to floating obstacles and trigger falling
+ for (var i = 0; i < platforms.length; i++) {
+ var platform = platforms[i];
+ // Skip the ground platform (first one)
+ if (i === 0) continue;
+ // Check if player is within trigger distance
+ var distanceToPlayer = Math.abs(player.x - platform.x);
+ // If player gets close and obstacle hasn't been activated yet
+ if (distanceToPlayer < platform.triggerDistance && !platform.isActive) {
+ platform.isActive = true;
+ // Fall quickly
+ tween(platform, {
+ y: platform.fallY
+ }, {
+ duration: 300,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ // After falling, wait a moment then rise slowly
+ LK.setTimeout(function () {
+ tween(platform, {
+ y: platform.originalY
+ }, {
+ duration: 2000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ platform.isActive = false;
+ }
+ });
+ }, 1000);
+ }
+ });
+ }
+ }
// Check enemy collisions
for (var i = 0; i < enemies.length; i++) {
if (player.intersects(enemies[i])) {
restartLevel();