/****
* Classes
****/
// Class for the balloons
var Balloon = Container.expand(function () {
  var self = Container.call(this);
  var balloonGraphics = self.attachAsset('balloon', {
    anchorX: 0.5,
    anchorY: 0.5
  });
  self.speed = -3;
  self.update = function () {
    self.y += self.speed;
    if (self.y < -50) {
      self.destroy();
    }
  };
});
//<Assets used in the game will automatically appear here>
// Class for the main character (kid)
var Kid = Container.expand(function () {
  var self = Container.call(this);
  var kidGraphics = self.attachAsset('kid', {
    anchorX: 0.5,
    anchorY: 0.5
  });
  self.update = function () {
    // Update logic for the kid
  };
});
/****
* Initialize Game
****/
var game = new LK.Game({
  backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Initialize arrays and variables
var balloons = [];
var score = 0;
var scoreTxt = new Text2('0', {
  size: 150,
  fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create the kid character and position it at the bottom center of the screen
var kid = game.addChild(new Kid());
kid.x = 2048 / 2;
kid.y = 2732 - 200;
// Function to handle move events
function handleMove(x, y, obj) {
  kid.x = x;
  kid.y = y;
}
// Mouse or touch move on game object
game.move = handleMove;
// Update function called every game tick
game.update = function () {
  // Update balloons
  for (var i = balloons.length - 1; i >= 0; i--) {
    if (balloons[i].intersects(kid)) {
      // Update score
      score += 1;
      scoreTxt.setText(score);
      balloons[i].destroy();
      balloons.splice(i, 1);
    }
  }
  // Spawn new balloons
  if (LK.ticks % 60 == 0) {
    var newBalloon = new Balloon();
    newBalloon.x = Math.random() * 2048;
    newBalloon.y = 2732;
    balloons.push(newBalloon);
    game.addChild(newBalloon);
  }
}; /****
* Classes
****/
// Class for the balloons
var Balloon = Container.expand(function () {
  var self = Container.call(this);
  var balloonGraphics = self.attachAsset('balloon', {
    anchorX: 0.5,
    anchorY: 0.5
  });
  self.speed = -3;
  self.update = function () {
    self.y += self.speed;
    if (self.y < -50) {
      self.destroy();
    }
  };
});
//<Assets used in the game will automatically appear here>
// Class for the main character (kid)
var Kid = Container.expand(function () {
  var self = Container.call(this);
  var kidGraphics = self.attachAsset('kid', {
    anchorX: 0.5,
    anchorY: 0.5
  });
  self.update = function () {
    // Update logic for the kid
  };
});
/****
* Initialize Game
****/
var game = new LK.Game({
  backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Initialize arrays and variables
var balloons = [];
var score = 0;
var scoreTxt = new Text2('0', {
  size: 150,
  fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create the kid character and position it at the bottom center of the screen
var kid = game.addChild(new Kid());
kid.x = 2048 / 2;
kid.y = 2732 - 200;
// Function to handle move events
function handleMove(x, y, obj) {
  kid.x = x;
  kid.y = y;
}
// Mouse or touch move on game object
game.move = handleMove;
// Update function called every game tick
game.update = function () {
  // Update balloons
  for (var i = balloons.length - 1; i >= 0; i--) {
    if (balloons[i].intersects(kid)) {
      // Update score
      score += 1;
      scoreTxt.setText(score);
      balloons[i].destroy();
      balloons.splice(i, 1);
    }
  }
  // Spawn new balloons
  if (LK.ticks % 60 == 0) {
    var newBalloon = new Balloon();
    newBalloon.x = Math.random() * 2048;
    newBalloon.y = 2732;
    balloons.push(newBalloon);
    game.addChild(newBalloon);
  }
};