===================================================================
--- original.js
+++ change.js
@@ -45,8 +45,15 @@
self.y -= self.speed;
} else {
self.y += self.speed / 2 + LK.ticks / 1500; // Increase downward speed over time
}
+ // Add horizontal movement
+ self.x += self.horizontalSpeed;
+ if (self.x < 0) {
+ self.x = 0;
+ } else if (self.x > 2048) {
+ self.x = 2048;
+ }
// Ensure player doesn't move out of bounds
if (self.y < 0) {
self.y = 0;
} else if (self.y > 2732) {
@@ -73,8 +80,9 @@
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var player = game.addChild(new Player());
+player.horizontalSpeed = 2; // Initialize horizontal speed
player.x = 1024;
player.y = 2732 - player.height;
var enemies = [];
for (var i = 0; i < 10; i++) {
@@ -91,8 +99,10 @@
obstacles.push(obstacle);
}
game.down = function (x, y, obj) {
player.movingUp = true;
+ // Toggle horizontal movement direction
+ player.horizontalSpeed = -player.horizontalSpeed;
};
game.up = function (x, y, obj) {
player.movingUp = false;
};