Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'enemyBossShipBullets')' in this line: 'var enemyBullet = enemy.enemyBossShipBullets[k];' Line Number: 214
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'enemyBossShipBullets')' in this line: 'var enemyBullet = enemy.enemyBossShipBullets[k];' Line Number: 214
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: initialY is not defined' in this line: 'if (self.y <= initialY) {' Line Number: 108
Code edit (1 edits merged)
Please save this source code
User prompt
update EnemyBossBullet so it continues to move off the screen
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: initialY is not defined' in this line: 'var angle = Math.atan2(initialY - self.y, initialX - self.x);' Line Number: 106
User prompt
Fix Bug: 'ReferenceError: heroShipY is not defined' in this line: 'enemy.shoot(heroShip.x, heroShipY);' Line Number: 228
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (j = enemy.enemyBossBullets.length - 1; j >= 0; j--) {' Line Number: 228
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (j = enemyBossShips.enemyBossBullets.length - 1; j >= 0; j--) {' Line Number: 228
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: player is not defined' in this line: 'enemy.shoot(player.X, player.Y);' Line Number: 223
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'y')' in this line: 'if (bullet.y > game.height + bullet.height || bullet.x < -bullet.width || bullet.x > game.width + bullet.width) {' Line Number: 240
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'move')' in this line: 'bullet.move(heroShip.x, heroShip.y);' Line Number: 237
User prompt
add code to call move for all enemyBossShipBullets
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'move')' in this line: 'bullet.move();' Line Number: 211
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'move')' in this line: 'bullet.move();' Line Number: 209
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: enemyBossBullets is not defined' in this line: 'for (var i = enemyBossBullets.length - 1; i >= 0; i--) {' Line Number: 209
===================================================================
--- original.js
+++ change.js
@@ -71,13 +71,15 @@
self.shootingInterval = 30;
self._shootingCounter = 0;
self.canShoot = false;
self.enemyBossShipBullets = [];
- self.shoot = function () {
+ self.shoot = function (playerX, playerY) {
if (self.canShoot) {
var bullet = new EnemyBossBullet();
bullet.x = self.x + 100;
bullet.y = self.y;
+ bullet.initialX = playerX;
+ bullet.initialY = playerY;
self.enemyBossShipBullets.push(bullet);
game.addChild(bullet);
}
};
@@ -96,11 +98,13 @@
// Enemy boss bullet class
var EnemyBossBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('enemyBossBullet', 'Evil Boss Bullet', 0.5, 1);
- self.speed = -5;
- self.move = function (playerX, playerY) {
- var angle = Math.atan2(playerY - self.y, playerX - self.x);
+ self.speed = 5;
+ self.initialX = 0;
+ self.initialY = 0;
+ self.move = function () {
+ var angle = Math.atan2(initialY - self.y, initialX - self.x);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
};
});
@@ -217,16 +221,21 @@
// Move enemy Boss ships
for (var i = enemyBossShips.length - 1; i >= 0; i--) {
var enemy = enemyBossShips[i];
enemy.move();
- enemy.shoot();
+ if (enemy._shootingCounter % enemy.shootingInterval == 0) {
+ enemy.shoot(heroShip.x, heroShip.y);
+ enemy._shootingCounter = 0;
+ } else {
+ enemy._shootingCounter += 1;
+ }
if (enemy.y > game.height + enemy.height / 2) {
enemy.destroy();
enemyBossShips.splice(i, 1);
}
for (var j = enemy.enemyBossShipBullets.length - 1; j >= 0; j--) {
var enemyBullet = enemy.enemyBossShipBullets[j];
- enemyBullet.move(heroShip.x, heroShip.y);
+ enemyBullet.move();
}
}
// Shoot bullets
a cute cool looking emoji face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute looking heart. bright red.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
an evil looking emoji. purple and blue colors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a shiny blue cute star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A start button. White on Red.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a grey touchpad. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a bright yellow shiny cute star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.