User prompt
Spawn 5 enemys from waves 1 to 2
User prompt
Make waves 1 to 4 spawn a random amount of fast enemys and regular enemys between 1-5
User prompt
Why are fast enemy’s spawning rather then the enemy
User prompt
Make the fast enemy speed 10
User prompt
Make a fast enemy asset
User prompt
The regular enemy’s are fast can you fix this?
User prompt
Fix Bug: 'Script error.' in or related to this line: 'var enemy = game.addChild(new Enemy());' Line Number: 138
User prompt
Fix Bug: 'Script error.' in or related to this line: 'var enemy = game.addChild(new Enemy());' Line Number: 138
User prompt
Make a fast enemy
User prompt
Fix Bug: 'ReferenceError: Can't find variable: stars' in or related to this line: 'for (var i = 0; i < stars.length; i++) {' Line Number: 202
User prompt
Fix Bug: 'ReferenceError: Can't find variable: stars' in or related to this line: 'for (var i = 0; i < stars.length; i++) {' Line Number: 202
User prompt
Make white stars that move in the background
User prompt
The background 1944 is not showing can you fix it?
User prompt
Make the background a background from the 1944
User prompt
Make 1 Boss Enemy and 2 enemys spawn on wave 9
User prompt
Don’t Let The Player Go Outside The Screen
User prompt
Make the boss enemy shoot every 0.45
User prompt
make the boss enemy die after 5 bullets hit it
User prompt
the boss enemy does not move can you fix it?
User prompt
get rid of the health bar
User prompt
Make the health bar not follow the player
User prompt
Fix Bug: 'Script error.' in or related to this line: 'var playerHealthBar = new PlayerHealthBar(hero.health);' Line Number: 189
User prompt
Make the player health bar follow the player
User prompt
Make a health bar for the player
User prompt
Get rid of the green block at the bottom of the screen
===================================================================
--- original.js
+++ change.js
@@ -144,32 +144,37 @@
anchorX: 0.5,
anchorY: 0.5
});
});
-var HealthBar = Container.expand(function (maxHealth, currentHealth) {
+var PlayerHealthBar = Container.expand(function (maxHealth) {
var self = Container.call(this);
var backgroundBar = self.attachAsset('block', {
width: 204,
height: 24,
- color: 0x000000
+ color: 0x000000,
+ anchorX: 0.5,
+ anchorY: 0.5
});
var healthBar = self.attachAsset('block', {
width: 200,
height: 20,
- color: 0x00ff00
+ color: 0x00ff00,
+ anchorX: 0.5,
+ anchorY: 0.5
});
self.updateHealth = function (newHealth) {
var healthRatio = newHealth / maxHealth;
healthBar.width = 200 * healthRatio;
+ healthBar.x = -(200 - healthBar.width) / 2; // Keep the health bar centered
if (healthRatio < 0.3) {
healthBar.color = 0xff0000; // Red color for critical health
} else if (healthRatio < 0.6) {
healthBar.color = 0xffff00; // Yellow color for medium health
} else {
healthBar.color = 0x00ff00; // Green color for high health
}
};
- self.updateHealth(currentHealth);
+ self.updateHealth(maxHealth);
});
/****
* Initialize Game
@@ -180,8 +185,12 @@
/****
* Game Code
****/
+var playerHealthBar = new PlayerHealthBar(hero.health);
+playerHealthBar.x = 2048 / 2; // Center the health bar horizontally
+playerHealthBar.y = 50; // Position the health bar at the top
+LK.gui.top.addChild(playerHealthBar);
var waveManager = game.addChild(new WaveManager());
var waveCounterTxt = new Text2('Wave: 0', {
size: 100,
fill: "#ffffff"
@@ -249,9 +258,9 @@
bullet.move();
// Check for bullet collision with hero or off-screen
if (bullet.intersects(hero)) {
hero.health -= 1; // Decrease hero's health by one
- heroHealthBar.updateHealth(hero.health); // Update the health bar
+ playerHealthBar.updateHealth(hero.health); // Update the player's health bar
LK.effects.flashObject(hero, 0xff0000, 500);
bullet.destroy();
enemyBullets.splice(i, 1);
if (hero.health <= 0) {