User prompt
backgrounds should be fully visible and their opacity should be full
User prompt
Let's collect perrys and save them unlimitedly. Let's have 2 perrys at the beginning of the game and have a button to use perrys. Let's not spam perrys So there will be different perry for each weapon with a cooldown time ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add something called "perry" to the game other than a powerup. When we get this, our character will make a very special hit with a special animation, of course suitable for the weapon. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
some weapons are so powerful bring nerf add background assets and Add a hand that goes up and down with every shot and the bullets come out of our hands ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Okay, every 3 levels, our weapon should change and the enemies should get stronger every time our weapon is changed, and when we get a power-up, our color should change, like 1.5-2 seconds before the power-up ends Then let's go back and forth between the power-up color and our own color, let our color change and then normalize, I think you understand. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let the game have 50 levels, each level has different enemies and different weapons, let the boss come every 10 levels, add parrying to the game like in Cuphead, like a special ability but different parrying for each weapon.
Code edit (1 edits merged)
Please save this source code
User prompt
Run & Gun Adventure
Initial prompt
make cuphead
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('boss', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 20;
self.maxHealth = 20;
self.speed = 2;
self.direction = 1;
self.shootCooldown = 0;
self.shootInterval = 60;
self.phase = 1;
self.points = 1000;
self.update = function () {
// Boss movement pattern
self.y += self.speed * self.direction;
if (self.y > 600 || self.y < 300) {
self.direction *= -1;
}
self.shootCooldown++;
// Different attack patterns based on phase
if (self.health < self.maxHealth * 0.5 && self.phase === 1) {
self.phase = 2;
self.shootInterval = 40;
}
if (self.shootCooldown >= self.shootInterval) {
self.shootCooldown = 0;
return self.phase; // Return phase for different bullet patterns
}
return 0;
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
return true; // Boss destroyed
}
tween(bossGraphics, {
tint: 0xffffff
}, {
duration: 100,
onFinish: function onFinish() {
bossGraphics.tint = 0xffffff;
}
});
bossGraphics.tint = 0xff0000;
return false;
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 2;
self.speed = -2;
self.shootCooldown = 0;
self.shootInterval = 120;
self.points = 100;
self.update = function () {
self.x += self.speed;
self.shootCooldown++;
if (self.shootCooldown >= self.shootInterval) {
self.shootCooldown = 0;
return true; // Signal to shoot
}
return false;
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
return true; // Enemy destroyed
}
tween(enemyGraphics, {
tint: 0xffffff
}, {
duration: 100,
onFinish: function onFinish() {
enemyGraphics.tint = 0xffffff;
}
});
enemyGraphics.tint = 0xff0000;
return false;
};
return self;
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = -8;
self.speedY = 0;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
};
return self;
});
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 3;
self.maxHealth = 3;
self.shootCooldown = 0;
self.shootInterval = 20;
self.invulnerable = 0;
self.powerupTime = 0;
self.powerupType = null;
self.update = function () {
if (self.invulnerable > 0) {
self.invulnerable--;
self.alpha = Math.sin(self.invulnerable * 0.3) > 0 ? 1 : 0.5;
} else {
self.alpha = 1;
}
if (self.powerupTime > 0) {
self.powerupTime--;
if (self.powerupTime === 0) {
self.powerupType = null;
self.shootInterval = 20;
}
}
self.shootCooldown++;
};
self.takeDamage = function () {
if (self.invulnerable > 0) return false;
self.health--;
self.invulnerable = 120; // 2 seconds of invulnerability
if (self.health <= 0) {
return true; // Hero destroyed
}
LK.effects.flashObject(self, 0xff0000, 500);
return false;
};
self.canShoot = function () {
if (self.shootCooldown >= self.shootInterval) {
self.shootCooldown = 0;
return true;
}
return false;
};
self.applyPowerup = function (type) {
self.powerupType = type;
self.powerupTime = 600; // 10 seconds
if (type === 'rapid') {
self.shootInterval = 10;
}
};
return self;
});
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('heroBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.damage = 1;
self.update = function () {
self.x += self.speed;
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupGraphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = Math.random() > 0.5 ? 'rapid' : 'triple';
self.speed = -3;
self.update = function () {
self.x += self.speed;
self.rotation += 0.05;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
game.setBackgroundColor(0x1a1a2e);
// Game variables
var hero;
var heroBullets = [];
var enemies = [];
var enemyBullets = [];
var powerups = [];
var boss = null;
var wave = 1;
var enemiesSpawned = 0;
var enemiesPerWave = 5;
var spawnCooldown = 0;
var gameStarted = false;
var isDragging = false;
var dragOffsetY = 0;
// Ground
var ground = LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 2732 - 100
});
game.addChild(ground);
// Hero
hero = new Hero();
hero.x = 200;
hero.y = 2732 - 200;
game.addChild(hero);
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.y = 20;
LK.gui.top.addChild(scoreTxt);
// Health display
var healthContainer = new Container();
LK.gui.topRight.addChild(healthContainer);
healthContainer.x = -120;
healthContainer.y = 40;
var healthBarBg = LK.getAsset('healthBarBg', {
anchorX: 0.5,
anchorY: 0.5
});
healthContainer.addChild(healthBarBg);
var healthBar = LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 0.5,
x: -100
});
healthContainer.addChild(healthBar);
// Wave text
var waveTxt = new Text2('Wave 1', {
size: 80,
fill: 0xFFFF00
});
waveTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(waveTxt);
waveTxt.alpha = 0;
// Touch controls
game.down = function (x, y, obj) {
var heroGlobalPos = hero.toGlobal({
x: 0,
y: 0
});
var localPos = game.toLocal(heroGlobalPos);
if (Math.abs(x - localPos.x) < 100 && Math.abs(y - localPos.y) < 100) {
isDragging = true;
dragOffsetY = y - hero.y;
gameStarted = true;
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
game.move = function (x, y, obj) {
if (isDragging) {
hero.y = Math.max(300, Math.min(2732 - 200, y - dragOffsetY));
}
};
// Helper functions
function spawnEnemy() {
var enemy = new Enemy();
enemy.x = 2048 + 50;
enemy.y = 300 + Math.random() * (2732 - 600);
enemies.push(enemy);
game.addChild(enemy);
}
function spawnBoss() {
boss = new Boss();
boss.x = 2048 - 200;
boss.y = 450;
game.addChild(boss);
// Show boss warning
waveTxt.setText('BOSS!');
waveTxt.alpha = 1;
tween(waveTxt, {
alpha: 0
}, {
duration: 2000
});
}
function spawnPowerup(x, y) {
if (Math.random() < 0.2) {
// 20% chance
var powerup = new PowerUp();
powerup.x = x;
powerup.y = y;
powerups.push(powerup);
game.addChild(powerup);
}
}
function shootHeroBullet() {
if (hero.powerupType === 'triple') {
// Triple shot
for (var i = -1; i <= 1; i++) {
var bullet = new HeroBullet();
bullet.x = hero.x + 40;
bullet.y = hero.y + i * 30;
heroBullets.push(bullet);
game.addChild(bullet);
}
} else {
// Normal shot
var bullet = new HeroBullet();
bullet.x = hero.x + 40;
bullet.y = hero.y;
heroBullets.push(bullet);
game.addChild(bullet);
}
LK.getSound('shoot').play();
}
function shootEnemyBullet(enemy) {
var bullet = new EnemyBullet();
bullet.x = enemy.x - 30;
bullet.y = enemy.y;
enemyBullets.push(bullet);
game.addChild(bullet);
LK.getSound('enemyShoot').play();
}
function shootBossBullet(phase) {
if (phase === 1) {
// Single aimed shot
var bullet = new EnemyBullet();
bullet.x = boss.x - 75;
bullet.y = boss.y;
var angle = Math.atan2(hero.y - boss.y, hero.x - boss.x);
bullet.speedX = Math.cos(angle) * 10;
bullet.speedY = Math.sin(angle) * 10;
enemyBullets.push(bullet);
game.addChild(bullet);
} else if (phase === 2) {
// Spread shot
for (var i = -2; i <= 2; i++) {
var bullet = new EnemyBullet();
bullet.x = boss.x - 75;
bullet.y = boss.y;
bullet.speedX = -8;
bullet.speedY = i * 2;
enemyBullets.push(bullet);
game.addChild(bullet);
}
}
LK.getSound('enemyShoot').play();
}
// Game update
game.update = function () {
if (!gameStarted) return;
// Update health bar
healthBar.scale.x = hero.health / hero.maxHealth;
// Spawn enemies
if (!boss && enemiesSpawned < enemiesPerWave) {
spawnCooldown++;
if (spawnCooldown >= 120) {
spawnCooldown = 0;
spawnEnemy();
enemiesSpawned++;
}
}
// Check for next wave
if (!boss && enemiesSpawned >= enemiesPerWave && enemies.length === 0) {
wave++;
enemiesSpawned = 0;
enemiesPerWave = Math.min(10, enemiesPerWave + 1);
if (wave % 5 === 0) {
// Boss wave
spawnBoss();
} else {
// Normal wave
waveTxt.setText('Wave ' + wave);
waveTxt.alpha = 1;
tween(waveTxt, {
alpha: 0
}, {
duration: 2000
});
}
}
// Hero shooting
if (hero.canShoot()) {
shootHeroBullet();
}
// Update hero bullets
for (var i = heroBullets.length - 1; i >= 0; i--) {
var bullet = heroBullets[i];
if (bullet.x > 2048 + 50) {
bullet.destroy();
heroBullets.splice(i, 1);
continue;
}
// Check enemy collisions
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
if (enemy.takeDamage(bullet.damage)) {
// Enemy destroyed
LK.setScore(LK.getScore() + enemy.points);
scoreTxt.setText('Score: ' + LK.getScore());
spawnPowerup(enemy.x, enemy.y);
enemy.destroy();
enemies.splice(j, 1);
LK.getSound('enemyDestroy').play();
}
bullet.destroy();
heroBullets.splice(i, 1);
break;
}
}
// Check boss collision
if (boss && bullet.intersects(boss)) {
if (boss.takeDamage(bullet.damage)) {
// Boss destroyed
LK.setScore(LK.getScore() + boss.points);
scoreTxt.setText('Score: ' + LK.getScore());
spawnPowerup(boss.x, boss.y);
boss.destroy();
boss = null;
LK.getSound('enemyDestroy').play();
}
bullet.destroy();
heroBullets.splice(i, 1);
}
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.x < -50) {
enemy.destroy();
enemies.splice(i, 1);
continue;
}
if (enemy.update()) {
shootEnemyBullet(enemy);
}
// Check collision with hero
if (enemy.intersects(hero)) {
if (hero.takeDamage()) {
LK.showGameOver();
}
enemy.destroy();
enemies.splice(i, 1);
LK.getSound('hit').play();
}
}
// Update boss
if (boss) {
var phase = boss.update();
if (phase > 0) {
shootBossBullet(phase);
}
// Check collision with hero
if (boss.intersects(hero)) {
if (hero.takeDamage()) {
LK.showGameOver();
}
LK.getSound('hit').play();
}
}
// Update enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var bullet = enemyBullets[i];
if (bullet.x < -50 || bullet.x > 2048 + 50 || bullet.y < -50 || bullet.y > 2732 + 50) {
bullet.destroy();
enemyBullets.splice(i, 1);
continue;
}
// Check collision with hero
if (bullet.intersects(hero)) {
if (hero.takeDamage()) {
LK.showGameOver();
}
bullet.destroy();
enemyBullets.splice(i, 1);
LK.getSound('hit').play();
}
}
// Update powerups
for (var i = powerups.length - 1; i >= 0; i--) {
var powerup = powerups[i];
if (powerup.x < -50) {
powerup.destroy();
powerups.splice(i, 1);
continue;
}
// Check collision with hero
if (powerup.intersects(hero)) {
hero.applyPowerup(powerup.type);
powerup.destroy();
powerups.splice(i, 1);
LK.getSound('powerupCollect').play();
}
}
};
// Start music
LK.playMusic('bgMusic'); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,519 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Boss = Container.expand(function () {
+ var self = Container.call(this);
+ var bossGraphics = self.attachAsset('boss', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 20;
+ self.maxHealth = 20;
+ self.speed = 2;
+ self.direction = 1;
+ self.shootCooldown = 0;
+ self.shootInterval = 60;
+ self.phase = 1;
+ self.points = 1000;
+ self.update = function () {
+ // Boss movement pattern
+ self.y += self.speed * self.direction;
+ if (self.y > 600 || self.y < 300) {
+ self.direction *= -1;
+ }
+ self.shootCooldown++;
+ // Different attack patterns based on phase
+ if (self.health < self.maxHealth * 0.5 && self.phase === 1) {
+ self.phase = 2;
+ self.shootInterval = 40;
+ }
+ if (self.shootCooldown >= self.shootInterval) {
+ self.shootCooldown = 0;
+ return self.phase; // Return phase for different bullet patterns
+ }
+ return 0;
+ };
+ self.takeDamage = function (damage) {
+ self.health -= damage;
+ if (self.health <= 0) {
+ return true; // Boss destroyed
+ }
+ tween(bossGraphics, {
+ tint: 0xffffff
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ bossGraphics.tint = 0xffffff;
+ }
+ });
+ bossGraphics.tint = 0xff0000;
+ return false;
+ };
+ return self;
+});
+var Enemy = Container.expand(function () {
+ var self = Container.call(this);
+ var enemyGraphics = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 2;
+ self.speed = -2;
+ self.shootCooldown = 0;
+ self.shootInterval = 120;
+ self.points = 100;
+ self.update = function () {
+ self.x += self.speed;
+ self.shootCooldown++;
+ if (self.shootCooldown >= self.shootInterval) {
+ self.shootCooldown = 0;
+ return true; // Signal to shoot
+ }
+ return false;
+ };
+ self.takeDamage = function (damage) {
+ self.health -= damage;
+ if (self.health <= 0) {
+ return true; // Enemy destroyed
+ }
+ tween(enemyGraphics, {
+ tint: 0xffffff
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ enemyGraphics.tint = 0xffffff;
+ }
+ });
+ enemyGraphics.tint = 0xff0000;
+ return false;
+ };
+ return self;
+});
+var EnemyBullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('enemyBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speedX = -8;
+ self.speedY = 0;
+ self.update = function () {
+ self.x += self.speedX;
+ self.y += self.speedY;
+ };
+ return self;
+});
+var Hero = Container.expand(function () {
+ var self = Container.call(this);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 3;
+ self.maxHealth = 3;
+ self.shootCooldown = 0;
+ self.shootInterval = 20;
+ self.invulnerable = 0;
+ self.powerupTime = 0;
+ self.powerupType = null;
+ self.update = function () {
+ if (self.invulnerable > 0) {
+ self.invulnerable--;
+ self.alpha = Math.sin(self.invulnerable * 0.3) > 0 ? 1 : 0.5;
+ } else {
+ self.alpha = 1;
+ }
+ if (self.powerupTime > 0) {
+ self.powerupTime--;
+ if (self.powerupTime === 0) {
+ self.powerupType = null;
+ self.shootInterval = 20;
+ }
+ }
+ self.shootCooldown++;
+ };
+ self.takeDamage = function () {
+ if (self.invulnerable > 0) return false;
+ self.health--;
+ self.invulnerable = 120; // 2 seconds of invulnerability
+ if (self.health <= 0) {
+ return true; // Hero destroyed
+ }
+ LK.effects.flashObject(self, 0xff0000, 500);
+ return false;
+ };
+ self.canShoot = function () {
+ if (self.shootCooldown >= self.shootInterval) {
+ self.shootCooldown = 0;
+ return true;
+ }
+ return false;
+ };
+ self.applyPowerup = function (type) {
+ self.powerupType = type;
+ self.powerupTime = 600; // 10 seconds
+ if (type === 'rapid') {
+ self.shootInterval = 10;
+ }
+ };
+ return self;
+});
+var HeroBullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('heroBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 15;
+ self.damage = 1;
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
+var PowerUp = Container.expand(function () {
+ var self = Container.call(this);
+ var powerupGraphics = self.attachAsset('powerup', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.type = Math.random() > 0.5 ? 'rapid' : 'triple';
+ self.speed = -3;
+ self.update = function () {
+ self.x += self.speed;
+ self.rotation += 0.05;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
backgroundColor: 0x000000
-});
\ No newline at end of file
+});
+
+/****
+* Game Code
+****/
+game.setBackgroundColor(0x1a1a2e);
+// Game variables
+var hero;
+var heroBullets = [];
+var enemies = [];
+var enemyBullets = [];
+var powerups = [];
+var boss = null;
+var wave = 1;
+var enemiesSpawned = 0;
+var enemiesPerWave = 5;
+var spawnCooldown = 0;
+var gameStarted = false;
+var isDragging = false;
+var dragOffsetY = 0;
+// Ground
+var ground = LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 2732 - 100
+});
+game.addChild(ground);
+// Hero
+hero = new Hero();
+hero.x = 200;
+hero.y = 2732 - 200;
+game.addChild(hero);
+// UI Elements
+var scoreTxt = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+scoreTxt.y = 20;
+LK.gui.top.addChild(scoreTxt);
+// Health display
+var healthContainer = new Container();
+LK.gui.topRight.addChild(healthContainer);
+healthContainer.x = -120;
+healthContainer.y = 40;
+var healthBarBg = LK.getAsset('healthBarBg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+healthContainer.addChild(healthBarBg);
+var healthBar = LK.getAsset('healthBar', {
+ anchorX: 0,
+ anchorY: 0.5,
+ x: -100
+});
+healthContainer.addChild(healthBar);
+// Wave text
+var waveTxt = new Text2('Wave 1', {
+ size: 80,
+ fill: 0xFFFF00
+});
+waveTxt.anchor.set(0.5, 0.5);
+LK.gui.center.addChild(waveTxt);
+waveTxt.alpha = 0;
+// Touch controls
+game.down = function (x, y, obj) {
+ var heroGlobalPos = hero.toGlobal({
+ x: 0,
+ y: 0
+ });
+ var localPos = game.toLocal(heroGlobalPos);
+ if (Math.abs(x - localPos.x) < 100 && Math.abs(y - localPos.y) < 100) {
+ isDragging = true;
+ dragOffsetY = y - hero.y;
+ gameStarted = true;
+ }
+};
+game.up = function (x, y, obj) {
+ isDragging = false;
+};
+game.move = function (x, y, obj) {
+ if (isDragging) {
+ hero.y = Math.max(300, Math.min(2732 - 200, y - dragOffsetY));
+ }
+};
+// Helper functions
+function spawnEnemy() {
+ var enemy = new Enemy();
+ enemy.x = 2048 + 50;
+ enemy.y = 300 + Math.random() * (2732 - 600);
+ enemies.push(enemy);
+ game.addChild(enemy);
+}
+function spawnBoss() {
+ boss = new Boss();
+ boss.x = 2048 - 200;
+ boss.y = 450;
+ game.addChild(boss);
+ // Show boss warning
+ waveTxt.setText('BOSS!');
+ waveTxt.alpha = 1;
+ tween(waveTxt, {
+ alpha: 0
+ }, {
+ duration: 2000
+ });
+}
+function spawnPowerup(x, y) {
+ if (Math.random() < 0.2) {
+ // 20% chance
+ var powerup = new PowerUp();
+ powerup.x = x;
+ powerup.y = y;
+ powerups.push(powerup);
+ game.addChild(powerup);
+ }
+}
+function shootHeroBullet() {
+ if (hero.powerupType === 'triple') {
+ // Triple shot
+ for (var i = -1; i <= 1; i++) {
+ var bullet = new HeroBullet();
+ bullet.x = hero.x + 40;
+ bullet.y = hero.y + i * 30;
+ heroBullets.push(bullet);
+ game.addChild(bullet);
+ }
+ } else {
+ // Normal shot
+ var bullet = new HeroBullet();
+ bullet.x = hero.x + 40;
+ bullet.y = hero.y;
+ heroBullets.push(bullet);
+ game.addChild(bullet);
+ }
+ LK.getSound('shoot').play();
+}
+function shootEnemyBullet(enemy) {
+ var bullet = new EnemyBullet();
+ bullet.x = enemy.x - 30;
+ bullet.y = enemy.y;
+ enemyBullets.push(bullet);
+ game.addChild(bullet);
+ LK.getSound('enemyShoot').play();
+}
+function shootBossBullet(phase) {
+ if (phase === 1) {
+ // Single aimed shot
+ var bullet = new EnemyBullet();
+ bullet.x = boss.x - 75;
+ bullet.y = boss.y;
+ var angle = Math.atan2(hero.y - boss.y, hero.x - boss.x);
+ bullet.speedX = Math.cos(angle) * 10;
+ bullet.speedY = Math.sin(angle) * 10;
+ enemyBullets.push(bullet);
+ game.addChild(bullet);
+ } else if (phase === 2) {
+ // Spread shot
+ for (var i = -2; i <= 2; i++) {
+ var bullet = new EnemyBullet();
+ bullet.x = boss.x - 75;
+ bullet.y = boss.y;
+ bullet.speedX = -8;
+ bullet.speedY = i * 2;
+ enemyBullets.push(bullet);
+ game.addChild(bullet);
+ }
+ }
+ LK.getSound('enemyShoot').play();
+}
+// Game update
+game.update = function () {
+ if (!gameStarted) return;
+ // Update health bar
+ healthBar.scale.x = hero.health / hero.maxHealth;
+ // Spawn enemies
+ if (!boss && enemiesSpawned < enemiesPerWave) {
+ spawnCooldown++;
+ if (spawnCooldown >= 120) {
+ spawnCooldown = 0;
+ spawnEnemy();
+ enemiesSpawned++;
+ }
+ }
+ // Check for next wave
+ if (!boss && enemiesSpawned >= enemiesPerWave && enemies.length === 0) {
+ wave++;
+ enemiesSpawned = 0;
+ enemiesPerWave = Math.min(10, enemiesPerWave + 1);
+ if (wave % 5 === 0) {
+ // Boss wave
+ spawnBoss();
+ } else {
+ // Normal wave
+ waveTxt.setText('Wave ' + wave);
+ waveTxt.alpha = 1;
+ tween(waveTxt, {
+ alpha: 0
+ }, {
+ duration: 2000
+ });
+ }
+ }
+ // Hero shooting
+ if (hero.canShoot()) {
+ shootHeroBullet();
+ }
+ // Update hero bullets
+ for (var i = heroBullets.length - 1; i >= 0; i--) {
+ var bullet = heroBullets[i];
+ if (bullet.x > 2048 + 50) {
+ bullet.destroy();
+ heroBullets.splice(i, 1);
+ continue;
+ }
+ // Check enemy collisions
+ for (var j = enemies.length - 1; j >= 0; j--) {
+ var enemy = enemies[j];
+ if (bullet.intersects(enemy)) {
+ if (enemy.takeDamage(bullet.damage)) {
+ // Enemy destroyed
+ LK.setScore(LK.getScore() + enemy.points);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ spawnPowerup(enemy.x, enemy.y);
+ enemy.destroy();
+ enemies.splice(j, 1);
+ LK.getSound('enemyDestroy').play();
+ }
+ bullet.destroy();
+ heroBullets.splice(i, 1);
+ break;
+ }
+ }
+ // Check boss collision
+ if (boss && bullet.intersects(boss)) {
+ if (boss.takeDamage(bullet.damage)) {
+ // Boss destroyed
+ LK.setScore(LK.getScore() + boss.points);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ spawnPowerup(boss.x, boss.y);
+ boss.destroy();
+ boss = null;
+ LK.getSound('enemyDestroy').play();
+ }
+ bullet.destroy();
+ heroBullets.splice(i, 1);
+ }
+ }
+ // Update enemies
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ var enemy = enemies[i];
+ if (enemy.x < -50) {
+ enemy.destroy();
+ enemies.splice(i, 1);
+ continue;
+ }
+ if (enemy.update()) {
+ shootEnemyBullet(enemy);
+ }
+ // Check collision with hero
+ if (enemy.intersects(hero)) {
+ if (hero.takeDamage()) {
+ LK.showGameOver();
+ }
+ enemy.destroy();
+ enemies.splice(i, 1);
+ LK.getSound('hit').play();
+ }
+ }
+ // Update boss
+ if (boss) {
+ var phase = boss.update();
+ if (phase > 0) {
+ shootBossBullet(phase);
+ }
+ // Check collision with hero
+ if (boss.intersects(hero)) {
+ if (hero.takeDamage()) {
+ LK.showGameOver();
+ }
+ LK.getSound('hit').play();
+ }
+ }
+ // Update enemy bullets
+ for (var i = enemyBullets.length - 1; i >= 0; i--) {
+ var bullet = enemyBullets[i];
+ if (bullet.x < -50 || bullet.x > 2048 + 50 || bullet.y < -50 || bullet.y > 2732 + 50) {
+ bullet.destroy();
+ enemyBullets.splice(i, 1);
+ continue;
+ }
+ // Check collision with hero
+ if (bullet.intersects(hero)) {
+ if (hero.takeDamage()) {
+ LK.showGameOver();
+ }
+ bullet.destroy();
+ enemyBullets.splice(i, 1);
+ LK.getSound('hit').play();
+ }
+ }
+ // Update powerups
+ for (var i = powerups.length - 1; i >= 0; i--) {
+ var powerup = powerups[i];
+ if (powerup.x < -50) {
+ powerup.destroy();
+ powerups.splice(i, 1);
+ continue;
+ }
+ // Check collision with hero
+ if (powerup.intersects(hero)) {
+ hero.applyPowerup(powerup.type);
+ powerup.destroy();
+ powerups.splice(i, 1);
+ LK.getSound('powerupCollect').play();
+ }
+ }
+};
+// Start music
+LK.playMusic('bgMusic');
\ No newline at end of file