User prompt
все типы врагов могут стрелять в героя
User prompt
все враги могут стрелять
User prompt
увеличь скорость передвижения врагов
User prompt
уменьши интервал времени спавна врагов
User prompt
в 1 волне 10 врагов, в каждой следующей + 1 враг
User prompt
увеличь количество врагов
User prompt
увеличь скорость появления врагов
User prompt
Fix Bug: 'ReferenceError: enemiesSpawnedThisWave is not defined' in this line: 'if (enemiesSpawnedThisWave < waveEnemyCount) {' Line Number: 460
User prompt
Fix Bug: 'ReferenceError: enemiesSpawnedThisWave is not defined' in this line: 'if (enemiesSpawnedThisWave < waveEnemyCount) {' Line Number: 460
User prompt
враги появляются постепенно
User prompt
игра зависает
User prompt
герой может убить снарядами врага после чего они исчезают
User prompt
оптимизируй код
User prompt
враги не могут сталкиваться и пересекать друг с другом
User prompt
оптимизируй количество врагов, придумай оптимальную систему появления врагов с прогрессией
User prompt
враги появляются группами по 10 штук в волне
User prompt
придумай систему спауна врагов с прогрессией
User prompt
оптимизируй количество врагов, придумай систему спауна с прогрессией
User prompt
враги не пересекают друг друга
User prompt
враги не выходят за границы экрана
User prompt
уменьши количество врагов
User prompt
враги не могут пресекаться с друг другом
User prompt
оптимизируй количество врагов, враги не могут пересекаться с друг другом
User prompt
увеличь темп игры
User prompt
увеличь темп игры
===================================================================
--- original.js
+++ change.js
@@ -130,8 +130,33 @@
});
// Define the EnemyType2 class
var EnemyType2 = Container.expand(function () {
var self = Container.call(this);
+ self.shoot = function () {
+ if (LK.ticks - self.lastShotTick >= self.shootInterval) {
+ var newEnemyBullet = new EnemyBullet();
+ newEnemyBullet.x = self.x;
+ newEnemyBullet.y = self.y + self.height / 2;
+ // Calculate the direction to the hero
+ var direction = {
+ x: spaceRanger.x - self.x,
+ y: spaceRanger.y - self.y
+ };
+ var magnitude = Math.sqrt(direction.x * direction.x + direction.y * direction.y);
+ direction.x /= magnitude;
+ direction.y /= magnitude;
+ // Set bullet speed to aim at the hero
+ newEnemyBullet.speedX = direction.x * 5;
+ newEnemyBullet.speedY = direction.y * 5;
+ newEnemyBullet.move = function () {
+ this.x += this.speedX;
+ this.y += this.speedY;
+ };
+ game.addChild(newEnemyBullet);
+ enemyBullets.push(newEnemyBullet);
+ self.lastShotTick = LK.ticks;
+ }
+ };
var enemyGraphics = self.createAsset('enemyType2', 'Enemy Type 2', 0.5, 0.5);
self.speed = 4;
self.health = 2;
self.move = function () {
@@ -140,8 +165,33 @@
});
// Define the EnemyType3 class
var EnemyType3 = Container.expand(function () {
var self = Container.call(this);
+ self.shoot = function () {
+ if (LK.ticks - self.lastShotTick >= self.shootInterval) {
+ var newEnemyBullet = new EnemyBullet();
+ newEnemyBullet.x = self.x;
+ newEnemyBullet.y = self.y + self.height / 2;
+ // Calculate the direction to the hero
+ var direction = {
+ x: spaceRanger.x - self.x,
+ y: spaceRanger.y - self.y
+ };
+ var magnitude = Math.sqrt(direction.x * direction.x + direction.y * direction.y);
+ direction.x /= magnitude;
+ direction.y /= magnitude;
+ // Set bullet speed to aim at the hero
+ newEnemyBullet.speedX = direction.x * 5;
+ newEnemyBullet.speedY = direction.y * 5;
+ newEnemyBullet.move = function () {
+ this.x += this.speedX;
+ this.y += this.speedY;
+ };
+ game.addChild(newEnemyBullet);
+ enemyBullets.push(newEnemyBullet);
+ self.lastShotTick = LK.ticks;
+ }
+ };
var enemyGraphics = self.createAsset('enemyType3', 'Enemy Type 3', 0.5, 0.5);
self.speed = 1;
self.health = 7;
self.move = function () {
@@ -150,8 +200,33 @@
});
// Define the EnemyType4 class
var EnemyType4 = Container.expand(function () {
var self = Container.call(this);
+ self.shoot = function () {
+ if (LK.ticks - self.lastShotTick >= self.shootInterval) {
+ var newEnemyBullet = new EnemyBullet();
+ newEnemyBullet.x = self.x;
+ newEnemyBullet.y = self.y + self.height / 2;
+ // Calculate the direction to the hero
+ var direction = {
+ x: spaceRanger.x - self.x,
+ y: spaceRanger.y - self.y
+ };
+ var magnitude = Math.sqrt(direction.x * direction.x + direction.y * direction.y);
+ direction.x /= magnitude;
+ direction.y /= magnitude;
+ // Set bullet speed to aim at the hero
+ newEnemyBullet.speedX = direction.x * 5;
+ newEnemyBullet.speedY = direction.y * 5;
+ newEnemyBullet.move = function () {
+ this.x += this.speedX;
+ this.y += this.speedY;
+ };
+ game.addChild(newEnemyBullet);
+ enemyBullets.push(newEnemyBullet);
+ self.lastShotTick = LK.ticks;
+ }
+ };
var enemyGraphics = self.createAsset('enemyType4', 'Enemy Type 4', 0.5, 0.5);
self.speed = 3;
self.health = 4;
self.move = function () {
@@ -161,8 +236,33 @@
});
// Define the EnemyType5 class
var EnemyType5 = Container.expand(function () {
var self = Container.call(this);
+ self.shoot = function () {
+ if (LK.ticks - self.lastShotTick >= self.shootInterval) {
+ var newEnemyBullet = new EnemyBullet();
+ newEnemyBullet.x = self.x;
+ newEnemyBullet.y = self.y + self.height / 2;
+ // Calculate the direction to the hero
+ var direction = {
+ x: spaceRanger.x - self.x,
+ y: spaceRanger.y - self.y
+ };
+ var magnitude = Math.sqrt(direction.x * direction.x + direction.y * direction.y);
+ direction.x /= magnitude;
+ direction.y /= magnitude;
+ // Set bullet speed to aim at the hero
+ newEnemyBullet.speedX = direction.x * 5;
+ newEnemyBullet.speedY = direction.y * 5;
+ newEnemyBullet.move = function () {
+ this.x += this.speedX;
+ this.y += this.speedY;
+ };
+ game.addChild(newEnemyBullet);
+ enemyBullets.push(newEnemyBullet);
+ self.lastShotTick = LK.ticks;
+ }
+ };
var enemyGraphics = self.createAsset('enemyType5', 'Enemy Type 5', 0.5, 0.5);
self.speed = 5;
self.health = 1;
self.move = function () {
@@ -342,9 +442,9 @@
}
// Move all aliens and make them shoot if they are of EnemyType1
for (var j = aliens.length - 1; j >= 0; j--) {
aliens[j].move();
- if (aliens[j] instanceof EnemyType1) {
+ if (aliens[j].shoot) {
aliens[j].shoot();
}
if (aliens[j].y > 2732 + aliens[j].height / 2) {
aliens[j].destroy();
military spaceship flies upward. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
meteorite. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
ракета, снаряд летит вверх. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
energy ball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
alien ship, flying saucer. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
alien spaceship heading down. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
alien spaceship heading down. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
alien spaceship heading down. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
alien spaceship heading down. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
сердце. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
lightning. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.