/**** 
* Classes
****/ 
var Bomb = Container.expand(function () {
	var self = Container.call(this);
	var bombGraphics = self.attachAsset('healthBar', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	bombGraphics.scale.x *= 1.5;
	bombGraphics.scale.y *= 1.5;
	bombGraphics.tint = 0xffff00; // Yellow color for bomb
	self.speed = 12;
	self.targetX = 0;
	self.targetY = 0;
	self.directionX = 0;
	self.directionY = 0;
	self.setTarget = function (x, y) {
		self.targetX = x;
		self.targetY = y;
		var deltaX = x - self.x;
		var deltaY = y - self.y;
		var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
		self.directionX = deltaX / distance * self.speed;
		self.directionY = deltaY / distance * self.speed;
	};
	self._move_migrated = function () {
		self.x += self.directionX;
		self.y += self.directionY;
		if (self.x > 2148 || self.x < -100 || self.y > 2832 || self.y < -100) {
			self.destroy();
		}
	};
});
var Explosion = Container.expand(function () {
	var self = Container.call(this);
	var explosionGraphics = self.attachAsset('explosion', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	explosionGraphics.scale.x *= 2;
	explosionGraphics.scale.y *= 2;
	self.duration = 30;
	self.tick = function () {
		self.duration--;
		if (self.duration <= 0) {
			self.destroy();
		}
	};
});
var FastCloud = Container.expand(function () {
	var self = Container.call(this);
	var cloudGraphics = self.attachAsset('cloud', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	cloudGraphics.scale.x *= 6;
	cloudGraphics.scale.y *= 6;
	self.speed = (Math.random() * 3 + 1) * 6;
	self._move_migrated = function () {
		self.x -= self.speed;
		if (self.x <= -cloudGraphics.width) {
			self.x = 2048 + cloudGraphics.width;
			self.y = Math.random() * 2732;
		}
	};
});
var HeroMissile = Container.expand(function () {
	var self = Container.call(this);
	var missileGraphics = self.attachAsset('missile', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	missileGraphics.scale.x *= 2;
	missileGraphics.scale.y *= 2;
	missileGraphics.tint = 0x00ff00;
	self.speed = 15;
	self._move_migrated = function () {
		self.x += self.speed;
		if (self.x > 2148) {
			self.destroy();
		}
	};
});
var MediumCloud = Container.expand(function () {
	var self = Container.call(this);
	var cloudGraphics = self.attachAsset('cloud', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	cloudGraphics.scale.x *= 4;
	cloudGraphics.scale.y *= 4;
	self.speed = (Math.random() * 2 + 1) * 4;
	self._move_migrated = function () {
		self.x -= self.speed;
		if (self.x <= -cloudGraphics.width) {
			self.x = 2048 + cloudGraphics.width;
			self.y = Math.random() * 2732;
		}
	};
});
var SlowCloud = Container.expand(function () {
	var self = Container.call(this);
	var cloudGraphics = self.attachAsset('cloud', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	cloudGraphics.scale.x *= 2;
	cloudGraphics.scale.y *= 2;
	self.speed = (Math.random() * 1 + 1) * 2;
	self._move_migrated = function () {
		self.x -= self.speed;
		if (self.x <= -cloudGraphics.width) {
			self.x = 2048 + cloudGraphics.width;
			self.y = Math.random() * 2732;
		}
	};
});
var Superman = Container.expand(function () {
	var self = Container.call(this);
	var supermanGraphics = self.attachAsset('superman', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.hitCount = 0;
	self._move_migrated = function (x, y) {
		self.x = x;
		self.y = y;
	};
});
var Target = Container.expand(function () {
	var self = Container.call(this);
	var targetGraphics = self.attachAsset('missile', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	targetGraphics.scale.x *= 3;
	targetGraphics.scale.y *= 3;
	self.speed = 8;
	self.lastX = undefined;
	self._move_migrated = function () {
		if (self.lastX === undefined) self.lastX = self.x;
		self.x -= self.speed;
		if (self.x < -100) {
			self.destroy();
		}
		self.lastX = self.x;
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000
});
/**** 
* Game Code
****/ 
game.setBackgroundColor(0x0000ff);
var gameStarted = false;
var startText = new Text2('START', {
	size: 150,
	fill: '#ffffff'
});
startText.anchor.set(0.5, 0.5);
startText.x = 2048 / 2;
startText.y = 2732 / 2;
game.addChild(startText);
var clouds = [];
for (var i = 0; i < 3; i++) {
	var slowCloud = new SlowCloud();
	slowCloud.x = Math.random() * 2048;
	slowCloud.y = Math.random() * 2732;
	clouds.push(slowCloud);
	game.addChild(slowCloud);
}
for (var i = 0; i < 3; i++) {
	var mediumCloud = new MediumCloud();
	mediumCloud.x = Math.random() * 2048;
	mediumCloud.y = Math.random() * 2732;
	clouds.push(mediumCloud);
	game.addChild(mediumCloud);
}
for (var i = 0; i < 3; i++) {
	var fastCloud = new FastCloud();
	fastCloud.x = Math.random() * 2048;
	fastCloud.y = Math.random() * 2732;
	clouds.push(fastCloud);
	game.addChild(fastCloud);
}
var superman = game.addChild(new Superman());
var targets = [];
var bombs = [];
superman.x = 200;
superman.y = 2732 / 2;
var isGameOver = false;
var tickOffset = 0;
var gameDuration = 0;
var score = 0;
var scoreText = new Text2('Score: 0', {
	size: 100,
	fill: '#ffffff'
});
scoreText.anchor.set(0, 0);
scoreText.x = 50;
scoreText.y = 50;
game.addChild(scoreText);
var gameDurationText = new Text2('0', {
	size: 150,
	fill: '#ffffff'
});
gameDurationText.anchor.set(.5, 0);
LK.gui.top.addChild(gameDurationText);
LK.on('tick', function () {
	if (!gameStarted) {
		return;
	}
	if (isGameOver) {
		LK.effects.flashScreen(0xff0000, 1000);
		LK.showGameOver();
	}
	// Move and cleanup bombs
	for (var b = bombs.length - 1; b >= 0; b--) {
		if (bombs[b]) {
			bombs[b]._move_migrated();
			if (bombs[b].x > 2148 || bombs[b].x < -100 || bombs[b].y > 2832 || bombs[b].y < -100) {
				bombs[b].destroy();
				bombs.splice(b, 1);
			}
		}
	}
	// Check bomb-target collisions
	for (var b = bombs.length - 1; b >= 0; b--) {
		if (bombs[b]) {
			for (var t = targets.length - 1; t >= 0; t--) {
				if (targets[t] && bombs[b].intersects(targets[t])) {
					// Create explosion at collision point
					var explosion = new Explosion();
					explosion.x = targets[t].x;
					explosion.y = targets[t].y;
					game.addChild(explosion);
					// Destroy bomb and target
					bombs[b].destroy();
					targets[t].destroy();
					bombs.splice(b, 1);
					targets.splice(t, 1);
					// Increase score
					score += 10;
					scoreText.setText('Score: ' + score);
					break;
				}
			}
		}
	}
	// Move and cleanup targets
	for (var a = targets.length - 1; a >= 0; a--) {
		if (targets[a]) {
			targets[a]._move_migrated();
			if (targets[a].x < -100) {
				targets[a].destroy();
				targets.splice(a, 1);
			}
		}
	}
	// Check if targets reach superman (game over condition)
	for (var e = targets.length - 1; e >= 0; e--) {
		if (targets[e] && superman.intersects(targets[e])) {
			isGameOver = true;
		}
	}
	clouds.forEach(function (cloud) {
		cloud._move_migrated();
	});
	if (tickOffset++ % 60 == 0) {
		gameDuration++;
		gameDurationText.setText(gameDuration);
	}
	// Spawn targets more frequently as game progresses
	var spawnRate = Math.max(Math.floor((45 - gameDuration * 2) * 1.45), Math.floor(15 * 1.45));
	if (tickOffset % spawnRate == 0) {
		var newTarget = new Target();
		newTarget.x = 2148;
		newTarget.y = Math.random() * 2732;
		newTarget.lastX = newTarget.x;
		targets.push(newTarget);
		game.addChild(newTarget);
	}
	game.children.forEach(function (child) {
		if (child instanceof Explosion) {
			child.tick();
		}
	});
});
var dragNode = null;
game.on('down', function (x, y, obj) {
	if (!gameStarted) {
		gameStarted = true;
		startText.visible = false;
	}
	if (gameStarted) {
		// Throw bomb towards tap location
		var bomb = new Bomb();
		bomb.x = superman.x;
		bomb.y = superman.y;
		bomb.setTarget(x, y);
		bombs.push(bomb);
		game.addChild(bomb);
	}
	dragNode = superman;
});
function handleMove(obj) {
	if (!gameStarted) {
		return;
	}
	var event = obj.event;
	var pos = game.toLocal(event.global);
	if (dragNode) {
		dragNode._move_migrated(pos.x, pos.y);
	}
}
game.on('move', function (x, y, obj) {
	obj.event = obj;
	handleMove(obj);
});
game.on('up', function (x, y, obj) {
	dragNode = null;
}); /**** 
* Classes
****/ 
var Bomb = Container.expand(function () {
	var self = Container.call(this);
	var bombGraphics = self.attachAsset('healthBar', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	bombGraphics.scale.x *= 1.5;
	bombGraphics.scale.y *= 1.5;
	bombGraphics.tint = 0xffff00; // Yellow color for bomb
	self.speed = 12;
	self.targetX = 0;
	self.targetY = 0;
	self.directionX = 0;
	self.directionY = 0;
	self.setTarget = function (x, y) {
		self.targetX = x;
		self.targetY = y;
		var deltaX = x - self.x;
		var deltaY = y - self.y;
		var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
		self.directionX = deltaX / distance * self.speed;
		self.directionY = deltaY / distance * self.speed;
	};
	self._move_migrated = function () {
		self.x += self.directionX;
		self.y += self.directionY;
		if (self.x > 2148 || self.x < -100 || self.y > 2832 || self.y < -100) {
			self.destroy();
		}
	};
});
var Explosion = Container.expand(function () {
	var self = Container.call(this);
	var explosionGraphics = self.attachAsset('explosion', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	explosionGraphics.scale.x *= 2;
	explosionGraphics.scale.y *= 2;
	self.duration = 30;
	self.tick = function () {
		self.duration--;
		if (self.duration <= 0) {
			self.destroy();
		}
	};
});
var FastCloud = Container.expand(function () {
	var self = Container.call(this);
	var cloudGraphics = self.attachAsset('cloud', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	cloudGraphics.scale.x *= 6;
	cloudGraphics.scale.y *= 6;
	self.speed = (Math.random() * 3 + 1) * 6;
	self._move_migrated = function () {
		self.x -= self.speed;
		if (self.x <= -cloudGraphics.width) {
			self.x = 2048 + cloudGraphics.width;
			self.y = Math.random() * 2732;
		}
	};
});
var HeroMissile = Container.expand(function () {
	var self = Container.call(this);
	var missileGraphics = self.attachAsset('missile', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	missileGraphics.scale.x *= 2;
	missileGraphics.scale.y *= 2;
	missileGraphics.tint = 0x00ff00;
	self.speed = 15;
	self._move_migrated = function () {
		self.x += self.speed;
		if (self.x > 2148) {
			self.destroy();
		}
	};
});
var MediumCloud = Container.expand(function () {
	var self = Container.call(this);
	var cloudGraphics = self.attachAsset('cloud', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	cloudGraphics.scale.x *= 4;
	cloudGraphics.scale.y *= 4;
	self.speed = (Math.random() * 2 + 1) * 4;
	self._move_migrated = function () {
		self.x -= self.speed;
		if (self.x <= -cloudGraphics.width) {
			self.x = 2048 + cloudGraphics.width;
			self.y = Math.random() * 2732;
		}
	};
});
var SlowCloud = Container.expand(function () {
	var self = Container.call(this);
	var cloudGraphics = self.attachAsset('cloud', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	cloudGraphics.scale.x *= 2;
	cloudGraphics.scale.y *= 2;
	self.speed = (Math.random() * 1 + 1) * 2;
	self._move_migrated = function () {
		self.x -= self.speed;
		if (self.x <= -cloudGraphics.width) {
			self.x = 2048 + cloudGraphics.width;
			self.y = Math.random() * 2732;
		}
	};
});
var Superman = Container.expand(function () {
	var self = Container.call(this);
	var supermanGraphics = self.attachAsset('superman', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.hitCount = 0;
	self._move_migrated = function (x, y) {
		self.x = x;
		self.y = y;
	};
});
var Target = Container.expand(function () {
	var self = Container.call(this);
	var targetGraphics = self.attachAsset('missile', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	targetGraphics.scale.x *= 3;
	targetGraphics.scale.y *= 3;
	self.speed = 8;
	self.lastX = undefined;
	self._move_migrated = function () {
		if (self.lastX === undefined) self.lastX = self.x;
		self.x -= self.speed;
		if (self.x < -100) {
			self.destroy();
		}
		self.lastX = self.x;
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000
});
/**** 
* Game Code
****/ 
game.setBackgroundColor(0x0000ff);
var gameStarted = false;
var startText = new Text2('START', {
	size: 150,
	fill: '#ffffff'
});
startText.anchor.set(0.5, 0.5);
startText.x = 2048 / 2;
startText.y = 2732 / 2;
game.addChild(startText);
var clouds = [];
for (var i = 0; i < 3; i++) {
	var slowCloud = new SlowCloud();
	slowCloud.x = Math.random() * 2048;
	slowCloud.y = Math.random() * 2732;
	clouds.push(slowCloud);
	game.addChild(slowCloud);
}
for (var i = 0; i < 3; i++) {
	var mediumCloud = new MediumCloud();
	mediumCloud.x = Math.random() * 2048;
	mediumCloud.y = Math.random() * 2732;
	clouds.push(mediumCloud);
	game.addChild(mediumCloud);
}
for (var i = 0; i < 3; i++) {
	var fastCloud = new FastCloud();
	fastCloud.x = Math.random() * 2048;
	fastCloud.y = Math.random() * 2732;
	clouds.push(fastCloud);
	game.addChild(fastCloud);
}
var superman = game.addChild(new Superman());
var targets = [];
var bombs = [];
superman.x = 200;
superman.y = 2732 / 2;
var isGameOver = false;
var tickOffset = 0;
var gameDuration = 0;
var score = 0;
var scoreText = new Text2('Score: 0', {
	size: 100,
	fill: '#ffffff'
});
scoreText.anchor.set(0, 0);
scoreText.x = 50;
scoreText.y = 50;
game.addChild(scoreText);
var gameDurationText = new Text2('0', {
	size: 150,
	fill: '#ffffff'
});
gameDurationText.anchor.set(.5, 0);
LK.gui.top.addChild(gameDurationText);
LK.on('tick', function () {
	if (!gameStarted) {
		return;
	}
	if (isGameOver) {
		LK.effects.flashScreen(0xff0000, 1000);
		LK.showGameOver();
	}
	// Move and cleanup bombs
	for (var b = bombs.length - 1; b >= 0; b--) {
		if (bombs[b]) {
			bombs[b]._move_migrated();
			if (bombs[b].x > 2148 || bombs[b].x < -100 || bombs[b].y > 2832 || bombs[b].y < -100) {
				bombs[b].destroy();
				bombs.splice(b, 1);
			}
		}
	}
	// Check bomb-target collisions
	for (var b = bombs.length - 1; b >= 0; b--) {
		if (bombs[b]) {
			for (var t = targets.length - 1; t >= 0; t--) {
				if (targets[t] && bombs[b].intersects(targets[t])) {
					// Create explosion at collision point
					var explosion = new Explosion();
					explosion.x = targets[t].x;
					explosion.y = targets[t].y;
					game.addChild(explosion);
					// Destroy bomb and target
					bombs[b].destroy();
					targets[t].destroy();
					bombs.splice(b, 1);
					targets.splice(t, 1);
					// Increase score
					score += 10;
					scoreText.setText('Score: ' + score);
					break;
				}
			}
		}
	}
	// Move and cleanup targets
	for (var a = targets.length - 1; a >= 0; a--) {
		if (targets[a]) {
			targets[a]._move_migrated();
			if (targets[a].x < -100) {
				targets[a].destroy();
				targets.splice(a, 1);
			}
		}
	}
	// Check if targets reach superman (game over condition)
	for (var e = targets.length - 1; e >= 0; e--) {
		if (targets[e] && superman.intersects(targets[e])) {
			isGameOver = true;
		}
	}
	clouds.forEach(function (cloud) {
		cloud._move_migrated();
	});
	if (tickOffset++ % 60 == 0) {
		gameDuration++;
		gameDurationText.setText(gameDuration);
	}
	// Spawn targets more frequently as game progresses
	var spawnRate = Math.max(Math.floor((45 - gameDuration * 2) * 1.45), Math.floor(15 * 1.45));
	if (tickOffset % spawnRate == 0) {
		var newTarget = new Target();
		newTarget.x = 2148;
		newTarget.y = Math.random() * 2732;
		newTarget.lastX = newTarget.x;
		targets.push(newTarget);
		game.addChild(newTarget);
	}
	game.children.forEach(function (child) {
		if (child instanceof Explosion) {
			child.tick();
		}
	});
});
var dragNode = null;
game.on('down', function (x, y, obj) {
	if (!gameStarted) {
		gameStarted = true;
		startText.visible = false;
	}
	if (gameStarted) {
		// Throw bomb towards tap location
		var bomb = new Bomb();
		bomb.x = superman.x;
		bomb.y = superman.y;
		bomb.setTarget(x, y);
		bombs.push(bomb);
		game.addChild(bomb);
	}
	dragNode = superman;
});
function handleMove(obj) {
	if (!gameStarted) {
		return;
	}
	var event = obj.event;
	var pos = game.toLocal(event.global);
	if (dragNode) {
		dragNode._move_migrated(pos.x, pos.y);
	}
}
game.on('move', function (x, y, obj) {
	obj.event = obj;
	handleMove(obj);
});
game.on('up', function (x, y, obj) {
	dragNode = null;
});
 A sky with clouds, tileable Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 An explosion Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 a puffy white cloud Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 pumkin bomb. In-Game asset. 2d. High contrast. No shadows
 flying pixel art green goblin. In-Game asset. 2d. High contrast. No shadows
 flying pixel art hero. In-Game asset. 2d. High contrast. No shadows