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 ****/ // 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; }; }); // 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 ****/ // 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 = 0; // No 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.topLeft.addChild(hpText); // 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 { 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(); } } } // 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 } } else if (enemies[l] instanceof Enemy2) { enemies[l].destroy(); enemies.splice(l, 1); LK.setScore(LK.getScore() + 3); // Add 3 points for destroying Enemy2 } else if (enemies[l] instanceof ShotgunEnemy) { enemies[l].destroy(); enemies.splice(l, 1); LK.setScore(LK.getScore() + 4); // Add 4 points for destroying ShotgunEnemy } else { enemies[l].destroy(); enemies.splice(l, 1); LK.setScore(LK.getScore() + 1); // Add 1 point for destroying Enemy } 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 > 4) { LK.clearInterval(waveInterval); } }, 10000); // Change wave every 10 seconds
===================================================================
--- original.js
+++ change.js
@@ -134,9 +134,9 @@
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; // Horizontal spread speed
+ bullet.speedX = 0; // No horizontal spread
bullet.speed = 10; // Match MGBullet speed
enemyBullets.push(bullet);
game.addChild(bullet);
}
@@ -338,8 +338,12 @@
} else if (enemies[l] instanceof Enemy2) {
enemies[l].destroy();
enemies.splice(l, 1);
LK.setScore(LK.getScore() + 3); // Add 3 points for destroying Enemy2
+ } else if (enemies[l] instanceof ShotgunEnemy) {
+ enemies[l].destroy();
+ enemies.splice(l, 1);
+ LK.setScore(LK.getScore() + 4); // Add 4 points for destroying ShotgunEnemy
} else {
enemies[l].destroy();
enemies.splice(l, 1);
LK.setScore(LK.getScore() + 1); // Add 1 point for destroying 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.