/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/**** 
* Classes
****/ 
var Boss = Container.expand(function (bossType) {
	var self = Container.call(this);
	// Determine boss asset and health based on type
	var assetId = 'boss';
	var health = 10;
	if (bossType === 50) {
		assetId = 'boss50';
		health = 20;
	} else if (bossType === 75) {
		assetId = 'boss75';
		health = 30;
	} else if (bossType === 100) {
		assetId = 'boss100';
		health = 50;
	}
	var bossGraphics = self.attachAsset(assetId, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 0.8;
	self.health = health;
	self.maxHealth = health;
	self.bossType = bossType || 25;
	self.isBoss = true;
	self.lastPlayerX = 0;
	self.lastPlayerY = 0;
	// Create health bar
	var healthBarWidth = bossGraphics.width * 0.8;
	var healthBarBackground = LK.getAsset('buttonBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: healthBarWidth / 260,
		scaleY: 0.3
	});
	healthBarBackground.y = -bossGraphics.height / 2 - 30;
	self.addChild(healthBarBackground);
	var healthBar = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: healthBarWidth / 200,
		scaleY: 0.4
	});
	healthBar.y = -bossGraphics.height / 2 - 30;
	healthBar.tint = 0x00ff00;
	self.addChild(healthBar);
	self.healthBar = healthBar;
	self.healthBarBackground = healthBarBackground;
	self.update = function () {
		if (player) {
			var dx = player.x - self.x;
			var dy = player.y - self.y;
			var distance = Math.sqrt(dx * dx + dy * dy);
			if (distance > 0) {
				self.x += dx / distance * self.speed;
				self.y += dy / distance * self.speed;
			}
			self.lastPlayerX = player.x;
			self.lastPlayerY = player.y;
		}
	};
	self.takeDamage = function (damage) {
		damage = damage || 1;
		self.health -= damage;
		LK.effects.flashObject(self, 0xFF4444, 200);
		// Update health bar
		var healthPercent = self.health / self.maxHealth;
		self.healthBar.scaleX = self.healthBarBackground.width * healthPercent / 200;
		if (healthPercent > 0.5) {
			self.healthBar.tint = 0x00ff00;
		} else if (healthPercent > 0.25) {
			self.healthBar.tint = 0xffff00;
		} else {
			self.healthBar.tint = 0xff0000;
		}
		if (self.health <= 0) {
			LK.effects.flashObject(self, 0xFFFFFF, 500);
			return true;
		}
		return false;
	};
	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 = 8;
	self.velocityX = 0;
	self.velocityY = 0;
	self.lifeTime = 120;
	self.age = 0;
	self.setDirection = function (targetX, targetY) {
		var dx = targetX - self.x;
		var dy = targetY - self.y;
		var distance = Math.sqrt(dx * dx + dy * dy);
		if (distance > 0) {
			self.velocityX = dx / distance * self.speed;
			self.velocityY = dy / distance * self.speed;
		}
	};
	self.update = function () {
		self.x += self.velocityX;
		self.y += self.velocityY;
		self.age++;
	};
	self.isExpired = function () {
		return self.age >= self.lifeTime || self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782;
	};
	return self;
});
var Enemy = Container.expand(function () {
	var self = Container.call(this);
	var enemyGraphics = self.attachAsset('enemy', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 1.5;
	self.health = 1;
	self.maxHealth = 1;
	self.lastPlayerX = 0;
	self.lastPlayerY = 0;
	// Create health bar for enemy
	var healthBarWidth = enemyGraphics.width * 0.6;
	var healthBarBackground = LK.getAsset('buttonBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: healthBarWidth / 260,
		scaleY: 0.2
	});
	healthBarBackground.y = -enemyGraphics.height / 2 - 20;
	self.addChild(healthBarBackground);
	var healthBar = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: healthBarWidth / 200,
		scaleY: 0.3
	});
	healthBar.y = -enemyGraphics.height / 2 - 20;
	healthBar.tint = 0x00ff00;
	self.addChild(healthBar);
	self.healthBar = healthBar;
	self.healthBarBackground = healthBarBackground;
	self.update = function () {
		if (player) {
			var dx = player.x - self.x;
			var dy = player.y - self.y;
			var distance = Math.sqrt(dx * dx + dy * dy);
			if (distance > 0) {
				self.x += dx / distance * self.speed;
				self.y += dy / distance * self.speed;
			}
			self.lastPlayerX = player.x;
			self.lastPlayerY = player.y;
		}
	};
	self.takeDamage = function (damage) {
		damage = damage || 1;
		self.health -= damage;
		// Update health bar
		var healthPercent = self.health / self.maxHealth;
		self.healthBar.scaleX = self.healthBarBackground.width * healthPercent / 200;
		if (healthPercent > 0.5) {
			self.healthBar.tint = 0x00ff00;
		} else if (healthPercent > 0.25) {
			self.healthBar.tint = 0xffff00;
		} else {
			self.healthBar.tint = 0xff0000;
		}
		if (self.health <= 0) {
			LK.effects.flashObject(self, 0xFFFFFF, 200);
			return true;
		}
		return false;
	};
	return self;
});
var Player = Container.expand(function () {
	var self = Container.call(this);
	// Create all directional graphics
	self.playerGraphicsUp = self.attachAsset('player_up', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.playerGraphicsDown = self.attachAsset('player_down', {
		anchorX: 0.5,
		anchorY: 0.5,
		visible: false
	});
	self.playerGraphicsLeft = self.attachAsset('player_left', {
		anchorX: 0.5,
		anchorY: 0.5,
		visible: false
	});
	self.playerGraphicsRight = self.attachAsset('player_right', {
		anchorX: 0.5,
		anchorY: 0.5,
		visible: false
	});
	self.currentDirection = 'up';
	self.health = 100;
	self.maxHealth = 100;
	self.speed = 4;
	self.ammunition = 30;
	self.maxAmmo = 30;
	self.isReloading = false;
	self.reloadTime = 2000;
	self.setDirection = function (direction) {
		// Hide all graphics first
		self.playerGraphicsUp.visible = false;
		self.playerGraphicsDown.visible = false;
		self.playerGraphicsLeft.visible = false;
		self.playerGraphicsRight.visible = false;
		// Show the correct direction
		switch (direction) {
			case 'up':
				self.playerGraphicsUp.visible = true;
				break;
			case 'down':
				self.playerGraphicsDown.visible = true;
				break;
			case 'left':
				self.playerGraphicsLeft.visible = true;
				break;
			case 'right':
				self.playerGraphicsRight.visible = true;
				break;
		}
		self.currentDirection = direction;
	};
	self.takeDamage = function (damage) {
		if (godModeActive) return; // God mode prevents damage
		self.health -= damage;
		if (self.health <= 0) {
			self.health = 0;
			LK.effects.flashScreen(0xFF0000, 1000);
			LK.showGameOver();
		} else {
			LK.effects.flashObject(self, 0xFF0000, 300);
		}
	};
	self.reload = function () {
		if (!self.isReloading && self.ammunition < self.maxAmmo) {
			self.isReloading = true;
			LK.getSound('reload').play();
			LK.setTimeout(function () {
				self.ammunition = self.maxAmmo;
				self.isReloading = false;
			}, self.reloadTime);
		}
	};
	self.canShoot = function () {
		return self.ammunition > 0 && !self.isReloading;
	};
	self.shoot = function () {
		if (self.canShoot()) {
			self.ammunition--;
			if (self.ammunition === 0) {
				self.reload();
			}
			return true;
		}
		return false;
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x2C3E50
});
/**** 
* Game Code
****/ 
var player;
var enemies = [];
var bullets = [];
var enemySpawnTimer = 0;
var enemySpawnRate = 180;
var gameStarted = false;
var lastTapTime = 0;
var tapCooldown = 150;
var mouseX = 2048 / 2;
var mouseY = 2732 / 2;
var bosses = [];
var lastBossScore = 0;
var bossActive = false;
var currentWeapon = 'shotgun';
var weaponStats = {
	shotgun: {
		damage: 2,
		fireRate: 20,
		name: 'Shotgun',
		cost: 20
	},
	smg: {
		damage: 1,
		fireRate: 25,
		name: 'SMG',
		cost: 100
	},
	sniper: {
		damage: 5,
		fireRate: 60,
		name: 'Sniper',
		cost: 100
	}
};
var weaponOwned = {
	shotgun: true,
	smg: false,
	sniper: false
};
var lastShotTime = 0;
var isShooting = false;
var shootingInterval = null;
var buyConfirmationActive = false;
var pendingWeapon = null;
var buyConfirmationGUI = null;
// UI Elements
var healthText = new Text2('Health: 100', {
	size: 60,
	fill: 0xFFFFFF
});
healthText.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthText);
healthText.x = 120;
healthText.y = 50;
var ammoText = new Text2('Ammo: 30/30', {
	size: 60,
	fill: 0xFFFFFF
});
ammoText.anchor.set(0, 0);
LK.gui.topLeft.addChild(ammoText);
ammoText.x = 120;
ammoText.y = 120;
var scoreText = new Text2('Score: 0', {
	size: 80,
	fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// High Score display in top right
var highScore = storage.highScore || 0;
var highScoreText = new Text2('High Score: ' + highScore, {
	size: 60,
	fill: 0xFFD700
});
highScoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(highScoreText);
highScoreText.x = -20;
highScoreText.y = 20;
// Cheats menu variables
var cheatsMenuActive = false;
var cheatsMenuGUI = null;
var godModeActive = false;
var gameSpeedMultiplier = 1;
// CHEATS button with background
var cheatsButtonBackground = LK.getAsset('buttonBackground', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.7
});
cheatsButtonBackground.y = 140;
LK.gui.top.addChild(cheatsButtonBackground);
var cheatsButton = new Text2('CHEATS', {
	size: 50,
	fill: 0xFF00FF
});
cheatsButton.anchor.set(0.5, 0);
LK.gui.top.addChild(cheatsButton);
cheatsButton.y = 100;
// Add game background
var gameBackground = LK.getAsset('gameBackground', {
	anchorX: 0,
	anchorY: 0,
	x: 0,
	y: 0
});
game.addChild(gameBackground);
// Initialize player
player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
// Movement controls
var movementKeys = {
	up: false,
	down: false,
	left: false,
	right: false
};
// Create virtual joystick areas for mobile
var moveUpArea = LK.getAsset('player_up', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.3,
	scaleX: 2,
	scaleY: 1
});
moveUpArea.x = 200;
moveUpArea.y = 2400;
game.addChild(moveUpArea);
var moveDownArea = LK.getAsset('player_up', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.3,
	scaleX: 2,
	scaleY: 1
});
moveDownArea.x = 200;
moveDownArea.y = 2600;
game.addChild(moveDownArea);
var moveLeftArea = LK.getAsset('player_up', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.3,
	scaleX: 1,
	scaleY: 2
});
moveLeftArea.x = 100;
moveLeftArea.y = 2500;
game.addChild(moveLeftArea);
var moveRightArea = LK.getAsset('player_up', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.3,
	scaleX: 1,
	scaleY: 2
});
moveRightArea.x = 300;
moveRightArea.y = 2500;
game.addChild(moveRightArea);
// Movement control handlers
moveUpArea.down = function () {
	movementKeys.up = true;
};
moveUpArea.up = function () {
	movementKeys.up = false;
};
moveDownArea.down = function () {
	movementKeys.down = true;
};
moveDownArea.up = function () {
	movementKeys.down = false;
};
moveLeftArea.down = function () {
	movementKeys.left = true;
};
moveLeftArea.up = function () {
	movementKeys.left = false;
};
moveRightArea.down = function () {
	movementKeys.right = true;
};
moveRightArea.up = function () {
	movementKeys.right = false;
};
// Add weapon area background
var weaponAreaBackground = LK.getAsset('buyBackground', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1900,
	y: 1350,
	scaleX: 0.8,
	scaleY: 1.2,
	alpha: 0.7
});
game.addChild(weaponAreaBackground);
// Add weapon selection buttons in right middle area
var shotgunButton = LK.getAsset('shotgun', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1900,
	y: 1200,
	alpha: 1.0
});
game.addChild(shotgunButton);
var smgButton = LK.getAsset('smg', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1900,
	y: 1350,
	alpha: 0.6
});
game.addChild(smgButton);
var sniperButton = LK.getAsset('sniper', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1900,
	y: 1500,
	alpha: 0.6
});
game.addChild(sniperButton);
// Initialize weapon button states
updateWeaponButtons();
// Weapon selection handlers
shotgunButton.down = function () {
	if (weaponOwned.shotgun) {
		currentWeapon = 'shotgun';
		shotgunButton.alpha = 1.0;
		smgButton.alpha = 0.6;
		sniperButton.alpha = 0.6;
	} else {
		showBuyConfirmation('shotgun');
	}
};
smgButton.down = function () {
	if (weaponOwned.smg) {
		currentWeapon = 'smg';
		shotgunButton.alpha = 0.6;
		smgButton.alpha = 1.0;
		sniperButton.alpha = 0.6;
	} else {
		showBuyConfirmation('smg');
	}
};
sniperButton.down = function () {
	if (weaponOwned.sniper) {
		currentWeapon = 'sniper';
		shotgunButton.alpha = 0.6;
		smgButton.alpha = 0.6;
		sniperButton.alpha = 1.0;
	} else {
		showBuyConfirmation('sniper');
	}
};
function showBuyConfirmation(weaponType) {
	if (buyConfirmationActive) return;
	var weaponCost = weaponStats[weaponType].cost;
	var canAfford = LK.getScore() >= weaponCost;
	buyConfirmationActive = true;
	pendingWeapon = weaponType;
	// Create buy confirmation GUI
	buyConfirmationGUI = new Container();
	LK.gui.center.addChild(buyConfirmationGUI);
	// Background
	var background = LK.getAsset('buyBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		alpha: 0.9
	});
	buyConfirmationGUI.addChild(background);
	// Title text
	var titleText = new Text2('Buy ' + weaponStats[weaponType].name + '?', {
		size: 60,
		fill: 0xFFFFFF
	});
	titleText.anchor.set(0.5, 0.5);
	titleText.y = -70;
	buyConfirmationGUI.addChild(titleText);
	// Cost text
	var costText = new Text2('Cost: ' + weaponCost + ' Score', {
		size: 50,
		fill: 0xFFD700
	});
	costText.anchor.set(0.5, 0.5);
	costText.y = -20;
	buyConfirmationGUI.addChild(costText);
	// Warning text for insufficient funds
	if (!canAfford) {
		var warningText = new Text2('Para yetersiz', {
			size: 45,
			fill: 0xFF4444
		});
		warningText.anchor.set(0.5, 0.5);
		warningText.y = 30;
		buyConfirmationGUI.addChild(warningText);
	}
	// Buy button
	var buyButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: 80
	});
	if (!canAfford) {
		buyButton.tint = 0x666666;
		buyButton.alpha = 0.5;
	}
	buyConfirmationGUI.addChild(buyButton);
	var buyText = new Text2('BUY', {
		size: 40,
		fill: canAfford ? 0xFFFFFF : 0x999999
	});
	buyText.anchor.set(0.5, 0.5);
	buyText.y = 80;
	buyConfirmationGUI.addChild(buyText);
	// Buy button handler
	buyButton.down = function () {
		if (LK.getScore() >= weaponCost) {
			LK.setScore(LK.getScore() - weaponCost);
			scoreText.setText('Score: ' + LK.getScore());
			weaponOwned[pendingWeapon] = true;
			currentWeapon = pendingWeapon;
			updateWeaponButtons();
		}
		hideBuyConfirmation();
	};
	// Cancel button (background click)
	background.down = function () {
		hideBuyConfirmation();
	};
}
function hideBuyConfirmation() {
	if (buyConfirmationGUI) {
		buyConfirmationGUI.destroy();
		buyConfirmationGUI = null;
	}
	buyConfirmationActive = false;
	pendingWeapon = null;
}
function updateWeaponButtons() {
	// Update shotgun button
	if (weaponOwned.shotgun) {
		shotgunButton.alpha = currentWeapon === 'shotgun' ? 1.0 : 0.6;
		shotgunButton.tint = 0xFFFFFF;
	} else {
		shotgunButton.alpha = 0.8;
		shotgunButton.tint = 0xFF4444;
	}
	// Update SMG button
	if (weaponOwned.smg) {
		smgButton.alpha = currentWeapon === 'smg' ? 1.0 : 0.6;
		smgButton.tint = 0xFFFFFF;
	} else {
		smgButton.alpha = 0.8;
		smgButton.tint = 0xFF4444;
	}
	// Update sniper button
	if (weaponOwned.sniper) {
		sniperButton.alpha = currentWeapon === 'sniper' ? 1.0 : 0.6;
		sniperButton.tint = 0xFFFFFF;
	} else {
		sniperButton.alpha = 0.8;
		sniperButton.tint = 0xFF4444;
	}
}
function spawnEnemy() {
	var enemy = new Enemy();
	// Calculate speed multiplier based on score (10% faster every 10 points)
	var speedMultiplier = 1 + Math.floor(LK.getScore() / 10) * 0.1;
	enemy.speed = enemy.speed * speedMultiplier;
	var side = Math.floor(Math.random() * 4);
	switch (side) {
		case 0:
			// Top
			enemy.x = Math.random() * 2048;
			enemy.y = -25;
			break;
		case 1:
			// Right
			enemy.x = 2073;
			enemy.y = Math.random() * 2732;
			break;
		case 2:
			// Bottom
			enemy.x = Math.random() * 2048;
			enemy.y = 2757;
			break;
		case 3:
			// Left
			enemy.x = -25;
			enemy.y = Math.random() * 2732;
			break;
	}
	enemies.push(enemy);
	game.addChild(enemy);
}
function spawnBoss() {
	var currentScore = LK.getScore();
	var bossType = 25; // Default boss
	if (currentScore >= 100) {
		bossType = 100;
	} else if (currentScore >= 75) {
		bossType = 75;
	} else if (currentScore >= 50) {
		bossType = 50;
	}
	var boss = new Boss(bossType);
	var side = Math.floor(Math.random() * 4);
	switch (side) {
		case 0:
			// Top
			boss.x = Math.random() * 2048;
			boss.y = -50;
			break;
		case 1:
			// Right
			boss.x = 2098;
			boss.y = Math.random() * 2732;
			break;
		case 2:
			// Bottom
			boss.x = Math.random() * 2048;
			boss.y = 2782;
			break;
		case 3:
			// Left
			boss.x = -50;
			boss.y = Math.random() * 2732;
			break;
	}
	bosses.push(boss);
	game.addChild(boss);
	bossActive = true;
	LK.playMusic('bossMusic');
}
function fireBullet(targetX, targetY) {
	if (player.shoot()) {
		if (currentWeapon === 'shotgun') {
			// Fire 3 bullets with spread for shotgun
			for (var i = 0; i < 3; i++) {
				var bullet = new Bullet();
				bullet.x = player.x;
				bullet.y = player.y;
				// Calculate angle to target
				var dx = targetX - player.x;
				var dy = targetY - player.y;
				var baseAngle = Math.atan2(dy, dx);
				// Add spread (-0.3, 0, +0.3 radians)
				var spreadAngle = baseAngle + (i - 1) * 0.3;
				var spreadTargetX = player.x + Math.cos(spreadAngle) * 500;
				var spreadTargetY = player.y + Math.sin(spreadAngle) * 500;
				bullet.setDirection(spreadTargetX, spreadTargetY);
				bullets.push(bullet);
				game.addChild(bullet);
			}
		} else if (currentWeapon === 'sniper') {
			// Sniper bullet with penetration
			var bullet = new Bullet();
			bullet.x = player.x;
			bullet.y = player.y;
			bullet.setDirection(targetX, targetY);
			bullet.isPenetrating = true;
			bullet.penetrationCount = 0;
			bullet.maxPenetration = 3;
			bullet.lifeTime = 360; // 3x longer range for sniper
			bullets.push(bullet);
			game.addChild(bullet);
		} else {
			// Regular bullet for SMG
			var bullet = new Bullet();
			bullet.x = player.x;
			bullet.y = player.y;
			bullet.setDirection(targetX, targetY);
			bullets.push(bullet);
			game.addChild(bullet);
		}
		LK.getSound('shoot').play();
	}
}
// Mouse/touch tracking for player direction
game.move = function (x, y, obj) {
	mouseX = x;
	mouseY = y;
	// Calculate direction from player to mouse
	var dx = mouseX - player.x;
	var dy = mouseY - player.y;
	// Determine which direction is dominant
	if (Math.abs(dx) > Math.abs(dy)) {
		// Horizontal movement is dominant
		if (dx > 0) {
			player.setDirection('right');
		} else {
			player.setDirection('left');
		}
	} else {
		// Vertical movement is dominant
		if (dy > 0) {
			player.setDirection('down');
		} else {
			player.setDirection('up');
		}
	}
};
// Cheats button click handler
cheatsButton.down = function (x, y, obj) {
	showCheatsMenu();
};
// Cheats button background click handler
cheatsButtonBackground.down = function (x, y, obj) {
	showCheatsMenu();
};
function showCheatsMenu() {
	if (cheatsMenuActive) return;
	cheatsMenuActive = true;
	game.paused = true;
	// Create cheats menu GUI
	cheatsMenuGUI = new Container();
	LK.gui.center.addChild(cheatsMenuGUI);
	// Background
	var background = LK.getAsset('buyBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		alpha: 0.9,
		scaleX: 1.2,
		scaleY: 1.5
	});
	cheatsMenuGUI.addChild(background);
	// Title text
	var titleText = new Text2('CHEATS MENU', {
		size: 70,
		fill: 0xFF00FF
	});
	titleText.anchor.set(0.5, 0.5);
	titleText.y = -150;
	cheatsMenuGUI.addChild(titleText);
	// +10 Score button
	var add10ScoreButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: -80
	});
	cheatsMenuGUI.addChild(add10ScoreButton);
	var add10ScoreText = new Text2('+10 SCORE', {
		size: 35,
		fill: 0xFFFFFF
	});
	add10ScoreText.anchor.set(0.5, 0.5);
	add10ScoreText.y = -80;
	cheatsMenuGUI.addChild(add10ScoreText);
	// God Mode button
	var godModeButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: -20
	});
	if (godModeActive) {
		godModeButton.tint = 0x00FF00;
	}
	cheatsMenuGUI.addChild(godModeButton);
	var godModeText = new Text2(godModeActive ? 'GOD MODE: ON' : 'GOD MODE: OFF', {
		size: 35,
		fill: 0xFFFFFF
	});
	godModeText.anchor.set(0.5, 0.5);
	godModeText.y = -20;
	cheatsMenuGUI.addChild(godModeText);
	// Game Speed 2x button
	var speed2xButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: 40
	});
	if (gameSpeedMultiplier === 2) {
		speed2xButton.tint = 0x00FF00;
	}
	cheatsMenuGUI.addChild(speed2xButton);
	var speed2xText = new Text2('SPEED 2X', {
		size: 35,
		fill: 0xFFFFFF
	});
	speed2xText.anchor.set(0.5, 0.5);
	speed2xText.y = 40;
	cheatsMenuGUI.addChild(speed2xText);
	// Game Speed 3x button
	var speed3xButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: 100
	});
	if (gameSpeedMultiplier === 3) {
		speed3xButton.tint = 0x00FF00;
	}
	cheatsMenuGUI.addChild(speed3xButton);
	var speed3xText = new Text2('SPEED 3X', {
		size: 35,
		fill: 0xFFFFFF
	});
	speed3xText.anchor.set(0.5, 0.5);
	speed3xText.y = 100;
	cheatsMenuGUI.addChild(speed3xText);
	// Close button
	var closeButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: 160,
		scaleX: 0.8
	});
	closeButton.tint = 0xFF4444;
	cheatsMenuGUI.addChild(closeButton);
	var closeText = new Text2('CLOSE', {
		size: 35,
		fill: 0xFFFFFF
	});
	closeText.anchor.set(0.5, 0.5);
	closeText.y = 160;
	cheatsMenuGUI.addChild(closeText);
	// Button handlers
	add10ScoreButton.down = function () {
		LK.setScore(LK.getScore() + 10);
		scoreText.setText('Score: ' + LK.getScore());
		if (LK.getScore() > highScore) {
			highScore = LK.getScore();
			storage.highScore = highScore;
			highScoreText.setText('High Score: ' + highScore);
		}
	};
	godModeButton.down = function () {
		godModeActive = !godModeActive;
		godModeText.setText(godModeActive ? 'GOD MODE: ON' : 'GOD MODE: OFF');
		godModeButton.tint = godModeActive ? 0x00FF00 : 0xFFFFFF;
	};
	speed2xButton.down = function () {
		gameSpeedMultiplier = gameSpeedMultiplier === 2 ? 1 : 2;
		speed2xButton.tint = gameSpeedMultiplier === 2 ? 0x00FF00 : 0xFFFFFF;
		if (gameSpeedMultiplier !== 3) {
			speed3xButton.tint = 0xFFFFFF;
		}
	};
	speed3xButton.down = function () {
		gameSpeedMultiplier = gameSpeedMultiplier === 3 ? 1 : 3;
		speed3xButton.tint = gameSpeedMultiplier === 3 ? 0x00FF00 : 0xFFFFFF;
		if (gameSpeedMultiplier !== 2) {
			speed2xButton.tint = 0xFFFFFF;
		}
	};
	closeButton.down = function () {
		hideCheatsMenu();
	};
	background.down = function () {
		hideCheatsMenu();
	};
}
function hideCheatsMenu() {
	if (cheatsMenuGUI) {
		cheatsMenuGUI.destroy();
		cheatsMenuGUI = null;
	}
	cheatsMenuActive = false;
	game.paused = false;
}
// Shooting controls
game.down = function (x, y, obj) {
	var currentTime = Date.now();
	var weaponFireRate = weaponStats[currentWeapon].fireRate;
	mouseX = x;
	mouseY = y;
	// Update direction when shooting
	var dx = mouseX - player.x;
	var dy = mouseY - player.y;
	if (Math.abs(dx) > Math.abs(dy)) {
		if (dx > 0) {
			player.setDirection('right');
		} else {
			player.setDirection('left');
		}
	} else {
		if (dy > 0) {
			player.setDirection('down');
		} else {
			player.setDirection('up');
		}
	}
	if (currentWeapon === 'smg') {
		// Start continuous firing for SMG
		isShooting = true;
		if (currentTime - lastShotTime > weaponFireRate) {
			fireBullet(x, y);
			lastShotTime = currentTime;
		}
		if (!shootingInterval) {
			shootingInterval = LK.setInterval(function () {
				if (isShooting && player.canShoot()) {
					fireBullet(mouseX, mouseY);
				}
			}, weaponFireRate);
		}
	} else {
		// Single shot for shotgun and sniper
		if (currentTime - lastShotTime > weaponFireRate) {
			fireBullet(x, y);
			lastShotTime = currentTime;
		}
	}
};
// Add mouse up handler to stop SMG firing
game.up = function (x, y, obj) {
	isShooting = false;
	if (shootingInterval) {
		LK.clearInterval(shootingInterval);
		shootingInterval = null;
	}
};
// Main game loop
game.update = function () {
	if (!player || game.paused) return;
	// Apply game speed multiplier
	for (var speedLoop = 0; speedLoop < gameSpeedMultiplier; speedLoop++) {
		if (game.paused) break;
		// Player movement
		if (movementKeys.up && player.y > 30) {
			player.y -= player.speed;
		}
		if (movementKeys.down && player.y < 2702) {
			player.y += player.speed;
		}
		if (movementKeys.left && player.x > 30) {
			player.x -= player.speed;
		}
		if (movementKeys.right && player.x < 2018) {
			player.x += player.speed;
		}
		// Spawn enemies
		enemySpawnTimer++;
		if (enemySpawnTimer >= enemySpawnRate) {
			spawnEnemy();
			enemySpawnTimer = 0;
			// Increase difficulty over time
			if (enemySpawnRate > 60) {
				enemySpawnRate--;
			}
		}
		// Check for boss spawn every 25 points
		if (LK.getScore() > 0 && LK.getScore() % 25 === 0 && LK.getScore() !== lastBossScore && !bossActive) {
			spawnBoss();
			lastBossScore = LK.getScore();
		}
		// Update bullets
		for (var i = bullets.length - 1; i >= 0; i--) {
			var bullet = bullets[i];
			if (bullet.isExpired()) {
				bullet.destroy();
				bullets.splice(i, 1);
				continue;
			}
			// Check bullet-enemy collisions
			for (var j = enemies.length - 1; j >= 0; j--) {
				var enemy = enemies[j];
				if (bullet.intersects(enemy)) {
					var damage = weaponStats[currentWeapon].damage;
					if (enemy.takeDamage(damage)) {
						LK.setScore(LK.getScore() + 1);
						scoreText.setText('Score: ' + LK.getScore());
						// Update high score if current score is higher
						if (LK.getScore() > highScore) {
							highScore = LK.getScore();
							storage.highScore = highScore;
							highScoreText.setText('High Score: ' + highScore);
						}
						LK.getSound('enemyHit').play();
						enemy.destroy();
						enemies.splice(j, 1);
					}
					// Handle bullet penetration for sniper
					if (bullet.isPenetrating && bullet.penetrationCount < bullet.maxPenetration) {
						bullet.penetrationCount++;
					} else {
						bullet.destroy();
						bullets.splice(i, 1);
					}
					break;
				}
			}
			// Check bullet-boss collisions
			for (var b = bosses.length - 1; b >= 0; b--) {
				var boss = bosses[b];
				if (bullet.intersects(boss)) {
					var damage = weaponStats[currentWeapon].damage;
					if (boss.takeDamage(damage)) {
						LK.setScore(LK.getScore() + 10);
						scoreText.setText('Score: ' + LK.getScore());
						// Update high score if current score is higher
						if (LK.getScore() > highScore) {
							highScore = LK.getScore();
							storage.highScore = highScore;
							highScoreText.setText('High Score: ' + highScore);
						}
						LK.getSound('bossDeath').play();
						boss.destroy();
						bosses.splice(b, 1);
						bossActive = false;
						LK.stopMusic();
					}
					// Handle bullet penetration for sniper
					if (bullet.isPenetrating && bullet.penetrationCount < bullet.maxPenetration) {
						bullet.penetrationCount++;
					} else {
						bullet.destroy();
						bullets.splice(i, 1);
					}
					break;
				}
			}
		}
		// Check player-enemy collisions
		for (var k = enemies.length - 1; k >= 0; k--) {
			var enemy = enemies[k];
			if (player.intersects(enemy)) {
				player.takeDamage(100);
				break;
			}
		}
		// Check player-boss collisions
		for (var m = bosses.length - 1; m >= 0; m--) {
			var boss = bosses[m];
			if (player.intersects(boss)) {
				player.takeDamage(100);
				break;
			}
		}
		// Update UI
		healthText.setText('Health: ' + player.health);
		if (player.isReloading) {
			ammoText.setText('Reloading...');
		} else {
			ammoText.setText('Ammo: ' + player.ammunition + '/' + player.maxAmmo);
		}
	} // Close speed multiplier loop
}; /**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/**** 
* Classes
****/ 
var Boss = Container.expand(function (bossType) {
	var self = Container.call(this);
	// Determine boss asset and health based on type
	var assetId = 'boss';
	var health = 10;
	if (bossType === 50) {
		assetId = 'boss50';
		health = 20;
	} else if (bossType === 75) {
		assetId = 'boss75';
		health = 30;
	} else if (bossType === 100) {
		assetId = 'boss100';
		health = 50;
	}
	var bossGraphics = self.attachAsset(assetId, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 0.8;
	self.health = health;
	self.maxHealth = health;
	self.bossType = bossType || 25;
	self.isBoss = true;
	self.lastPlayerX = 0;
	self.lastPlayerY = 0;
	// Create health bar
	var healthBarWidth = bossGraphics.width * 0.8;
	var healthBarBackground = LK.getAsset('buttonBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: healthBarWidth / 260,
		scaleY: 0.3
	});
	healthBarBackground.y = -bossGraphics.height / 2 - 30;
	self.addChild(healthBarBackground);
	var healthBar = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: healthBarWidth / 200,
		scaleY: 0.4
	});
	healthBar.y = -bossGraphics.height / 2 - 30;
	healthBar.tint = 0x00ff00;
	self.addChild(healthBar);
	self.healthBar = healthBar;
	self.healthBarBackground = healthBarBackground;
	self.update = function () {
		if (player) {
			var dx = player.x - self.x;
			var dy = player.y - self.y;
			var distance = Math.sqrt(dx * dx + dy * dy);
			if (distance > 0) {
				self.x += dx / distance * self.speed;
				self.y += dy / distance * self.speed;
			}
			self.lastPlayerX = player.x;
			self.lastPlayerY = player.y;
		}
	};
	self.takeDamage = function (damage) {
		damage = damage || 1;
		self.health -= damage;
		LK.effects.flashObject(self, 0xFF4444, 200);
		// Update health bar
		var healthPercent = self.health / self.maxHealth;
		self.healthBar.scaleX = self.healthBarBackground.width * healthPercent / 200;
		if (healthPercent > 0.5) {
			self.healthBar.tint = 0x00ff00;
		} else if (healthPercent > 0.25) {
			self.healthBar.tint = 0xffff00;
		} else {
			self.healthBar.tint = 0xff0000;
		}
		if (self.health <= 0) {
			LK.effects.flashObject(self, 0xFFFFFF, 500);
			return true;
		}
		return false;
	};
	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 = 8;
	self.velocityX = 0;
	self.velocityY = 0;
	self.lifeTime = 120;
	self.age = 0;
	self.setDirection = function (targetX, targetY) {
		var dx = targetX - self.x;
		var dy = targetY - self.y;
		var distance = Math.sqrt(dx * dx + dy * dy);
		if (distance > 0) {
			self.velocityX = dx / distance * self.speed;
			self.velocityY = dy / distance * self.speed;
		}
	};
	self.update = function () {
		self.x += self.velocityX;
		self.y += self.velocityY;
		self.age++;
	};
	self.isExpired = function () {
		return self.age >= self.lifeTime || self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782;
	};
	return self;
});
var Enemy = Container.expand(function () {
	var self = Container.call(this);
	var enemyGraphics = self.attachAsset('enemy', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 1.5;
	self.health = 1;
	self.maxHealth = 1;
	self.lastPlayerX = 0;
	self.lastPlayerY = 0;
	// Create health bar for enemy
	var healthBarWidth = enemyGraphics.width * 0.6;
	var healthBarBackground = LK.getAsset('buttonBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: healthBarWidth / 260,
		scaleY: 0.2
	});
	healthBarBackground.y = -enemyGraphics.height / 2 - 20;
	self.addChild(healthBarBackground);
	var healthBar = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: healthBarWidth / 200,
		scaleY: 0.3
	});
	healthBar.y = -enemyGraphics.height / 2 - 20;
	healthBar.tint = 0x00ff00;
	self.addChild(healthBar);
	self.healthBar = healthBar;
	self.healthBarBackground = healthBarBackground;
	self.update = function () {
		if (player) {
			var dx = player.x - self.x;
			var dy = player.y - self.y;
			var distance = Math.sqrt(dx * dx + dy * dy);
			if (distance > 0) {
				self.x += dx / distance * self.speed;
				self.y += dy / distance * self.speed;
			}
			self.lastPlayerX = player.x;
			self.lastPlayerY = player.y;
		}
	};
	self.takeDamage = function (damage) {
		damage = damage || 1;
		self.health -= damage;
		// Update health bar
		var healthPercent = self.health / self.maxHealth;
		self.healthBar.scaleX = self.healthBarBackground.width * healthPercent / 200;
		if (healthPercent > 0.5) {
			self.healthBar.tint = 0x00ff00;
		} else if (healthPercent > 0.25) {
			self.healthBar.tint = 0xffff00;
		} else {
			self.healthBar.tint = 0xff0000;
		}
		if (self.health <= 0) {
			LK.effects.flashObject(self, 0xFFFFFF, 200);
			return true;
		}
		return false;
	};
	return self;
});
var Player = Container.expand(function () {
	var self = Container.call(this);
	// Create all directional graphics
	self.playerGraphicsUp = self.attachAsset('player_up', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.playerGraphicsDown = self.attachAsset('player_down', {
		anchorX: 0.5,
		anchorY: 0.5,
		visible: false
	});
	self.playerGraphicsLeft = self.attachAsset('player_left', {
		anchorX: 0.5,
		anchorY: 0.5,
		visible: false
	});
	self.playerGraphicsRight = self.attachAsset('player_right', {
		anchorX: 0.5,
		anchorY: 0.5,
		visible: false
	});
	self.currentDirection = 'up';
	self.health = 100;
	self.maxHealth = 100;
	self.speed = 4;
	self.ammunition = 30;
	self.maxAmmo = 30;
	self.isReloading = false;
	self.reloadTime = 2000;
	self.setDirection = function (direction) {
		// Hide all graphics first
		self.playerGraphicsUp.visible = false;
		self.playerGraphicsDown.visible = false;
		self.playerGraphicsLeft.visible = false;
		self.playerGraphicsRight.visible = false;
		// Show the correct direction
		switch (direction) {
			case 'up':
				self.playerGraphicsUp.visible = true;
				break;
			case 'down':
				self.playerGraphicsDown.visible = true;
				break;
			case 'left':
				self.playerGraphicsLeft.visible = true;
				break;
			case 'right':
				self.playerGraphicsRight.visible = true;
				break;
		}
		self.currentDirection = direction;
	};
	self.takeDamage = function (damage) {
		if (godModeActive) return; // God mode prevents damage
		self.health -= damage;
		if (self.health <= 0) {
			self.health = 0;
			LK.effects.flashScreen(0xFF0000, 1000);
			LK.showGameOver();
		} else {
			LK.effects.flashObject(self, 0xFF0000, 300);
		}
	};
	self.reload = function () {
		if (!self.isReloading && self.ammunition < self.maxAmmo) {
			self.isReloading = true;
			LK.getSound('reload').play();
			LK.setTimeout(function () {
				self.ammunition = self.maxAmmo;
				self.isReloading = false;
			}, self.reloadTime);
		}
	};
	self.canShoot = function () {
		return self.ammunition > 0 && !self.isReloading;
	};
	self.shoot = function () {
		if (self.canShoot()) {
			self.ammunition--;
			if (self.ammunition === 0) {
				self.reload();
			}
			return true;
		}
		return false;
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x2C3E50
});
/**** 
* Game Code
****/ 
var player;
var enemies = [];
var bullets = [];
var enemySpawnTimer = 0;
var enemySpawnRate = 180;
var gameStarted = false;
var lastTapTime = 0;
var tapCooldown = 150;
var mouseX = 2048 / 2;
var mouseY = 2732 / 2;
var bosses = [];
var lastBossScore = 0;
var bossActive = false;
var currentWeapon = 'shotgun';
var weaponStats = {
	shotgun: {
		damage: 2,
		fireRate: 20,
		name: 'Shotgun',
		cost: 20
	},
	smg: {
		damage: 1,
		fireRate: 25,
		name: 'SMG',
		cost: 100
	},
	sniper: {
		damage: 5,
		fireRate: 60,
		name: 'Sniper',
		cost: 100
	}
};
var weaponOwned = {
	shotgun: true,
	smg: false,
	sniper: false
};
var lastShotTime = 0;
var isShooting = false;
var shootingInterval = null;
var buyConfirmationActive = false;
var pendingWeapon = null;
var buyConfirmationGUI = null;
// UI Elements
var healthText = new Text2('Health: 100', {
	size: 60,
	fill: 0xFFFFFF
});
healthText.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthText);
healthText.x = 120;
healthText.y = 50;
var ammoText = new Text2('Ammo: 30/30', {
	size: 60,
	fill: 0xFFFFFF
});
ammoText.anchor.set(0, 0);
LK.gui.topLeft.addChild(ammoText);
ammoText.x = 120;
ammoText.y = 120;
var scoreText = new Text2('Score: 0', {
	size: 80,
	fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// High Score display in top right
var highScore = storage.highScore || 0;
var highScoreText = new Text2('High Score: ' + highScore, {
	size: 60,
	fill: 0xFFD700
});
highScoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(highScoreText);
highScoreText.x = -20;
highScoreText.y = 20;
// Cheats menu variables
var cheatsMenuActive = false;
var cheatsMenuGUI = null;
var godModeActive = false;
var gameSpeedMultiplier = 1;
// CHEATS button with background
var cheatsButtonBackground = LK.getAsset('buttonBackground', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.7
});
cheatsButtonBackground.y = 140;
LK.gui.top.addChild(cheatsButtonBackground);
var cheatsButton = new Text2('CHEATS', {
	size: 50,
	fill: 0xFF00FF
});
cheatsButton.anchor.set(0.5, 0);
LK.gui.top.addChild(cheatsButton);
cheatsButton.y = 100;
// Add game background
var gameBackground = LK.getAsset('gameBackground', {
	anchorX: 0,
	anchorY: 0,
	x: 0,
	y: 0
});
game.addChild(gameBackground);
// Initialize player
player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
// Movement controls
var movementKeys = {
	up: false,
	down: false,
	left: false,
	right: false
};
// Create virtual joystick areas for mobile
var moveUpArea = LK.getAsset('player_up', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.3,
	scaleX: 2,
	scaleY: 1
});
moveUpArea.x = 200;
moveUpArea.y = 2400;
game.addChild(moveUpArea);
var moveDownArea = LK.getAsset('player_up', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.3,
	scaleX: 2,
	scaleY: 1
});
moveDownArea.x = 200;
moveDownArea.y = 2600;
game.addChild(moveDownArea);
var moveLeftArea = LK.getAsset('player_up', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.3,
	scaleX: 1,
	scaleY: 2
});
moveLeftArea.x = 100;
moveLeftArea.y = 2500;
game.addChild(moveLeftArea);
var moveRightArea = LK.getAsset('player_up', {
	anchorX: 0.5,
	anchorY: 0.5,
	alpha: 0.3,
	scaleX: 1,
	scaleY: 2
});
moveRightArea.x = 300;
moveRightArea.y = 2500;
game.addChild(moveRightArea);
// Movement control handlers
moveUpArea.down = function () {
	movementKeys.up = true;
};
moveUpArea.up = function () {
	movementKeys.up = false;
};
moveDownArea.down = function () {
	movementKeys.down = true;
};
moveDownArea.up = function () {
	movementKeys.down = false;
};
moveLeftArea.down = function () {
	movementKeys.left = true;
};
moveLeftArea.up = function () {
	movementKeys.left = false;
};
moveRightArea.down = function () {
	movementKeys.right = true;
};
moveRightArea.up = function () {
	movementKeys.right = false;
};
// Add weapon area background
var weaponAreaBackground = LK.getAsset('buyBackground', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1900,
	y: 1350,
	scaleX: 0.8,
	scaleY: 1.2,
	alpha: 0.7
});
game.addChild(weaponAreaBackground);
// Add weapon selection buttons in right middle area
var shotgunButton = LK.getAsset('shotgun', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1900,
	y: 1200,
	alpha: 1.0
});
game.addChild(shotgunButton);
var smgButton = LK.getAsset('smg', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1900,
	y: 1350,
	alpha: 0.6
});
game.addChild(smgButton);
var sniperButton = LK.getAsset('sniper', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1900,
	y: 1500,
	alpha: 0.6
});
game.addChild(sniperButton);
// Initialize weapon button states
updateWeaponButtons();
// Weapon selection handlers
shotgunButton.down = function () {
	if (weaponOwned.shotgun) {
		currentWeapon = 'shotgun';
		shotgunButton.alpha = 1.0;
		smgButton.alpha = 0.6;
		sniperButton.alpha = 0.6;
	} else {
		showBuyConfirmation('shotgun');
	}
};
smgButton.down = function () {
	if (weaponOwned.smg) {
		currentWeapon = 'smg';
		shotgunButton.alpha = 0.6;
		smgButton.alpha = 1.0;
		sniperButton.alpha = 0.6;
	} else {
		showBuyConfirmation('smg');
	}
};
sniperButton.down = function () {
	if (weaponOwned.sniper) {
		currentWeapon = 'sniper';
		shotgunButton.alpha = 0.6;
		smgButton.alpha = 0.6;
		sniperButton.alpha = 1.0;
	} else {
		showBuyConfirmation('sniper');
	}
};
function showBuyConfirmation(weaponType) {
	if (buyConfirmationActive) return;
	var weaponCost = weaponStats[weaponType].cost;
	var canAfford = LK.getScore() >= weaponCost;
	buyConfirmationActive = true;
	pendingWeapon = weaponType;
	// Create buy confirmation GUI
	buyConfirmationGUI = new Container();
	LK.gui.center.addChild(buyConfirmationGUI);
	// Background
	var background = LK.getAsset('buyBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		alpha: 0.9
	});
	buyConfirmationGUI.addChild(background);
	// Title text
	var titleText = new Text2('Buy ' + weaponStats[weaponType].name + '?', {
		size: 60,
		fill: 0xFFFFFF
	});
	titleText.anchor.set(0.5, 0.5);
	titleText.y = -70;
	buyConfirmationGUI.addChild(titleText);
	// Cost text
	var costText = new Text2('Cost: ' + weaponCost + ' Score', {
		size: 50,
		fill: 0xFFD700
	});
	costText.anchor.set(0.5, 0.5);
	costText.y = -20;
	buyConfirmationGUI.addChild(costText);
	// Warning text for insufficient funds
	if (!canAfford) {
		var warningText = new Text2('Para yetersiz', {
			size: 45,
			fill: 0xFF4444
		});
		warningText.anchor.set(0.5, 0.5);
		warningText.y = 30;
		buyConfirmationGUI.addChild(warningText);
	}
	// Buy button
	var buyButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: 80
	});
	if (!canAfford) {
		buyButton.tint = 0x666666;
		buyButton.alpha = 0.5;
	}
	buyConfirmationGUI.addChild(buyButton);
	var buyText = new Text2('BUY', {
		size: 40,
		fill: canAfford ? 0xFFFFFF : 0x999999
	});
	buyText.anchor.set(0.5, 0.5);
	buyText.y = 80;
	buyConfirmationGUI.addChild(buyText);
	// Buy button handler
	buyButton.down = function () {
		if (LK.getScore() >= weaponCost) {
			LK.setScore(LK.getScore() - weaponCost);
			scoreText.setText('Score: ' + LK.getScore());
			weaponOwned[pendingWeapon] = true;
			currentWeapon = pendingWeapon;
			updateWeaponButtons();
		}
		hideBuyConfirmation();
	};
	// Cancel button (background click)
	background.down = function () {
		hideBuyConfirmation();
	};
}
function hideBuyConfirmation() {
	if (buyConfirmationGUI) {
		buyConfirmationGUI.destroy();
		buyConfirmationGUI = null;
	}
	buyConfirmationActive = false;
	pendingWeapon = null;
}
function updateWeaponButtons() {
	// Update shotgun button
	if (weaponOwned.shotgun) {
		shotgunButton.alpha = currentWeapon === 'shotgun' ? 1.0 : 0.6;
		shotgunButton.tint = 0xFFFFFF;
	} else {
		shotgunButton.alpha = 0.8;
		shotgunButton.tint = 0xFF4444;
	}
	// Update SMG button
	if (weaponOwned.smg) {
		smgButton.alpha = currentWeapon === 'smg' ? 1.0 : 0.6;
		smgButton.tint = 0xFFFFFF;
	} else {
		smgButton.alpha = 0.8;
		smgButton.tint = 0xFF4444;
	}
	// Update sniper button
	if (weaponOwned.sniper) {
		sniperButton.alpha = currentWeapon === 'sniper' ? 1.0 : 0.6;
		sniperButton.tint = 0xFFFFFF;
	} else {
		sniperButton.alpha = 0.8;
		sniperButton.tint = 0xFF4444;
	}
}
function spawnEnemy() {
	var enemy = new Enemy();
	// Calculate speed multiplier based on score (10% faster every 10 points)
	var speedMultiplier = 1 + Math.floor(LK.getScore() / 10) * 0.1;
	enemy.speed = enemy.speed * speedMultiplier;
	var side = Math.floor(Math.random() * 4);
	switch (side) {
		case 0:
			// Top
			enemy.x = Math.random() * 2048;
			enemy.y = -25;
			break;
		case 1:
			// Right
			enemy.x = 2073;
			enemy.y = Math.random() * 2732;
			break;
		case 2:
			// Bottom
			enemy.x = Math.random() * 2048;
			enemy.y = 2757;
			break;
		case 3:
			// Left
			enemy.x = -25;
			enemy.y = Math.random() * 2732;
			break;
	}
	enemies.push(enemy);
	game.addChild(enemy);
}
function spawnBoss() {
	var currentScore = LK.getScore();
	var bossType = 25; // Default boss
	if (currentScore >= 100) {
		bossType = 100;
	} else if (currentScore >= 75) {
		bossType = 75;
	} else if (currentScore >= 50) {
		bossType = 50;
	}
	var boss = new Boss(bossType);
	var side = Math.floor(Math.random() * 4);
	switch (side) {
		case 0:
			// Top
			boss.x = Math.random() * 2048;
			boss.y = -50;
			break;
		case 1:
			// Right
			boss.x = 2098;
			boss.y = Math.random() * 2732;
			break;
		case 2:
			// Bottom
			boss.x = Math.random() * 2048;
			boss.y = 2782;
			break;
		case 3:
			// Left
			boss.x = -50;
			boss.y = Math.random() * 2732;
			break;
	}
	bosses.push(boss);
	game.addChild(boss);
	bossActive = true;
	LK.playMusic('bossMusic');
}
function fireBullet(targetX, targetY) {
	if (player.shoot()) {
		if (currentWeapon === 'shotgun') {
			// Fire 3 bullets with spread for shotgun
			for (var i = 0; i < 3; i++) {
				var bullet = new Bullet();
				bullet.x = player.x;
				bullet.y = player.y;
				// Calculate angle to target
				var dx = targetX - player.x;
				var dy = targetY - player.y;
				var baseAngle = Math.atan2(dy, dx);
				// Add spread (-0.3, 0, +0.3 radians)
				var spreadAngle = baseAngle + (i - 1) * 0.3;
				var spreadTargetX = player.x + Math.cos(spreadAngle) * 500;
				var spreadTargetY = player.y + Math.sin(spreadAngle) * 500;
				bullet.setDirection(spreadTargetX, spreadTargetY);
				bullets.push(bullet);
				game.addChild(bullet);
			}
		} else if (currentWeapon === 'sniper') {
			// Sniper bullet with penetration
			var bullet = new Bullet();
			bullet.x = player.x;
			bullet.y = player.y;
			bullet.setDirection(targetX, targetY);
			bullet.isPenetrating = true;
			bullet.penetrationCount = 0;
			bullet.maxPenetration = 3;
			bullet.lifeTime = 360; // 3x longer range for sniper
			bullets.push(bullet);
			game.addChild(bullet);
		} else {
			// Regular bullet for SMG
			var bullet = new Bullet();
			bullet.x = player.x;
			bullet.y = player.y;
			bullet.setDirection(targetX, targetY);
			bullets.push(bullet);
			game.addChild(bullet);
		}
		LK.getSound('shoot').play();
	}
}
// Mouse/touch tracking for player direction
game.move = function (x, y, obj) {
	mouseX = x;
	mouseY = y;
	// Calculate direction from player to mouse
	var dx = mouseX - player.x;
	var dy = mouseY - player.y;
	// Determine which direction is dominant
	if (Math.abs(dx) > Math.abs(dy)) {
		// Horizontal movement is dominant
		if (dx > 0) {
			player.setDirection('right');
		} else {
			player.setDirection('left');
		}
	} else {
		// Vertical movement is dominant
		if (dy > 0) {
			player.setDirection('down');
		} else {
			player.setDirection('up');
		}
	}
};
// Cheats button click handler
cheatsButton.down = function (x, y, obj) {
	showCheatsMenu();
};
// Cheats button background click handler
cheatsButtonBackground.down = function (x, y, obj) {
	showCheatsMenu();
};
function showCheatsMenu() {
	if (cheatsMenuActive) return;
	cheatsMenuActive = true;
	game.paused = true;
	// Create cheats menu GUI
	cheatsMenuGUI = new Container();
	LK.gui.center.addChild(cheatsMenuGUI);
	// Background
	var background = LK.getAsset('buyBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		alpha: 0.9,
		scaleX: 1.2,
		scaleY: 1.5
	});
	cheatsMenuGUI.addChild(background);
	// Title text
	var titleText = new Text2('CHEATS MENU', {
		size: 70,
		fill: 0xFF00FF
	});
	titleText.anchor.set(0.5, 0.5);
	titleText.y = -150;
	cheatsMenuGUI.addChild(titleText);
	// +10 Score button
	var add10ScoreButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: -80
	});
	cheatsMenuGUI.addChild(add10ScoreButton);
	var add10ScoreText = new Text2('+10 SCORE', {
		size: 35,
		fill: 0xFFFFFF
	});
	add10ScoreText.anchor.set(0.5, 0.5);
	add10ScoreText.y = -80;
	cheatsMenuGUI.addChild(add10ScoreText);
	// God Mode button
	var godModeButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: -20
	});
	if (godModeActive) {
		godModeButton.tint = 0x00FF00;
	}
	cheatsMenuGUI.addChild(godModeButton);
	var godModeText = new Text2(godModeActive ? 'GOD MODE: ON' : 'GOD MODE: OFF', {
		size: 35,
		fill: 0xFFFFFF
	});
	godModeText.anchor.set(0.5, 0.5);
	godModeText.y = -20;
	cheatsMenuGUI.addChild(godModeText);
	// Game Speed 2x button
	var speed2xButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: 40
	});
	if (gameSpeedMultiplier === 2) {
		speed2xButton.tint = 0x00FF00;
	}
	cheatsMenuGUI.addChild(speed2xButton);
	var speed2xText = new Text2('SPEED 2X', {
		size: 35,
		fill: 0xFFFFFF
	});
	speed2xText.anchor.set(0.5, 0.5);
	speed2xText.y = 40;
	cheatsMenuGUI.addChild(speed2xText);
	// Game Speed 3x button
	var speed3xButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: 100
	});
	if (gameSpeedMultiplier === 3) {
		speed3xButton.tint = 0x00FF00;
	}
	cheatsMenuGUI.addChild(speed3xButton);
	var speed3xText = new Text2('SPEED 3X', {
		size: 35,
		fill: 0xFFFFFF
	});
	speed3xText.anchor.set(0.5, 0.5);
	speed3xText.y = 100;
	cheatsMenuGUI.addChild(speed3xText);
	// Close button
	var closeButton = LK.getAsset('buyButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		y: 160,
		scaleX: 0.8
	});
	closeButton.tint = 0xFF4444;
	cheatsMenuGUI.addChild(closeButton);
	var closeText = new Text2('CLOSE', {
		size: 35,
		fill: 0xFFFFFF
	});
	closeText.anchor.set(0.5, 0.5);
	closeText.y = 160;
	cheatsMenuGUI.addChild(closeText);
	// Button handlers
	add10ScoreButton.down = function () {
		LK.setScore(LK.getScore() + 10);
		scoreText.setText('Score: ' + LK.getScore());
		if (LK.getScore() > highScore) {
			highScore = LK.getScore();
			storage.highScore = highScore;
			highScoreText.setText('High Score: ' + highScore);
		}
	};
	godModeButton.down = function () {
		godModeActive = !godModeActive;
		godModeText.setText(godModeActive ? 'GOD MODE: ON' : 'GOD MODE: OFF');
		godModeButton.tint = godModeActive ? 0x00FF00 : 0xFFFFFF;
	};
	speed2xButton.down = function () {
		gameSpeedMultiplier = gameSpeedMultiplier === 2 ? 1 : 2;
		speed2xButton.tint = gameSpeedMultiplier === 2 ? 0x00FF00 : 0xFFFFFF;
		if (gameSpeedMultiplier !== 3) {
			speed3xButton.tint = 0xFFFFFF;
		}
	};
	speed3xButton.down = function () {
		gameSpeedMultiplier = gameSpeedMultiplier === 3 ? 1 : 3;
		speed3xButton.tint = gameSpeedMultiplier === 3 ? 0x00FF00 : 0xFFFFFF;
		if (gameSpeedMultiplier !== 2) {
			speed2xButton.tint = 0xFFFFFF;
		}
	};
	closeButton.down = function () {
		hideCheatsMenu();
	};
	background.down = function () {
		hideCheatsMenu();
	};
}
function hideCheatsMenu() {
	if (cheatsMenuGUI) {
		cheatsMenuGUI.destroy();
		cheatsMenuGUI = null;
	}
	cheatsMenuActive = false;
	game.paused = false;
}
// Shooting controls
game.down = function (x, y, obj) {
	var currentTime = Date.now();
	var weaponFireRate = weaponStats[currentWeapon].fireRate;
	mouseX = x;
	mouseY = y;
	// Update direction when shooting
	var dx = mouseX - player.x;
	var dy = mouseY - player.y;
	if (Math.abs(dx) > Math.abs(dy)) {
		if (dx > 0) {
			player.setDirection('right');
		} else {
			player.setDirection('left');
		}
	} else {
		if (dy > 0) {
			player.setDirection('down');
		} else {
			player.setDirection('up');
		}
	}
	if (currentWeapon === 'smg') {
		// Start continuous firing for SMG
		isShooting = true;
		if (currentTime - lastShotTime > weaponFireRate) {
			fireBullet(x, y);
			lastShotTime = currentTime;
		}
		if (!shootingInterval) {
			shootingInterval = LK.setInterval(function () {
				if (isShooting && player.canShoot()) {
					fireBullet(mouseX, mouseY);
				}
			}, weaponFireRate);
		}
	} else {
		// Single shot for shotgun and sniper
		if (currentTime - lastShotTime > weaponFireRate) {
			fireBullet(x, y);
			lastShotTime = currentTime;
		}
	}
};
// Add mouse up handler to stop SMG firing
game.up = function (x, y, obj) {
	isShooting = false;
	if (shootingInterval) {
		LK.clearInterval(shootingInterval);
		shootingInterval = null;
	}
};
// Main game loop
game.update = function () {
	if (!player || game.paused) return;
	// Apply game speed multiplier
	for (var speedLoop = 0; speedLoop < gameSpeedMultiplier; speedLoop++) {
		if (game.paused) break;
		// Player movement
		if (movementKeys.up && player.y > 30) {
			player.y -= player.speed;
		}
		if (movementKeys.down && player.y < 2702) {
			player.y += player.speed;
		}
		if (movementKeys.left && player.x > 30) {
			player.x -= player.speed;
		}
		if (movementKeys.right && player.x < 2018) {
			player.x += player.speed;
		}
		// Spawn enemies
		enemySpawnTimer++;
		if (enemySpawnTimer >= enemySpawnRate) {
			spawnEnemy();
			enemySpawnTimer = 0;
			// Increase difficulty over time
			if (enemySpawnRate > 60) {
				enemySpawnRate--;
			}
		}
		// Check for boss spawn every 25 points
		if (LK.getScore() > 0 && LK.getScore() % 25 === 0 && LK.getScore() !== lastBossScore && !bossActive) {
			spawnBoss();
			lastBossScore = LK.getScore();
		}
		// Update bullets
		for (var i = bullets.length - 1; i >= 0; i--) {
			var bullet = bullets[i];
			if (bullet.isExpired()) {
				bullet.destroy();
				bullets.splice(i, 1);
				continue;
			}
			// Check bullet-enemy collisions
			for (var j = enemies.length - 1; j >= 0; j--) {
				var enemy = enemies[j];
				if (bullet.intersects(enemy)) {
					var damage = weaponStats[currentWeapon].damage;
					if (enemy.takeDamage(damage)) {
						LK.setScore(LK.getScore() + 1);
						scoreText.setText('Score: ' + LK.getScore());
						// Update high score if current score is higher
						if (LK.getScore() > highScore) {
							highScore = LK.getScore();
							storage.highScore = highScore;
							highScoreText.setText('High Score: ' + highScore);
						}
						LK.getSound('enemyHit').play();
						enemy.destroy();
						enemies.splice(j, 1);
					}
					// Handle bullet penetration for sniper
					if (bullet.isPenetrating && bullet.penetrationCount < bullet.maxPenetration) {
						bullet.penetrationCount++;
					} else {
						bullet.destroy();
						bullets.splice(i, 1);
					}
					break;
				}
			}
			// Check bullet-boss collisions
			for (var b = bosses.length - 1; b >= 0; b--) {
				var boss = bosses[b];
				if (bullet.intersects(boss)) {
					var damage = weaponStats[currentWeapon].damage;
					if (boss.takeDamage(damage)) {
						LK.setScore(LK.getScore() + 10);
						scoreText.setText('Score: ' + LK.getScore());
						// Update high score if current score is higher
						if (LK.getScore() > highScore) {
							highScore = LK.getScore();
							storage.highScore = highScore;
							highScoreText.setText('High Score: ' + highScore);
						}
						LK.getSound('bossDeath').play();
						boss.destroy();
						bosses.splice(b, 1);
						bossActive = false;
						LK.stopMusic();
					}
					// Handle bullet penetration for sniper
					if (bullet.isPenetrating && bullet.penetrationCount < bullet.maxPenetration) {
						bullet.penetrationCount++;
					} else {
						bullet.destroy();
						bullets.splice(i, 1);
					}
					break;
				}
			}
		}
		// Check player-enemy collisions
		for (var k = enemies.length - 1; k >= 0; k--) {
			var enemy = enemies[k];
			if (player.intersects(enemy)) {
				player.takeDamage(100);
				break;
			}
		}
		// Check player-boss collisions
		for (var m = bosses.length - 1; m >= 0; m--) {
			var boss = bosses[m];
			if (player.intersects(boss)) {
				player.takeDamage(100);
				break;
			}
		}
		// Update UI
		healthText.setText('Health: ' + player.health);
		if (player.isReloading) {
			ammoText.setText('Reloading...');
		} else {
			ammoText.setText('Ammo: ' + player.ammunition + '/' + player.maxAmmo);
		}
	} // Close speed multiplier loop
};
 terrorist sketch 1. In-Game asset. 2d. High contrast. No shadows
 Bullet. In-Game asset. 2d. High contrast. No shadows
 boss sketch ballistic shield. In-Game asset. 2d. High contrast. No shadows
 angry devil golem holding a big shield on right hand. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
 red big monster dragon sketch. In-Game asset. 2d. High contrast. No shadows
 god sketch. 3d model In-Game asset. 2d. High contrast. No shadows
 dust 2 dark. In-Game asset. 2d. High contrast. No shadows
 black smg icon with white stroke. In-Game asset. 2d. High contrast. No shadows
 black sniper icon with white stroke. In-Game asset. 2d. High contrast. No shadows
 black shotgun icon with white stroke. In-Game asset. 2d. High contrast. No shadows