User prompt
Elimina todo lo que tenga que ver con sonidos, con música y con todo lo que tenga que ver de sonidos y música, por favor.
User prompt
Ahora me deja poner los sonidos, pero ahora el juego se traba. ¿Podrías borrar todos los sonidos que agregué?
User prompt
¡PERO NO ME DEJA PONER SONIDOS! Literalmente estoy poniendo los sonidos y me dicen que falló.
User prompt
¡Haz que las estrellas aparezcan al inicio de la pantalla! ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
a que las estrellas aparezcan en la pantalla de inicio. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Talla de inicio, apareca estrellas. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que todos los ataques del jefe hagan una vida, ya que considerando que Jugasson tiene una vida, no tiene sentido que los ataques del jefe tengan más o menos daño.
User prompt
que aquí al lado del botón jugar hay un botón de explicación donde explica todas las características del juego inclusión de los ataques del jefe
User prompt
que el titulo en vez de ser Boss Battle sea Space Ranger.
User prompt
Haz que el botón de jugar se vea un poquito más llamativo. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que el botón de jugar sea un botón que diga jugar y no el jugador.
User prompt
Crea una pantalla de inicio para el juego.
User prompt
Añade la carpeta de música que está en activos al código del juego.
User prompt
Crea partículas blancas muy pequeñas que no hagan daño y funcionen como estrellas.
User prompt
Haz que el láser solamente dure 10 segundos. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
que solamente puede activar el láser en el modo en el modo rápido y que no y que solamente puede usarlo una vez pero que dure 30 segundos en vez de 5 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que el jefe cuando active el láser, antes de activarlo, esté quieto por 3 segundos. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
A que cuando el boss active el láser, tenga un tiempito de recarga, y que también solo te dure 5 segundos, y no toda la partida, y cuan... ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
¡Haz que el jugador solo tenga uno de vida!
User prompt
haz que el láser del jefe sea más más largo o sea acabar que todo una línea
User prompt
a que el láser después de 5 segundos desaparezca ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que en el modo rápido del jefe los ataques también vayan más rápido y los ataques especiales sean más rápidos en el tiempo de recarga
User prompt
Me refería a que cuando el jefe tenía poca vida atacaba más rápido, ¿no? Que cuando el jugador tenía poca vida atacaba más rápido.
User prompt
Sabes que cuando pierdes la mitad de vida, ataques un mon... Más rápido, todos tus ataques se hacen súper o mega rápido, y que no tengas un tiempo de recarga cada vez que lanzas un ataque. Básicamente acá atacas súper o mega rápido. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que el ataque, el láser sea más gordo.
/**** * 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.maxHealth = 10000; self.health = 10000; self.attackCooldown = 0; self.attackInterval = 180; // 3 seconds at 60fps self.moveDirection = 1; // 1 for right, -1 for left self.moveSpeed = 2; self.leftBound = 200; self.rightBound = 1848; self.verticalDirection = 1; // 1 for down, -1 for up self.verticalSpeed = 1; self.topBound = 300; self.bottomBound = 500; self.specialAttackTimer = 0; self.specialAttackInterval = 300; // 5 seconds at 60fps self.isCharging = false; self.chargeTime = 0; self.maxChargeTime = 60; // 1 second at 60fps self.indicator = null; self.finalAttackTriggered = false; self.isFinalAttacking = false; self.finalAttackTime = 0; self.maxFinalAttackTime = 180; // 3 seconds at 60fps self.finalAttackCanceled = false; self.laserAttackTimer = 0; self.laserAttackInterval = 900; // 15 seconds at 60fps self.takeDamage = function (damage) { self.health -= damage; if (self.health < 0) self.health = 0; // Flash red when taking damage tween(bossGraphics, { tint: 0xff8888 }, { duration: 100, onFinish: function onFinish() { tween(bossGraphics, { tint: 0xffffff }, { duration: 100 }); } }); }; self.attack = function () { return { x: self.x, y: self.y + 100, damage: 25 }; }; self.specialAttack = function () { return { x: self.x, y: self.y + 100, damage: 5 }; }; self.startFinalAttack = function () { self.isFinalAttacking = true; self.finalAttackTime = 0; self.finalAttackCanceled = false; // Boss stops moving during final attack }; self.cancelFinalAttack = function () { self.finalAttackCanceled = true; self.isFinalAttacking = false; self.finalAttackTime = 0; }; self.finalAttack = function () { return { x: 1024, // Center of screen horizontally y: 1366, // Center vertically to cover entire map damage: 50 }; }; self.laserAttack = function () { return { x: self.x, y: 1366, // Center vertically damage: 50 }; }; self.update = function () { // Check for final attack trigger (when health drops to 1000 or below) if (self.health <= 1000 && !self.finalAttackTriggered && !self.isFinalAttacking) { self.finalAttackTriggered = true; self.startFinalAttack(); return "finalAttack"; } // Handle final attack if (self.isFinalAttacking && !self.finalAttackCanceled) { self.finalAttackTime++; if (self.finalAttackTime >= self.maxFinalAttackTime) { // Final attack completes - deal damage to entire screen self.isFinalAttacking = false; return "finalAttackComplete"; } return false; // Boss doesn't move during final attack } // Handle special attack timing if (!self.isFinalAttacking) { self.specialAttackTimer++; // Check if it's time for special attack if (self.specialAttackTimer >= self.specialAttackInterval && !self.isCharging) { self.isCharging = true; self.chargeTime = 0; // Create indicator if (!self.indicator) { self.indicator = self.addChild(LK.getAsset('bossSpecialIndicator', { anchorX: 0.5, anchorY: 0.5 })); self.indicator.y = 80; // Position above boss } } // Handle laser attack timing self.laserAttackTimer++; if (self.laserAttackTimer >= self.laserAttackInterval) { self.laserAttackTimer = 0; return "laser"; } } // Handle charging phase (boss stops moving) if (self.isCharging) { self.chargeTime++; // Make indicator blink if (self.indicator) { self.indicator.alpha = Math.sin(self.chargeTime * 0.3) * 0.5 + 0.5; } if (self.chargeTime >= self.maxChargeTime) { // End charging, launch special attack self.isCharging = false; self.specialAttackTimer = 0; // Remove indicator if (self.indicator) { self.indicator.destroy(); self.indicator = null; } return "special"; // Signal to create special attack } } else if (!self.isFinalAttacking) { // Normal movement only when not charging and not doing final attack // Handle horizontal movement self.x += self.moveSpeed * self.moveDirection; // Change direction when hitting bounds if (self.x <= self.leftBound) { self.moveDirection = 1; // Move right self.x = self.leftBound; } else if (self.x >= self.rightBound) { self.moveDirection = -1; // Move left self.x = self.rightBound; } // Handle vertical movement self.y += self.verticalSpeed * self.verticalDirection; // Change direction when hitting vertical bounds if (self.y <= self.topBound) { self.verticalDirection = 1; // Move down self.y = self.topBound; } else if (self.y >= self.bottomBound) { self.verticalDirection = -1; // Move up self.y = self.bottomBound; } } // Normal attacks (only when not charging and not doing final attack) if (!self.isCharging && !self.isFinalAttacking) { self.attackCooldown++; if (self.attackCooldown >= self.attackInterval) { self.attackCooldown = 0; return true; // Signal to create attack } } return false; }; return self; }); var BossAttack = Container.expand(function () { var self = Container.call(this); var attackGraphics = self.attachAsset('bossAttack', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.damage = 25; self.update = function () { self.y += self.speed; }; return self; }); var BossFinalAttack = Container.expand(function () { var self = Container.call(this); var attackGraphics = self.attachAsset('bossFinalAttack', { anchorX: 0.5, anchorY: 0.5 }); attackGraphics.alpha = 0.4; // Semi-transparent red overlay covering entire screen self.damage = 50; self.lifeTime = 0; self.maxLifeTime = 60; // 1 second visible self.update = function () { self.lifeTime++; // Pulsing effect for entire screen coverage attackGraphics.alpha = 0.4 + Math.sin(self.lifeTime * 0.3) * 0.3; }; return self; }); var BossLaser = Container.expand(function () { var self = Container.call(this); var laserGraphics = self.attachAsset('bossLaser', { anchorX: 0.5, anchorY: 0.5 }); self.damage = 50; self.lifeTime = 0; self.maxLifeTime = 600; // 10 seconds visible self.update = function () { self.lifeTime++; // Follow boss position horizontally self.x = boss.x; // Pulsing effect laserGraphics.alpha = 0.7 + Math.sin(self.lifeTime * 0.4) * 0.3; }; return self; }); var BossSpecialAttack = Container.expand(function () { var self = Container.call(this); var attackGraphics = self.attachAsset('bossSpecialAttack', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6; self.damage = 5; self.update = function () { self.y += self.speed; }; return self; }); // Game variables var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.maxHealth = 100; self.health = 100; self.attackDamage = 50; self.takeDamage = function (damage) { self.health -= damage; if (self.health < 0) self.health = 0; // Flash red when taking damage tween(playerGraphics, { tint: 0xff8888 }, { duration: 100, onFinish: function onFinish() { tween(playerGraphics, { tint: 0xffffff }, { duration: 100 }); } }); }; self.attack = function () { return { x: self.x, y: self.y - 50, damage: self.attackDamage }; }; return self; }); var PlayerAttack = Container.expand(function () { var self = Container.call(this); var attackGraphics = self.attachAsset('playerAttack', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -24; self.damage = 50; self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Sounds // Attack effects // Attack button // Player assets // Boss assets // Game variables var boss; var player; var playerAttacks = []; var bossAttacks = []; var bossSpecialAttacks = []; var bossFinalAttacks = []; var bossLasers = []; var dragNode = null; var playerLastX = 0; var playerLastY = 0; // Health bars var bossHealthBarBg, bossHealthBar; var playerHealthBarBg, playerHealthBar; // Health text var bossHealthText, playerHealthText; // Initialize boss boss = game.addChild(new Boss()); boss.x = 1024; boss.y = 400; // Initialize player player = game.addChild(new Player()); player.x = 1024; player.y = 2200; playerLastX = player.x; playerLastY = player.y; // Create boss health bar bossHealthBarBg = game.addChild(LK.getAsset('bossHealthBarBg', { anchorX: 0.5, anchorY: 0.5 })); bossHealthBarBg.x = 1024; bossHealthBarBg.y = 200; bossHealthBar = game.addChild(LK.getAsset('bossHealthBar', { anchorX: 0.5, anchorY: 0.5 })); bossHealthBar.x = 1024; bossHealthBar.y = 200; // Create player health bar playerHealthBarBg = game.addChild(LK.getAsset('playerHealthBarBg', { anchorX: 0.5, anchorY: 0.5 })); playerHealthBarBg.x = 1024; playerHealthBarBg.y = 2500; playerHealthBar = game.addChild(LK.getAsset('playerHealthBar', { anchorX: 0.5, anchorY: 0.5 })); playerHealthBar.x = 1024; playerHealthBar.y = 2500; // Create health text bossHealthText = new Text2('10000/10000', { size: 40, fill: 0xFFFFFF }); bossHealthText.anchor.set(0.5, 0.5); bossHealthText.x = 1024; bossHealthText.y = 160; game.addChild(bossHealthText); playerHealthText = new Text2('100/100', { size: 30, fill: 0xFFFFFF }); playerHealthText.anchor.set(0.5, 0.5); playerHealthText.x = 1024; playerHealthText.y = 2540; game.addChild(playerHealthText); // Player movement game.move = function (x, y, obj) { if (dragNode) { dragNode.x = x; dragNode.y = y; // Keep player within bounds if (dragNode.x < 50) dragNode.x = 50; if (dragNode.x > 1998) dragNode.x = 1998; if (dragNode.y < 800) dragNode.y = 800; if (dragNode.y > 2600) dragNode.y = 2600; } }; game.down = function (x, y, obj) { dragNode = player; game.move(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; // Main game update loop game.update = function () { // Update player attacks for (var i = playerAttacks.length - 1; i >= 0; i--) { var attack = playerAttacks[i]; // Check if attack hit boss if (attack.intersects(boss)) { boss.takeDamage(attack.damage); // Cancel final attack if boss is doing it if (boss.isFinalAttacking && !boss.finalAttackCanceled) { boss.cancelFinalAttack(); } LK.getSound('hitSound').play(); attack.destroy(); playerAttacks.splice(i, 1); continue; } // Remove if off screen if (attack.y < -50) { attack.destroy(); playerAttacks.splice(i, 1); } } // Update boss attacks for (var j = bossAttacks.length - 1; j >= 0; j--) { var bossAttack = bossAttacks[j]; // Check if attack hit player if (bossAttack.intersects(player)) { player.takeDamage(bossAttack.damage); LK.getSound('hitSound').play(); bossAttack.destroy(); bossAttacks.splice(j, 1); continue; } // Remove if off screen if (bossAttack.y > 2780) { bossAttack.destroy(); bossAttacks.splice(j, 1); } } // Update boss special attacks for (var k = bossSpecialAttacks.length - 1; k >= 0; k--) { var specialAttack = bossSpecialAttacks[k]; // Check if special attack hit player if (specialAttack.intersects(player)) { player.takeDamage(specialAttack.damage); LK.getSound('hitSound').play(); specialAttack.destroy(); bossSpecialAttacks.splice(k, 1); continue; } // Remove if off screen if (specialAttack.y > 2780) { specialAttack.destroy(); bossSpecialAttacks.splice(k, 1); } } // Player automatic attack every 20 frames if (LK.ticks % 20 == 0) { var attackData = player.attack(); var newPlayerAttack = new PlayerAttack(); newPlayerAttack.x = attackData.x; newPlayerAttack.y = attackData.y; playerAttacks.push(newPlayerAttack); game.addChild(newPlayerAttack); } // Update boss final attacks for (var l = bossFinalAttacks.length - 1; l >= 0; l--) { var finalAttack = bossFinalAttacks[l]; // Check if final attack hit player (covers entire screen) if (finalAttack.intersects(player)) { player.takeDamage(finalAttack.damage); LK.getSound('hitSound').play(); } // Remove after lifetime expires if (finalAttack.lifeTime >= finalAttack.maxLifeTime) { finalAttack.destroy(); bossFinalAttacks.splice(l, 1); } } // Update boss laser attacks for (var m = bossLasers.length - 1; m >= 0; m--) { var laser = bossLasers[m]; // Check if laser hit player AND player is moving var playerIsMoving = player.x !== playerLastX || player.y !== playerLastY; if (laser.intersects(player) && playerIsMoving) { player.takeDamage(laser.damage); LK.getSound('hitSound').play(); } // Remove after lifetime expires if (laser.lifeTime >= laser.maxLifeTime) { laser.destroy(); bossLasers.splice(m, 1); } } // Update player movement tracking playerLastX = player.x; playerLastY = player.y; // Boss attack logic var bossUpdateResult = boss.update(); if (bossUpdateResult === true) { var attackData = boss.attack(); var newBossAttack = new BossAttack(); newBossAttack.x = attackData.x; newBossAttack.y = attackData.y; bossAttacks.push(newBossAttack); game.addChild(newBossAttack); LK.getSound('bossAttackSound').play(); } else if (bossUpdateResult === "special") { var specialAttackData = boss.specialAttack(); var newSpecialAttack = new BossSpecialAttack(); newSpecialAttack.x = specialAttackData.x; newSpecialAttack.y = specialAttackData.y; bossSpecialAttacks.push(newSpecialAttack); game.addChild(newSpecialAttack); LK.getSound('bossAttackSound').play(); } else if (bossUpdateResult === "finalAttack") { // Flash screen red to indicate final attack starting LK.effects.flashScreen(0xff0000, 500); } else if (bossUpdateResult === "finalAttackComplete") { // Create final attack that covers entire map/screen var finalAttackData = boss.finalAttack(); var newFinalAttack = new BossFinalAttack(); newFinalAttack.x = 1024; // Center horizontally to cover entire map width newFinalAttack.y = 1366; // Center vertically to cover entire map height bossFinalAttacks.push(newFinalAttack); game.addChild(newFinalAttack); LK.getSound('bossAttackSound').play(); } else if (bossUpdateResult === "laser") { // Create laser attack var laserAttackData = boss.laserAttack(); var newLaser = new BossLaser(); newLaser.x = laserAttackData.x; newLaser.y = laserAttackData.y; bossLasers.push(newLaser); game.addChild(newLaser); LK.getSound('bossAttackSound').play(); } // Update health bars var bossHealthPercent = boss.health / boss.maxHealth; bossHealthBar.scaleX = bossHealthPercent; var playerHealthPercent = player.health / player.maxHealth; playerHealthBar.scaleX = playerHealthPercent; // Update health text bossHealthText.setText(boss.health + '/' + boss.maxHealth); playerHealthText.setText(player.health + '/' + player.maxHealth); // Check win condition if (boss.health <= 0) { LK.showYouWin(); } // Check lose condition if (player.health <= 0) { LK.showGameOver(); } };
/****
* 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.maxHealth = 10000;
self.health = 10000;
self.attackCooldown = 0;
self.attackInterval = 180; // 3 seconds at 60fps
self.moveDirection = 1; // 1 for right, -1 for left
self.moveSpeed = 2;
self.leftBound = 200;
self.rightBound = 1848;
self.verticalDirection = 1; // 1 for down, -1 for up
self.verticalSpeed = 1;
self.topBound = 300;
self.bottomBound = 500;
self.specialAttackTimer = 0;
self.specialAttackInterval = 300; // 5 seconds at 60fps
self.isCharging = false;
self.chargeTime = 0;
self.maxChargeTime = 60; // 1 second at 60fps
self.indicator = null;
self.finalAttackTriggered = false;
self.isFinalAttacking = false;
self.finalAttackTime = 0;
self.maxFinalAttackTime = 180; // 3 seconds at 60fps
self.finalAttackCanceled = false;
self.laserAttackTimer = 0;
self.laserAttackInterval = 900; // 15 seconds at 60fps
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health < 0) self.health = 0;
// Flash red when taking damage
tween(bossGraphics, {
tint: 0xff8888
}, {
duration: 100,
onFinish: function onFinish() {
tween(bossGraphics, {
tint: 0xffffff
}, {
duration: 100
});
}
});
};
self.attack = function () {
return {
x: self.x,
y: self.y + 100,
damage: 25
};
};
self.specialAttack = function () {
return {
x: self.x,
y: self.y + 100,
damage: 5
};
};
self.startFinalAttack = function () {
self.isFinalAttacking = true;
self.finalAttackTime = 0;
self.finalAttackCanceled = false;
// Boss stops moving during final attack
};
self.cancelFinalAttack = function () {
self.finalAttackCanceled = true;
self.isFinalAttacking = false;
self.finalAttackTime = 0;
};
self.finalAttack = function () {
return {
x: 1024,
// Center of screen horizontally
y: 1366,
// Center vertically to cover entire map
damage: 50
};
};
self.laserAttack = function () {
return {
x: self.x,
y: 1366,
// Center vertically
damage: 50
};
};
self.update = function () {
// Check for final attack trigger (when health drops to 1000 or below)
if (self.health <= 1000 && !self.finalAttackTriggered && !self.isFinalAttacking) {
self.finalAttackTriggered = true;
self.startFinalAttack();
return "finalAttack";
}
// Handle final attack
if (self.isFinalAttacking && !self.finalAttackCanceled) {
self.finalAttackTime++;
if (self.finalAttackTime >= self.maxFinalAttackTime) {
// Final attack completes - deal damage to entire screen
self.isFinalAttacking = false;
return "finalAttackComplete";
}
return false; // Boss doesn't move during final attack
}
// Handle special attack timing
if (!self.isFinalAttacking) {
self.specialAttackTimer++;
// Check if it's time for special attack
if (self.specialAttackTimer >= self.specialAttackInterval && !self.isCharging) {
self.isCharging = true;
self.chargeTime = 0;
// Create indicator
if (!self.indicator) {
self.indicator = self.addChild(LK.getAsset('bossSpecialIndicator', {
anchorX: 0.5,
anchorY: 0.5
}));
self.indicator.y = 80; // Position above boss
}
}
// Handle laser attack timing
self.laserAttackTimer++;
if (self.laserAttackTimer >= self.laserAttackInterval) {
self.laserAttackTimer = 0;
return "laser";
}
}
// Handle charging phase (boss stops moving)
if (self.isCharging) {
self.chargeTime++;
// Make indicator blink
if (self.indicator) {
self.indicator.alpha = Math.sin(self.chargeTime * 0.3) * 0.5 + 0.5;
}
if (self.chargeTime >= self.maxChargeTime) {
// End charging, launch special attack
self.isCharging = false;
self.specialAttackTimer = 0;
// Remove indicator
if (self.indicator) {
self.indicator.destroy();
self.indicator = null;
}
return "special"; // Signal to create special attack
}
} else if (!self.isFinalAttacking) {
// Normal movement only when not charging and not doing final attack
// Handle horizontal movement
self.x += self.moveSpeed * self.moveDirection;
// Change direction when hitting bounds
if (self.x <= self.leftBound) {
self.moveDirection = 1; // Move right
self.x = self.leftBound;
} else if (self.x >= self.rightBound) {
self.moveDirection = -1; // Move left
self.x = self.rightBound;
}
// Handle vertical movement
self.y += self.verticalSpeed * self.verticalDirection;
// Change direction when hitting vertical bounds
if (self.y <= self.topBound) {
self.verticalDirection = 1; // Move down
self.y = self.topBound;
} else if (self.y >= self.bottomBound) {
self.verticalDirection = -1; // Move up
self.y = self.bottomBound;
}
}
// Normal attacks (only when not charging and not doing final attack)
if (!self.isCharging && !self.isFinalAttacking) {
self.attackCooldown++;
if (self.attackCooldown >= self.attackInterval) {
self.attackCooldown = 0;
return true; // Signal to create attack
}
}
return false;
};
return self;
});
var BossAttack = Container.expand(function () {
var self = Container.call(this);
var attackGraphics = self.attachAsset('bossAttack', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.damage = 25;
self.update = function () {
self.y += self.speed;
};
return self;
});
var BossFinalAttack = Container.expand(function () {
var self = Container.call(this);
var attackGraphics = self.attachAsset('bossFinalAttack', {
anchorX: 0.5,
anchorY: 0.5
});
attackGraphics.alpha = 0.4; // Semi-transparent red overlay covering entire screen
self.damage = 50;
self.lifeTime = 0;
self.maxLifeTime = 60; // 1 second visible
self.update = function () {
self.lifeTime++;
// Pulsing effect for entire screen coverage
attackGraphics.alpha = 0.4 + Math.sin(self.lifeTime * 0.3) * 0.3;
};
return self;
});
var BossLaser = Container.expand(function () {
var self = Container.call(this);
var laserGraphics = self.attachAsset('bossLaser', {
anchorX: 0.5,
anchorY: 0.5
});
self.damage = 50;
self.lifeTime = 0;
self.maxLifeTime = 600; // 10 seconds visible
self.update = function () {
self.lifeTime++;
// Follow boss position horizontally
self.x = boss.x;
// Pulsing effect
laserGraphics.alpha = 0.7 + Math.sin(self.lifeTime * 0.4) * 0.3;
};
return self;
});
var BossSpecialAttack = Container.expand(function () {
var self = Container.call(this);
var attackGraphics = self.attachAsset('bossSpecialAttack', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 6;
self.damage = 5;
self.update = function () {
self.y += self.speed;
};
return self;
});
// Game variables
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.maxHealth = 100;
self.health = 100;
self.attackDamage = 50;
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health < 0) self.health = 0;
// Flash red when taking damage
tween(playerGraphics, {
tint: 0xff8888
}, {
duration: 100,
onFinish: function onFinish() {
tween(playerGraphics, {
tint: 0xffffff
}, {
duration: 100
});
}
});
};
self.attack = function () {
return {
x: self.x,
y: self.y - 50,
damage: self.attackDamage
};
};
return self;
});
var PlayerAttack = Container.expand(function () {
var self = Container.call(this);
var attackGraphics = self.attachAsset('playerAttack', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -24;
self.damage = 50;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Sounds
// Attack effects
// Attack button
// Player assets
// Boss assets
// Game variables
var boss;
var player;
var playerAttacks = [];
var bossAttacks = [];
var bossSpecialAttacks = [];
var bossFinalAttacks = [];
var bossLasers = [];
var dragNode = null;
var playerLastX = 0;
var playerLastY = 0;
// Health bars
var bossHealthBarBg, bossHealthBar;
var playerHealthBarBg, playerHealthBar;
// Health text
var bossHealthText, playerHealthText;
// Initialize boss
boss = game.addChild(new Boss());
boss.x = 1024;
boss.y = 400;
// Initialize player
player = game.addChild(new Player());
player.x = 1024;
player.y = 2200;
playerLastX = player.x;
playerLastY = player.y;
// Create boss health bar
bossHealthBarBg = game.addChild(LK.getAsset('bossHealthBarBg', {
anchorX: 0.5,
anchorY: 0.5
}));
bossHealthBarBg.x = 1024;
bossHealthBarBg.y = 200;
bossHealthBar = game.addChild(LK.getAsset('bossHealthBar', {
anchorX: 0.5,
anchorY: 0.5
}));
bossHealthBar.x = 1024;
bossHealthBar.y = 200;
// Create player health bar
playerHealthBarBg = game.addChild(LK.getAsset('playerHealthBarBg', {
anchorX: 0.5,
anchorY: 0.5
}));
playerHealthBarBg.x = 1024;
playerHealthBarBg.y = 2500;
playerHealthBar = game.addChild(LK.getAsset('playerHealthBar', {
anchorX: 0.5,
anchorY: 0.5
}));
playerHealthBar.x = 1024;
playerHealthBar.y = 2500;
// Create health text
bossHealthText = new Text2('10000/10000', {
size: 40,
fill: 0xFFFFFF
});
bossHealthText.anchor.set(0.5, 0.5);
bossHealthText.x = 1024;
bossHealthText.y = 160;
game.addChild(bossHealthText);
playerHealthText = new Text2('100/100', {
size: 30,
fill: 0xFFFFFF
});
playerHealthText.anchor.set(0.5, 0.5);
playerHealthText.x = 1024;
playerHealthText.y = 2540;
game.addChild(playerHealthText);
// Player movement
game.move = function (x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
// Keep player within bounds
if (dragNode.x < 50) dragNode.x = 50;
if (dragNode.x > 1998) dragNode.x = 1998;
if (dragNode.y < 800) dragNode.y = 800;
if (dragNode.y > 2600) dragNode.y = 2600;
}
};
game.down = function (x, y, obj) {
dragNode = player;
game.move(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Main game update loop
game.update = function () {
// Update player attacks
for (var i = playerAttacks.length - 1; i >= 0; i--) {
var attack = playerAttacks[i];
// Check if attack hit boss
if (attack.intersects(boss)) {
boss.takeDamage(attack.damage);
// Cancel final attack if boss is doing it
if (boss.isFinalAttacking && !boss.finalAttackCanceled) {
boss.cancelFinalAttack();
}
LK.getSound('hitSound').play();
attack.destroy();
playerAttacks.splice(i, 1);
continue;
}
// Remove if off screen
if (attack.y < -50) {
attack.destroy();
playerAttacks.splice(i, 1);
}
}
// Update boss attacks
for (var j = bossAttacks.length - 1; j >= 0; j--) {
var bossAttack = bossAttacks[j];
// Check if attack hit player
if (bossAttack.intersects(player)) {
player.takeDamage(bossAttack.damage);
LK.getSound('hitSound').play();
bossAttack.destroy();
bossAttacks.splice(j, 1);
continue;
}
// Remove if off screen
if (bossAttack.y > 2780) {
bossAttack.destroy();
bossAttacks.splice(j, 1);
}
}
// Update boss special attacks
for (var k = bossSpecialAttacks.length - 1; k >= 0; k--) {
var specialAttack = bossSpecialAttacks[k];
// Check if special attack hit player
if (specialAttack.intersects(player)) {
player.takeDamage(specialAttack.damage);
LK.getSound('hitSound').play();
specialAttack.destroy();
bossSpecialAttacks.splice(k, 1);
continue;
}
// Remove if off screen
if (specialAttack.y > 2780) {
specialAttack.destroy();
bossSpecialAttacks.splice(k, 1);
}
}
// Player automatic attack every 20 frames
if (LK.ticks % 20 == 0) {
var attackData = player.attack();
var newPlayerAttack = new PlayerAttack();
newPlayerAttack.x = attackData.x;
newPlayerAttack.y = attackData.y;
playerAttacks.push(newPlayerAttack);
game.addChild(newPlayerAttack);
}
// Update boss final attacks
for (var l = bossFinalAttacks.length - 1; l >= 0; l--) {
var finalAttack = bossFinalAttacks[l];
// Check if final attack hit player (covers entire screen)
if (finalAttack.intersects(player)) {
player.takeDamage(finalAttack.damage);
LK.getSound('hitSound').play();
}
// Remove after lifetime expires
if (finalAttack.lifeTime >= finalAttack.maxLifeTime) {
finalAttack.destroy();
bossFinalAttacks.splice(l, 1);
}
}
// Update boss laser attacks
for (var m = bossLasers.length - 1; m >= 0; m--) {
var laser = bossLasers[m];
// Check if laser hit player AND player is moving
var playerIsMoving = player.x !== playerLastX || player.y !== playerLastY;
if (laser.intersects(player) && playerIsMoving) {
player.takeDamage(laser.damage);
LK.getSound('hitSound').play();
}
// Remove after lifetime expires
if (laser.lifeTime >= laser.maxLifeTime) {
laser.destroy();
bossLasers.splice(m, 1);
}
}
// Update player movement tracking
playerLastX = player.x;
playerLastY = player.y;
// Boss attack logic
var bossUpdateResult = boss.update();
if (bossUpdateResult === true) {
var attackData = boss.attack();
var newBossAttack = new BossAttack();
newBossAttack.x = attackData.x;
newBossAttack.y = attackData.y;
bossAttacks.push(newBossAttack);
game.addChild(newBossAttack);
LK.getSound('bossAttackSound').play();
} else if (bossUpdateResult === "special") {
var specialAttackData = boss.specialAttack();
var newSpecialAttack = new BossSpecialAttack();
newSpecialAttack.x = specialAttackData.x;
newSpecialAttack.y = specialAttackData.y;
bossSpecialAttacks.push(newSpecialAttack);
game.addChild(newSpecialAttack);
LK.getSound('bossAttackSound').play();
} else if (bossUpdateResult === "finalAttack") {
// Flash screen red to indicate final attack starting
LK.effects.flashScreen(0xff0000, 500);
} else if (bossUpdateResult === "finalAttackComplete") {
// Create final attack that covers entire map/screen
var finalAttackData = boss.finalAttack();
var newFinalAttack = new BossFinalAttack();
newFinalAttack.x = 1024; // Center horizontally to cover entire map width
newFinalAttack.y = 1366; // Center vertically to cover entire map height
bossFinalAttacks.push(newFinalAttack);
game.addChild(newFinalAttack);
LK.getSound('bossAttackSound').play();
} else if (bossUpdateResult === "laser") {
// Create laser attack
var laserAttackData = boss.laserAttack();
var newLaser = new BossLaser();
newLaser.x = laserAttackData.x;
newLaser.y = laserAttackData.y;
bossLasers.push(newLaser);
game.addChild(newLaser);
LK.getSound('bossAttackSound').play();
}
// Update health bars
var bossHealthPercent = boss.health / boss.maxHealth;
bossHealthBar.scaleX = bossHealthPercent;
var playerHealthPercent = player.health / player.maxHealth;
playerHealthBar.scaleX = playerHealthPercent;
// Update health text
bossHealthText.setText(boss.health + '/' + boss.maxHealth);
playerHealthText.setText(player.health + '/' + player.maxHealth);
// Check win condition
if (boss.health <= 0) {
LK.showYouWin();
}
// Check lose condition
if (player.health <= 0) {
LK.showGameOver();
}
};
Una nave espacial futurista mirada desde arriba en pixel art. In-Game asset. 2d. High contrast. No shadows
Un mounstro gigante con alas mirado desde arriba en pixel art. In-Game asset. 2d. High contrast. No shadows
Fuego amarillo en pixel art. In-Game asset. 2d. High contrast. No shadows
Una barra de jefe final en juego pixel art. In-Game asset. 2d. High contrast. No shadows
Ráfaga de fuego roja en pixel art. In-Game asset. 2d. High contrast. No shadows
Estrella blanca en pixel art. In-Game asset. 2d. High contrast. No shadows