===================================================================
--- original.js
+++ change.js
@@ -10,8 +10,9 @@
});
self.speed = 3;
self.update = function () {
self.x += self.speed + LK.ticks / 500; // Increase speed over time
+ self.y += Math.sin(LK.ticks / 100) * 2; // Add vertical oscillation
// Reset enemy position if it moves out of bounds
if (self.x > 2048) {
self.x = -self.width;
self.y += (Math.random() - 0.5) * 20; // Add random vertical movement
@@ -30,8 +31,16 @@
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.speed = 2;
+ self.update = function () {
+ self.x -= self.speed;
+ if (self.x < -self.width) {
+ self.x = 2048 + Math.random() * 2048;
+ self.y = Math.random() * 2732;
+ }
+ };
});
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
@@ -113,8 +122,11 @@
if (player.intersects(enemy)) {
LK.showGameOver();
}
});
+ obstacles.forEach(function (obstacle) {
+ obstacle.update();
+ });
if (LK.ticks % 120 === 0 && enemies.length < 15) {
var newEnemy = game.addChild(new Enemy());
newEnemy.x = -newEnemy.width;
newEnemy.y = Math.random() * 2732;