User prompt
reduce 2nd stage boss3 dificulty
User prompt
make boss3 life shorter
User prompt
Returno shoot power to original state
User prompt
make the hero power double on each shot
User prompt
Make the hero stop shooting when enemy health gets to 0
User prompt
Add the same black asset when each boss is killed, to make a better view on "next stage" asset
User prompt
Create a black background wallpaper, that is shown when and while the boss intro appears
User prompt
The hero only starts to shoot when the boss intro asset disappears. reduce cooldown time on shoots to one shot each 150ms
User prompt
The music starts at the same time as the game logo
User prompt
When boss health comes to 0, it vanishes and stops attacking.
Code edit (1 edits merged)
Please save this source code
User prompt
Quando eu clicar no botão Next Stage, ele se esconde e só aparece novamente quando finalizo o novo chefe
User prompt
The button must be an asset that is clickable
User prompt
Add button: Next Stage to make progress to next boss
User prompt
✅ Fix win condition to only trigger after defeating all 4 bosses
User prompt
The message "YOU WIN! Play again" only must be displayed when you kill all 4 bossess
User prompt
transform all sound effects to mp3
User prompt
The game must have 4 stages, each one with its own boss
User prompt
The hero must face the bossess in the following order: Boss1, Boss2, Boss3, Boss4
User prompt
make the hero autoshoot very fast
User prompt
When i finished the 1st boss, i must face the 2nd boss. When i finish the 2nd boss, i must face the 3rd Boss. When i Finish the 3rd boss, then i must face the final boss
User prompt
When i finished the 1st boss, i must face the 2nd boss
Code edit (1 edits merged)
Please save this source code
User prompt
the game is ending when i finish 1st boss.
User prompt
the game is mute
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Boss = Container.expand(function () { var self = Container.call(this); self.maxHealth = 300; self.health = self.maxHealth; self.patternIndex = 0; self.patternTimer = 0; self.isVulnerable = false; self.vulnerabilityTimer = 0; self.attackPatterns = []; self.attackPatternsPhase2 = []; self.currentPhase = 1; self.lastHealthPercentage = 1.0; self.takeDamage = function (damage) { if (self.isVulnerable) { self.health -= damage; LK.effects.flashObject(self, 0xffffff, 200); LK.getSound('bossHit').play(); if (self.health <= 0) { self.health = 0; self.onDefeat(); } } }; self.onDefeat = function () { LK.getSound('bossDefeat').play(); // Restore player health to maximum after boss defeat if (player) { player.health = player.maxHealth; } // Only increment boss index after confirming current boss is defeated var nextBossIndex = currentBossIndex + 1; console.log("Boss defeated. Current index:", currentBossIndex, "Next index:", nextBossIndex, "Total bosses:", bossConfigs.length); if (nextBossIndex >= bossConfigs.length) { console.log("All bosses defeated - showing win screen"); LK.showYouWin(); } else { // Update the index only when we're sure we're progressing to next boss currentBossIndex = nextBossIndex; console.log("Progressing to boss", currentBossIndex + 1); // Add a small delay to ensure proper cleanup before spawning next boss LK.setTimeout(function () { spawnNextBoss(); }, 500); } }; self.executePattern = function () { // Override in specific boss classes }; self.update = function () { self.patternTimer++; if (self.vulnerabilityTimer > 0) { self.vulnerabilityTimer--; if (self.vulnerabilityTimer <= 0) { self.isVulnerable = false; } } // Check for phase transition at 50% health var currentHealthPercentage = self.health / self.maxHealth; if (self.currentPhase === 1 && currentHealthPercentage <= 0.5 && self.lastHealthPercentage > 0.5) { self.currentPhase = 2; self.patternIndex = 0; self.patternTimer = 0; LK.effects.flashObject(self, 0xffffff, 1000); // Start phase 2 flashing effect self.startPhase2Flash(); // Start phase 2 flashing effect self.startPhase2Flash(); // Start phase 2 flashing effect self.startPhase2Flash(); } self.lastHealthPercentage = currentHealthPercentage; self.executePattern(); }; return self; }); var Boss4 = Boss.expand(function () { var self = Boss.call(this); var bossGraphics = self.attachAsset('boss4', { anchorX: 0.5, anchorY: 0.5, alpha: 1.0 }); self.maxHealth = 600; self.health = self.maxHealth; self.attackPatterns = [{ duration: 120, action: 'ultimate_sweep' }, { duration: 100, action: 'chaos_storm' }, { duration: 150, action: 'teleport_barrage' }, { duration: 120, action: 'gravity_pull' }, { duration: 80, action: 'laser_grid' }, { duration: 90, action: 'vulnerable' }]; self.attackPatternsPhase2 = [{ duration: 80, action: 'apocalypse_sweep' }, { duration: 60, action: 'death_spiral' }, { duration: 100, action: 'final_barrage' }, { duration: 120, action: 'dimensional_rift' }, { duration: 70, action: 'omega_grid' }, { duration: 60, action: 'vulnerable' }]; self.executePattern = function () { var patterns = self.currentPhase === 1 ? self.attackPatterns : self.attackPatternsPhase2; var currentPattern = patterns[self.patternIndex]; if (self.patternTimer >= currentPattern.duration) { self.patternTimer = 0; self.patternIndex = (self.patternIndex + 1) % patterns.length; } switch (currentPattern.action) { case 'ultimate_sweep': if (self.patternTimer % 8 === 0) { self.ultimateSweep(); } break; case 'chaos_storm': if (self.patternTimer % 4 === 0) { self.chaosStorm(); } break; case 'teleport_barrage': if (self.patternTimer % 25 === 0) { self.teleportBarrage(); } break; case 'gravity_pull': if (self.patternTimer === 1) { self.gravityPull(); } break; case 'laser_grid': if (self.patternTimer % 15 === 0) { self.laserGrid(); } break; case 'vulnerable': self.isVulnerable = true; self.vulnerabilityTimer = 90; tween(bossGraphics, { alpha: 0.4 }, { duration: 200 }); break; case 'apocalypse_sweep': if (self.patternTimer % 5 === 0) { self.apocalypseSweep(); } break; case 'death_spiral': if (self.patternTimer % 6 === 0) { self.deathSpiral(); } break; case 'final_barrage': if (self.patternTimer % 3 === 0) { self.finalBarrage(); } break; case 'dimensional_rift': if (self.patternTimer % 20 === 0) { self.dimensionalRift(); } break; case 'omega_grid': if (self.patternTimer % 10 === 0) { self.omegaGrid(); } break; } }; self.ultimateSweep = function () { for (var i = 0; i < 7; i++) { var bullet = new BossBullet(); bullet.x = self.x + (i - 3) * 40; bullet.y = self.y + 50; bullet.direction = { x: (i - 3) * 0.2, y: 1 }; bullet.speed = 7; bossBullets.push(bullet); game.addChild(bullet); } }; self.chaosStorm = function () { for (var i = 0; i < 4; i++) { var bullet = new BossBullet(); bullet.x = self.x + (Math.random() - 0.5) * 400; bullet.y = self.y + 50; bullet.direction = { x: (Math.random() - 0.5) * 4, y: 0.8 + Math.random() * 0.4 }; bullet.speed = 6 + Math.random() * 3; bossBullets.push(bullet); game.addChild(bullet); } }; self.teleportBarrage = function () { var teleportPositions = [{ x: arenaLeft + 200, y: arenaTop + 250 }, { x: arenaRight - 200, y: arenaTop + 250 }, { x: 1024, y: arenaTop + 150 }, { x: arenaLeft + 300, y: arenaTop + 400 }, { x: arenaRight - 300, y: arenaTop + 400 }]; var randomPos = teleportPositions[Math.floor(Math.random() * teleportPositions.length)]; tween(self, { x: randomPos.x, y: randomPos.y }, { duration: 200 }); // Massive bullet spread after teleport LK.setTimeout(function () { for (var i = 0; i < 12; i++) { var angle = i / 12 * Math.PI * 2; var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y; bullet.direction = { x: Math.cos(angle), y: Math.sin(angle) }; bullet.speed = 5; bossBullets.push(bullet); game.addChild(bullet); } }, 300); }; self.gravityPull = function () { // Pull effect - move towards player position over time var targetX = Math.max(arenaLeft + 200, Math.min(arenaRight - 200, player.x)); var targetY = Math.max(arenaTop + 200, Math.min(arenaBottom - 300, player.y - 150)); tween(self, { x: targetX, y: targetY }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { // Explosion of bullets in all directions for (var i = 0; i < 16; i++) { var angle = i / 16 * Math.PI * 2; var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y; bullet.direction = { x: Math.cos(angle), y: Math.sin(angle) }; bullet.speed = 6; bossBullets.push(bullet); game.addChild(bullet); } } }); }; self.laserGrid = function () { // Create grid pattern of bullets for (var row = 0; row < 3; row++) { for (var col = 0; col < 5; col++) { var bullet = new BossBullet(); bullet.x = arenaLeft + 200 + col * 300; bullet.y = self.y + row * 80; bullet.direction = { x: 0, y: 1 }; bullet.speed = 4 + row; bossBullets.push(bullet); game.addChild(bullet); } } }; self.apocalypseSweep = function () { // Even more intense sweep for phase 2 for (var i = 0; i < 9; i++) { var bullet = new BossBullet(); bullet.x = self.x + (i - 4) * 35; bullet.y = self.y + 50; bullet.direction = { x: (i - 4) * 0.25, y: 1 }; bullet.speed = 8; bossBullets.push(bullet); game.addChild(bullet); } }; self.deathSpiral = function () { // Rotating spiral pattern var spiralCount = 6; for (var i = 0; i < spiralCount; i++) { var angle = (self.patternTimer * 0.3 + i * Math.PI * 2 / spiralCount) % (Math.PI * 2); var bullet = new BossBullet(); bullet.x = self.x + Math.cos(angle) * 100; bullet.y = self.y + Math.sin(angle) * 50 + 50; bullet.direction = { x: Math.cos(angle + Math.PI / 4) * 0.8, y: Math.sin(angle + Math.PI / 4) * 0.8 + 0.6 }; bullet.speed = 7; bossBullets.push(bullet); game.addChild(bullet); } }; self.finalBarrage = function () { // Overwhelming bullet hell for (var i = 0; i < 6; i++) { var bullet = new BossBullet(); bullet.x = self.x + (Math.random() - 0.5) * 500; bullet.y = self.y + Math.random() * 100; var angleToPlayer = Math.atan2(player.y - bullet.y, player.x - bullet.x); bullet.direction = { x: Math.cos(angleToPlayer + (Math.random() - 0.5) * 0.8), y: Math.sin(angleToPlayer + (Math.random() - 0.5) * 0.8) }; bullet.speed = 5 + Math.random() * 4; bossBullets.push(bullet); game.addChild(bullet); } }; self.dimensionalRift = function () { // Teleport to multiple positions rapidly var positions = [{ x: arenaLeft + 150, y: arenaTop + 200 }, { x: arenaRight - 150, y: arenaTop + 200 }, { x: 1024, y: arenaTop + 350 }, { x: arenaLeft + 300, y: arenaTop + 500 }, { x: arenaRight - 300, y: arenaTop + 500 }]; for (var p = 0; p < 3; p++) { var pos = positions[Math.floor(Math.random() * positions.length)]; LK.setTimeout(function () { tween(self, { x: pos.x, y: pos.y }, { duration: 150 }); // Shoot bullets from each position for (var j = 0; j < 8; j++) { var angle = j / 8 * Math.PI * 2; var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y; bullet.direction = { x: Math.cos(angle), y: Math.sin(angle) }; bullet.speed = 6; bossBullets.push(bullet); game.addChild(bullet); } }, p * 200); } }; self.omegaGrid = function () { // Ultimate grid attack for (var row = 0; row < 4; row++) { for (var col = 0; col < 7; col++) { var bullet = new BossBullet(); bullet.x = arenaLeft + 150 + col * 250; bullet.y = self.y + row * 60; bullet.direction = { x: (col - 3) * 0.1, y: 1 }; bullet.speed = 5 + row; bossBullets.push(bullet); game.addChild(bullet); } } }; self.startPhase2Flash = function () { var flashToGold = function flashToGold() { tween(bossGraphics, { tint: 0xFFD700 }, { duration: 600, easing: tween.easeInOut, onFinish: flashToWhite }); }; var flashToWhite = function flashToWhite() { tween(bossGraphics, { tint: 0xFFFFFF }, { duration: 600, easing: tween.easeInOut, onFinish: flashToGold }); }; flashToGold(); }; return self; }); var Boss3 = Boss.expand(function () { var self = Boss.call(this); var bossGraphics = self.attachAsset('boss3', { anchorX: 0.5, anchorY: 0.5, alpha: 1.0 }); self.maxHealth = 500; self.health = self.maxHealth; self.attackPatterns = [{ duration: 100, action: 'laser_sweep' }, { duration: 80, action: 'bullet_hell' }, { duration: 120, action: 'dash_attack' }, { duration: 150, action: 'dive_attack' }, { duration: 100, action: 'horizontal_sweep' }, { duration: 120, action: 'diagonal_attack' }, { duration: 60, action: 'vulnerable' }]; self.attackPatternsPhase2 = [{ duration: 80, action: 'mega_laser_sweep' }, { duration: 60, action: 'chaos_bullets' }, { duration: 100, action: 'triple_dash' }, { duration: 120, action: 'power_dive' }, { duration: 80, action: 'spiral_sweep' }, { duration: 90, action: 'diagonal_barrage' }, { duration: 40, action: 'vulnerable' }]; self.executePattern = function () { var patterns = self.currentPhase === 1 ? self.attackPatterns : self.attackPatternsPhase2; var currentPattern = patterns[self.patternIndex]; if (self.patternTimer >= currentPattern.duration) { self.patternTimer = 0; self.patternIndex = (self.patternIndex + 1) % patterns.length; } switch (currentPattern.action) { case 'laser_sweep': if (self.patternTimer % 10 === 0) { self.shootLaser(); } break; case 'bullet_hell': if (self.patternTimer % 5 === 0) { self.shootRandomBullets(); } break; case 'dash_attack': if (self.patternTimer === 1) { var targetY = Math.min(player.y, arenaBottom - 150); // Keep boss at least 150px from bottom tween(self, { y: targetY }, { duration: 500 }); } break; case 'dive_attack': if (self.patternTimer === 1) { self.diveAttack(); } break; case 'vulnerable': self.isVulnerable = true; self.vulnerabilityTimer = 60; tween(bossGraphics, { alpha: 0.5 }, { duration: 200 }); break; case 'mega_laser_sweep': if (self.patternTimer % 6 === 0) { self.shootMegaLaser(); } break; case 'chaos_bullets': if (self.patternTimer % 3 === 0) { self.shootChaosBullets(); } break; case 'triple_dash': if (self.patternTimer % 30 === 0) { self.tripleDash(); } break; case 'power_dive': if (self.patternTimer === 1) { self.powerDive(); } break; case 'horizontal_sweep': if (self.patternTimer % 20 === 0) { self.horizontalSweep(); } break; case 'diagonal_attack': if (self.patternTimer % 15 === 0) { self.diagonalAttack(); } break; case 'spiral_sweep': if (self.patternTimer % 12 === 0) { self.spiralSweep(); } break; case 'diagonal_barrage': if (self.patternTimer % 8 === 0) { self.diagonalBarrage(); } break; } }; self.shootLaser = function () { for (var i = 0; i < 3; i++) { var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y + 50 + i * 20; bullet.direction = { x: 0, y: 1 }; bullet.speed = 6; bossBullets.push(bullet); game.addChild(bullet); } }; self.shootRandomBullets = function () { var bullet = new BossBullet(); bullet.x = self.x + (Math.random() - 0.5) * 200; bullet.y = self.y + 50; bullet.direction = { x: (Math.random() - 0.5) * 2, y: 1 }; bossBullets.push(bullet); game.addChild(bullet); }; self.shootMegaLaser = function () { for (var i = 0; i < 5; i++) { var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y + 50 + i * 15; bullet.direction = { x: 0, y: 1 }; bullet.speed = 8; bossBullets.push(bullet); game.addChild(bullet); } }; self.shootChaosBullets = function () { for (var i = 0; i < 3; i++) { var bullet = new BossBullet(); bullet.x = self.x + (Math.random() - 0.5) * 300; bullet.y = self.y + 50; bullet.direction = { x: (Math.random() - 0.5) * 3, y: 1 }; bullet.speed = 7; bossBullets.push(bullet); game.addChild(bullet); } }; self.tripleDash = function () { var dashTargets = [player.y - 100, player.y, player.y + 100]; // Ensure all dash targets stay above bottom threshold for (var j = 0; j < dashTargets.length; j++) { dashTargets[j] = Math.min(dashTargets[j], arenaBottom - 150); } for (var i = 0; i < dashTargets.length; i++) { tween(self, { y: dashTargets[i] }, { duration: 200, delay: i * 100 }); } }; self.diveAttack = function () { // Dive down to near bottom of screen tween(self, { y: arenaBottom - 100 }, { duration: 800, easing: tween.easeIn, onFinish: function onFinish() { // Return to top after brief pause LK.setTimeout(function () { tween(self, { y: arenaTop + 200 }, { duration: 600, easing: tween.easeOut }); }, 300); } }); }; self.powerDive = function () { // More aggressive dive attack for phase 2 tween(self, { y: arenaBottom - 80 }, { duration: 600, easing: tween.easeIn, onFinish: function onFinish() { // Shoot bullets while at bottom for (var i = 0; i < 5; i++) { var bullet = new BossBullet(); bullet.x = self.x + (i - 2) * 40; bullet.y = self.y; bullet.direction = { x: (i - 2) * 0.3, y: -1 }; bullet.speed = 5; bossBullets.push(bullet); game.addChild(bullet); } // Return to top faster LK.setTimeout(function () { tween(self, { y: arenaTop + 200 }, { duration: 400, easing: tween.easeOut }); }, 200); } }); }; self.horizontalSweep = function () { // Move horizontally across screen while shooting var targetX = self.x < 1024 ? arenaRight - 200 : arenaLeft + 200; tween(self, { x: targetX }, { duration: 1000, easing: tween.easeInOut }); // Shoot bullets downward while moving for (var i = 0; i < 2; i++) { var bullet = new BossBullet(); bullet.x = self.x + (i - 0.5) * 60; bullet.y = self.y + 50; bullet.direction = { x: 0, y: 1 }; bullet.speed = 5; bossBullets.push(bullet); game.addChild(bullet); } }; self.diagonalAttack = function () { // Move diagonally while shooting var targetX = self.x < 1024 ? arenaRight - 150 : arenaLeft + 150; var targetY = Math.min(self.y + 100, arenaBottom - 200); tween(self, { x: targetX, y: targetY }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { // Return to center top tween(self, { x: 1024, y: arenaTop + 200 }, { duration: 600, easing: tween.easeOut }); } }); // Shoot bullets diagonally for (var i = 0; i < 3; i++) { var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y + 40; bullet.direction = { x: (i - 1) * 0.5, y: 1 }; bullet.speed = 6; bossBullets.push(bullet); game.addChild(bullet); } }; self.spiralSweep = function () { // More aggressive horizontal movement for phase 2 var targetX = self.x < 1024 ? arenaRight - 150 : arenaLeft + 150; tween(self, { x: targetX }, { duration: 600, easing: tween.easeInOut }); // Shoot in spiral pattern while moving for (var i = 0; i < 4; i++) { var angle = (self.patternTimer * 0.2 + i * Math.PI / 2) % (Math.PI * 2); var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y + 50; bullet.direction = { x: Math.cos(angle) * 0.8, y: Math.sin(angle) * 0.8 + 0.5 }; bullet.speed = 6; bossBullets.push(bullet); game.addChild(bullet); } }; self.diagonalBarrage = function () { // Rapid diagonal movement with heavy firepower var targets = [{ x: arenaLeft + 200, y: arenaTop + 300 }, { x: arenaRight - 200, y: arenaTop + 300 }, { x: 1024, y: arenaTop + 150 }]; var targetIndex = Math.floor(self.patternTimer / 30) % targets.length; var target = targets[targetIndex]; tween(self, { x: target.x, y: target.y }, { duration: 400, easing: tween.easeInOut }); // Heavy diagonal shooting for (var i = 0; i < 5; i++) { var bullet = new BossBullet(); bullet.x = self.x + (i - 2) * 30; bullet.y = self.y + 50; var angleToPlayer = Math.atan2(player.y - bullet.y, player.x - bullet.x); bullet.direction = { x: Math.cos(angleToPlayer + (i - 2) * 0.3), y: Math.sin(angleToPlayer + (i - 2) * 0.3) }; bullet.speed = 7; bossBullets.push(bullet); game.addChild(bullet); } }; self.startPhase2Flash = function () { var flashToYellow = function flashToYellow() { tween(bossGraphics, { tint: 0xFFFF00 }, { duration: 800, easing: tween.easeInOut, onFinish: flashToRed }); }; var flashToRed = function flashToRed() { tween(bossGraphics, { tint: 0xFF0000 }, { duration: 800, easing: tween.easeInOut, onFinish: flashToYellow }); }; flashToYellow(); }; return self; }); var Boss2 = Boss.expand(function () { var self = Boss.call(this); var bossGraphics = self.attachAsset('boss2', { anchorX: 0.5, anchorY: 0.5, alpha: 1.0 }); self.maxHealth = 400; self.health = self.maxHealth; self.attackPatterns = [{ duration: 90, action: 'circle_pattern' }, { duration: 60, action: 'rapid_fire' }, { duration: 120, action: 'teleport' }, { duration: 80, action: 'vulnerable' }]; self.attackPatternsPhase2 = [{ duration: 70, action: 'double_circle' }, { duration: 45, action: 'homing_barrage' }, { duration: 90, action: 'shadow_teleport' }, { duration: 60, action: 'vulnerable' }]; self.executePattern = function () { var patterns = self.currentPhase === 1 ? self.attackPatterns : self.attackPatternsPhase2; var currentPattern = patterns[self.patternIndex]; if (self.patternTimer >= currentPattern.duration) { self.patternTimer = 0; self.patternIndex = (self.patternIndex + 1) % patterns.length; } switch (currentPattern.action) { case 'circle_pattern': if (self.patternTimer % 15 === 0) { self.shootCircle(); } break; case 'rapid_fire': if (self.patternTimer % 8 === 0) { self.shootAtPlayer(); } break; case 'teleport': if (self.patternTimer === 1) { var newX = arenaLeft + 200 + Math.random() * (arenaRight - arenaLeft - 400); tween(self, { x: newX }, { duration: 300 }); } break; case 'vulnerable': self.isVulnerable = true; self.vulnerabilityTimer = 80; tween(bossGraphics, { alpha: 0.6 }, { duration: 200 }); break; case 'double_circle': if (self.patternTimer % 12 === 0) { self.shootDoubleCircle(); } break; case 'homing_barrage': if (self.patternTimer % 6 === 0) { self.shootHomingBarrage(); } break; case 'shadow_teleport': if (self.patternTimer % 20 === 0) { self.shadowTeleport(); } break; } }; self.shootCircle = function () { for (var i = 0; i < 8; i++) { var angle = i / 8 * Math.PI * 2; var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y; bullet.direction = { x: Math.cos(angle), y: Math.sin(angle) }; bossBullets.push(bullet); game.addChild(bullet); } }; self.shootAtPlayer = function () { var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y + 50; var dx = player.x - self.x; var dy = player.y - self.y; var length = Math.sqrt(dx * dx + dy * dy); bullet.direction = { x: dx / length, y: dy / length }; bossBullets.push(bullet); game.addChild(bullet); }; self.shootDoubleCircle = function () { for (var ring = 0; ring < 2; ring++) { for (var i = 0; i < 6; i++) { var angle = i / 6 * Math.PI * 2 + ring * Math.PI / 6; var bullet = new BossBullet(); bullet.x = self.x; bullet.y = self.y; bullet.direction = { x: Math.cos(angle), y: Math.sin(angle) }; bullet.speed = 4 + ring * 2; bossBullets.push(bullet); game.addChild(bullet); } } }; self.shootHomingBarrage = function () { for (var i = 0; i < 2; i++) { var bullet = new BossBullet(); bullet.x = self.x + (i - 0.5) * 40; bullet.y = self.y + 50; var dx = player.x - bullet.x; var dy = player.y - bullet.y; var length = Math.sqrt(dx * dx + dy * dy); bullet.direction = { x: dx / length, y: dy / length }; bullet.speed = 6; bossBullets.push(bullet); game.addChild(bullet); } }; self.shadowTeleport = function () { var teleportPositions = [{ x: arenaLeft + 150, y: self.y }, { x: arenaRight - 150, y: self.y }, { x: 1024, y: arenaTop + 150 }]; var randomPos = teleportPositions[Math.floor(Math.random() * teleportPositions.length)]; tween(self, { x: randomPos.x, y: randomPos.y }, { duration: 250 }); }; self.startPhase2Flash = function () { var flashToYellow = function flashToYellow() { tween(bossGraphics, { tint: 0xFFFF00 }, { duration: 800, easing: tween.easeInOut, onFinish: flashToRed }); }; var flashToRed = function flashToRed() { tween(bossGraphics, { tint: 0xFF0000 }, { duration: 800, easing: tween.easeInOut, onFinish: flashToYellow }); }; flashToYellow(); }; return self; }); var Boss1 = Boss.expand(function () { var self = Boss.call(this); var bossGraphics = self.attachAsset('boss1', { anchorX: 0.5, anchorY: 0.5, alpha: 1.0 }); self.attackPatterns = [{ duration: 120, action: 'move_left' }, { duration: 60, action: 'shoot_spread' }, { duration: 120, action: 'move_right' }, { duration: 60, action: 'shoot_spread' }, { duration: 90, action: 'vulnerable' }]; self.attackPatternsPhase2 = [{ duration: 80, action: 'speed_dash' }, { duration: 40, action: 'rapid_spread' }, { duration: 80, action: 'speed_dash' }, { duration: 40, action: 'rapid_spread' }, { duration: 70, action: 'vulnerable' }]; self.executePattern = function () { var patterns = self.currentPhase === 1 ? self.attackPatterns : self.attackPatternsPhase2; var currentPattern = patterns[self.patternIndex]; if (self.patternTimer >= currentPattern.duration) { self.patternTimer = 0; self.patternIndex = (self.patternIndex + 1) % patterns.length; } switch (currentPattern.action) { case 'move_left': if (self.x > arenaLeft + 100) { self.x -= 2; } break; case 'move_right': if (self.x < arenaRight - 100) { self.x += 2; } break; case 'shoot_spread': if (self.patternTimer % 20 === 0) { self.shootSpread(); } break; case 'vulnerable': self.isVulnerable = true; self.vulnerabilityTimer = 90; tween(bossGraphics, { alpha: 0.7 }, { duration: 200 }); break; case 'speed_dash': if (self.x > arenaLeft + 100 && self.patternTimer < 40) { self.x -= 4; } else if (self.x < arenaRight - 100 && self.patternTimer >= 40) { self.x += 4; } break; case 'rapid_spread': if (self.patternTimer % 10 === 0) { self.shootRapidSpread(); } break; } }; self.shootSpread = function () { for (var i = -2; i <= 2; i++) { var bullet = new BossBullet(); bullet.x = self.x + i * 30; bullet.y = self.y + 50; bullet.direction = { x: i * 0.3, y: 1 }; bossBullets.push(bullet); game.addChild(bullet); } }; self.shootRapidSpread = function () { for (var i = -3; i <= 3; i++) { var bullet = new BossBullet(); bullet.x = self.x + i * 25; bullet.y = self.y + 50; bullet.direction = { x: i * 0.4, y: 1 }; bullet.speed = 6; bossBullets.push(bullet); game.addChild(bullet); } }; self.startPhase2Flash = function () { var flashToYellow = function flashToYellow() { tween(bossGraphics, { tint: 0xFFFF00 }, { duration: 800, easing: tween.easeInOut, onFinish: flashToRed }); }; var flashToRed = function flashToRed() { tween(bossGraphics, { tint: 0xFF0000 }, { duration: 800, easing: tween.easeInOut, onFinish: flashToYellow }); }; flashToYellow(); }; return self; }); var BossBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bossBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.damage = 15; self.direction = { x: 0, y: 1 }; self.update = function () { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; }; return self; }); var BossIntroScreen = Container.expand(function () { var self = Container.call(this); self.showIntro = function (bossName, introAssetId) { // Create intro image var introGraphics = self.attachAsset(introAssetId, { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, alpha: 0 }); // Fade in animation tween(introGraphics, { alpha: 1 }, { duration: 800, easing: tween.easeInOut }); // Auto-hide after 4 seconds LK.setTimeout(function () { tween(self, { alpha: 0 }, { duration: 500, onFinish: function onFinish() { self.destroy(); } }); }, 4000); }; return self; }); var DoubleShotPowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('doubleShotPowerUp', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.collected = false; self.update = function () { self.y += self.speed; }; return self; }); var HealthPowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('healthPowerUp', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.collected = false; self.update = function () { self.y += self.speed; }; return self; }); var IntroScreen = Container.expand(function () { var self = Container.call(this); // Game logo var logoGraphics = self.attachAsset('gameLogo', { anchorX: 0.5, anchorY: 0.5 }); logoGraphics.x = 0; logoGraphics.y = -200; // Entrance animation logoGraphics.alpha = 0; tween(logoGraphics, { alpha: 1 }, { duration: 800 }); return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerLeftGraphics = self.attachAsset('playerLeft', { anchorX: 0.5, anchorY: 0.5, visible: true, alpha: 1.0 }); var playerRightGraphics = self.attachAsset('playerRight', { anchorX: 0.5, anchorY: 0.5, visible: true, alpha: 1.0 }); self.maxHealth = 150; self.health = self.maxHealth; self.speed = 8; self.canShoot = true; self.shootCooldown = 0; self.lastX = 0; self.facing = 'left'; // 'left' or 'right' only self.hasDoubleShot = false; self.doubleShotTimer = 0; self.updateFacing = function () { var newFacing = self.facing; if (self.x < self.lastX - 5) { newFacing = 'left'; } else if (self.x > self.lastX + 5) { newFacing = 'right'; } if (newFacing !== self.facing) { self.facing = newFacing; playerLeftGraphics.visible = newFacing === 'left'; playerRightGraphics.visible = newFacing === 'right'; } self.lastX = self.x; }; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { self.health = 0; LK.showGameOver(); } LK.effects.flashObject(self, 0xff0000, 500); LK.getSound('playerHit').play(); }; self.shoot = function () { if (self.canShoot && self.shootCooldown <= 0) { if (self.hasDoubleShot) { // Shoot two bullets side by side var bullet1 = new PlayerBullet(); bullet1.x = self.x - 20; bullet1.y = self.y - 50; playerBullets.push(bullet1); game.addChild(bullet1); var bullet2 = new PlayerBullet(); bullet2.x = self.x + 20; bullet2.y = self.y - 50; playerBullets.push(bullet2); game.addChild(bullet2); } else { // Normal single shot var bullet = new PlayerBullet(); bullet.x = self.x; bullet.y = self.y - 50; playerBullets.push(bullet); game.addChild(bullet); } self.shootCooldown = 15; LK.getSound('playerShoot').play(); } }; self.update = function () { if (self.shootCooldown > 0) { self.shootCooldown--; } // Handle double shot timer if (self.doubleShotTimer > 0) { self.doubleShotTimer--; if (self.doubleShotTimer <= 0) { self.hasDoubleShot = false; } } self.updateFacing(); }; self.collectDoubleShotPowerUp = function () { self.hasDoubleShot = true; self.doubleShotTimer = 600; // 10 seconds at 60fps LK.effects.flashObject(self, 0x00ff00, 300); }; self.collectHealthPowerUp = function () { var recoveryAmount = Math.ceil(self.maxHealth * 0.2); // 20% recovery if (self.health >= self.maxHealth) { // If at max health, increase max health self.maxHealth += recoveryAmount; self.health = self.maxHealth; } else { // Normal health recovery self.health = Math.min(self.maxHealth, self.health + recoveryAmount); } LK.effects.flashObject(self, 0x00ff00, 500); }; 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.damage = 10; self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ var gameStarted = false; var introScreen = null; var arena = game.attachAsset('arena', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, visible: false }); var arenaLeft = arena.x - arena.width / 2; var arenaRight = arena.x + arena.width / 2; var arenaTop = arena.y - arena.height / 2; var arenaBottom = arena.y + arena.height / 2; var player = null; var playerBullets = []; var bossBullets = []; var doubleShotPowerUps = []; var healthPowerUps = []; var powerUpSpawnTimer = 0; var currentBoss = null; var currentBossIndex = 0; var bossConfigs = [{ "class": Boss1, name: "ZombiEagle" }, { "class": Boss2, name: "Purple Phantom" }, { "class": Boss3, name: "Golden Destroyer" }, { "class": Boss4, name: "Omega Overlord" }]; var playerHealthBar = null; var bossHealthBarContainer = null; var bossHealthBarBg = null; var bossHealthBarFill = null; var bossNameText = null; // Show intro screen introScreen = game.addChild(new IntroScreen()); introScreen.x = 1024; introScreen.y = 1366; // Auto-start game after 4 seconds LK.setTimeout(function () { if (!gameStarted) { startMainGame(); if (introScreen) { introScreen.destroy(); introScreen = null; } } }, 4000); function startMainGame() { gameStarted = true; arena.visible = true; game.setChildIndex(arena, 0); // Send arena to back // Initialize player player = game.addChild(new Player()); player.x = 1024; player.y = 1366; player.lastX = player.x; game.setChildIndex(player, game.children.length - 1); // Bring player to front // Initialize UI elements playerHealthBar = new Text2('Health: 100', { size: 48, fill: '#FFFFFF', font: 'monospace', stroke: '#000000', strokeThickness: 6 }); playerHealthBar.x = arenaLeft + 50; playerHealthBar.y = arenaTop + 100; game.addChild(playerHealthBar); bossHealthBarContainer = new Container(); bossHealthBarContainer.x = 1024; bossHealthBarContainer.y = arenaTop + 50; game.addChild(bossHealthBarContainer); bossHealthBarBg = bossHealthBarContainer.attachAsset('bossHealthBarBg', { anchorX: 0.5, anchorY: 0.5 }); bossHealthBarFill = bossHealthBarContainer.attachAsset('bossHealthBarFill', { anchorX: 0.5, anchorY: 0.5 }); bossNameText = new Text2('ZombiEagle', { size: 56, fill: '#FFFF00', font: 'monospace', stroke: '#000000', strokeThickness: 6 }); bossNameText.anchor.set(0.5, 0); bossNameText.x = 1024; bossNameText.y = arenaTop + 10; game.addChild(bossNameText); // Spawn first boss and start music spawnNextBoss(); LK.playMusic('epicboss'); } function spawnNextBoss() { // Safety check to prevent spawning beyond available bosses if (currentBossIndex >= bossConfigs.length) { console.log("All bosses defeated, currentBossIndex:", currentBossIndex); return; } // Additional validation to ensure boss config exists if (!bossConfigs[currentBossIndex]) { console.log("Invalid boss index:", currentBossIndex, "resetting to 0"); currentBossIndex = 0; } console.log("Spawning boss", currentBossIndex + 1, "of", bossConfigs.length); if (currentBoss) { currentBoss.destroy(); } // Clear boss bullets for (var i = bossBullets.length - 1; i >= 0; i--) { bossBullets[i].destroy(); bossBullets.splice(i, 1); } var bossConfig = bossConfigs[currentBossIndex]; // Show boss intro screen var bossIntroScreen = game.addChild(new BossIntroScreen()); bossIntroScreen.x = 1024; bossIntroScreen.y = 1366; // Determine intro asset based on boss index var introAssetId = 'boss' + (currentBossIndex + 1) + 'Intro'; bossIntroScreen.showIntro(bossConfig.name, introAssetId); // Delay boss spawning by 4 seconds to show intro LK.setTimeout(function () { // Switch arena based on boss var arenaAssetName = 'arena'; if (currentBossIndex === 1) { arenaAssetName = 'arena2'; } else if (currentBossIndex === 2) { arenaAssetName = 'arena3'; } else if (currentBossIndex === 3) { arenaAssetName = 'arena4'; } arena.destroy(); arena = game.attachAsset(arenaAssetName, { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, visible: true }); game.setChildIndex(arena, 0); // Send arena to back // Recalculate arena bounds arenaLeft = arena.x - arena.width / 2; arenaRight = arena.x + arena.width / 2; arenaTop = arena.y - arena.height / 2; arenaBottom = arena.y + arena.height / 2; currentBoss = game.addChild(new bossConfig["class"]()); currentBoss.x = 1024; currentBoss.y = arenaTop + 200; bossNameText.setText(bossConfig.name); // Reset player position to center of arena for new phase if (player) { player.x = 1024; player.y = 1366; player.lastX = player.x; } // Update boss health bar position for new arena if (bossHealthBarContainer) { bossHealthBarContainer.y = arenaTop + 50; } if (bossNameText) { bossNameText.y = arenaTop + 10; } // Update player health bar position for new arena if (playerHealthBar) { playerHealthBar.x = arenaLeft + 50; playerHealthBar.y = arenaTop + 100; } }, 4000); } var dragActive = false; game.down = function (x, y, obj) { if (gameStarted) { dragActive = true; player.shoot(); } }; game.up = function (x, y, obj) { if (gameStarted) { dragActive = false; } }; game.move = function (x, y, obj) { if (gameStarted && dragActive) { var localPos = game.toLocal({ x: x, y: y }); player.x = Math.max(arenaLeft + 60, Math.min(arenaRight - 60, localPos.x)); player.y = Math.max(arenaTop + 60, Math.min(arenaBottom - 60, localPos.y)); } }; game.update = function () { if (!gameStarted) { return; } // Update player bullets for (var i = playerBullets.length - 1; i >= 0; i--) { var bullet = playerBullets[i]; if (bullet.y < arenaTop - 50) { bullet.destroy(); playerBullets.splice(i, 1); continue; } if (currentBoss && bullet.intersects(currentBoss)) { currentBoss.takeDamage(bullet.damage); bullet.destroy(); playerBullets.splice(i, 1); continue; } } // Update boss bullets for (var i = bossBullets.length - 1; i >= 0; i--) { var bullet = bossBullets[i]; if (bullet.x < arenaLeft - 50 || bullet.x > arenaRight + 50 || bullet.y < arenaTop - 50 || bullet.y > arenaBottom + 50) { bullet.destroy(); bossBullets.splice(i, 1); continue; } if (bullet.intersects(player)) { player.takeDamage(bullet.damage); bullet.destroy(); bossBullets.splice(i, 1); continue; } } // Spawn power-ups randomly powerUpSpawnTimer++; if (powerUpSpawnTimer >= 900 && Math.random() < 0.04) { // 15 seconds minimum, then 4% chance per frame var powerUpType = Math.random() < 0.5 ? 'double' : 'health'; if (powerUpType === 'double') { var powerUp = new DoubleShotPowerUp(); powerUp.x = arenaLeft + 100 + Math.random() * (arenaRight - arenaLeft - 200); powerUp.y = arenaTop - 50; doubleShotPowerUps.push(powerUp); game.addChild(powerUp); } else { var healthPowerUp = new HealthPowerUp(); healthPowerUp.x = arenaLeft + 100 + Math.random() * (arenaRight - arenaLeft - 200); healthPowerUp.y = arenaTop - 50; healthPowerUps.push(healthPowerUp); game.addChild(healthPowerUp); } powerUpSpawnTimer = 0; } // Update power-ups for (var i = doubleShotPowerUps.length - 1; i >= 0; i--) { var powerUp = doubleShotPowerUps[i]; // Remove if off screen if (powerUp.y > arenaBottom + 50) { powerUp.destroy(); doubleShotPowerUps.splice(i, 1); continue; } // Check collision with player if (!powerUp.collected && powerUp.intersects(player)) { player.collectDoubleShotPowerUp(); powerUp.collected = true; // Tween power-up away with scaling effect tween(powerUp, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 300, onFinish: function onFinish() { powerUp.destroy(); } }); doubleShotPowerUps.splice(i, 1); continue; } } // Update health power-ups for (var i = healthPowerUps.length - 1; i >= 0; i--) { var healthPowerUp = healthPowerUps[i]; // Remove if off screen if (healthPowerUp.y > arenaBottom + 50) { healthPowerUp.destroy(); healthPowerUps.splice(i, 1); continue; } // Check collision with player if (!healthPowerUp.collected && healthPowerUp.intersects(player)) { player.collectHealthPowerUp(); healthPowerUp.collected = true; // Tween power-up away with scaling effect tween(healthPowerUp, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 300, onFinish: function onFinish() { healthPowerUp.destroy(); } }); healthPowerUps.splice(i, 1); continue; } } // Update UI playerHealthBar.setText('Health: ' + player.health); if (currentBoss) { var healthPercentage = currentBoss.health / currentBoss.maxHealth; bossHealthBarFill.width = 400 * healthPercentage; } };
===================================================================
--- original.js
+++ change.js
@@ -34,12 +34,18 @@
// Restore player health to maximum after boss defeat
if (player) {
player.health = player.maxHealth;
}
- currentBossIndex++;
- if (currentBossIndex >= bossConfigs.length) {
+ // Only increment boss index after confirming current boss is defeated
+ var nextBossIndex = currentBossIndex + 1;
+ console.log("Boss defeated. Current index:", currentBossIndex, "Next index:", nextBossIndex, "Total bosses:", bossConfigs.length);
+ if (nextBossIndex >= bossConfigs.length) {
+ console.log("All bosses defeated - showing win screen");
LK.showYouWin();
} else {
+ // Update the index only when we're sure we're progressing to next boss
+ currentBossIndex = nextBossIndex;
+ console.log("Progressing to boss", currentBossIndex + 1);
// Add a small delay to ensure proper cleanup before spawning next boss
LK.setTimeout(function () {
spawnNextBoss();
}, 500);
@@ -1492,8 +1498,13 @@
if (currentBossIndex >= bossConfigs.length) {
console.log("All bosses defeated, currentBossIndex:", currentBossIndex);
return;
}
+ // Additional validation to ensure boss config exists
+ if (!bossConfigs[currentBossIndex]) {
+ console.log("Invalid boss index:", currentBossIndex, "resetting to 0");
+ currentBossIndex = 0;
+ }
console.log("Spawning boss", currentBossIndex + 1, "of", bossConfigs.length);
if (currentBoss) {
currentBoss.destroy();
}
Uma águia zumbi, vista aérea, estilo pixel art. In-Game asset. 2d. High contrast. No shadows
gota de sangue com contorno branco, pixel art, fundo transparente. In-Game asset. 2d. High contrast. No shadows
Um fantasma zumbi voador, arte pixel, vista aerea frontal. In-Game asset. 2d. High contrast. No shadows
um gárgula voador com olhos brilhantes, pixel 32bits art style, vista aerea frontal. In-Game asset. 2d. High contrast. No shadows
uma caverna escura estilo jogo de rpg, arte pixel, background game arena. In-Game asset. 2d. High contrast. No shadows
O telhado de um castelo medieval abandonado com suas torres. arte pixel 32 bits, vista aerea frontal. In-Game asset. 2d. High contrast. No shadows
um conjunto de montanhas de gelo, arte pixel 32bits, arena battle background. In-Game asset. 2d. High contrast. No shadows
MUDE A COR DA POÇÃO PARA AZUL
Escreva abaixo da poção o texto "HEALTH", ARTE PIXEL 32BITS
Make this dragon with 3 heads and a gray color scale
add details on left and right image to enlarge it