Code edit (3 edits merged)
Please save this source code
User prompt
add code so that EnemyBossShip moves side to side
User prompt
Fix Bug: 'Timeout.tick error: bigEnemyPoints is not defined' in this line: 'if (currentScore >= (smallEnemyPoints * 10 + bigEnemyPoints) * currentLevel && !game.bossSpawned) {' Line Number: 193
Code edit (8 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'enemyBossShipBullets')' in this line: 'var enemyBullet = enemyBossShips[i].enemyBossShipBullets[k];' Line Number: 243
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -56,9 +56,9 @@
var self = Container.call(this);
var shipGraphics = self.createAsset('enemyShip', 'Evil smiley', 0.5, 0.5);
self.speed = 2;
self.hitCount = 0;
- self.maxHits = 3 * game.currentLevel;
+ self.maxHits = 3;
self.move = function () {
self.y += self.speed;
};
self.isDestroyed = function () {
@@ -141,11 +141,10 @@
****/
// Initialize starfield
var game = new LK.Game({
backgroundColor: 0xFEF3BD,
- bossSpawned: false,
+ bossSpawned: false
// Flag to track if boss has been spawned
- currentLevel: 1
});
/****
* Game Code
@@ -158,8 +157,9 @@
// Initialize important asset arrays and score tracking
var heroBullets = [];
var enemyShips = [];
var enemyBossShips = [];
+var currentLevel = 1;
var currentScore = 0;
var highScore = 0;
var scoreDisplay = game.addChild(new ScoreDisplay());
scoreDisplay.x = 150;
@@ -175,11 +175,32 @@
var enemyShip = new EnemyShip();
enemyShip.speed = speed || Math.random() * 3 + 1; // Default speed if not provided
enemyShip.x = Math.random() * (game.width - enemyShip.width) + enemyShip.width / 2;
enemyShip.y = -enemyShip.height / 2;
+ enemyShip.maxHits = enemyShip.maxHits + currentLevel;
game.addChild(enemyShip);
enemyShips.push(enemyShip);
}
+// Function to randomly spawn enemy ships or the enemy boss
+function randomSpawnEnemyShip() {
+ var minSpawnDelay = 1000; // 1 second
+ var maxSpawnDelay = 3000; // 3 seconds
+ var spawnDelay = Math.random() * (maxSpawnDelay - minSpawnDelay) + minSpawnDelay;
+ LK.setTimeout(function () {
+ if (currentScore >= 400 + 100 * currentLevel && !game.bossSpawned) {
+ game.bossSpawned = true;
+ var enemyBossShip = new EnemyBossShip();
+ enemyBossShip.x = game.width / 2;
+ enemyBossShip.y = -enemyBossShip.height / 2;
+ enemyBossShip.maxHits = enemyBossShip.maxHits + 2 * currentLevel;
+ game.addChild(enemyBossShip);
+ enemyBossShips.push(enemyBossShip);
+ } else if (!game.bossSpawned) {
+ spawnEnemyShip();
+ }
+ randomSpawnEnemyShip(); // Schedule next spawn
+ }, spawnDelay);
+}
// Game tick event
LK.on('tick', function () {
// Move the starfield
@@ -216,14 +237,16 @@
heroBullets.splice(i, 1);
enemyBossShips[j].hitCount++;
if (enemyBossShips[j].isDestroyed()) {
for (var k = enemyBossShips[j].enemyBossShipBullets.length - 1; k >= 0; k--) {
- var enemyBullet = enemyBossShips[i].enemyBossShipBullets[k];
+ var enemyBullet = enemyBossShips[j].enemyBossShipBullets[k];
enemyBullet.destroy();
}
enemyBossShips[j].destroy();
enemyBossShips.splice(j, 1);
- currentScore += 1000;
+ game.bossSpawned = false;
+ currentLevel += 1;
+ currentScore += 400;
scoreDisplay.updateScore(currentScore);
}
}
}
@@ -267,27 +290,8 @@
}
}
heroShip._shootingCounter += 1;
});
-// Function to randomly spawn enemy ships or the enemy boss
-function randomSpawnEnemyShip() {
- var minSpawnDelay = 1000; // 1 second
- var maxSpawnDelay = 3000; // 3 seconds
- var spawnDelay = Math.random() * (maxSpawnDelay - minSpawnDelay) + minSpawnDelay;
- LK.setTimeout(function () {
- if (currentScore >= 200 && !game.bossSpawned) {
- game.bossSpawned = true;
- var enemyBossShip = new EnemyBossShip();
- enemyBossShip.x = game.width / 2;
- enemyBossShip.y = -enemyBossShip.height / 2;
- game.addChild(enemyBossShip);
- enemyBossShips.push(enemyBossShip);
- } else if (!game.bossSpawned) {
- spawnEnemyShip();
- }
- randomSpawnEnemyShip(); // Schedule next spawn
- }, spawnDelay);
-}
randomSpawnEnemyShip(); // Start the spawning process
// Touch controls to make heroShip follow the pointer
game.on('move', function (obj) {
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.