User prompt
make the upgrade last for 6 seconds
User prompt
make the health pack spawn every 30 seconds
User prompt
make the health pack heal you to max health
User prompt
make the health pack spawn every 10 seconds
User prompt
make the gun power up last for 3 seconds āŖš” Consider importing and using the following plugins: @upit/tween.v1
User prompt
play a shoot should when a enimybullet appers
User prompt
play a shoot sound when ever a player bullet appers
User prompt
play the shoot sound when the player shoots
User prompt
make the gun power up last for 7 seconds āŖš” Consider importing and using the following plugins: @upit/tween.v1
User prompt
make the gun power up spawn every 13 seconbs
User prompt
make a health pack and make it spawn every 50 seconbs
User prompt
make the score stay the same when the boss is hit
User prompt
make the enimeys stop coming when the boss is in the screen and make the enimeys come agen when the boss is dead
User prompt
make the boss stop shooting when its about to hit etch edge
User prompt
make the boss shot 50% slower
User prompt
dellet the health packs
User prompt
make the health packs spawn every 20 seconds
User prompt
make the gun power up shoot three bullets that shoots in three different directions
User prompt
make the gun upgrades spawn every 7 seconds
User prompt
make gun up power ups that spawn every 15 seconds
User prompt
make the player have 10 health
User prompt
make health packs that spawn every 10 seconds and it makes the player at full health
User prompt
make the player have 5 health
User prompt
make the player take 1 damage for etch bullet hits the player
User prompt
make the player nave 70% less health
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BossShip = Container.expand(function () { var self = Container.call(this); var bossGraphics = self.attachAsset('bossShip', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; self.moveDirection = 1; self.shootTimer = 0; self.maxHealth = 50; self.health = self.maxHealth; self.shootPattern = 0; self.patternTimer = 0; // Create boss health bar background var healthBarBg = self.attachAsset('bossHealthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBarBg.y = -140; // Create boss health bar fill var healthBarFill = self.attachAsset('bossHealthBarFill', { anchorX: 0.5, anchorY: 0.5 }); healthBarFill.y = -140; self.healthBarFill = healthBarFill; // Method to update health bar self.updateHealthBar = function () { var healthPercent = self.health / self.maxHealth; self.healthBarFill.scaleX = healthPercent; if (healthPercent > 0.6) { self.healthBarFill.tint = 0xff0000; // Red } else if (healthPercent > 0.3) { self.healthBarFill.tint = 0xff6600; // Orange } else { self.healthBarFill.tint = 0xffff00; // Yellow } }; self.update = function () { self.y += self.speed; // Move side to side self.x += self.moveDirection * 2; if (self.x <= 100 || self.x >= 1948) { self.moveDirection *= -1; } // Handle shooting patterns self.shootTimer--; self.patternTimer++; if (self.patternTimer % 300 === 0) { self.shootPattern = (self.shootPattern + 1) % 3; } if (self.shootTimer <= 0) { self.shootTimer = 20; self.shouldShoot = true; } }; return self; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.update = function () { self.y += self.speed; }; return self; }); var EnemyShip = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemyShip', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.movePattern = Math.random() < 0.5 ? 'straight' : 'zigzag'; self.zigzagTimer = 0; self.zigzagDirection = Math.random() < 0.5 ? -1 : 1; self.shootTimer = Math.random() * 60 + 60; // Random initial shoot delay self.maxHealth = 3; self.health = self.maxHealth; // Create health bar background var healthBarBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBarBg.y = -50; // Create health bar fill var healthBarFill = self.attachAsset('healthBarFill', { anchorX: 0.5, anchorY: 0.5 }); healthBarFill.y = -50; self.healthBarFill = healthBarFill; // Method to update health bar self.updateHealthBar = function () { var healthPercent = self.health / self.maxHealth; self.healthBarFill.scaleX = healthPercent; if (healthPercent > 0.6) { self.healthBarFill.tint = 0x00ff00; // Green } else if (healthPercent > 0.3) { self.healthBarFill.tint = 0xffff00; // Yellow } else { self.healthBarFill.tint = 0xff0000; // Red } }; self.update = function () { self.y += self.speed; if (self.movePattern === 'zigzag') { self.zigzagTimer += 1; if (self.zigzagTimer % 60 === 0) { self.zigzagDirection *= -1; } self.x += self.zigzagDirection * 2; } // Keep enemy within screen bounds if (self.x < 50) self.x = 50; if (self.x > 1998) self.x = 1998; // Handle shooting self.shootTimer--; if (self.shootTimer <= 0) { self.shootTimer = Math.random() * 120 + 90; // Slower random shoot interval self.shouldShoot = true; } }; return self; }); var PlayerBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('playerBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -12; self.update = function () { self.y += self.speed; }; return self; }); var PlayerShip = Container.expand(function () { var self = Container.call(this); var shipGraphics = self.attachAsset('playerShip', { anchorX: 0.5, anchorY: 0.5 }); self.maxHealth = 15; self.health = self.maxHealth; // Create health bar background var healthBarBg = self.attachAsset('playerHealthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBarBg.y = -80; // Create health bar fill var healthBarFill = self.attachAsset('playerHealthBarFill', { anchorX: 0.5, anchorY: 0.5 }); healthBarFill.y = -80; self.healthBarFill = healthBarFill; // Method to update health bar self.updateHealthBar = function () { var healthPercent = self.health / self.maxHealth; self.healthBarFill.scaleX = healthPercent; if (healthPercent > 0.6) { self.healthBarFill.tint = 0x00ff00; // Green } else if (healthPercent > 0.3) { self.healthBarFill.tint = 0xffff00; // Yellow } else { self.healthBarFill.tint = 0xff0000; // Red } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000011 }); /**** * Game Code ****/ // Game variables var playerShip; var playerBullets = []; var enemyBullets = []; var enemyShips = []; var bossShips = []; var difficultyLevel = 1; var enemySpawnRate = 120; // frames between spawns var bulletFireRate = 15; // frames between shots var dragNode = null; var lastBossScore = 0; // UI Elements var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Initialize player ship playerShip = game.addChild(new PlayerShip()); playerShip.x = 1024; // Center horizontally playerShip.y = 2400; // Near bottom of screen // Update score display function updateScore() { scoreTxt.setText('Score: ' + LK.getScore()); } // Handle movement function handleMove(x, y, obj) { if (dragNode) { dragNode.x = x; dragNode.y = y; // Keep player within screen bounds if (dragNode.x < 40) dragNode.x = 40; if (dragNode.x > 2008) dragNode.x = 2008; if (dragNode.y < 200) dragNode.y = 200; if (dragNode.y > 2600) dragNode.y = 2600; } } // Event handlers game.move = handleMove; game.down = function (x, y, obj) { dragNode = playerShip; handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; // Main game update loop game.update = function () { // Fire player bullets if (LK.ticks % bulletFireRate === 0) { var newBullet = new PlayerBullet(); newBullet.x = playerShip.x; newBullet.y = playerShip.y - 60; newBullet.lastY = newBullet.y; playerBullets.push(newBullet); game.addChild(newBullet); LK.getSound('shoot').play(); } // Spawn boss every 1000 points var currentScore = LK.getScore(); if (Math.floor(currentScore / 1000) > Math.floor(lastBossScore / 1000) && bossShips.length === 0) { var newBoss = new BossShip(); newBoss.x = 1024; // Center horizontally newBoss.y = -125; newBoss.lastY = newBoss.y; newBoss.lastIntersecting = false; bossShips.push(newBoss); game.addChild(newBoss); lastBossScore = currentScore; } // Spawn enemies if (LK.ticks % enemySpawnRate === 0) { var newEnemy = new EnemyShip(); newEnemy.x = Math.random() * 1800 + 124; // Random x position within bounds newEnemy.y = -50; newEnemy.lastY = newEnemy.y; newEnemy.lastIntersecting = false; enemyShips.push(newEnemy); game.addChild(newEnemy); } // Update and check player bullets for (var i = playerBullets.length - 1; i >= 0; i--) { var bullet = playerBullets[i]; // Remove bullets that go off screen if (bullet.lastY >= -25 && bullet.y < -25) { bullet.destroy(); playerBullets.splice(i, 1); continue; } // Check bullet-enemy collisions var bulletHit = false; for (var j = enemyShips.length - 1; j >= 0; j--) { var enemy = enemyShips[j]; if (bullet.intersects(enemy)) { // Damage enemy enemy.health--; enemy.updateHealthBar(); LK.setScore(LK.getScore() + 5); updateScore(); // Flash effect on enemy LK.effects.flashObject(enemy, 0xffffff, 200); bullet.destroy(); playerBullets.splice(i, 1); bulletHit = true; // Check if enemy is destroyed if (enemy.health <= 0) { LK.setScore(LK.getScore() + 5); // Bonus points for destroying enemy updateScore(); LK.getSound('enemyDestroy').play(); enemy.destroy(); enemyShips.splice(j, 1); } break; } } // Check bullet-boss collisions if (!bulletHit) { for (var b = bossShips.length - 1; b >= 0; b--) { var boss = bossShips[b]; if (bullet.intersects(boss)) { // Damage boss boss.health--; boss.updateHealthBar(); LK.setScore(LK.getScore() + 10); updateScore(); // Flash effect on boss LK.effects.flashObject(boss, 0xffffff, 200); bullet.destroy(); playerBullets.splice(i, 1); bulletHit = true; // Check if boss is destroyed if (boss.health <= 0) { LK.setScore(LK.getScore() + 500); // Big bonus for destroying boss updateScore(); LK.getSound('enemyDestroy').play(); boss.destroy(); bossShips.splice(b, 1); } break; } } } if (!bulletHit) { bullet.lastY = bullet.y; } } // Update and check enemies for (var k = enemyShips.length - 1; k >= 0; k--) { var enemy = enemyShips[k]; // Create enemy bullet if enemy should shoot if (enemy.shouldShoot) { var newEnemyBullet = new EnemyBullet(); newEnemyBullet.x = enemy.x; newEnemyBullet.y = enemy.y + 40; newEnemyBullet.lastY = newEnemyBullet.y; newEnemyBullet.lastIntersecting = false; enemyBullets.push(newEnemyBullet); game.addChild(newEnemyBullet); enemy.shouldShoot = false; } // Check if enemy reached bottom edge - instant kill player if (enemy.lastY <= 2780 && enemy.y > 2780) { // Enemy reached bottom - instant kill player playerShip.health = 0; playerShip.updateHealthBar(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Check player-enemy collision var currentIntersecting = enemy.intersects(playerShip); if (!enemy.lastIntersecting && currentIntersecting) { // Damage player playerShip.health--; playerShip.updateHealthBar(); // Flash effect on player LK.effects.flashObject(playerShip, 0xff0000, 300); // Destroy enemy enemy.destroy(); enemyShips.splice(k, 1); continue; } enemy.lastY = enemy.y; enemy.lastIntersecting = currentIntersecting; } // Update and check bosses for (var n = bossShips.length - 1; n >= 0; n--) { var boss = bossShips[n]; // Create boss bullets with different patterns if (boss.shouldShoot) { if (boss.shootPattern === 0) { // Single shot at player var newBossBullet = new EnemyBullet(); newBossBullet.x = boss.x; newBossBullet.y = boss.y + 125; newBossBullet.lastY = newBossBullet.y; newBossBullet.lastIntersecting = false; enemyBullets.push(newBossBullet); game.addChild(newBossBullet); } else if (boss.shootPattern === 1) { // Triple shot for (var s = -1; s <= 1; s++) { var newBossBullet = new EnemyBullet(); newBossBullet.x = boss.x + s * 60; newBossBullet.y = boss.y + 125; newBossBullet.lastY = newBossBullet.y; newBossBullet.lastIntersecting = false; enemyBullets.push(newBossBullet); game.addChild(newBossBullet); } } else { // Spread shot (5 bullets) for (var s = -2; s <= 2; s++) { var newBossBullet = new EnemyBullet(); newBossBullet.x = boss.x + s * 40; newBossBullet.y = boss.y + 125; newBossBullet.lastY = newBossBullet.y; newBossBullet.lastIntersecting = false; enemyBullets.push(newBossBullet); game.addChild(newBossBullet); } } boss.shouldShoot = false; } // Check if boss reached bottom edge - instant kill player if (boss.lastY <= 2780 && boss.y > 2780) { playerShip.health = 0; playerShip.updateHealthBar(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Check player-boss collision var bossPlayerIntersecting = boss.intersects(playerShip); if (!boss.lastIntersecting && bossPlayerIntersecting) { // Damage player playerShip.health -= 2; // Boss does more damage playerShip.updateHealthBar(); // Flash effect on player LK.effects.flashObject(playerShip, 0xff0000, 300); } boss.lastY = boss.y; boss.lastIntersecting = bossPlayerIntersecting; } // Update and check enemy bullets for (var m = enemyBullets.length - 1; m >= 0; m--) { var enemyBullet = enemyBullets[m]; // Remove bullets that go off screen if (enemyBullet.lastY <= 2780 && enemyBullet.y > 2780) { enemyBullet.destroy(); enemyBullets.splice(m, 1); continue; } // Check enemy bullet-player collision var bulletPlayerIntersecting = enemyBullet.intersects(playerShip); if (!enemyBullet.lastIntersecting && bulletPlayerIntersecting) { // Damage player playerShip.health--; playerShip.updateHealthBar(); // Flash effect on player LK.effects.flashObject(playerShip, 0xff0000, 300); // Destroy bullet enemyBullet.destroy(); enemyBullets.splice(m, 1); continue; } enemyBullet.lastY = enemyBullet.y; enemyBullet.lastIntersecting = bulletPlayerIntersecting; } // Check if player is dead if (playerShip.health <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Increase difficulty over time if (LK.ticks % 1800 === 0) { // Every 30 seconds difficultyLevel++; if (enemySpawnRate > 30) { enemySpawnRate -= 10; } if (bulletFireRate > 8 && difficultyLevel % 3 === 0) { bulletFireRate -= 1; } } }; // Start background music LK.playMusic('gameMusic');
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BossShip = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('bossShip', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.moveDirection = 1;
self.shootTimer = 0;
self.maxHealth = 50;
self.health = self.maxHealth;
self.shootPattern = 0;
self.patternTimer = 0;
// Create boss health bar background
var healthBarBg = self.attachAsset('bossHealthBarBg', {
anchorX: 0.5,
anchorY: 0.5
});
healthBarBg.y = -140;
// Create boss health bar fill
var healthBarFill = self.attachAsset('bossHealthBarFill', {
anchorX: 0.5,
anchorY: 0.5
});
healthBarFill.y = -140;
self.healthBarFill = healthBarFill;
// Method to update health bar
self.updateHealthBar = function () {
var healthPercent = self.health / self.maxHealth;
self.healthBarFill.scaleX = healthPercent;
if (healthPercent > 0.6) {
self.healthBarFill.tint = 0xff0000; // Red
} else if (healthPercent > 0.3) {
self.healthBarFill.tint = 0xff6600; // Orange
} else {
self.healthBarFill.tint = 0xffff00; // Yellow
}
};
self.update = function () {
self.y += self.speed;
// Move side to side
self.x += self.moveDirection * 2;
if (self.x <= 100 || self.x >= 1948) {
self.moveDirection *= -1;
}
// Handle shooting patterns
self.shootTimer--;
self.patternTimer++;
if (self.patternTimer % 300 === 0) {
self.shootPattern = (self.shootPattern + 1) % 3;
}
if (self.shootTimer <= 0) {
self.shootTimer = 20;
self.shouldShoot = true;
}
};
return self;
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.y += self.speed;
};
return self;
});
var EnemyShip = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemyShip', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.movePattern = Math.random() < 0.5 ? 'straight' : 'zigzag';
self.zigzagTimer = 0;
self.zigzagDirection = Math.random() < 0.5 ? -1 : 1;
self.shootTimer = Math.random() * 60 + 60; // Random initial shoot delay
self.maxHealth = 3;
self.health = self.maxHealth;
// Create health bar background
var healthBarBg = self.attachAsset('healthBarBg', {
anchorX: 0.5,
anchorY: 0.5
});
healthBarBg.y = -50;
// Create health bar fill
var healthBarFill = self.attachAsset('healthBarFill', {
anchorX: 0.5,
anchorY: 0.5
});
healthBarFill.y = -50;
self.healthBarFill = healthBarFill;
// Method to update health bar
self.updateHealthBar = function () {
var healthPercent = self.health / self.maxHealth;
self.healthBarFill.scaleX = healthPercent;
if (healthPercent > 0.6) {
self.healthBarFill.tint = 0x00ff00; // Green
} else if (healthPercent > 0.3) {
self.healthBarFill.tint = 0xffff00; // Yellow
} else {
self.healthBarFill.tint = 0xff0000; // Red
}
};
self.update = function () {
self.y += self.speed;
if (self.movePattern === 'zigzag') {
self.zigzagTimer += 1;
if (self.zigzagTimer % 60 === 0) {
self.zigzagDirection *= -1;
}
self.x += self.zigzagDirection * 2;
}
// Keep enemy within screen bounds
if (self.x < 50) self.x = 50;
if (self.x > 1998) self.x = 1998;
// Handle shooting
self.shootTimer--;
if (self.shootTimer <= 0) {
self.shootTimer = Math.random() * 120 + 90; // Slower random shoot interval
self.shouldShoot = true;
}
};
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('playerBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.update = function () {
self.y += self.speed;
};
return self;
});
var PlayerShip = Container.expand(function () {
var self = Container.call(this);
var shipGraphics = self.attachAsset('playerShip', {
anchorX: 0.5,
anchorY: 0.5
});
self.maxHealth = 15;
self.health = self.maxHealth;
// Create health bar background
var healthBarBg = self.attachAsset('playerHealthBarBg', {
anchorX: 0.5,
anchorY: 0.5
});
healthBarBg.y = -80;
// Create health bar fill
var healthBarFill = self.attachAsset('playerHealthBarFill', {
anchorX: 0.5,
anchorY: 0.5
});
healthBarFill.y = -80;
self.healthBarFill = healthBarFill;
// Method to update health bar
self.updateHealthBar = function () {
var healthPercent = self.health / self.maxHealth;
self.healthBarFill.scaleX = healthPercent;
if (healthPercent > 0.6) {
self.healthBarFill.tint = 0x00ff00; // Green
} else if (healthPercent > 0.3) {
self.healthBarFill.tint = 0xffff00; // Yellow
} else {
self.healthBarFill.tint = 0xff0000; // Red
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000011
});
/****
* Game Code
****/
// Game variables
var playerShip;
var playerBullets = [];
var enemyBullets = [];
var enemyShips = [];
var bossShips = [];
var difficultyLevel = 1;
var enemySpawnRate = 120; // frames between spawns
var bulletFireRate = 15; // frames between shots
var dragNode = null;
var lastBossScore = 0;
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Initialize player ship
playerShip = game.addChild(new PlayerShip());
playerShip.x = 1024; // Center horizontally
playerShip.y = 2400; // Near bottom of screen
// Update score display
function updateScore() {
scoreTxt.setText('Score: ' + LK.getScore());
}
// Handle movement
function handleMove(x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
// Keep player within screen bounds
if (dragNode.x < 40) dragNode.x = 40;
if (dragNode.x > 2008) dragNode.x = 2008;
if (dragNode.y < 200) dragNode.y = 200;
if (dragNode.y > 2600) dragNode.y = 2600;
}
}
// Event handlers
game.move = handleMove;
game.down = function (x, y, obj) {
dragNode = playerShip;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Main game update loop
game.update = function () {
// Fire player bullets
if (LK.ticks % bulletFireRate === 0) {
var newBullet = new PlayerBullet();
newBullet.x = playerShip.x;
newBullet.y = playerShip.y - 60;
newBullet.lastY = newBullet.y;
playerBullets.push(newBullet);
game.addChild(newBullet);
LK.getSound('shoot').play();
}
// Spawn boss every 1000 points
var currentScore = LK.getScore();
if (Math.floor(currentScore / 1000) > Math.floor(lastBossScore / 1000) && bossShips.length === 0) {
var newBoss = new BossShip();
newBoss.x = 1024; // Center horizontally
newBoss.y = -125;
newBoss.lastY = newBoss.y;
newBoss.lastIntersecting = false;
bossShips.push(newBoss);
game.addChild(newBoss);
lastBossScore = currentScore;
}
// Spawn enemies
if (LK.ticks % enemySpawnRate === 0) {
var newEnemy = new EnemyShip();
newEnemy.x = Math.random() * 1800 + 124; // Random x position within bounds
newEnemy.y = -50;
newEnemy.lastY = newEnemy.y;
newEnemy.lastIntersecting = false;
enemyShips.push(newEnemy);
game.addChild(newEnemy);
}
// Update and check player bullets
for (var i = playerBullets.length - 1; i >= 0; i--) {
var bullet = playerBullets[i];
// Remove bullets that go off screen
if (bullet.lastY >= -25 && bullet.y < -25) {
bullet.destroy();
playerBullets.splice(i, 1);
continue;
}
// Check bullet-enemy collisions
var bulletHit = false;
for (var j = enemyShips.length - 1; j >= 0; j--) {
var enemy = enemyShips[j];
if (bullet.intersects(enemy)) {
// Damage enemy
enemy.health--;
enemy.updateHealthBar();
LK.setScore(LK.getScore() + 5);
updateScore();
// Flash effect on enemy
LK.effects.flashObject(enemy, 0xffffff, 200);
bullet.destroy();
playerBullets.splice(i, 1);
bulletHit = true;
// Check if enemy is destroyed
if (enemy.health <= 0) {
LK.setScore(LK.getScore() + 5); // Bonus points for destroying enemy
updateScore();
LK.getSound('enemyDestroy').play();
enemy.destroy();
enemyShips.splice(j, 1);
}
break;
}
}
// Check bullet-boss collisions
if (!bulletHit) {
for (var b = bossShips.length - 1; b >= 0; b--) {
var boss = bossShips[b];
if (bullet.intersects(boss)) {
// Damage boss
boss.health--;
boss.updateHealthBar();
LK.setScore(LK.getScore() + 10);
updateScore();
// Flash effect on boss
LK.effects.flashObject(boss, 0xffffff, 200);
bullet.destroy();
playerBullets.splice(i, 1);
bulletHit = true;
// Check if boss is destroyed
if (boss.health <= 0) {
LK.setScore(LK.getScore() + 500); // Big bonus for destroying boss
updateScore();
LK.getSound('enemyDestroy').play();
boss.destroy();
bossShips.splice(b, 1);
}
break;
}
}
}
if (!bulletHit) {
bullet.lastY = bullet.y;
}
}
// Update and check enemies
for (var k = enemyShips.length - 1; k >= 0; k--) {
var enemy = enemyShips[k];
// Create enemy bullet if enemy should shoot
if (enemy.shouldShoot) {
var newEnemyBullet = new EnemyBullet();
newEnemyBullet.x = enemy.x;
newEnemyBullet.y = enemy.y + 40;
newEnemyBullet.lastY = newEnemyBullet.y;
newEnemyBullet.lastIntersecting = false;
enemyBullets.push(newEnemyBullet);
game.addChild(newEnemyBullet);
enemy.shouldShoot = false;
}
// Check if enemy reached bottom edge - instant kill player
if (enemy.lastY <= 2780 && enemy.y > 2780) {
// Enemy reached bottom - instant kill player
playerShip.health = 0;
playerShip.updateHealthBar();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Check player-enemy collision
var currentIntersecting = enemy.intersects(playerShip);
if (!enemy.lastIntersecting && currentIntersecting) {
// Damage player
playerShip.health--;
playerShip.updateHealthBar();
// Flash effect on player
LK.effects.flashObject(playerShip, 0xff0000, 300);
// Destroy enemy
enemy.destroy();
enemyShips.splice(k, 1);
continue;
}
enemy.lastY = enemy.y;
enemy.lastIntersecting = currentIntersecting;
}
// Update and check bosses
for (var n = bossShips.length - 1; n >= 0; n--) {
var boss = bossShips[n];
// Create boss bullets with different patterns
if (boss.shouldShoot) {
if (boss.shootPattern === 0) {
// Single shot at player
var newBossBullet = new EnemyBullet();
newBossBullet.x = boss.x;
newBossBullet.y = boss.y + 125;
newBossBullet.lastY = newBossBullet.y;
newBossBullet.lastIntersecting = false;
enemyBullets.push(newBossBullet);
game.addChild(newBossBullet);
} else if (boss.shootPattern === 1) {
// Triple shot
for (var s = -1; s <= 1; s++) {
var newBossBullet = new EnemyBullet();
newBossBullet.x = boss.x + s * 60;
newBossBullet.y = boss.y + 125;
newBossBullet.lastY = newBossBullet.y;
newBossBullet.lastIntersecting = false;
enemyBullets.push(newBossBullet);
game.addChild(newBossBullet);
}
} else {
// Spread shot (5 bullets)
for (var s = -2; s <= 2; s++) {
var newBossBullet = new EnemyBullet();
newBossBullet.x = boss.x + s * 40;
newBossBullet.y = boss.y + 125;
newBossBullet.lastY = newBossBullet.y;
newBossBullet.lastIntersecting = false;
enemyBullets.push(newBossBullet);
game.addChild(newBossBullet);
}
}
boss.shouldShoot = false;
}
// Check if boss reached bottom edge - instant kill player
if (boss.lastY <= 2780 && boss.y > 2780) {
playerShip.health = 0;
playerShip.updateHealthBar();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Check player-boss collision
var bossPlayerIntersecting = boss.intersects(playerShip);
if (!boss.lastIntersecting && bossPlayerIntersecting) {
// Damage player
playerShip.health -= 2; // Boss does more damage
playerShip.updateHealthBar();
// Flash effect on player
LK.effects.flashObject(playerShip, 0xff0000, 300);
}
boss.lastY = boss.y;
boss.lastIntersecting = bossPlayerIntersecting;
}
// Update and check enemy bullets
for (var m = enemyBullets.length - 1; m >= 0; m--) {
var enemyBullet = enemyBullets[m];
// Remove bullets that go off screen
if (enemyBullet.lastY <= 2780 && enemyBullet.y > 2780) {
enemyBullet.destroy();
enemyBullets.splice(m, 1);
continue;
}
// Check enemy bullet-player collision
var bulletPlayerIntersecting = enemyBullet.intersects(playerShip);
if (!enemyBullet.lastIntersecting && bulletPlayerIntersecting) {
// Damage player
playerShip.health--;
playerShip.updateHealthBar();
// Flash effect on player
LK.effects.flashObject(playerShip, 0xff0000, 300);
// Destroy bullet
enemyBullet.destroy();
enemyBullets.splice(m, 1);
continue;
}
enemyBullet.lastY = enemyBullet.y;
enemyBullet.lastIntersecting = bulletPlayerIntersecting;
}
// Check if player is dead
if (playerShip.health <= 0) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Increase difficulty over time
if (LK.ticks % 1800 === 0) {
// Every 30 seconds
difficultyLevel++;
if (enemySpawnRate > 30) {
enemySpawnRate -= 10;
}
if (bulletFireRate > 8 && difficultyLevel % 3 === 0) {
bulletFireRate -= 1;
}
}
};
// Start background music
LK.playMusic('gameMusic');
boss enimey space ship. In-Game asset. 2d. High contrast. No shadows
enimy space ship. In-Game asset. 2d. High contrast. No shadows
player space ship. In-Game asset. 2d. High contrast. No shadows
bullet. In-Game asset. 2d. High contrast. No shadows
shot gun. In-Game asset. 2d. High contrast. No shadows
first aid kit. In-Game asset. 2d. High contrast. No shadows