/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/**** 
* Classes
****/ 
var Asteroid = Container.expand(function () {
	var self = Container.call(this);
	var asteroidGraphics = self.attachAsset('asteroid', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 2; // Slow down the asteroid
	self.hitPoints = 3; // Asteroid requires 3 hits to be destroyed
	self.rotationSpeed = Math.random() * 0.05 - 0.025;
	self.active = true;
	self.update = function () {
		if (self.active) {
			self.y += self.speed;
			self.rotation += self.rotationSpeed;
		}
	};
	return self;
});
var Bullet = Container.expand(function () {
	var self = Container.call(this);
	var bulletGraphics = self.attachAsset('bullet', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = -15;
	self.active = true;
	self.update = function () {
		if (self.active) {
			self.y += self.speed;
		}
	};
	return self;
});
var Explosion = Container.expand(function () {
	var self = Container.call(this);
	var explosionGraphics = self.attachAsset('explosion', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.initialize = function (x, y) {
		self.x = x;
		self.y = y;
		self.alpha = 1;
		self.scale.x = 0.5;
		self.scale.y = 0.5;
		// Animate explosion
		tween(self, {
			alpha: 0,
			scaleX: 2,
			scaleY: 2
		}, {
			duration: 500,
			easing: tween.easeOut,
			onFinish: function onFinish() {
				self.destroy();
			}
		});
	};
	return self;
});
var Spaceship = Container.expand(function () {
	var self = Container.call(this);
	var spaceshipGraphics = self.attachAsset('spaceship', {
		anchorY: 0.5
	});
	self.width = spaceshipGraphics.width;
	self.height = spaceshipGraphics.height;
	self.isHit = false;
	self.flash = function () {
		LK.effects.flashObject(self, 0xff0000, 300);
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000
});
/**** 
* Game Code
****/ 
// Game variables
var spaceship;
var bullets = [];
var asteroids = [];
var gameWidth = 2048;
var gameHeight = 2732;
var score = 0;
var level = 1;
var asteroidSpawnRate = 60;
var maxAsteroids = 5;
var bulletCooldown = 0;
var gameStarted = false;
// Setup game elements
function setupGame() {
	// Reset game state
	score = 0;
	level = 1;
	asteroidSpawnRate = 60;
	maxAsteroids = 5;
	// Clear existing elements
	for (var i = bullets.length - 1; i >= 0; i--) {
		bullets[i].destroy();
	}
	bullets = [];
	for (var i = asteroids.length - 1; i >= 0; i--) {
		asteroids[i].destroy();
	}
	asteroids = [];
	if (spaceship) {
		spaceship.destroy();
	}
	// Add background image
	var background = LK.getAsset('background', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	background.x = gameWidth / 2;
	background.y = gameHeight / 2;
	game.addChild(background);
	spaceship = new Spaceship();
	spaceship.x = gameWidth / 2;
	spaceship.y = gameHeight - 150;
	game.addChild(spaceship);
	// Set score
	LK.setScore(0);
	scoreTxt.setText("SCORE: 0");
	// Start background music
	LK.playMusic('gameMusic', {
		fade: {
			start: 0,
			end: 0.4,
			duration: 1000
		}
	});
	gameStarted = true;
}
// UI setup
var scoreTxt = new Text2("SCORE: 0", {
	size: 80,
	fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 50;
// Create title text initially
var titleTxt = new Text2("ASTEROID BLASTER", {
	size: 120,
	fill: 0xFFFFFF
});
titleTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(titleTxt);
var instructionTxt = new Text2("TAP TO START\nMove ship: Touch/Drag\nShoot: Tap screen", {
	size: 60,
	fill: 0xCCCCCC
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.y = 200;
LK.gui.center.addChild(instructionTxt);
// Create a bullet
function createBullet() {
	if (bulletCooldown <= 0) {
		var bullet = new Bullet();
		bullet.x = spaceship.x;
		bullet.y = spaceship.y - spaceship.height / 2;
		bullets.push(bullet);
		game.addChild(bullet);
		// Play sound
		LK.getSound('shoot').play();
		// Set cooldown
		bulletCooldown = 10;
	}
}
// Create an asteroid
function createAsteroid() {
	var asteroid = new Asteroid();
	// Random position along top of screen
	asteroid.x = Math.random() * gameWidth;
	asteroid.y = -100;
	// Random size variation
	var scaleFactor = 0.8 + Math.random() * 0.8;
	asteroid.scale.x = scaleFactor;
	asteroid.scale.y = scaleFactor;
	// Speed increases with level
	asteroid.speed = 5 + level * 0.5 + Math.random() * 2;
	asteroids.push(asteroid);
	game.addChild(asteroid);
}
// Create explosion effect
function createExplosion(x, y) {
	var explosion = new Explosion();
	explosion.initialize(x, y);
	game.addChild(explosion);
	// Add smoke effect
	var smoke = new Explosion();
	smoke.initialize(x, y);
	smoke.alpha = 0.5;
	smoke.scale.x = 1.5;
	smoke.scale.y = 1.5;
	game.addChild(smoke);
	// Play explosion sound
	LK.getSound('explosion').play();
}
// Game touch/mouse handlers
var isDragging = false;
game.down = function (x, y, obj) {
	if (!gameStarted) {
		// Remove title screen
		titleTxt.destroy();
		instructionTxt.destroy();
		// Start the game
		setupGame();
		return;
	}
	// If clicking on spaceship, start dragging
	if (spaceship.getBounds().contains(x, y)) {
		isDragging = true;
	} else {
		// Fire bullet
		createBullet();
	}
};
game.up = function (x, y, obj) {
	isDragging = false;
};
game.move = function (x, y, obj) {
	if (gameStarted) {
		// Move spaceship, but keep within screen bounds
		spaceship.x = Math.max(spaceship.width / 2, Math.min(gameWidth - spaceship.width / 2, x));
	}
};
// Game main update loop
game.update = function () {
	if (!gameStarted) {
		return;
	}
	// Decrease bullet cooldown
	if (bulletCooldown > 0) {
		bulletCooldown--;
	}
	// Update bullets
	for (var i = bullets.length - 1; i >= 0; i--) {
		var bullet = bullets[i];
		// Remove bullets that go off screen
		if (bullet.y < -50) {
			bullet.destroy();
			bullets.splice(i, 1);
			continue;
		}
		// Check for collisions with asteroids
		for (var j = asteroids.length - 1; j >= 0; j--) {
			var asteroid = asteroids[j];
			if (bullet.active && asteroid.active && bullet.intersects(asteroid)) {
				// Reduce asteroid hit points
				asteroid.hitPoints -= 1;
				// Check if asteroid is destroyed
				if (asteroid.hitPoints <= 0) {
					// Create explosion
					createExplosion(asteroid.x, asteroid.y);
					// Update score
					score += 10;
					LK.setScore(score);
					scoreTxt.setText("SCORE: " + score);
					// Level progression
					if (score >= level * 200) {
						level++;
						maxAsteroids += 2;
						asteroidSpawnRate = Math.max(30, asteroidSpawnRate - 5);
					}
					// Remove asteroid
					asteroid.active = false;
					asteroid.destroy();
					asteroids.splice(j, 1);
				}
				// Remove bullet
				bullet.active = false;
				bullet.destroy();
				bullets.splice(i, 1);
				break;
			}
		}
	}
	// Update asteroids
	for (var i = asteroids.length - 1; i >= 0; i--) {
		var asteroid = asteroids[i];
		// End game if an asteroid reaches the bottom of the screen
		if (asteroid.y > gameHeight) {
			// Remove asteroid
			asteroid.active = false;
			asteroid.destroy();
			asteroids.splice(i, 1);
			// Game over
			LK.showGameOver();
			gameStarted = false;
			continue;
		}
		// Check for collision with spaceship
		if (asteroid.active && spaceship.intersects(asteroid)) {
			// Create explosion
			createExplosion(asteroid.x, asteroid.y);
			// Flash spaceship
			spaceship.flash();
			// Play hit sound
			LK.getSound('hit').play();
			// Remove asteroid
			asteroid.active = false;
			asteroid.destroy();
			asteroids.splice(i, 1);
			// Game over if hit
			LK.showGameOver();
			gameStarted = false;
		}
	}
	// Spawn new asteroids
	if (LK.ticks % asteroidSpawnRate === 0 && asteroids.length < maxAsteroids) {
		createAsteroid();
	}
}; /**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/**** 
* Classes
****/ 
var Asteroid = Container.expand(function () {
	var self = Container.call(this);
	var asteroidGraphics = self.attachAsset('asteroid', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 2; // Slow down the asteroid
	self.hitPoints = 3; // Asteroid requires 3 hits to be destroyed
	self.rotationSpeed = Math.random() * 0.05 - 0.025;
	self.active = true;
	self.update = function () {
		if (self.active) {
			self.y += self.speed;
			self.rotation += self.rotationSpeed;
		}
	};
	return self;
});
var Bullet = Container.expand(function () {
	var self = Container.call(this);
	var bulletGraphics = self.attachAsset('bullet', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = -15;
	self.active = true;
	self.update = function () {
		if (self.active) {
			self.y += self.speed;
		}
	};
	return self;
});
var Explosion = Container.expand(function () {
	var self = Container.call(this);
	var explosionGraphics = self.attachAsset('explosion', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.initialize = function (x, y) {
		self.x = x;
		self.y = y;
		self.alpha = 1;
		self.scale.x = 0.5;
		self.scale.y = 0.5;
		// Animate explosion
		tween(self, {
			alpha: 0,
			scaleX: 2,
			scaleY: 2
		}, {
			duration: 500,
			easing: tween.easeOut,
			onFinish: function onFinish() {
				self.destroy();
			}
		});
	};
	return self;
});
var Spaceship = Container.expand(function () {
	var self = Container.call(this);
	var spaceshipGraphics = self.attachAsset('spaceship', {
		anchorY: 0.5
	});
	self.width = spaceshipGraphics.width;
	self.height = spaceshipGraphics.height;
	self.isHit = false;
	self.flash = function () {
		LK.effects.flashObject(self, 0xff0000, 300);
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000
});
/**** 
* Game Code
****/ 
// Game variables
var spaceship;
var bullets = [];
var asteroids = [];
var gameWidth = 2048;
var gameHeight = 2732;
var score = 0;
var level = 1;
var asteroidSpawnRate = 60;
var maxAsteroids = 5;
var bulletCooldown = 0;
var gameStarted = false;
// Setup game elements
function setupGame() {
	// Reset game state
	score = 0;
	level = 1;
	asteroidSpawnRate = 60;
	maxAsteroids = 5;
	// Clear existing elements
	for (var i = bullets.length - 1; i >= 0; i--) {
		bullets[i].destroy();
	}
	bullets = [];
	for (var i = asteroids.length - 1; i >= 0; i--) {
		asteroids[i].destroy();
	}
	asteroids = [];
	if (spaceship) {
		spaceship.destroy();
	}
	// Add background image
	var background = LK.getAsset('background', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	background.x = gameWidth / 2;
	background.y = gameHeight / 2;
	game.addChild(background);
	spaceship = new Spaceship();
	spaceship.x = gameWidth / 2;
	spaceship.y = gameHeight - 150;
	game.addChild(spaceship);
	// Set score
	LK.setScore(0);
	scoreTxt.setText("SCORE: 0");
	// Start background music
	LK.playMusic('gameMusic', {
		fade: {
			start: 0,
			end: 0.4,
			duration: 1000
		}
	});
	gameStarted = true;
}
// UI setup
var scoreTxt = new Text2("SCORE: 0", {
	size: 80,
	fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 50;
// Create title text initially
var titleTxt = new Text2("ASTEROID BLASTER", {
	size: 120,
	fill: 0xFFFFFF
});
titleTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(titleTxt);
var instructionTxt = new Text2("TAP TO START\nMove ship: Touch/Drag\nShoot: Tap screen", {
	size: 60,
	fill: 0xCCCCCC
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.y = 200;
LK.gui.center.addChild(instructionTxt);
// Create a bullet
function createBullet() {
	if (bulletCooldown <= 0) {
		var bullet = new Bullet();
		bullet.x = spaceship.x;
		bullet.y = spaceship.y - spaceship.height / 2;
		bullets.push(bullet);
		game.addChild(bullet);
		// Play sound
		LK.getSound('shoot').play();
		// Set cooldown
		bulletCooldown = 10;
	}
}
// Create an asteroid
function createAsteroid() {
	var asteroid = new Asteroid();
	// Random position along top of screen
	asteroid.x = Math.random() * gameWidth;
	asteroid.y = -100;
	// Random size variation
	var scaleFactor = 0.8 + Math.random() * 0.8;
	asteroid.scale.x = scaleFactor;
	asteroid.scale.y = scaleFactor;
	// Speed increases with level
	asteroid.speed = 5 + level * 0.5 + Math.random() * 2;
	asteroids.push(asteroid);
	game.addChild(asteroid);
}
// Create explosion effect
function createExplosion(x, y) {
	var explosion = new Explosion();
	explosion.initialize(x, y);
	game.addChild(explosion);
	// Add smoke effect
	var smoke = new Explosion();
	smoke.initialize(x, y);
	smoke.alpha = 0.5;
	smoke.scale.x = 1.5;
	smoke.scale.y = 1.5;
	game.addChild(smoke);
	// Play explosion sound
	LK.getSound('explosion').play();
}
// Game touch/mouse handlers
var isDragging = false;
game.down = function (x, y, obj) {
	if (!gameStarted) {
		// Remove title screen
		titleTxt.destroy();
		instructionTxt.destroy();
		// Start the game
		setupGame();
		return;
	}
	// If clicking on spaceship, start dragging
	if (spaceship.getBounds().contains(x, y)) {
		isDragging = true;
	} else {
		// Fire bullet
		createBullet();
	}
};
game.up = function (x, y, obj) {
	isDragging = false;
};
game.move = function (x, y, obj) {
	if (gameStarted) {
		// Move spaceship, but keep within screen bounds
		spaceship.x = Math.max(spaceship.width / 2, Math.min(gameWidth - spaceship.width / 2, x));
	}
};
// Game main update loop
game.update = function () {
	if (!gameStarted) {
		return;
	}
	// Decrease bullet cooldown
	if (bulletCooldown > 0) {
		bulletCooldown--;
	}
	// Update bullets
	for (var i = bullets.length - 1; i >= 0; i--) {
		var bullet = bullets[i];
		// Remove bullets that go off screen
		if (bullet.y < -50) {
			bullet.destroy();
			bullets.splice(i, 1);
			continue;
		}
		// Check for collisions with asteroids
		for (var j = asteroids.length - 1; j >= 0; j--) {
			var asteroid = asteroids[j];
			if (bullet.active && asteroid.active && bullet.intersects(asteroid)) {
				// Reduce asteroid hit points
				asteroid.hitPoints -= 1;
				// Check if asteroid is destroyed
				if (asteroid.hitPoints <= 0) {
					// Create explosion
					createExplosion(asteroid.x, asteroid.y);
					// Update score
					score += 10;
					LK.setScore(score);
					scoreTxt.setText("SCORE: " + score);
					// Level progression
					if (score >= level * 200) {
						level++;
						maxAsteroids += 2;
						asteroidSpawnRate = Math.max(30, asteroidSpawnRate - 5);
					}
					// Remove asteroid
					asteroid.active = false;
					asteroid.destroy();
					asteroids.splice(j, 1);
				}
				// Remove bullet
				bullet.active = false;
				bullet.destroy();
				bullets.splice(i, 1);
				break;
			}
		}
	}
	// Update asteroids
	for (var i = asteroids.length - 1; i >= 0; i--) {
		var asteroid = asteroids[i];
		// End game if an asteroid reaches the bottom of the screen
		if (asteroid.y > gameHeight) {
			// Remove asteroid
			asteroid.active = false;
			asteroid.destroy();
			asteroids.splice(i, 1);
			// Game over
			LK.showGameOver();
			gameStarted = false;
			continue;
		}
		// Check for collision with spaceship
		if (asteroid.active && spaceship.intersects(asteroid)) {
			// Create explosion
			createExplosion(asteroid.x, asteroid.y);
			// Flash spaceship
			spaceship.flash();
			// Play hit sound
			LK.getSound('hit').play();
			// Remove asteroid
			asteroid.active = false;
			asteroid.destroy();
			asteroids.splice(i, 1);
			// Game over if hit
			LK.showGameOver();
			gameStarted = false;
		}
	}
	// Spawn new asteroids
	if (LK.ticks % asteroidSpawnRate === 0 && asteroids.length < maxAsteroids) {
		createAsteroid();
	}
};
:quality(85)/https://cdn.frvr.ai/67e1298f05294da8e7487ff3.png%3F3) 
 Plasma Bolt β A glowing energy ball with a sci-fi effect.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67e12a1a05294da8e7487ffe.png%3F3) 
 πͺ¨ Large Asteroid β Moves slow but takes 3-4 hits to destroy.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67e12bbe05294da8e748800b.png%3F3) 
 π₯ Shockwave Effect β A ring-like wave when something explodes.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67e15b3be7971efb59b948be.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/67e16cb6e7bcfd4c8f1816b7.png%3F3)