/**** 
* Classes
****/ 
// Class for obstacles
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.x += self.speed;
		if (self.x < -100) {
			self.destroy();
		}
	};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for the player character
var Player = Container.expand(function () {
	var self = Container.call(this);
	var playerGraphics = self.attachAsset('player', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.velocityY = 0;
	self.gravity = 0.5;
	self.jumpStrength = -10;
	self.update = function () {
		self.velocityY += self.gravity;
		self.y += self.velocityY;
		// Prevent player from falling below the ground
		if (self.y > 2400) {
			self.y = 2400;
			self.velocityY = 0;
		}
	};
	self.jump = function () {
		self.velocityY = self.jumpStrength;
	};
});
// Class for stars
var Star = Container.expand(function () {
	var self = Container.call(this);
	var starGraphics = self.attachAsset('star', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = -5;
	self.update = function () {
		self.x += self.speed;
		if (self.x < -100) {
			self.destroy();
		}
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000 //Init game with black background
});
/**** 
* Game Code
****/ 
var background = game.addChild(LK.getAsset('background', {
	anchorX: 0.0,
	anchorY: 0.0,
	x: 0,
	y: 0
}));
// Initialize player
var player = game.addChild(new Player());
player.x = 200;
player.y = 2400;
// Arrays to keep track of obstacles and stars
var obstacles = [];
var stars = [];
// Score display
var score = 0;
var scoreTxt = new Text2('Score: 0', {
	size: 100,
	fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to spawn obstacles
function spawnObstacle() {
	var obstacle = new Obstacle();
	obstacle.x = 2200;
	obstacle.y = 2400;
	obstacles.push(obstacle);
	game.addChild(obstacle);
}
// Function to spawn stars
function spawnStar() {
	var star = new Star();
	star.x = 2200;
	star.y = Math.random() * 2000 + 500;
	stars.push(star);
	game.addChild(star);
}
// Handle game updates
game.update = function () {
	player.update();
	// Update obstacles
	for (var i = obstacles.length - 1; i >= 0; i--) {
		var obstacle = obstacles[i];
		obstacle.update();
		if (player.intersects(obstacle)) {
			LK.effects.flashScreen(0xff0000, 1000);
			LK.showGameOver();
		}
	}
	// Update stars
	for (var j = stars.length - 1; j >= 0; j--) {
		var star = stars[j];
		star.update();
		if (player.intersects(star)) {
			score += 10;
			scoreTxt.setText('Score: ' + score);
			star.destroy();
			stars.splice(j, 1);
		}
	}
	// Spawn new obstacles and stars
	if (LK.ticks % 120 == 0) {
		spawnObstacle();
	}
	if (LK.ticks % 180 == 0) {
		spawnStar();
	}
};
// Handle player jump on tap
game.down = function (x, y, obj) {
	player.jump();
}; /**** 
* Classes
****/ 
// Class for obstacles
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.x += self.speed;
		if (self.x < -100) {
			self.destroy();
		}
	};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Class for the player character
var Player = Container.expand(function () {
	var self = Container.call(this);
	var playerGraphics = self.attachAsset('player', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.velocityY = 0;
	self.gravity = 0.5;
	self.jumpStrength = -10;
	self.update = function () {
		self.velocityY += self.gravity;
		self.y += self.velocityY;
		// Prevent player from falling below the ground
		if (self.y > 2400) {
			self.y = 2400;
			self.velocityY = 0;
		}
	};
	self.jump = function () {
		self.velocityY = self.jumpStrength;
	};
});
// Class for stars
var Star = Container.expand(function () {
	var self = Container.call(this);
	var starGraphics = self.attachAsset('star', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = -5;
	self.update = function () {
		self.x += self.speed;
		if (self.x < -100) {
			self.destroy();
		}
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000 //Init game with black background
});
/**** 
* Game Code
****/ 
var background = game.addChild(LK.getAsset('background', {
	anchorX: 0.0,
	anchorY: 0.0,
	x: 0,
	y: 0
}));
// Initialize player
var player = game.addChild(new Player());
player.x = 200;
player.y = 2400;
// Arrays to keep track of obstacles and stars
var obstacles = [];
var stars = [];
// Score display
var score = 0;
var scoreTxt = new Text2('Score: 0', {
	size: 100,
	fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to spawn obstacles
function spawnObstacle() {
	var obstacle = new Obstacle();
	obstacle.x = 2200;
	obstacle.y = 2400;
	obstacles.push(obstacle);
	game.addChild(obstacle);
}
// Function to spawn stars
function spawnStar() {
	var star = new Star();
	star.x = 2200;
	star.y = Math.random() * 2000 + 500;
	stars.push(star);
	game.addChild(star);
}
// Handle game updates
game.update = function () {
	player.update();
	// Update obstacles
	for (var i = obstacles.length - 1; i >= 0; i--) {
		var obstacle = obstacles[i];
		obstacle.update();
		if (player.intersects(obstacle)) {
			LK.effects.flashScreen(0xff0000, 1000);
			LK.showGameOver();
		}
	}
	// Update stars
	for (var j = stars.length - 1; j >= 0; j--) {
		var star = stars[j];
		star.update();
		if (player.intersects(star)) {
			score += 10;
			scoreTxt.setText('Score: ' + score);
			star.destroy();
			stars.splice(j, 1);
		}
	}
	// Spawn new obstacles and stars
	if (LK.ticks % 120 == 0) {
		spawnObstacle();
	}
	if (LK.ticks % 180 == 0) {
		spawnStar();
	}
};
// Handle player jump on tap
game.down = function (x, y, obj) {
	player.jump();
};
:quality(85)/https://cdn.frvr.ai/67d572c3540f369ec4071614.png%3F3) 
 star red and blu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67d573d3540f369ec407161e.png%3F3) 
 BouncyBall MG red and blu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67d57417540f369ec4071628.png%3F3) 
 obstacle red and blu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67d574d6540f369ec4071633.png%3F3) 
 background red and blu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows