/****
* Classes
****/
// Define the Obstacle class
var Obstacle = Container.expand(function () {
  var self = Container.call(this);
  var obstacleGraphics = self.attachAsset('obstacle', {
    anchorX: 0.5,
    anchorY: 0.5
  });
  self.speed = 5;
  self.update = function () {
    self.y += self.speed;
    if (self.y > 2732) {
      self.y = -100; // Reset position to top
      self.x = Math.random() * 2048; // Randomize x position
    }
  };
});
//<Assets used in the game will automatically appear here>
// Define the Player class
var Player = Container.expand(function () {
  var self = Container.call(this);
  var playerGraphics = self.attachAsset('player', {
    anchorX: 0.5,
    anchorY: 0.5
  });
  self.speed = 10;
  self.update = function () {
    // Player update logic, if any
  };
});
/****
* Initialize Game
****/
var game = new LK.Game({
  backgroundColor: 0x000000 //Init game with black background 
});
/****
* Game Code
****/
// Initialize player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
// Initialize obstacles
var obstacles = [];
for (var i = 0; i < 5; i++) {
  var obstacle = new Obstacle();
  obstacle.x = Math.random() * 2048;
  obstacle.y = Math.random() * -2732;
  obstacles.push(obstacle);
  game.addChild(obstacle);
}
// Handle player movement
game.move = function (x, y, obj) {
  player.x = x;
};
// Game update loop
game.update = function () {
  for (var i = 0; i < obstacles.length; i++) {
    obstacles[i].update();
    if (player.intersects(obstacles[i])) {
      LK.effects.flashScreen(0xff0000, 1000);
      LK.showGameOver();
    }
  }
}; /****
* Classes
****/
// Define the Obstacle class
var Obstacle = Container.expand(function () {
  var self = Container.call(this);
  var obstacleGraphics = self.attachAsset('obstacle', {
    anchorX: 0.5,
    anchorY: 0.5
  });
  self.speed = 5;
  self.update = function () {
    self.y += self.speed;
    if (self.y > 2732) {
      self.y = -100; // Reset position to top
      self.x = Math.random() * 2048; // Randomize x position
    }
  };
});
//<Assets used in the game will automatically appear here>
// Define the Player class
var Player = Container.expand(function () {
  var self = Container.call(this);
  var playerGraphics = self.attachAsset('player', {
    anchorX: 0.5,
    anchorY: 0.5
  });
  self.speed = 10;
  self.update = function () {
    // Player update logic, if any
  };
});
/****
* Initialize Game
****/
var game = new LK.Game({
  backgroundColor: 0x000000 //Init game with black background 
});
/****
* Game Code
****/
// Initialize player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
// Initialize obstacles
var obstacles = [];
for (var i = 0; i < 5; i++) {
  var obstacle = new Obstacle();
  obstacle.x = Math.random() * 2048;
  obstacle.y = Math.random() * -2732;
  obstacles.push(obstacle);
  game.addChild(obstacle);
}
// Handle player movement
game.move = function (x, y, obj) {
  player.x = x;
};
// Game update loop
game.update = function () {
  for (var i = 0; i < obstacles.length; i++) {
    obstacles[i].update();
    if (player.intersects(obstacles[i])) {
      LK.effects.flashScreen(0xff0000, 1000);
      LK.showGameOver();
    }
  }
};