Code edit (4 edits merged)
Please save this source code
User prompt
reduce the length of healthbars
User prompt
make halthbars shorter
User prompt
make bullets go through healthbars
User prompt
make bullets not hit healthbars
User prompt
make it so health bars dont have a hitbox
User prompt
make a sound when enemies are hit, and make a sound when the player or base take damage
User prompt
make background music
User prompt
make a sound for when enemies die
User prompt
make the bases health bar as big as the base
User prompt
make the bases healthbar a seperate asset
User prompt
make all the health bars thinner
User prompt
make it so that only the bases healthbar is so thick
User prompt
make the bases healthbar visible over the base
User prompt
make the bases healthbar the same size as the base
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of null (reading 'height')' in or related to this line: 'var healthBarGraphics = self.attachAsset('healthBar', {' Line Number: 33
User prompt
make the healthbar for the base seperate from the others
User prompt
make the health bars on everything but the base much thinner
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of null (reading 'height')' in or related to this line: 'var healthBarGraphics = self.attachAsset('healthBar', {' Line Number: 110
User prompt
make the bases health bar as tall as the base
User prompt
make the bases health bar as big as it is
Code edit (1 edits merged)
Please save this source code
User prompt
make heros health bar below him
User prompt
get rid of keyboard movement
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -43,8 +43,10 @@
bullets[i].destroy();
bullets.splice(i, 1);
}
}
+ // Play boss death sound
+ LK.getSound('bossDeath').play();
self.destroy();
};
});
// Bullet class
@@ -89,28 +91,25 @@
bullets[i].destroy();
bullets.splice(i, 1);
}
}
+ // Play enemy death sound
+ LK.getSound('enemyDeath').play();
self.destroy();
};
});
// HealthBar class
-var HealthBar = Container.expand(function (assetId) {
+var HealthBar = Container.expand(function () {
var self = Container.call(this);
- var healthBarGraphics = self.attachAsset(assetId || 'healthBar', {
+ var healthBarGraphics = self.attachAsset('healthBar', {
anchorX: 0.5,
anchorY: 0.5,
- height: 20
+ height: 25
});
self.update = function () {
// Update logic for health bar
// Adjust width of health bar based on health of parent
- if (self.parent instanceof Base) {
- healthBarGraphics.width = self.parent.width;
- healthBarGraphics.height = self.parent.height;
- } else {
- healthBarGraphics.width = self.parent.health * 2;
- }
+ healthBarGraphics.width = self.parent.health * 2;
};
});
// Hero class
var Hero = Container.expand(function () {
@@ -164,9 +163,9 @@
var base = game.addChild(new Base());
base.x = 2048 / 2;
base.y = 2732 - 50;
// Attach health bar to base
-var baseHealthBar = base.addChild(new HealthBar('baseHealthBar'));
+var baseHealthBar = base.addChild(new HealthBar());
baseHealthBar.y = 0; // Position health bar above base
// Initialize enemies array
var enemies = [];
// Initialize bullets array