/****
* 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 asteroidTypes = ['asteroid_large', 'asteroid_medium', 'asteroid_small'];
var asteroidType = asteroidTypes[Math.floor(Math.random() * asteroidTypes.length)];
var asteroid = self.attachAsset(asteroidType, {
anchorX: 0.5,
anchorY: 0.5
});
asteroid.alpha = 0.6 + Math.random() * 0.4;
self.speed = 0.5 + Math.random() * 1.5;
self.rotationSpeed = (Math.random() - 0.5) * 0.03;
self.driftX = (Math.random() - 0.5) * 0.8;
self.update = function () {
self.y += self.speed;
self.x += self.driftX;
self.rotation += self.rotationSpeed;
if (self.y > 2800) {
self.y = -100;
self.x = Math.random() * 2048;
}
// Keep asteroids within screen bounds
if (self.x < -50) self.x = 2098;
if (self.x > 2098) self.x = -50;
};
return self;
});
var BossShip = Container.expand(function () {
var self = Container.call(this);
var shipBody = self.attachAsset('boss_ship_body', {
anchorX: 0.5,
anchorY: 0.5
});
var shipNose = self.attachAsset('boss_ship_nose', {
anchorX: 0.5,
anchorY: 0.5
});
shipNose.y = 80;
var shipWingLeft = self.attachAsset('boss_ship_wing_left', {
anchorX: 0.5,
anchorY: 0.5
});
shipWingLeft.x = -80;
shipWingLeft.y = -10;
var shipWingRight = self.attachAsset('boss_ship_wing_right', {
anchorX: 0.5,
anchorY: 0.5
});
shipWingRight.x = 80;
shipWingRight.y = -10;
var shipCockpit = self.attachAsset('boss_ship_cockpit', {
anchorX: 0.5,
anchorY: 0.5
});
shipCockpit.y = 20;
var thrusterMain = self.attachAsset('boss_thruster_main', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterMain.y = -125;
thrusterMain.alpha = 0.8;
var thrusterLeft = self.attachAsset('boss_thruster_left', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterLeft.x = -50;
thrusterLeft.y = -100;
thrusterLeft.alpha = 0.7;
var thrusterRight = self.attachAsset('boss_thruster_right', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterRight.x = 50;
thrusterRight.y = -100;
thrusterRight.alpha = 0.7;
self.speed = 2;
self.health = 500;
self.maxHealth = 500;
self.lastShootTime = 0;
self.shootDelay = 80;
self.directionX = 1;
self.movePattern = 0;
self.moveTimer = 0;
self.isBoss = true;
self.update = function () {
// Boss movement patterns
self.moveTimer++;
if (self.moveTimer % 180 == 0) {
self.movePattern = Math.floor(Math.random() * 3);
}
// Different movement patterns
if (self.movePattern == 0) {
// Side to side movement
self.x += self.directionX * 3;
if (self.x <= 200 || self.x >= 1848) {
self.directionX *= -1;
}
} else if (self.movePattern == 1) {
// Circular movement
self.x += Math.sin(self.moveTimer * 0.05) * 4;
self.y += Math.cos(self.moveTimer * 0.03) * 2;
} else {
// Aggressive forward movement
self.y += self.speed * 2;
self.x += Math.sin(self.moveTimer * 0.08) * 2;
}
// Keep boss on screen
if (self.x < 100) self.x = 100;
if (self.x > 1948) self.x = 1948;
if (self.y < 100) self.y = 100;
if (self.y > 800) self.y = 800;
// Thruster effects
thrusterMain.alpha = 0.5 + Math.random() * 0.5;
thrusterLeft.alpha = 0.4 + Math.random() * 0.4;
thrusterRight.alpha = 0.4 + Math.random() * 0.4;
// Boss shooting pattern - multiple bullets
if (LK.ticks - self.lastShootTime > self.shootDelay) {
// Shoot 5 bullets in spread pattern
for (var i = 0; i < 5; i++) {
var bullet = new EnemyBullet();
bullet.x = self.x + (i - 2) * 40;
bullet.y = self.y + 100;
bullet.speed = 10 + Math.random() * 4;
enemyBullets.push(bullet);
game.addChild(bullet);
}
self.lastShootTime = LK.ticks;
}
};
return self;
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bullet = self.attachAsset('enemy_bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.lastY = 0;
self.update = function () {
self.lastY = self.y;
self.y += self.speed;
};
return self;
});
var EnemyShip = Container.expand(function () {
var self = Container.call(this);
var shipBody = self.attachAsset('g_arttrma_hzl_ate', {
anchorX: 0.5,
anchorY: 0.5
});
var thrusterMain = self.attachAsset('enemy_thruster_main', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterMain.y = -40;
thrusterMain.alpha = 0.7;
var thrusterLeft = self.attachAsset('enemy_thruster_left', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterLeft.x = -20;
thrusterLeft.y = -35;
thrusterLeft.alpha = 0.6;
var thrusterRight = self.attachAsset('enemy_thruster_right', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterRight.x = 20;
thrusterRight.y = -35;
thrusterRight.alpha = 0.6;
self.speed = 3;
self.health = 50;
self.lastShootTime = 0;
self.shootDelay = 300 + Math.random() * 200;
self.directionX = Math.random() > 0.5 ? 1 : -1;
self.update = function () {
// Move down and side to side
self.y += self.speed;
self.x += self.directionX * 2;
// Change direction at screen edges
if (self.x <= 100 || self.x >= 1948) {
self.directionX *= -1;
}
// Thruster effect
thrusterMain.alpha = 0.4 + Math.random() * 0.4;
thrusterLeft.alpha = 0.3 + Math.random() * 0.3;
thrusterRight.alpha = 0.3 + Math.random() * 0.3;
// Shoot randomly
if (LK.ticks - self.lastShootTime > self.shootDelay) {
var bullet = new EnemyBullet();
bullet.x = self.x;
bullet.y = self.y + 50;
enemyBullets.push(bullet);
game.addChild(bullet);
self.lastShootTime = LK.ticks;
self.shootDelay = 300 + Math.random() * 200;
}
};
return self;
});
var ExplosionParticle = Container.expand(function () {
var self = Container.call(this);
var particle = self.attachAsset('explosion_particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = (Math.random() - 0.5) * 20;
self.velocityY = (Math.random() - 0.5) * 20;
self.life = 30;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.life--;
self.alpha = self.life / 30;
particle.scaleX = self.life / 30;
particle.scaleY = self.life / 30;
};
return self;
});
var HealthPowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupBody = self.attachAsset('powerup_health', {
anchorX: 0.5,
anchorY: 0.5
});
var powerupCore = self.attachAsset('powerup_health_core', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.rotationSpeed = 0.1;
self.pulseTimer = 0;
self.type = 'health';
self.healthAmount = 30;
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed;
self.pulseTimer += 0.2;
var pulse = Math.sin(self.pulseTimer) * 0.3 + 0.7;
powerupBody.alpha = pulse;
powerupCore.alpha = pulse + 0.3;
};
return self;
});
var Planet = Container.expand(function () {
var self = Container.call(this);
var planetTypes = ['planet_large', 'planet_medium', 'planet_small'];
var planetType = planetTypes[Math.floor(Math.random() * planetTypes.length)];
var planet = self.attachAsset(planetType, {
anchorX: 0.5,
anchorY: 0.5
});
planet.alpha = 0.3 + Math.random() * 0.4;
self.speed = 1 + Math.random() * 2;
self.rotationSpeed = (Math.random() - 0.5) * 0.02;
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed;
if (self.y > 2800) {
self.y = -150;
self.x = Math.random() * 2048;
}
};
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var bullet = self.attachAsset('player_bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.lastY = 0;
self.update = function () {
self.lastY = self.y;
self.y += self.speed;
};
return self;
});
var PlayerShip = Container.expand(function () {
var self = Container.call(this);
var shipBody = self.attachAsset('uzaygemisi', {
anchorX: 0.5,
anchorY: 0.5
});
var thrusterMain = self.attachAsset('player_thruster_main', {
anchorX: 0.5,
anchorY: 0
});
thrusterMain.y = 50;
thrusterMain.alpha = 0.8;
var thrusterLeft = self.attachAsset('player_thruster_left', {
anchorX: 0.5,
anchorY: 0
});
thrusterLeft.x = -25;
thrusterLeft.y = 45;
thrusterLeft.alpha = 0.7;
var thrusterRight = self.attachAsset('player_thruster_right', {
anchorX: 0.5,
anchorY: 0
});
thrusterRight.x = 25;
thrusterRight.y = 45;
thrusterRight.alpha = 0.7;
self.speed = 8;
self.health = 100;
self.lastShootTime = 0;
self.shootDelay = 100;
self.shotsPerBurst = 1;
self.activateRapidFire = function () {
self.shootDelay = 30;
self.shotsPerBurst = 3;
rapidFireActive = true;
rapidFireEndTime = LK.ticks + 600;
};
self.deactivateRapidFire = function () {
self.shootDelay = originalShootDelay;
self.shotsPerBurst = 1;
rapidFireActive = false;
};
self.update = function () {
// Keep ship on screen
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
if (self.y < 100) self.y = 100;
if (self.y > 2632) self.y = 2632;
// Thruster effect
thrusterMain.alpha = 0.5 + Math.random() * 0.5;
thrusterLeft.alpha = 0.4 + Math.random() * 0.4;
thrusterRight.alpha = 0.4 + Math.random() * 0.4;
};
self.shoot = function () {
if (LK.ticks - self.lastShootTime > self.shootDelay) {
for (var s = 0; s < self.shotsPerBurst; s++) {
var bullet = new PlayerBullet();
bullet.x = self.x + (s - Math.floor(self.shotsPerBurst / 2)) * 25;
bullet.y = self.y - 60;
playerBullets.push(bullet);
game.addChild(bullet);
}
self.lastShootTime = LK.ticks;
LK.getSound('shoot').play();
}
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupBody = self.attachAsset('powerup_rapid_fire', {
anchorX: 0.5,
anchorY: 0.5
});
var powerupCore = self.attachAsset('powerup_core', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.rotationSpeed = 0.1;
self.pulseTimer = 0;
self.type = 'rapidfire';
self.shotsPerBurst = 3;
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed;
self.pulseTimer += 0.2;
var pulse = Math.sin(self.pulseTimer) * 0.3 + 0.7;
powerupBody.alpha = pulse;
powerupCore.alpha = pulse + 0.3;
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var star = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
star.alpha = 0.5 + Math.random() * 0.5;
self.speed = 2 + Math.random() * 3;
self.update = function () {
self.y += self.speed;
if (self.y > 2800) {
self.y = -50;
self.x = Math.random() * 2048;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000011
});
/****
* Game Code
****/
// Load saved game data
var savedHighScore = storage.highScore || 0;
var savedTotalGamesPlayed = storage.totalGamesPlayed || 0;
var savedTotalEnemiesDestroyed = storage.totalEnemiesDestroyed || 0;
var savedTotalBossesDefeated = storage.totalBossesDefeated || 0;
var savedDifficultyLevel = storage.difficultyLevel || 1;
var player;
var enemies = [];
var playerBullets = [];
var enemyBullets = [];
var stars = [];
var planets = [];
var asteroids = [];
var explosions = [];
var powerUps = [];
var scoreTxt;
var healthTxt;
var isDragging = false;
var dragStartX = 0;
var dragStartY = 0;
var enemySpawnTimer = 0;
var powerUpSpawnTimer = 0;
var waveNumber = 1;
var enemiesPerWave = 3;
var rapidFireActive = false;
var rapidFireEndTime = 0;
var originalShootDelay = 100;
var difficultyLevel = 1;
var lastDifficultyScore = 0;
var lastHealthBonusScore = 0;
var bosses = [];
var lastBossScore = 0;
var bossSpawnInterval = 1000;
var bossHealthTxt;
var currentGameEnemiesDestroyed = 0;
var currentGameBossesDefeated = 0;
var gameStartTime = LK.ticks;
// Create starfield background
for (var i = 0; i < 50; i++) {
var star = new Star();
star.x = Math.random() * 2048;
star.y = Math.random() * 2732;
stars.push(star);
game.addChild(star);
}
// Create planets background - removed spinning spaceship
// Create asteroids background
for (var i = 0; i < 12; i++) {
var asteroid = new Asteroid();
asteroid.x = Math.random() * 2048;
asteroid.y = Math.random() * 2732;
asteroids.push(asteroid);
game.addChild(asteroid);
}
// Create player ship
player = new PlayerShip();
player.x = 1024;
player.y = 2200;
game.addChild(player);
// Create UI
scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.setText('Score: ' + LK.getScore());
LK.gui.top.addChild(scoreTxt);
healthTxt = new Text2('Health: 100', {
size: 50,
fill: 0x00FF00
});
healthTxt.anchor.set(0, 0);
healthTxt.x = 120;
healthTxt.y = 20;
LK.gui.topLeft.addChild(healthTxt);
// Boss health display (initially hidden)
bossHealthTxt = new Text2('Boss Health: 500', {
size: 45,
fill: 0xFF0000
});
bossHealthTxt.anchor.set(0.5, 0);
bossHealthTxt.x = 0;
bossHealthTxt.y = 80;
bossHealthTxt.visible = false;
LK.gui.top.addChild(bossHealthTxt);
// Game title display
var gameTitleTxt = new Text2('Galaxy Destroyer', {
size: 70,
fill: 0x00FFFF
});
gameTitleTxt.anchor.set(0.5, 0);
gameTitleTxt.x = 0;
gameTitleTxt.y = 150;
LK.gui.top.addChild(gameTitleTxt);
// High score display
var highScoreTxt = new Text2('High Score: ' + savedHighScore, {
size: 40,
fill: 0xFFD700
});
highScoreTxt.anchor.set(1, 0);
highScoreTxt.x = -20;
highScoreTxt.y = 20;
LK.gui.topRight.addChild(highScoreTxt);
// Touch controls
game.down = function (x, y, obj) {
isDragging = true;
dragStartX = x;
dragStartY = y;
player.shoot();
};
game.move = function (x, y, obj) {
if (isDragging) {
player.x = x;
player.y = y;
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
game.update = function () {
// Check rapid fire duration
if (rapidFireActive && LK.ticks >= rapidFireEndTime) {
player.deactivateRapidFire();
}
// Spawn enemies
enemySpawnTimer++;
var spawnRate = superChallengeMode ? 30 : 120; // Much faster spawning after 500 score
if (enemySpawnTimer >= spawnRate) {
var maxEnemies = superChallengeMode ? enemiesPerWave * 3 : enemiesPerWave; // Allow 3x more enemies
if (enemies.length < maxEnemies) {
var enemy = new EnemyShip();
enemy.x = Math.random() * 1800 + 100;
enemy.y = -50;
// Apply difficulty scaling
if (superChallengeMode) {
// Super challenging mode: extremely fast, tanky enemies with rapid fire
enemy.speed = 8 + (difficultyLevel - 1) * 1.5;
enemy.health = 150 + (difficultyLevel - 1) * 25;
enemy.shootDelay = Math.max(50, 80 - (difficultyLevel - 1) * 10);
} else {
enemy.speed = 3 + (difficultyLevel - 1) * 0.5;
enemy.health = 50 + (difficultyLevel - 1) * 10;
enemy.shootDelay = Math.max(100, 300 - (difficultyLevel - 1) * 30);
}
enemies.push(enemy);
game.addChild(enemy);
}
enemySpawnTimer = 0;
}
// Spawn power-ups
powerUpSpawnTimer++;
if (powerUpSpawnTimer >= 900) {
if (Math.random() < 0.7) {
var powerUp = new PowerUp();
powerUp.x = Math.random() * 1800 + 100;
powerUp.y = -50;
powerUps.push(powerUp);
game.addChild(powerUp);
}
powerUpSpawnTimer = 0;
}
// Spawn health bonus every 250 score
if (currentScore >= lastHealthBonusScore + 250) {
var healthPowerUp = new HealthPowerUp();
healthPowerUp.x = Math.random() * 1800 + 100;
healthPowerUp.y = -50;
powerUps.push(healthPowerUp);
game.addChild(healthPowerUp);
lastHealthBonusScore = Math.floor(currentScore / 250) * 250;
}
// Spawn boss every 1000 score
if (currentScore >= lastBossScore + bossSpawnInterval && bosses.length == 0) {
var boss = new BossShip();
boss.x = 1024;
boss.y = 200;
bosses.push(boss);
game.addChild(boss);
lastBossScore = Math.floor(currentScore / bossSpawnInterval) * bossSpawnInterval;
bossHealthTxt.visible = true;
bossHealthTxt.setText('Boss Health: ' + boss.health);
}
// Update player bullets
for (var i = playerBullets.length - 1; i >= 0; i--) {
var bullet = playerBullets[i];
if (bullet.lastY >= -50 && bullet.y < -50) {
bullet.destroy();
playerBullets.splice(i, 1);
continue;
}
bullet.lastY = bullet.y;
}
// Update enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var bullet = enemyBullets[i];
if (bullet.lastY <= 2800 && bullet.y > 2800) {
bullet.destroy();
enemyBullets.splice(i, 1);
continue;
}
bullet.lastY = bullet.y;
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.y > 2800) {
enemy.destroy();
enemies.splice(i, 1);
continue;
}
}
// Update bosses
for (var i = bosses.length - 1; i >= 0; i--) {
var boss = bosses[i];
if (boss.y > 2800) {
boss.destroy();
bosses.splice(i, 1);
bossHealthTxt.visible = false;
continue;
}
// Update boss health display
if (bossHealthTxt.visible) {
bossHealthTxt.setText('Boss Health: ' + boss.health);
}
}
// Update explosions
for (var i = explosions.length - 1; i >= 0; i--) {
var explosion = explosions[i];
if (explosion.life <= 0) {
explosion.destroy();
explosions.splice(i, 1);
}
}
// Update power-ups
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
if (powerUp.y > 2800) {
powerUp.destroy();
powerUps.splice(i, 1);
continue;
}
// Check collision with player
if (powerUp.intersects(player)) {
if (powerUp.type === 'rapidfire') {
player.activateRapidFire();
} else if (powerUp.type === 'health') {
player.health = Math.min(player.health + powerUp.healthAmount, 100);
healthTxt.setText('Health: ' + player.health);
if (player.health > 30) {
healthTxt.tint = 0x00FF00;
}
}
LK.getSound('powerup').play();
powerUp.destroy();
powerUps.splice(i, 1);
}
}
// Check player bullet vs enemy collisions
for (var i = playerBullets.length - 1; i >= 0; i--) {
var bullet = playerBullets[i];
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
// Create explosion
for (var k = 0; k < 8; k++) {
var particle = new ExplosionParticle();
particle.x = enemy.x;
particle.y = enemy.y;
explosions.push(particle);
game.addChild(particle);
}
LK.setScore(LK.getScore() + 10);
currentGameEnemiesDestroyed++;
LK.getSound('explosion').play();
bullet.destroy();
playerBullets.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
break;
}
}
// Check bullet vs boss collisions
for (var j = bosses.length - 1; j >= 0; j--) {
var boss = bosses[j];
if (bullet.intersects(boss)) {
boss.health -= 25;
// Create explosion
for (var k = 0; k < 5; k++) {
var particle = new ExplosionParticle();
particle.x = bullet.x;
particle.y = bullet.y;
explosions.push(particle);
game.addChild(particle);
}
LK.getSound('hit').play();
bullet.destroy();
playerBullets.splice(i, 1);
// Boss defeated
if (boss.health <= 0) {
// Massive explosion
for (var k = 0; k < 20; k++) {
var particle = new ExplosionParticle();
particle.x = boss.x + (Math.random() - 0.5) * 200;
particle.y = boss.y + (Math.random() - 0.5) * 200;
explosions.push(particle);
game.addChild(particle);
}
LK.setScore(LK.getScore() + 500);
currentGameBossesDefeated++;
LK.getSound('explosion').play();
boss.destroy();
bosses.splice(j, 1);
bossHealthTxt.visible = false;
}
break;
}
}
}
// Check enemy bullet vs player collisions
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var bullet = enemyBullets[i];
if (bullet.intersects(player)) {
player.health -= 10;
healthTxt.setText('Health: ' + player.health);
if (player.health <= 0) {
healthTxt.tint = 0xFF0000;
} else if (player.health <= 30) {
healthTxt.tint = 0xFFFF00;
}
LK.getSound('hit').play();
bullet.destroy();
enemyBullets.splice(i, 1);
if (player.health <= 0) {
// Save game statistics before game over
var currentScore = LK.getScore();
if (currentScore > savedHighScore) {
storage.highScore = currentScore;
}
storage.totalGamesPlayed = savedTotalGamesPlayed + 1;
storage.totalEnemiesDestroyed = savedTotalEnemiesDestroyed + currentGameEnemiesDestroyed;
storage.totalBossesDefeated = savedTotalBossesDefeated + currentGameBossesDefeated;
storage.difficultyLevel = Math.max(savedDifficultyLevel, difficultyLevel);
LK.showGameOver();
}
}
}
// Check enemy vs player collisions
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.intersects(player)) {
player.health -= 20;
healthTxt.setText('Health: ' + player.health);
if (player.health <= 0) {
healthTxt.tint = 0xFF0000;
} else if (player.health <= 30) {
healthTxt.tint = 0xFFFF00;
}
LK.getSound('hit').play();
enemy.destroy();
enemies.splice(i, 1);
if (player.health <= 0) {
// Save game statistics before game over
var currentScore = LK.getScore();
if (currentScore > savedHighScore) {
storage.highScore = currentScore;
}
storage.totalGamesPlayed = savedTotalGamesPlayed + 1;
storage.totalEnemiesDestroyed = savedTotalEnemiesDestroyed + currentGameEnemiesDestroyed;
storage.totalBossesDefeated = savedTotalBossesDefeated + currentGameBossesDefeated;
storage.difficultyLevel = Math.max(savedDifficultyLevel, difficultyLevel);
LK.showGameOver();
}
}
}
// Check boss vs player collisions
for (var i = bosses.length - 1; i >= 0; i--) {
var boss = bosses[i];
if (boss.intersects(player)) {
player.health -= 30;
healthTxt.setText('Health: ' + player.health);
if (player.health <= 0) {
healthTxt.tint = 0xFF0000;
} else if (player.health <= 30) {
healthTxt.tint = 0xFFFF00;
}
LK.getSound('hit').play();
if (player.health <= 0) {
// Save game statistics before game over
var currentScore = LK.getScore();
if (currentScore > savedHighScore) {
storage.highScore = currentScore;
}
storage.totalGamesPlayed = savedTotalGamesPlayed + 1;
storage.totalEnemiesDestroyed = savedTotalEnemiesDestroyed + currentGameEnemiesDestroyed;
storage.totalBossesDefeated = savedTotalBossesDefeated + currentGameBossesDefeated;
storage.difficultyLevel = Math.max(savedDifficultyLevel, difficultyLevel);
LK.showGameOver();
}
}
}
// Update difficulty level every 150 points
var currentScore = LK.getScore();
if (currentScore >= lastDifficultyScore + 150) {
difficultyLevel++;
lastDifficultyScore = Math.floor(currentScore / 150) * 150;
}
// Super challenging mode after 500 score
var superChallengeMode = currentScore >= 500;
// Check for wave completion
if (enemies.length === 0 && enemySpawnTimer >= 120) {
waveNumber++;
enemiesPerWave = Math.min(waveNumber + 2, 8);
// Restore some health on wave completion
player.health = Math.min(player.health + 20, 100);
healthTxt.setText('Health: ' + player.health);
if (player.health > 30) {
healthTxt.tint = 0x00FF00;
}
}
// Win condition
if (LK.getScore() >= 100000) {
// Save game statistics before win
var currentScore = LK.getScore();
if (currentScore > savedHighScore) {
storage.highScore = currentScore;
}
storage.totalGamesPlayed = savedTotalGamesPlayed + 1;
storage.totalEnemiesDestroyed = savedTotalEnemiesDestroyed + currentGameEnemiesDestroyed;
storage.totalBossesDefeated = savedTotalBossesDefeated + currentGameBossesDefeated;
storage.difficultyLevel = Math.max(savedDifficultyLevel, difficultyLevel);
LK.showYouWin();
}
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
}; /****
* 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 asteroidTypes = ['asteroid_large', 'asteroid_medium', 'asteroid_small'];
var asteroidType = asteroidTypes[Math.floor(Math.random() * asteroidTypes.length)];
var asteroid = self.attachAsset(asteroidType, {
anchorX: 0.5,
anchorY: 0.5
});
asteroid.alpha = 0.6 + Math.random() * 0.4;
self.speed = 0.5 + Math.random() * 1.5;
self.rotationSpeed = (Math.random() - 0.5) * 0.03;
self.driftX = (Math.random() - 0.5) * 0.8;
self.update = function () {
self.y += self.speed;
self.x += self.driftX;
self.rotation += self.rotationSpeed;
if (self.y > 2800) {
self.y = -100;
self.x = Math.random() * 2048;
}
// Keep asteroids within screen bounds
if (self.x < -50) self.x = 2098;
if (self.x > 2098) self.x = -50;
};
return self;
});
var BossShip = Container.expand(function () {
var self = Container.call(this);
var shipBody = self.attachAsset('boss_ship_body', {
anchorX: 0.5,
anchorY: 0.5
});
var shipNose = self.attachAsset('boss_ship_nose', {
anchorX: 0.5,
anchorY: 0.5
});
shipNose.y = 80;
var shipWingLeft = self.attachAsset('boss_ship_wing_left', {
anchorX: 0.5,
anchorY: 0.5
});
shipWingLeft.x = -80;
shipWingLeft.y = -10;
var shipWingRight = self.attachAsset('boss_ship_wing_right', {
anchorX: 0.5,
anchorY: 0.5
});
shipWingRight.x = 80;
shipWingRight.y = -10;
var shipCockpit = self.attachAsset('boss_ship_cockpit', {
anchorX: 0.5,
anchorY: 0.5
});
shipCockpit.y = 20;
var thrusterMain = self.attachAsset('boss_thruster_main', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterMain.y = -125;
thrusterMain.alpha = 0.8;
var thrusterLeft = self.attachAsset('boss_thruster_left', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterLeft.x = -50;
thrusterLeft.y = -100;
thrusterLeft.alpha = 0.7;
var thrusterRight = self.attachAsset('boss_thruster_right', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterRight.x = 50;
thrusterRight.y = -100;
thrusterRight.alpha = 0.7;
self.speed = 2;
self.health = 500;
self.maxHealth = 500;
self.lastShootTime = 0;
self.shootDelay = 80;
self.directionX = 1;
self.movePattern = 0;
self.moveTimer = 0;
self.isBoss = true;
self.update = function () {
// Boss movement patterns
self.moveTimer++;
if (self.moveTimer % 180 == 0) {
self.movePattern = Math.floor(Math.random() * 3);
}
// Different movement patterns
if (self.movePattern == 0) {
// Side to side movement
self.x += self.directionX * 3;
if (self.x <= 200 || self.x >= 1848) {
self.directionX *= -1;
}
} else if (self.movePattern == 1) {
// Circular movement
self.x += Math.sin(self.moveTimer * 0.05) * 4;
self.y += Math.cos(self.moveTimer * 0.03) * 2;
} else {
// Aggressive forward movement
self.y += self.speed * 2;
self.x += Math.sin(self.moveTimer * 0.08) * 2;
}
// Keep boss on screen
if (self.x < 100) self.x = 100;
if (self.x > 1948) self.x = 1948;
if (self.y < 100) self.y = 100;
if (self.y > 800) self.y = 800;
// Thruster effects
thrusterMain.alpha = 0.5 + Math.random() * 0.5;
thrusterLeft.alpha = 0.4 + Math.random() * 0.4;
thrusterRight.alpha = 0.4 + Math.random() * 0.4;
// Boss shooting pattern - multiple bullets
if (LK.ticks - self.lastShootTime > self.shootDelay) {
// Shoot 5 bullets in spread pattern
for (var i = 0; i < 5; i++) {
var bullet = new EnemyBullet();
bullet.x = self.x + (i - 2) * 40;
bullet.y = self.y + 100;
bullet.speed = 10 + Math.random() * 4;
enemyBullets.push(bullet);
game.addChild(bullet);
}
self.lastShootTime = LK.ticks;
}
};
return self;
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bullet = self.attachAsset('enemy_bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.lastY = 0;
self.update = function () {
self.lastY = self.y;
self.y += self.speed;
};
return self;
});
var EnemyShip = Container.expand(function () {
var self = Container.call(this);
var shipBody = self.attachAsset('g_arttrma_hzl_ate', {
anchorX: 0.5,
anchorY: 0.5
});
var thrusterMain = self.attachAsset('enemy_thruster_main', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterMain.y = -40;
thrusterMain.alpha = 0.7;
var thrusterLeft = self.attachAsset('enemy_thruster_left', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterLeft.x = -20;
thrusterLeft.y = -35;
thrusterLeft.alpha = 0.6;
var thrusterRight = self.attachAsset('enemy_thruster_right', {
anchorX: 0.5,
anchorY: 1.0
});
thrusterRight.x = 20;
thrusterRight.y = -35;
thrusterRight.alpha = 0.6;
self.speed = 3;
self.health = 50;
self.lastShootTime = 0;
self.shootDelay = 300 + Math.random() * 200;
self.directionX = Math.random() > 0.5 ? 1 : -1;
self.update = function () {
// Move down and side to side
self.y += self.speed;
self.x += self.directionX * 2;
// Change direction at screen edges
if (self.x <= 100 || self.x >= 1948) {
self.directionX *= -1;
}
// Thruster effect
thrusterMain.alpha = 0.4 + Math.random() * 0.4;
thrusterLeft.alpha = 0.3 + Math.random() * 0.3;
thrusterRight.alpha = 0.3 + Math.random() * 0.3;
// Shoot randomly
if (LK.ticks - self.lastShootTime > self.shootDelay) {
var bullet = new EnemyBullet();
bullet.x = self.x;
bullet.y = self.y + 50;
enemyBullets.push(bullet);
game.addChild(bullet);
self.lastShootTime = LK.ticks;
self.shootDelay = 300 + Math.random() * 200;
}
};
return self;
});
var ExplosionParticle = Container.expand(function () {
var self = Container.call(this);
var particle = self.attachAsset('explosion_particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = (Math.random() - 0.5) * 20;
self.velocityY = (Math.random() - 0.5) * 20;
self.life = 30;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.life--;
self.alpha = self.life / 30;
particle.scaleX = self.life / 30;
particle.scaleY = self.life / 30;
};
return self;
});
var HealthPowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupBody = self.attachAsset('powerup_health', {
anchorX: 0.5,
anchorY: 0.5
});
var powerupCore = self.attachAsset('powerup_health_core', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.rotationSpeed = 0.1;
self.pulseTimer = 0;
self.type = 'health';
self.healthAmount = 30;
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed;
self.pulseTimer += 0.2;
var pulse = Math.sin(self.pulseTimer) * 0.3 + 0.7;
powerupBody.alpha = pulse;
powerupCore.alpha = pulse + 0.3;
};
return self;
});
var Planet = Container.expand(function () {
var self = Container.call(this);
var planetTypes = ['planet_large', 'planet_medium', 'planet_small'];
var planetType = planetTypes[Math.floor(Math.random() * planetTypes.length)];
var planet = self.attachAsset(planetType, {
anchorX: 0.5,
anchorY: 0.5
});
planet.alpha = 0.3 + Math.random() * 0.4;
self.speed = 1 + Math.random() * 2;
self.rotationSpeed = (Math.random() - 0.5) * 0.02;
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed;
if (self.y > 2800) {
self.y = -150;
self.x = Math.random() * 2048;
}
};
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var bullet = self.attachAsset('player_bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.lastY = 0;
self.update = function () {
self.lastY = self.y;
self.y += self.speed;
};
return self;
});
var PlayerShip = Container.expand(function () {
var self = Container.call(this);
var shipBody = self.attachAsset('uzaygemisi', {
anchorX: 0.5,
anchorY: 0.5
});
var thrusterMain = self.attachAsset('player_thruster_main', {
anchorX: 0.5,
anchorY: 0
});
thrusterMain.y = 50;
thrusterMain.alpha = 0.8;
var thrusterLeft = self.attachAsset('player_thruster_left', {
anchorX: 0.5,
anchorY: 0
});
thrusterLeft.x = -25;
thrusterLeft.y = 45;
thrusterLeft.alpha = 0.7;
var thrusterRight = self.attachAsset('player_thruster_right', {
anchorX: 0.5,
anchorY: 0
});
thrusterRight.x = 25;
thrusterRight.y = 45;
thrusterRight.alpha = 0.7;
self.speed = 8;
self.health = 100;
self.lastShootTime = 0;
self.shootDelay = 100;
self.shotsPerBurst = 1;
self.activateRapidFire = function () {
self.shootDelay = 30;
self.shotsPerBurst = 3;
rapidFireActive = true;
rapidFireEndTime = LK.ticks + 600;
};
self.deactivateRapidFire = function () {
self.shootDelay = originalShootDelay;
self.shotsPerBurst = 1;
rapidFireActive = false;
};
self.update = function () {
// Keep ship on screen
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
if (self.y < 100) self.y = 100;
if (self.y > 2632) self.y = 2632;
// Thruster effect
thrusterMain.alpha = 0.5 + Math.random() * 0.5;
thrusterLeft.alpha = 0.4 + Math.random() * 0.4;
thrusterRight.alpha = 0.4 + Math.random() * 0.4;
};
self.shoot = function () {
if (LK.ticks - self.lastShootTime > self.shootDelay) {
for (var s = 0; s < self.shotsPerBurst; s++) {
var bullet = new PlayerBullet();
bullet.x = self.x + (s - Math.floor(self.shotsPerBurst / 2)) * 25;
bullet.y = self.y - 60;
playerBullets.push(bullet);
game.addChild(bullet);
}
self.lastShootTime = LK.ticks;
LK.getSound('shoot').play();
}
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupBody = self.attachAsset('powerup_rapid_fire', {
anchorX: 0.5,
anchorY: 0.5
});
var powerupCore = self.attachAsset('powerup_core', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.rotationSpeed = 0.1;
self.pulseTimer = 0;
self.type = 'rapidfire';
self.shotsPerBurst = 3;
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed;
self.pulseTimer += 0.2;
var pulse = Math.sin(self.pulseTimer) * 0.3 + 0.7;
powerupBody.alpha = pulse;
powerupCore.alpha = pulse + 0.3;
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var star = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
star.alpha = 0.5 + Math.random() * 0.5;
self.speed = 2 + Math.random() * 3;
self.update = function () {
self.y += self.speed;
if (self.y > 2800) {
self.y = -50;
self.x = Math.random() * 2048;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000011
});
/****
* Game Code
****/
// Load saved game data
var savedHighScore = storage.highScore || 0;
var savedTotalGamesPlayed = storage.totalGamesPlayed || 0;
var savedTotalEnemiesDestroyed = storage.totalEnemiesDestroyed || 0;
var savedTotalBossesDefeated = storage.totalBossesDefeated || 0;
var savedDifficultyLevel = storage.difficultyLevel || 1;
var player;
var enemies = [];
var playerBullets = [];
var enemyBullets = [];
var stars = [];
var planets = [];
var asteroids = [];
var explosions = [];
var powerUps = [];
var scoreTxt;
var healthTxt;
var isDragging = false;
var dragStartX = 0;
var dragStartY = 0;
var enemySpawnTimer = 0;
var powerUpSpawnTimer = 0;
var waveNumber = 1;
var enemiesPerWave = 3;
var rapidFireActive = false;
var rapidFireEndTime = 0;
var originalShootDelay = 100;
var difficultyLevel = 1;
var lastDifficultyScore = 0;
var lastHealthBonusScore = 0;
var bosses = [];
var lastBossScore = 0;
var bossSpawnInterval = 1000;
var bossHealthTxt;
var currentGameEnemiesDestroyed = 0;
var currentGameBossesDefeated = 0;
var gameStartTime = LK.ticks;
// Create starfield background
for (var i = 0; i < 50; i++) {
var star = new Star();
star.x = Math.random() * 2048;
star.y = Math.random() * 2732;
stars.push(star);
game.addChild(star);
}
// Create planets background - removed spinning spaceship
// Create asteroids background
for (var i = 0; i < 12; i++) {
var asteroid = new Asteroid();
asteroid.x = Math.random() * 2048;
asteroid.y = Math.random() * 2732;
asteroids.push(asteroid);
game.addChild(asteroid);
}
// Create player ship
player = new PlayerShip();
player.x = 1024;
player.y = 2200;
game.addChild(player);
// Create UI
scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.setText('Score: ' + LK.getScore());
LK.gui.top.addChild(scoreTxt);
healthTxt = new Text2('Health: 100', {
size: 50,
fill: 0x00FF00
});
healthTxt.anchor.set(0, 0);
healthTxt.x = 120;
healthTxt.y = 20;
LK.gui.topLeft.addChild(healthTxt);
// Boss health display (initially hidden)
bossHealthTxt = new Text2('Boss Health: 500', {
size: 45,
fill: 0xFF0000
});
bossHealthTxt.anchor.set(0.5, 0);
bossHealthTxt.x = 0;
bossHealthTxt.y = 80;
bossHealthTxt.visible = false;
LK.gui.top.addChild(bossHealthTxt);
// Game title display
var gameTitleTxt = new Text2('Galaxy Destroyer', {
size: 70,
fill: 0x00FFFF
});
gameTitleTxt.anchor.set(0.5, 0);
gameTitleTxt.x = 0;
gameTitleTxt.y = 150;
LK.gui.top.addChild(gameTitleTxt);
// High score display
var highScoreTxt = new Text2('High Score: ' + savedHighScore, {
size: 40,
fill: 0xFFD700
});
highScoreTxt.anchor.set(1, 0);
highScoreTxt.x = -20;
highScoreTxt.y = 20;
LK.gui.topRight.addChild(highScoreTxt);
// Touch controls
game.down = function (x, y, obj) {
isDragging = true;
dragStartX = x;
dragStartY = y;
player.shoot();
};
game.move = function (x, y, obj) {
if (isDragging) {
player.x = x;
player.y = y;
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
game.update = function () {
// Check rapid fire duration
if (rapidFireActive && LK.ticks >= rapidFireEndTime) {
player.deactivateRapidFire();
}
// Spawn enemies
enemySpawnTimer++;
var spawnRate = superChallengeMode ? 30 : 120; // Much faster spawning after 500 score
if (enemySpawnTimer >= spawnRate) {
var maxEnemies = superChallengeMode ? enemiesPerWave * 3 : enemiesPerWave; // Allow 3x more enemies
if (enemies.length < maxEnemies) {
var enemy = new EnemyShip();
enemy.x = Math.random() * 1800 + 100;
enemy.y = -50;
// Apply difficulty scaling
if (superChallengeMode) {
// Super challenging mode: extremely fast, tanky enemies with rapid fire
enemy.speed = 8 + (difficultyLevel - 1) * 1.5;
enemy.health = 150 + (difficultyLevel - 1) * 25;
enemy.shootDelay = Math.max(50, 80 - (difficultyLevel - 1) * 10);
} else {
enemy.speed = 3 + (difficultyLevel - 1) * 0.5;
enemy.health = 50 + (difficultyLevel - 1) * 10;
enemy.shootDelay = Math.max(100, 300 - (difficultyLevel - 1) * 30);
}
enemies.push(enemy);
game.addChild(enemy);
}
enemySpawnTimer = 0;
}
// Spawn power-ups
powerUpSpawnTimer++;
if (powerUpSpawnTimer >= 900) {
if (Math.random() < 0.7) {
var powerUp = new PowerUp();
powerUp.x = Math.random() * 1800 + 100;
powerUp.y = -50;
powerUps.push(powerUp);
game.addChild(powerUp);
}
powerUpSpawnTimer = 0;
}
// Spawn health bonus every 250 score
if (currentScore >= lastHealthBonusScore + 250) {
var healthPowerUp = new HealthPowerUp();
healthPowerUp.x = Math.random() * 1800 + 100;
healthPowerUp.y = -50;
powerUps.push(healthPowerUp);
game.addChild(healthPowerUp);
lastHealthBonusScore = Math.floor(currentScore / 250) * 250;
}
// Spawn boss every 1000 score
if (currentScore >= lastBossScore + bossSpawnInterval && bosses.length == 0) {
var boss = new BossShip();
boss.x = 1024;
boss.y = 200;
bosses.push(boss);
game.addChild(boss);
lastBossScore = Math.floor(currentScore / bossSpawnInterval) * bossSpawnInterval;
bossHealthTxt.visible = true;
bossHealthTxt.setText('Boss Health: ' + boss.health);
}
// Update player bullets
for (var i = playerBullets.length - 1; i >= 0; i--) {
var bullet = playerBullets[i];
if (bullet.lastY >= -50 && bullet.y < -50) {
bullet.destroy();
playerBullets.splice(i, 1);
continue;
}
bullet.lastY = bullet.y;
}
// Update enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var bullet = enemyBullets[i];
if (bullet.lastY <= 2800 && bullet.y > 2800) {
bullet.destroy();
enemyBullets.splice(i, 1);
continue;
}
bullet.lastY = bullet.y;
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.y > 2800) {
enemy.destroy();
enemies.splice(i, 1);
continue;
}
}
// Update bosses
for (var i = bosses.length - 1; i >= 0; i--) {
var boss = bosses[i];
if (boss.y > 2800) {
boss.destroy();
bosses.splice(i, 1);
bossHealthTxt.visible = false;
continue;
}
// Update boss health display
if (bossHealthTxt.visible) {
bossHealthTxt.setText('Boss Health: ' + boss.health);
}
}
// Update explosions
for (var i = explosions.length - 1; i >= 0; i--) {
var explosion = explosions[i];
if (explosion.life <= 0) {
explosion.destroy();
explosions.splice(i, 1);
}
}
// Update power-ups
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
if (powerUp.y > 2800) {
powerUp.destroy();
powerUps.splice(i, 1);
continue;
}
// Check collision with player
if (powerUp.intersects(player)) {
if (powerUp.type === 'rapidfire') {
player.activateRapidFire();
} else if (powerUp.type === 'health') {
player.health = Math.min(player.health + powerUp.healthAmount, 100);
healthTxt.setText('Health: ' + player.health);
if (player.health > 30) {
healthTxt.tint = 0x00FF00;
}
}
LK.getSound('powerup').play();
powerUp.destroy();
powerUps.splice(i, 1);
}
}
// Check player bullet vs enemy collisions
for (var i = playerBullets.length - 1; i >= 0; i--) {
var bullet = playerBullets[i];
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
// Create explosion
for (var k = 0; k < 8; k++) {
var particle = new ExplosionParticle();
particle.x = enemy.x;
particle.y = enemy.y;
explosions.push(particle);
game.addChild(particle);
}
LK.setScore(LK.getScore() + 10);
currentGameEnemiesDestroyed++;
LK.getSound('explosion').play();
bullet.destroy();
playerBullets.splice(i, 1);
enemy.destroy();
enemies.splice(j, 1);
break;
}
}
// Check bullet vs boss collisions
for (var j = bosses.length - 1; j >= 0; j--) {
var boss = bosses[j];
if (bullet.intersects(boss)) {
boss.health -= 25;
// Create explosion
for (var k = 0; k < 5; k++) {
var particle = new ExplosionParticle();
particle.x = bullet.x;
particle.y = bullet.y;
explosions.push(particle);
game.addChild(particle);
}
LK.getSound('hit').play();
bullet.destroy();
playerBullets.splice(i, 1);
// Boss defeated
if (boss.health <= 0) {
// Massive explosion
for (var k = 0; k < 20; k++) {
var particle = new ExplosionParticle();
particle.x = boss.x + (Math.random() - 0.5) * 200;
particle.y = boss.y + (Math.random() - 0.5) * 200;
explosions.push(particle);
game.addChild(particle);
}
LK.setScore(LK.getScore() + 500);
currentGameBossesDefeated++;
LK.getSound('explosion').play();
boss.destroy();
bosses.splice(j, 1);
bossHealthTxt.visible = false;
}
break;
}
}
}
// Check enemy bullet vs player collisions
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var bullet = enemyBullets[i];
if (bullet.intersects(player)) {
player.health -= 10;
healthTxt.setText('Health: ' + player.health);
if (player.health <= 0) {
healthTxt.tint = 0xFF0000;
} else if (player.health <= 30) {
healthTxt.tint = 0xFFFF00;
}
LK.getSound('hit').play();
bullet.destroy();
enemyBullets.splice(i, 1);
if (player.health <= 0) {
// Save game statistics before game over
var currentScore = LK.getScore();
if (currentScore > savedHighScore) {
storage.highScore = currentScore;
}
storage.totalGamesPlayed = savedTotalGamesPlayed + 1;
storage.totalEnemiesDestroyed = savedTotalEnemiesDestroyed + currentGameEnemiesDestroyed;
storage.totalBossesDefeated = savedTotalBossesDefeated + currentGameBossesDefeated;
storage.difficultyLevel = Math.max(savedDifficultyLevel, difficultyLevel);
LK.showGameOver();
}
}
}
// Check enemy vs player collisions
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.intersects(player)) {
player.health -= 20;
healthTxt.setText('Health: ' + player.health);
if (player.health <= 0) {
healthTxt.tint = 0xFF0000;
} else if (player.health <= 30) {
healthTxt.tint = 0xFFFF00;
}
LK.getSound('hit').play();
enemy.destroy();
enemies.splice(i, 1);
if (player.health <= 0) {
// Save game statistics before game over
var currentScore = LK.getScore();
if (currentScore > savedHighScore) {
storage.highScore = currentScore;
}
storage.totalGamesPlayed = savedTotalGamesPlayed + 1;
storage.totalEnemiesDestroyed = savedTotalEnemiesDestroyed + currentGameEnemiesDestroyed;
storage.totalBossesDefeated = savedTotalBossesDefeated + currentGameBossesDefeated;
storage.difficultyLevel = Math.max(savedDifficultyLevel, difficultyLevel);
LK.showGameOver();
}
}
}
// Check boss vs player collisions
for (var i = bosses.length - 1; i >= 0; i--) {
var boss = bosses[i];
if (boss.intersects(player)) {
player.health -= 30;
healthTxt.setText('Health: ' + player.health);
if (player.health <= 0) {
healthTxt.tint = 0xFF0000;
} else if (player.health <= 30) {
healthTxt.tint = 0xFFFF00;
}
LK.getSound('hit').play();
if (player.health <= 0) {
// Save game statistics before game over
var currentScore = LK.getScore();
if (currentScore > savedHighScore) {
storage.highScore = currentScore;
}
storage.totalGamesPlayed = savedTotalGamesPlayed + 1;
storage.totalEnemiesDestroyed = savedTotalEnemiesDestroyed + currentGameEnemiesDestroyed;
storage.totalBossesDefeated = savedTotalBossesDefeated + currentGameBossesDefeated;
storage.difficultyLevel = Math.max(savedDifficultyLevel, difficultyLevel);
LK.showGameOver();
}
}
}
// Update difficulty level every 150 points
var currentScore = LK.getScore();
if (currentScore >= lastDifficultyScore + 150) {
difficultyLevel++;
lastDifficultyScore = Math.floor(currentScore / 150) * 150;
}
// Super challenging mode after 500 score
var superChallengeMode = currentScore >= 500;
// Check for wave completion
if (enemies.length === 0 && enemySpawnTimer >= 120) {
waveNumber++;
enemiesPerWave = Math.min(waveNumber + 2, 8);
// Restore some health on wave completion
player.health = Math.min(player.health + 20, 100);
healthTxt.setText('Health: ' + player.health);
if (player.health > 30) {
healthTxt.tint = 0x00FF00;
}
}
// Win condition
if (LK.getScore() >= 100000) {
// Save game statistics before win
var currentScore = LK.getScore();
if (currentScore > savedHighScore) {
storage.highScore = currentScore;
}
storage.totalGamesPlayed = savedTotalGamesPlayed + 1;
storage.totalEnemiesDestroyed = savedTotalEnemiesDestroyed + currentGameEnemiesDestroyed;
storage.totalBossesDefeated = savedTotalBossesDefeated + currentGameBossesDefeated;
storage.difficultyLevel = Math.max(savedDifficultyLevel, difficultyLevel);
LK.showYouWin();
}
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
};
uzay gemisi. In-Game asset. 2d. High contrast. No shadows
beyaz renkli yıldız. In-Game asset. 2d. High contrast. No shadows
jüpiter. In-Game asset. 2d. High contrast. No shadows
satürn. In-Game asset. 2d. High contrast. No shadows
dünya. In-Game asset. 2d. High contrast. No shadows
asteroit. In-Game asset. 2d. High contrast. No shadows
bonus. In-Game asset. 2d. High contrast. No shadows
mermi. In-Game asset. 2d. High contrast. No shadows
patlama. In-Game asset. 2d. High contrast. No shadows