User prompt
make it so bullets dont hit dead enemies
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'destroy')' in or related to this line: 'bullets[j].destroy();' Line Number: 176
User prompt
make it so bullets dont get stuck on an enemy after it dies
User prompt
make enemies spawn in more often
User prompt
make a boss enemy that spawns in every once in a while with more health
User prompt
have enemies spawn
User prompt
make all enemies move towards player
User prompt
go back to before the sationary enemies
User prompt
the enemies are not spawning
User prompt
get rid of hero movement with keyboard
User prompt
make the enemies spawn from the top of the screen
User prompt
make enemies that come towards the player
User prompt
get rid of the spawn points
User prompt
make all enemies go towards the player
User prompt
bulletss are hitting dead enemies
User prompt
bullets keep getting locked at the closest enemy position
User prompt
make it so that only one enemy spawns at each position
User prompt
make stationary enemies spawn in a grid towards the top of the screen
User prompt
have enemies spawn in at certain positions and stay there
User prompt
fix bullets so they dont get stuck at a certain y
User prompt
make hero move with mouse but bound to same y level
Code edit (1 edits merged)
Please save this source code
User prompt
delete pause button
User prompt
pauseGame() is broken
User prompt
make it so p pauses
===================================================================
--- original.js
+++ change.js
@@ -15,39 +15,8 @@
self.destroy();
}
};
});
-// Enemy class
-var Enemy = Container.expand(function () {
- var self = Container.call(this);
- var enemyGraphics = self.attachAsset('enemy', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.health = 50;
- self.speed = 3;
- self.update = function () {
- // Update logic for enemy
- // Move towards hero
- var dx = hero.x - self.x;
- var dy = hero.y - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance > 0) {
- self.x += self.speed * dx / distance;
- self.y += self.speed * dy / distance;
- }
- };
- self.takeDamage = function (amount) {
- self.health -= amount;
- if (self.health <= 0) {
- self.die();
- }
- };
- self.die = function () {
- // Handle enemy death
- self.destroy();
- };
-});
//<Assets used in the game will automatically appear here>
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
@@ -78,8 +47,30 @@
// Handle hero death
LK.showGameOver();
};
});
+// StationaryEnemy class
+var StationaryEnemy = Container.expand(function () {
+ var self = Container.call(this);
+ var enemyGraphics = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 50;
+ self.update = function () {
+ // Update logic for stationary enemy
+ };
+ self.takeDamage = function (amount) {
+ self.health -= amount;
+ if (self.health <= 0) {
+ self.die();
+ }
+ };
+ self.die = function () {
+ // Handle enemy death
+ self.destroy();
+ };
+});
/****
* Initialize Game
****/
@@ -97,13 +88,13 @@
// Initialize enemies array
var enemies = [];
// Initialize bullets array
var bullets = [];
-// Function to spawn enemies
+// Function to spawn stationary enemies
function spawnEnemy() {
- var enemy = new Enemy();
- enemy.x = Math.random() * 2048;
- enemy.y = 0;
+ var enemy = new StationaryEnemy();
+ enemy.x = 1024; // Set the x position
+ enemy.y = 1366; // Set the y position
enemies.push(enemy);
game.addChild(enemy);
}
// Function to shoot bullets