54
1
1y
User prompt
Me gustaría generar un Sprite para el jugador y para el enemigo las balas y los misiles
User prompt
Me gustaría una pantalla de que ganaste y que los jefes tengan más vida
User prompt
Un boss en la ronda 10 y otro en la ronda 20 que los jefes tengan 2 para disparar misiles y 1 para disparar balas y el de la ronda 20 que tenga 2 para disparar coetes y que tenga 2 para disparar balas y más vida
User prompt
Añade una pantalla de game over y un botón para jugar de nuevo
User prompt
Me gustaría que las cosas fueran más grandes por qué en móvil se ve pequeño y que los aviones se muevan ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(explosion, {' Line Number: 96 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Puedes añadir esprites para el jugador los aviones enemigos las balas y los misiles
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'action')' in or related to this line: 'obj.upgrade.action();' Line Number: 338
Code edit (1 edits merged)
Please save this source code
User prompt
Sky Warrior - Aerial Combat Survival
Initial prompt
Puedes crear un juego donde eres un avión con 3 vidas y tienes que pelear contra otros aviones que disparan y que haya 20 oleadas y que después de cada 1 oleada puedas elegir una mejora y que después de cada oleada hayan enemigos más difíciles y que tengan misiles que quiten 2 de vida
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('enemyJet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 2.5
});
self.maxHealth = 10;
self.health = 10;
self.speed = 1;
self.fireRate = 90;
self.fireTimer = 0;
self.missileRate = 180;
self.missileTimer = 0;
self.rocketRate = 150;
self.rocketTimer = 0;
self.horizontalSpeed = 1;
self.horizontalDirection = 1;
self.weaponSystems = {
bullets: 1,
missiles: 0,
rockets: 0
};
self.bossType = 1; // 1 for wave 10, 2 for wave 20
self.update = function () {
self.y += self.speed;
// Horizontal movement
self.x += self.horizontalSpeed * self.horizontalDirection;
if (self.x < 200 || self.x > 1848) {
self.horizontalDirection *= -1;
}
// Update timers
if (self.fireTimer > 0) {
self.fireTimer--;
}
if (self.missileTimer > 0) {
self.missileTimer--;
}
if (self.rocketTimer > 0) {
self.rocketTimer--;
}
// Fire bullets
if (self.fireTimer <= 0 && self.y > 0 && self.y < 2400) {
for (var i = 0; i < self.weaponSystems.bullets; i++) {
self.fireBullet(i);
}
self.fireTimer = self.fireRate;
}
// Fire missiles
if (self.weaponSystems.missiles > 0 && self.missileTimer <= 0 && self.y > 0 && self.y < 2400) {
for (var i = 0; i < self.weaponSystems.missiles; i++) {
self.fireMissile(i);
}
self.missileTimer = self.missileRate;
}
// Fire rockets
if (self.weaponSystems.rockets > 0 && self.rocketTimer <= 0 && self.y > 0 && self.y < 2400) {
for (var i = 0; i < self.weaponSystems.rockets; i++) {
self.fireRocket(i);
}
self.rocketTimer = self.rocketRate;
}
};
self.fireBullet = function (index) {
var bullet = new EnemyBullet();
var offset = (index - (self.weaponSystems.bullets - 1) / 2) * 40;
bullet.x = self.x + offset;
bullet.y = self.y + 75;
enemyBullets.push(bullet);
game.addChild(bullet);
};
self.fireMissile = function (index) {
var missile = new Missile();
var offset = (index - (self.weaponSystems.missiles - 1) / 2) * 60;
missile.x = self.x + offset;
missile.y = self.y + 75;
missiles.push(missile);
game.addChild(missile);
LK.getSound('missile').play();
};
self.fireRocket = function (index) {
var rocket = new Rocket();
var offset = (index - (self.weaponSystems.rockets - 1) / 2) * 80;
rocket.x = self.x + offset;
rocket.y = self.y + 75;
rockets.push(rocket);
game.addChild(rocket);
LK.getSound('missile').play();
};
self.takeDamage = function (damage) {
self.health -= damage;
// Flash effect when taking damage
LK.effects.flashObject(self, 0xFF0000, 200);
if (self.health <= 0) {
// Create multiple explosions for boss death
for (var i = 0; i < 5; i++) {
var explosion = LK.getAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x + (Math.random() - 0.5) * 200,
y: self.y + (Math.random() - 0.5) * 200
});
game.addChild(explosion);
tween(explosion, {
alpha: 0
}, {
duration: 800,
delay: i * 100,
onFinish: function onFinish() {
explosion.destroy();
}
});
}
self.destroy();
LK.getSound('explosion').play();
return true;
}
return false;
};
return self;
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('enemyBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 6;
self.damage = 1;
self.update = function () {
self.y += self.speed;
};
return self;
});
var EnemyJet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('enemyJet', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 1;
self.speed = 2;
self.fireRate = 120;
self.fireTimer = Math.random() * 60;
self.canFireMissiles = false;
self.missileRate = 300;
self.missileTimer = Math.random() * 150;
self.horizontalSpeed = (Math.random() - 0.5) * 3;
self.horizontalDirection = Math.random() > 0.5 ? 1 : -1;
self.update = function () {
self.y += self.speed;
// Add horizontal movement
self.x += self.horizontalSpeed * self.horizontalDirection;
// Bounce off screen edges
if (self.x < 100 || self.x > 1948) {
self.horizontalDirection *= -1;
}
if (self.fireTimer > 0) {
self.fireTimer--;
}
if (self.missileTimer > 0) {
self.missileTimer--;
}
// Fire bullets
if (self.fireTimer <= 0 && self.y > 0 && self.y < 2400) {
self.fireBullet();
self.fireTimer = self.fireRate + Math.random() * 60;
}
// Fire missiles (if capable)
if (self.canFireMissiles && self.missileTimer <= 0 && self.y > 0 && self.y < 2400) {
self.fireMissile();
self.missileTimer = self.missileRate + Math.random() * 120;
}
};
self.fireBullet = function () {
var bullet = new EnemyBullet();
bullet.x = self.x;
bullet.y = self.y + 50;
enemyBullets.push(bullet);
game.addChild(bullet);
};
self.fireMissile = function () {
var missile = new Missile();
missile.x = self.x;
missile.y = self.y + 50;
missiles.push(missile);
game.addChild(missile);
LK.getSound('missile').play();
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
// Create explosion effect
var explosion = LK.getAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y
});
game.addChild(explosion);
// Fade out explosion
tween(explosion, {
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
explosion.destroy();
}
});
self.destroy();
LK.getSound('explosion').play();
return true;
}
return false;
};
return self;
});
var Missile = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('missile', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.damage = 2;
self.trackingSpeed = 0.5;
self.update = function () {
// Basic homing behavior
if (player) {
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
self.x += dx / distance * self.trackingSpeed;
self.y += dy / distance * self.trackingSpeed;
}
}
self.y += self.speed;
};
return self;
});
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('playerBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.damage = 1;
self.update = function () {
self.y += self.speed;
};
return self;
});
var PlayerJet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('playerJet', {
anchorX: 0.5,
anchorY: 0.5
});
self.maxHealth = 3;
self.health = 3;
self.speed = 8;
self.fireRate = 15;
self.fireTimer = 0;
self.invulnerable = false;
self.invulnerableTimer = 0;
self.update = function () {
if (self.fireTimer > 0) {
self.fireTimer--;
}
if (self.invulnerable) {
self.invulnerableTimer--;
if (self.invulnerableTimer <= 0) {
self.invulnerable = false;
graphics.alpha = 1;
} else {
graphics.alpha = 0.5;
}
}
// Auto-fire
if (self.fireTimer <= 0) {
self.fire();
self.fireTimer = self.fireRate;
}
};
self.fire = function () {
var bullet = new PlayerBullet();
bullet.x = self.x;
bullet.y = self.y - 50;
playerBullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
};
self.takeDamage = function (damage) {
if (self.invulnerable) return;
self.health -= damage;
self.invulnerable = true;
self.invulnerableTimer = 60;
LK.effects.flashObject(self, 0xFF0000, 500);
if (self.health <= 0) {
gameOver();
}
updateHealthDisplay();
};
return self;
});
var Rocket = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('missile', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
graphics.tint = 0xFF4444;
self.speed = 5;
self.damage = 3;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001122
});
/****
* Game Code
****/
// Background setup
var background1 = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
var background2 = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: -2732
});
game.addChild(background1);
game.addChild(background2);
// Game state variables
var currentWave = 1;
var maxWaves = 20;
var waveEnemies = [];
var enemiesSpawned = 0;
var enemiesToSpawn = 5;
var spawnTimer = 0;
var spawnRate = 60;
var waveComplete = false;
var gameState = 'playing'; // 'playing', 'upgrading', 'gameover'
// Game objects
var player = null;
var playerBullets = [];
var enemyBullets = [];
var missiles = [];
var rockets = [];
var enemies = [];
var currentBoss = null;
// UI elements
var waveText = null;
var healthText = null;
var upgradeContainer = null;
// Initialize player
player = new PlayerJet();
player.x = 1024;
player.y = 2300;
game.addChild(player);
// Initialize UI
waveText = new Text2('Wave: 1', {
size: 60,
fill: 0xFFFFFF
});
waveText.anchor.set(0.5, 0);
LK.gui.top.addChild(waveText);
waveText.y = 50;
healthText = new Text2('Health: 3', {
size: 50,
fill: 0xFF4444
});
healthText.anchor.set(0, 0);
LK.gui.topRight.addChild(healthText);
healthText.x = -200;
healthText.y = 50;
function updateHealthDisplay() {
healthText.setText('Health: ' + player.health);
}
function updateWaveDisplay() {
waveText.setText('Wave: ' + currentWave);
}
function spawnEnemy() {
// Spawn boss on waves 10 and 20
if ((currentWave === 10 || currentWave === 20) && enemiesSpawned === 0) {
var boss = new Boss();
boss.x = 1024;
boss.y = -150;
if (currentWave === 10) {
// Wave 10 boss: 2 missiles, 1 bullet
boss.maxHealth = 30;
boss.health = 30;
boss.weaponSystems.bullets = 1;
boss.weaponSystems.missiles = 2;
boss.weaponSystems.rockets = 0;
boss.bossType = 1;
} else if (currentWave === 20) {
// Wave 20 boss: 2 rockets, 2 bullets, more health
boss.maxHealth = 50;
boss.health = 50;
boss.weaponSystems.bullets = 2;
boss.weaponSystems.missiles = 0;
boss.weaponSystems.rockets = 2;
boss.bossType = 2;
}
enemies.push(boss);
game.addChild(boss);
currentBoss = boss;
enemiesSpawned++;
return;
}
var enemy = new EnemyJet();
enemy.x = Math.random() * 1700 + 174;
enemy.y = -90;
// Scale difficulty based on wave
enemy.health = Math.floor(currentWave / 5) + 1;
enemy.speed = 2 + currentWave * 0.2;
enemy.fireRate = Math.max(60 - currentWave * 2, 30);
// Enable missiles for later waves
if (currentWave >= 5) {
enemy.canFireMissiles = true;
}
enemies.push(enemy);
game.addChild(enemy);
enemiesSpawned++;
}
function startWave() {
currentWave++;
if (currentWave > maxWaves) {
showYouWinScreen();
return;
}
// Boss waves spawn only 1 enemy (the boss)
if (currentWave === 10 || currentWave === 20) {
enemiesToSpawn = 1;
} else {
enemiesToSpawn = 5 + Math.floor(currentWave * 1.5);
}
enemiesSpawned = 0;
spawnTimer = 0;
waveComplete = false;
gameState = 'playing';
updateWaveDisplay();
// Hide upgrade menu if visible
if (upgradeContainer) {
upgradeContainer.destroy();
upgradeContainer = null;
}
}
function completeWave() {
if (currentWave >= maxWaves) {
showYouWinScreen();
return;
}
waveComplete = true;
gameState = 'upgrading';
showUpgradeMenu();
}
function showUpgradeMenu() {
upgradeContainer = new Container();
game.addChild(upgradeContainer);
var titleText = new Text2('Choose Upgrade', {
size: 80,
fill: 0xFFFF00
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 800;
upgradeContainer.addChild(titleText);
var upgrades = [{
text: 'Faster Firing',
action: function action() {
player.fireRate = Math.max(player.fireRate - 3, 5);
}
}, {
text: 'More Health',
action: function action() {
player.maxHealth++;
player.health = player.maxHealth;
}
}, {
text: 'Faster Movement',
action: function action() {
player.speed += 2;
}
}, {
text: 'Stronger Bullets',
action: function action() {/* Implement bullet upgrade */}
}];
for (var i = 0; i < 3; i++) {
var upgrade = upgrades[i];
var button = new Container();
var buttonBg = LK.getAsset('playerJet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.5
});
buttonBg.tint = 0x444444;
button.addChild(buttonBg);
var buttonText = new Text2(upgrade.text, {
size: 40,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
button.addChild(buttonText);
button.x = 1024;
button.y = 1200 + i * 200;
button.upgrade = upgrade;
button.down = function (x, y, obj) {
this.upgrade.action();
updateHealthDisplay();
startWave();
};
upgradeContainer.addChild(button);
}
}
function gameOver() {
gameState = 'gameover';
showGameOverScreen();
}
function showGameOverScreen() {
var gameOverContainer = new Container();
game.addChild(gameOverContainer);
gameOverContainer.zIndex = 1000;
// Semi-transparent background
var overlay = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
overlay.alpha = 0.7;
overlay.tint = 0x000000;
gameOverContainer.addChild(overlay);
// Game Over title
var gameOverText = new Text2('GAME OVER', {
size: 120,
fill: 0xFF0000
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = 1024;
gameOverText.y = 1200;
gameOverContainer.addChild(gameOverText);
// Final score/wave text
var finalScoreText = new Text2('Final Wave: ' + currentWave, {
size: 60,
fill: 0xFFFFFF
});
finalScoreText.anchor.set(0.5, 0.5);
finalScoreText.x = 1024;
finalScoreText.y = 1350;
gameOverContainer.addChild(finalScoreText);
// Restart button
var restartButton = new Container();
var buttonBg = LK.getAsset('playerJet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 2
});
buttonBg.tint = 0x00AA00;
restartButton.addChild(buttonBg);
var buttonText = new Text2('PLAY AGAIN', {
size: 50,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
restartButton.addChild(buttonText);
restartButton.x = 1024;
restartButton.y = 1600;
restartButton.down = function (x, y, obj) {
restartGame();
};
gameOverContainer.addChild(restartButton);
}
function showYouWinScreen() {
var youWinContainer = new Container();
game.addChild(youWinContainer);
youWinContainer.zIndex = 1000;
// Semi-transparent background
var overlay = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
overlay.alpha = 0.7;
overlay.tint = 0x000000;
youWinContainer.addChild(overlay);
// You Win title
var youWinText = new Text2('YOU WIN!', {
size: 120,
fill: 0x00FF00
});
youWinText.anchor.set(0.5, 0.5);
youWinText.x = 1024;
youWinText.y = 1200;
youWinContainer.addChild(youWinText);
// Congratulations text
var congratsText = new Text2('You defeated all waves!', {
size: 60,
fill: 0xFFFFFF
});
congratsText.anchor.set(0.5, 0.5);
congratsText.x = 1024;
congratsText.y = 1350;
youWinContainer.addChild(congratsText);
// Play again button
var playAgainButton = new Container();
var buttonBg = LK.getAsset('playerJet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 2
});
buttonBg.tint = 0x00AA00;
playAgainButton.addChild(buttonBg);
var buttonText = new Text2('PLAY AGAIN', {
size: 50,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
playAgainButton.addChild(buttonText);
playAgainButton.x = 1024;
playAgainButton.y = 1600;
playAgainButton.down = function (x, y, obj) {
restartGame();
};
youWinContainer.addChild(playAgainButton);
}
function restartGame() {
// Reset game state
gameState = 'playing';
currentWave = 1;
waveComplete = false;
enemiesSpawned = 0;
enemiesToSpawn = 5;
spawnTimer = 0;
// Clear all game objects
for (var i = playerBullets.length - 1; i >= 0; i--) {
playerBullets[i].destroy();
}
playerBullets = [];
for (var i = enemyBullets.length - 1; i >= 0; i--) {
enemyBullets[i].destroy();
}
enemyBullets = [];
for (var i = missiles.length - 1; i >= 0; i--) {
missiles[i].destroy();
}
missiles = [];
for (var i = rockets.length - 1; i >= 0; i--) {
rockets[i].destroy();
}
rockets = [];
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].destroy();
}
enemies = [];
currentBoss = null;
// Reset player
if (player) {
player.destroy();
}
player = new PlayerJet();
player.x = 1024;
player.y = 2300;
player.health = player.maxHealth;
player.fireRate = 15;
player.speed = 8;
game.addChild(player);
// Clear any existing containers
if (upgradeContainer) {
upgradeContainer.destroy();
upgradeContainer = null;
}
// Find and remove game over or win screen containers
for (var i = game.children.length - 1; i >= 0; i--) {
var child = game.children[i];
if (child instanceof Container && child.zIndex === 1000) {
child.destroy();
break;
}
}
// Update UI
updateWaveDisplay();
updateHealthDisplay();
}
// Input handling
var dragActive = false;
game.down = function (x, y, obj) {
if (gameState === 'playing') {
dragActive = true;
player.x = x;
player.y = y;
}
};
game.move = function (x, y, obj) {
if (gameState === 'playing' && dragActive) {
player.x = Math.max(70, Math.min(1978, x));
player.y = Math.max(150, Math.min(2582, y));
}
};
game.up = function (x, y, obj) {
dragActive = false;
};
// Main game loop
game.update = function () {
if (gameState !== 'playing') return;
// Scroll background
background1.y += 2;
background2.y += 2;
if (background1.y >= 2732) {
background1.y = background2.y - 2732;
}
if (background2.y >= 2732) {
background2.y = background1.y - 2732;
}
// Spawn enemies
if (enemiesSpawned < enemiesToSpawn) {
spawnTimer++;
if (spawnTimer >= spawnRate) {
spawnEnemy();
spawnTimer = 0;
}
}
// Update player bullets
for (var i = playerBullets.length - 1; i >= 0; i--) {
var bullet = playerBullets[i];
if (bullet.y < -50) {
bullet.destroy();
playerBullets.splice(i, 1);
continue;
}
// Check collision with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
if (enemy.takeDamage(bullet.damage)) {
enemies.splice(j, 1);
// Reset boss reference if boss was destroyed
if (enemy === currentBoss) {
currentBoss = null;
}
}
bullet.destroy();
playerBullets.splice(i, 1);
break;
}
}
}
// Update enemy bullets
for (var i = enemyBullets.length - 1; i >= 0; i--) {
var bullet = enemyBullets[i];
if (bullet.y > 2782) {
bullet.destroy();
enemyBullets.splice(i, 1);
continue;
}
// Check collision with player
if (bullet.intersects(player)) {
player.takeDamage(bullet.damage);
bullet.destroy();
enemyBullets.splice(i, 1);
}
}
// Update missiles
for (var i = missiles.length - 1; i >= 0; i--) {
var missile = missiles[i];
if (missile.y > 2782 || missile.y < -50 || missile.x < -50 || missile.x > 2098) {
missile.destroy();
missiles.splice(i, 1);
continue;
}
// Check collision with player
if (missile.intersects(player)) {
player.takeDamage(missile.damage);
missile.destroy();
missiles.splice(i, 1);
}
}
// Update rockets
for (var i = rockets.length - 1; i >= 0; i--) {
var rocket = rockets[i];
if (rocket.y > 2782 || rocket.y < -50 || rocket.x < -50 || rocket.x > 2098) {
rocket.destroy();
rockets.splice(i, 1);
continue;
}
// Check collision with player
if (rocket.intersects(player)) {
player.takeDamage(rocket.damage);
rocket.destroy();
rockets.splice(i, 1);
}
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.y > 2782) {
enemy.destroy();
enemies.splice(i, 1);
}
}
// Check wave completion
if (enemiesSpawned >= enemiesToSpawn && enemies.length === 0 && !waveComplete) {
completeWave();
}
};
// Start first wave
updateWaveDisplay();
updateHealthDisplay();
LK.playMusic('bgmusic'); ===================================================================
--- original.js
+++ change.js
@@ -412,18 +412,18 @@
boss.x = 1024;
boss.y = -150;
if (currentWave === 10) {
// Wave 10 boss: 2 missiles, 1 bullet
- boss.maxHealth = 15;
- boss.health = 15;
+ boss.maxHealth = 30;
+ boss.health = 30;
boss.weaponSystems.bullets = 1;
boss.weaponSystems.missiles = 2;
boss.weaponSystems.rockets = 0;
boss.bossType = 1;
} else if (currentWave === 20) {
// Wave 20 boss: 2 rockets, 2 bullets, more health
- boss.maxHealth = 25;
- boss.health = 25;
+ boss.maxHealth = 50;
+ boss.health = 50;
boss.weaponSystems.bullets = 2;
boss.weaponSystems.missiles = 0;
boss.weaponSystems.rockets = 2;
boss.bossType = 2;
@@ -451,9 +451,9 @@
}
function startWave() {
currentWave++;
if (currentWave > maxWaves) {
- LK.showYouWin();
+ showYouWinScreen();
return;
}
// Boss waves spawn only 1 enemy (the boss)
if (currentWave === 10 || currentWave === 20) {
@@ -473,9 +473,9 @@
}
}
function completeWave() {
if (currentWave >= maxWaves) {
- LK.showYouWin();
+ showYouWinScreen();
return;
}
waveComplete = true;
gameState = 'upgrading';
@@ -598,8 +598,63 @@
restartGame();
};
gameOverContainer.addChild(restartButton);
}
+function showYouWinScreen() {
+ var youWinContainer = new Container();
+ game.addChild(youWinContainer);
+ youWinContainer.zIndex = 1000;
+ // Semi-transparent background
+ var overlay = LK.getAsset('background', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0
+ });
+ overlay.alpha = 0.7;
+ overlay.tint = 0x000000;
+ youWinContainer.addChild(overlay);
+ // You Win title
+ var youWinText = new Text2('YOU WIN!', {
+ size: 120,
+ fill: 0x00FF00
+ });
+ youWinText.anchor.set(0.5, 0.5);
+ youWinText.x = 1024;
+ youWinText.y = 1200;
+ youWinContainer.addChild(youWinText);
+ // Congratulations text
+ var congratsText = new Text2('You defeated all waves!', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ congratsText.anchor.set(0.5, 0.5);
+ congratsText.x = 1024;
+ congratsText.y = 1350;
+ youWinContainer.addChild(congratsText);
+ // Play again button
+ var playAgainButton = new Container();
+ var buttonBg = LK.getAsset('playerJet', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 4,
+ scaleY: 2
+ });
+ buttonBg.tint = 0x00AA00;
+ playAgainButton.addChild(buttonBg);
+ var buttonText = new Text2('PLAY AGAIN', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ playAgainButton.addChild(buttonText);
+ playAgainButton.x = 1024;
+ playAgainButton.y = 1600;
+ playAgainButton.down = function (x, y, obj) {
+ restartGame();
+ };
+ youWinContainer.addChild(playAgainButton);
+}
function restartGame() {
// Reset game state
gameState = 'playing';
currentWave = 1;
@@ -644,9 +699,9 @@
if (upgradeContainer) {
upgradeContainer.destroy();
upgradeContainer = null;
}
- // Find and remove game over container
+ // Find and remove game over or win screen containers
for (var i = game.children.length - 1; i >= 0; i--) {
var child = game.children[i];
if (child instanceof Container && child.zIndex === 1000) {
child.destroy();
Un avión militar enemigo visto desde arriba sin fondo y realista. 2d. High contrast. No shadows
Explosión realista vista desde arriba. 2d. High contrast. No shadows
Un avión militar realista visto desde arriba
Realistic guided missile seen from above
Fondo aéreo con nubes y montañas realista visto desde arriba
Bala realista
2 estelas realistas de avión vista desde arriba sin avión. In-Game asset