User prompt
when passed wave 5, +50HP and +1 bullets/second fire rate with 2 bullets shooting/shoot
User prompt
added wave 6, no enemy and enemy2, but more from enemy3 (and enemy3 will shoot with a fire rate of 3-4 bullets/second in that wave)
User prompt
+ 5H HP for player when kill enemy and +10HP when shoot the oil barrel
User prompt
atgmenemy can shoot bullets anywhere it wants, but towards player with the sam 10-60% accuracy
User prompt
atgm bullet targets towards player, but with accuracy = 10-50%
User prompt
atgmenemy speed = 5-7, and atgmbullet speed = 15-20, accuracy = 15-45%
User prompt
atgmbullet speed = 15, not atgmenemy speed
User prompt
atgm speed = 15
User prompt
atgm bullet moves like mgbullet (the direction too, speed = 1/2 mgbullet)
User prompt
atgm value = 20 pts and its HP=75
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (bullets[k].intersects(oilBarrels[m])) {' Line Number: 429
User prompt
make atgmbullet shoots like mgbullet, but don't change the speed
Code edit (1 edits merged)
Please save this source code
User prompt
add atgm enemy (texture:atgm) and it shoots atgm bullet (speed = 1/3 of mgbullet and when hits player, -30 to 50 HP), speed: 0.1 - 0.25 bullets/second
User prompt
show points
User prompt
show HP at the top center
User prompt
make shotgunbullet move like mgbullet, but spreads like shotgun
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (oilBarrels[m].intersects(enemies[n])) {' Line Number: 396
User prompt
shotgunbullet shoot spreading like shotgun, and added oil barrels, when hit it, +10 pts and if enemy is near enough, -40 HP
User prompt
now shotgunenemy value = 4 pts and all bullets shoots like mgbullet
User prompt
make shotgun enemy shoot the closer the more damage and the further the less damage player have
User prompt
make shotgunbullet move like mgbullet, but spreads like shotgun
User prompt
added shotgunenemy with HP = 10 and shoots shotgunbullet with each hit player (closest -20 Hp and furthest -5 HP), spreads when shoot
User prompt
the player shoots when you click only
/**** * Classes ****/ // ATGMBullet class for bullets fired by ATGMEnemy var ATGMBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('atgmrocket', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.floor(Math.random() * (20 - 15 + 1)) + 15; // Random speed between 15 and 20 self.update = function () { self.y += self.speed; self.x += self.speedX || 0; // Add horizontal movement similar to MGBullet }; }); // ATGMEnemy class for a new enemy type that shoots ATGMBullets var ATGMEnemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('atgm', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.floor(Math.random() * (7 - 5 + 1)) + 5; // Random speed between 5 and 7 self.hp = 75; // Set HP for ATGMEnemy self.update = function () { self.y += self.speed; }; }); // Bullet class for bullets fired by the player's plane var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.update = function () { self.y += self.speed; }; }); // Enemy class for enemy planes var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; }; }); // Enemy2 class for a stronger enemy type var Enemy2 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy2', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.hp = 20; // Set HP for Enemy2 self.update = function () { self.y += self.speed; }; }); // Enemy3 class for a machine gun shooting enemy var Enemy3 = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy3', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.hp = 20; // Set HP for Enemy3 self.update = function () { self.y += self.speed; }; }); //<Assets used in the game will automatically appear here> // EnemyBullet class for bullets fired by enemy planes var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.speedX = 0; self.speedY = self.speed; self.update = function () { self.y += self.speed; }; }); // MGBullet class for machine gun bullets fired by Enemy3 var MGBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('mgbullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.y += self.speed; }; }); // OilBarrel class for oil barrels that give points and damage nearby enemies var OilBarrel = Container.expand(function () { var self = Container.call(this); var barrelGraphics = self.attachAsset('oilbarrel', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // OilBarrel update logic, if any }; }); // Plane class representing the player's plane var Plane = Container.expand(function () { var self = Container.call(this); var planeGraphics = self.attachAsset('plane', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.hp = 100; // Add HP property to Plane self.update = function () { // Plane update logic, if any }; }); // ShotgunBullet class for bullets fired by ShotgunEnemy var ShotgunBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('shotgunbullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; // Match MGBullet speed self.speedX = 0; // Initialize horizontal speed self.update = function () { self.x += self.speedX; // Add horizontal movement self.y += self.speed; // Vertical movement }; }); // ShotgunEnemy class for a new enemy type that shoots shotgun bullets var ShotgunEnemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('shotgunenemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.hp = 10; // Set HP for ShotgunEnemy self.update = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Initialize oil barrels var oilBarrels = []; function spawnOilBarrel() { var oilBarrel = new OilBarrel(); oilBarrel.x = Math.random() * 2048; oilBarrel.y = Math.random() * 2732; oilBarrels.push(oilBarrel); game.addChild(oilBarrel); } LK.setInterval(spawnOilBarrel, 10000); // Spawn an oil barrel every 10 seconds // Function to fire shotgun bullets from ShotgunEnemy function fireShotgunBullets(shotgunEnemy) { for (var i = -1; i <= 1; i++) { var bullet = new ShotgunBullet(); bullet.x = shotgunEnemy.x + i * 20; // Spread bullets horizontally bullet.y = shotgunEnemy.y + 50; bullet.speedX = i * 2; // Add horizontal spread bullet.speed = 10; // Match MGBullet speed enemyBullets.push(bullet); game.addChild(bullet); } } // Function to spawn ShotgunEnemy function spawnShotgunEnemy() { var shotgunEnemy = new ShotgunEnemy(); shotgunEnemy.x = Math.random() * 2048; shotgunEnemy.y = -50; enemies.push(shotgunEnemy); game.addChild(shotgunEnemy); var shootInterval = LK.setInterval(function () { if (enemies.includes(shotgunEnemy)) { fireShotgunBullets(shotgunEnemy); } else { LK.clearInterval(shootInterval); } }, 2000); // Fire shotgun bullets every 2 seconds } // Function to spawn Enemy3 function spawnEnemy3() { var enemy3 = new Enemy3(); enemy3.hp = 20; // Set Enemy3 HP to 20 enemy3.x = Math.random() * 2048; enemy3.y = -50; enemies.push(enemy3); game.addChild(enemy3); var shootInterval = LK.setInterval(function () { if (enemies.includes(enemy3)) { fireMGBullets(enemy3); } else { LK.clearInterval(shootInterval); } }, 500); // Fire 2 bullets per second } // Function to fire MG bullets from Enemy3 function fireMGBullets(enemy3) { var bullet = new MGBullet(); bullet.attackPower = 5; // Set attack power for MGBullet bullet.x = enemy3.x; bullet.y = enemy3.y + 50; enemyBullets.push(bullet); game.addChild(bullet); } // Function to spawn Enemy2 function spawnEnemy2() { var enemy2 = new Enemy2(); enemy2.x = Math.random() * 2048; enemy2.y = -50; enemies.push(enemy2); game.addChild(enemy2); var shootInterval = LK.setInterval(function () { if (enemies.includes(enemy2)) { fireEnemy2Bullets(enemy2); } else { LK.clearInterval(shootInterval); } }, 2000); } // Function to fire two bullets from Enemy2 function fireEnemy2Bullets(enemy2) { for (var i = -1; i <= 1; i += 2) { var bullet = new EnemyBullet(); bullet.x = enemy2.x + i * 20; // Offset bullets to the sides bullet.y = enemy2.y + 50; bullet.speedX = i * 2; // Slight horizontal speed for spread bullet.speedY = 5; enemyBullets.push(bullet); game.addChild(bullet); } } // Initialize player plane var playerPlane = game.addChild(new Plane()); playerPlane.x = 2048 / 2; playerPlane.y = 2732 - 200; // Display player HP var hpText = new Text2('HP: ' + playerPlane.hp, { size: 50, fill: "#ffffff" }); hpText.anchor.set(0.5, 0); LK.gui.top.addChild(hpText); // Display player points var pointsText = new Text2('Points: ' + LK.getScore(), { size: 50, fill: "#ffffff" }); pointsText.anchor.set(1, 0); LK.gui.topRight.addChild(pointsText); // Arrays to keep track of bullets and enemies var bullets = []; var enemyBullets = []; var enemies = []; // Variables for player upgrades var fireRate = 1; // Bullets per second var bulletDamage = 10; // Damage per bullet // Function to handle player movement function handleMove(x, y, obj) { playerPlane.x = x; playerPlane.y = y; } // Function to spawn enemies function spawnEnemy() { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = -50; enemies.push(enemy); game.addChild(enemy); var shootInterval = LK.setInterval(function () { if (enemies.includes(enemy)) { fireEnemyBullet(enemy); } else { LK.clearInterval(shootInterval); } }, 2000); } // Function to fire bullets function fireEnemyBullet(enemy) { var bullet = new EnemyBullet(); bullet.x = enemy.x; bullet.y = enemy.y + 50; // Set enemy bullet speed to move downwards bullet.speedX = 0; bullet.speedY = 5; // Ensure bullet moves downwards enemyBullets.push(bullet); game.addChild(bullet); } function fireBullet() { var bullet = new Bullet(); bullet.x = playerPlane.x; bullet.y = playerPlane.y - 50; bullet.damage = bulletDamage; // Set bullet damage bullets.push(bullet); game.addChild(bullet); } // Game update loop game.update = function () { // Update enemy bullets for (var i = enemyBullets.length - 1; i >= 0; i--) { enemyBullets[i].update(); if (enemyBullets[i].y > 2732) { enemyBullets[i].destroy(); enemyBullets.splice(i, 1); } } // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].update(); if (bullets[i].y < -50) { bullets[i].destroy(); bullets.splice(i, 1); } } // Update enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (enemies[j].y > 2732) { enemies[j].destroy(); enemies.splice(j, 1); } } // Check for collisions between player plane and enemy bullets for (var i = enemyBullets.length - 1; i >= 0; i--) { if (playerPlane.intersects(enemyBullets[i])) { if (enemyBullets[i] instanceof MGBullet) { playerPlane.hp -= 5; // Decrease player HP by 5 when hit by MGBullet } else if (enemyBullets[i] instanceof ShotgunBullet) { var distance = Math.abs(playerPlane.x - enemyBullets[i].x); var damage = Math.max(5, 20 - distance / 50 * 15); // Calculate damage based on distance playerPlane.hp -= damage; // Apply calculated damage } else if (enemyBullets[i] instanceof ATGMBullet) { playerPlane.hp -= Math.floor(Math.random() * (50 - 30 + 1)) + 30; // Decrease player HP by 30 to 50 for ATGMBullet } else { playerPlane.hp -= 10; // Decrease player HP by 10 for other enemy bullets } enemyBullets[i].destroy(); enemyBullets.splice(i, 1); // Update HP display hpText.setText('HP: ' + playerPlane.hp); // Game over when player HP is 0 if (playerPlane.hp <= 0) { LK.showGameOver(); } } } // Update points display pointsText.setText('Points: ' + LK.getScore()); // Auto-upgrade system if (LK.getScore() >= 100 && LK.getScore() % 100 === 0) { var upgradeType = Math.random() < 0.5 ? 'fireRate' : 'bulletDamage'; if (upgradeType === 'fireRate') { fireRate += 0.1; // Increase fire rate } else { bulletDamage += 1; // Increase bullet damage } } // Check for collisions for (var k = bullets.length - 1; k >= 0; k--) { for (var l = enemies.length - 1; l >= 0; l--) { if (bullets[k].intersects(enemies[l])) { bullets[k].destroy(); bullets.splice(k, 1); if (enemies[l] instanceof Enemy3) { enemies[l].hp -= 10; if (enemies[l].hp <= 0) { enemies[l].destroy(); enemies.splice(l, 1); LK.setScore(LK.getScore() + 5); // Add 5 points for destroying Enemy3 playerPlane.hp += 5; // Increase player HP by 5 } } else if (enemies[l] instanceof Enemy2) { enemies[l].destroy(); enemies.splice(l, 1); LK.setScore(LK.getScore() + 3); // Add 3 points for destroying Enemy2 playerPlane.hp += 5; // Increase player HP by 5 } else if (enemies[l] instanceof ShotgunEnemy) { enemies[l].destroy(); enemies.splice(l, 1); LK.setScore(LK.getScore() + 4); // Add 4 points for destroying ShotgunEnemy playerPlane.hp += 5; // Increase player HP by 5 } else if (enemies[l] instanceof ATGMEnemy) { enemies[l].destroy(); enemies.splice(l, 1); LK.setScore(LK.getScore() + 20); // Add 20 points for destroying ATGMEnemy playerPlane.hp += 5; // Increase player HP by 5 } else { enemies[l].destroy(); enemies.splice(l, 1); LK.setScore(LK.getScore() + 1); // Add 1 point for destroying Enemy playerPlane.hp += 5; // Increase player HP by 5 } break; } } for (var m = oilBarrels.length - 1; m >= 0; m--) { if (bullets[k] && bullets[k].intersects(oilBarrels[m])) { bullets[k].destroy(); bullets.splice(k, 1); oilBarrels[m].destroy(); oilBarrels.splice(m, 1); LK.setScore(LK.getScore() + 10); // Add 10 points for hitting OilBarrel playerPlane.hp += 10; // Increase player HP by 10 for (var n = enemies.length - 1; n >= 0; n--) { if (oilBarrels[m] && oilBarrels[m].intersects(enemies[n])) { enemies[n].hp -= 40; // Damage nearby enemies if (enemies[n].hp <= 0) { enemies[n].destroy(); enemies.splice(n, 1); } } } break; } } } }; // Set up event listeners game.move = handleMove; game.down = function (x, y, obj) { handleMove(x, y, obj); fireBullet(); }; // Wave management var currentWave = 1; var waveInterval = LK.setInterval(function () { if (currentWave === 1) { // Wave 1: Basic enemies LK.setInterval(spawnEnemy, 2000); } else if (currentWave === 2) { // Wave 2: Harder enemies LK.setInterval(spawnEnemy2, 5000); // Spawn Enemy2 every 5 seconds LK.setInterval(spawnEnemy3, 3000); // Spawn Enemy3 every 3 seconds } currentWave++; if (currentWave === 3) { // Wave 3: Even more challenging enemies LK.setInterval(spawnEnemy2, 3000); // Spawn Enemy2 every 3 seconds LK.setInterval(spawnEnemy3, 2000); // Spawn Enemy3 every 2 seconds } if (currentWave === 4) { // Wave 4: Introduce ShotgunEnemy LK.setInterval(spawnShotgunEnemy, 4000); // Spawn ShotgunEnemy every 4 seconds } if (currentWave === 5) { // Wave 5: Introduce ATGMEnemy LK.setInterval(spawnATGMEnemy, 2000); LK.setInterval(spawnShotgunEnemy, 2000); } if (currentWave === 6) { // Increase player HP by 50 playerPlane.hp += 50; hpText.setText('HP: ' + playerPlane.hp); // Increase fire rate by 1 bullet/second and shoot 2 bullets per shot fireRate += 1; game.down = function (x, y, obj) { handleMove(x, y, obj); for (var i = 0; i < 2; i++) { fireBullet(); } }; // Wave 6: More Enemy3 with increased fire rate LK.setInterval(spawnEnemy3, 1000); // Spawn Enemy3 every second var shootInterval = LK.setInterval(function () { enemies.forEach(function (enemy) { if (enemy instanceof Enemy3) { fireMGBullets(enemy); } }); }, 250); // Fire 3-4 bullets per second } if (currentWave > 6) { LK.clearInterval(waveInterval); } }, 10000); // Change wave every 10 seconds // Function to fire ATGMBullets from ATGMEnemy function fireATGMBullets(atgmEnemy) { var bullet = new ATGMBullet(); bullet.x = atgmEnemy.x; bullet.y = atgmEnemy.y + 50; var accuracy = Math.random() * (0.6 - 0.1) + 0.1; // Random accuracy between 10% and 60% var direction = Math.atan2(playerPlane.y - bullet.y, playerPlane.x - bullet.x); bullet.speedX = bullet.speed * Math.cos(direction) * accuracy; bullet.speedY = bullet.speed * Math.sin(direction) * accuracy; enemyBullets.push(bullet); game.addChild(bullet); } // Function to spawn ATGMEnemy function spawnATGMEnemy() { var atgmEnemy = new ATGMEnemy(); atgmEnemy.x = Math.random() * 2048; atgmEnemy.y = -50; enemies.push(atgmEnemy); game.addChild(atgmEnemy); var shootInterval = LK.setInterval(function () { if (enemies.includes(atgmEnemy)) { fireATGMBullets(atgmEnemy); } else { LK.clearInterval(shootInterval); } }, 2000); // Fire ATGMBullets every 4 seconds }
===================================================================
--- original.js
+++ change.js
@@ -472,8 +472,19 @@
LK.setInterval(spawnATGMEnemy, 2000);
LK.setInterval(spawnShotgunEnemy, 2000);
}
if (currentWave === 6) {
+ // Increase player HP by 50
+ playerPlane.hp += 50;
+ hpText.setText('HP: ' + playerPlane.hp);
+ // Increase fire rate by 1 bullet/second and shoot 2 bullets per shot
+ fireRate += 1;
+ game.down = function (x, y, obj) {
+ handleMove(x, y, obj);
+ for (var i = 0; i < 2; i++) {
+ fireBullet();
+ }
+ };
// Wave 6: More Enemy3 with increased fire rate
LK.setInterval(spawnEnemy3, 1000); // Spawn Enemy3 every second
var shootInterval = LK.setInterval(function () {
enemies.forEach(function (enemy) {
a fighter plane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
MG bullet 2D(flat and have colors). Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a flat fighter plane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A fighter plane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A stronger fighter plane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
MG bullet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
oil barrel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
an ATGM. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.