===================================================================
--- original.js
+++ change.js
@@ -27,9 +27,10 @@
var Hurdle = Container.expand(function () {
var self = Container.call(this);
var hurdleGraphics = self.attachAsset('hurdle', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ tint: 0xff0000 // Highlight hurdles by changing their color to red
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
@@ -54,16 +55,19 @@
character.x = 2048 / 2;
character.y = 2732 - 200;
// Initialize hurdles array
var hurdles = [];
-// Function to create a new hurdle
+// Function to create new hurdles
function createHurdle() {
- var lane = Math.floor(Math.random() * 3);
- var hurdle = new Hurdle();
- hurdle.x = 2048 / 3 * lane + 2048 / 6;
- hurdle.y = -100;
- hurdles.push(hurdle);
- game.addChild(hurdle);
+ // Create two hurdles at a time
+ for (var i = 0; i < 2; i++) {
+ var lane = Math.floor(Math.random() * 3);
+ var hurdle = new Hurdle();
+ hurdle.x = 2048 / 3 * lane + 2048 / 6;
+ hurdle.y = -100 - i * 100; // Offset each hurdle
+ hurdles.push(hurdle);
+ game.addChild(hurdle);
+ }
}
// Set interval to create hurdles
var hurdleInterval = LK.setInterval(createHurdle, 1000);
// Handle touch events for character movement