User prompt
в каждой новой волне врагов, количества врагов увеличивается на 1
User prompt
новая волна не появляется пока не убиты враги прошлой волны
User prompt
волны появления зомби по 10, каждая последующая волна + 1 враг
User prompt
зомби появляются с меньшей интенсивностью
User prompt
увеличь скорость стрельбы
User prompt
добавь задний фон, болото
User prompt
при управлении игрок стоит на месте, а карта прокручивается под ним
User prompt
зомби появляются не волнами а бесконечно
User prompt
скорость стрельбы увеличивается с каждой новой волной, скорость стрельбы не увеливается от убийства врагов
User prompt
сделай волны зомби, каждый этап новый этап зомби на 20% больше и они на 1% быстрее двигаются в каждой волне
User prompt
враги стремятся к герою
User prompt
уменьши количество выпускаемых пуль, и увеличь скорость полета пуль
User prompt
с каждым убитым врагом увеличивается скорочть стрельбы и скорость респавна врагов
User prompt
выведи счетчик убитых врагов на экран
User prompt
добавь в интерфевейс количество жизней
User prompt
у игрока три жизни, если враг коснется игрока, то одна жизнь исчезает, если жизни заканчиватюся - игрок игрок умирает
User prompt
стреляют автоматически в направлении ближайшего к игроку врага
User prompt
пули убивают врагов
User prompt
игрок постоянно следует за мышкой
User prompt
игрок двигается мышью
Initial prompt
battle of the hordes
/****
* Classes
****/
// LivesDisplay class
var LivesDisplay = Container.expand(function () {
var self = Container.call(this);
self.livesText = new Text2('Lives: 3', {
size: 100,
fill: "#ffffff"
});
self.livesText.anchor.set(0.5, 0);
LK.gui.top.addChild(self.livesText);
self.updateLives = function (lives) {
self.livesText.setText('Lives: ' + lives);
};
});
// ScoreDisplay class
var ScoreDisplay = Container.expand(function () {
var self = Container.call(this);
self.scoreText = new Text2('Score: 0', {
size: 100,
fill: "#ffffff"
});
self.scoreText.anchor.set(0.5, 0);
self.scoreText.y = 150; // Offset from the LivesDisplay
LK.gui.top.addChild(self.scoreText);
self.updateScore = function (score) {
self.scoreText.setText('Score: ' + score);
};
});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5);
self.x = 2048 / 2;
self.y = 2732 / 2;
self.lives = 3; // Hero starts with 3 lives
});
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('enemy', 'Enemy character', 0.5, 0.5);
self.speed = 2;
self.move = function () {
// Movement towards the hero's position
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
};
});
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('bullet', 'Bullet Graphics', 0.5, 0.5);
self.speed = 10;
self.move = function () {
self.y -= self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundAsset: 'swamp',
// Add swamp background asset
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize hero, lives display, and score display
var hero = game.addChild(new Hero());
var livesDisplay = game.addChild(new LivesDisplay());
var scoreDisplay = game.addChild(new ScoreDisplay());
var score = 0; // Global score variable
// Update the lives display when hero's lives change
Hero.prototype.updateLives = function () {
livesDisplay.updateLives(this.lives);
};
// Initialize enemies and bullets arrays
var enemies = [];
var bullets = [];
// Initialize firing rate, enemy spawn rate, and wave system
var firingRate = 30; // Increased firing rate (ticks)
var spawnRate = 180; // Increased enemy spawn rate (ticks) to decrease intensity
var waveCount = 0; // Number of waves that have passed
var enemiesPerWave = 10; // Base number of enemies per wave
var enemySpeedIncrease = 0.01; // Speed increase per wave
var score = 0; // Global score variable
// Function to spawn enemies
function spawnEnemy() {
var enemiesToSpawn = enemiesPerWave + waveCount + 1;
for (var i = 0; i < enemiesToSpawn; i++) {
var angle = Math.random() * Math.PI * 2; // Random angle
var radius = 1200; // Spawn circle radius
var enemy = new Enemy();
enemy.speed += enemy.speed * waveCount * enemySpeedIncrease; // Increase speed by 1% per wave
enemy.x = 1024 + radius * Math.cos(angle);
enemy.y = 1366 + radius * Math.sin(angle);
enemies.push(enemy);
game.addChild(enemy);
}
}
// Function to fire a bullet
function fireBullet() {
if (enemies.length === 0) {
return;
} // No enemies to shoot at
var nearestEnemy = enemies.reduce(function (closest, enemy) {
var closestDist = Math.sqrt(Math.pow(closest.x - hero.x, 2) + Math.pow(closest.y - hero.y, 2));
var enemyDist = Math.sqrt(Math.pow(enemy.x - hero.x, 2) + Math.pow(enemy.y - hero.y, 2));
return enemyDist < closestDist ? enemy : closest;
}, enemies[0]);
var angleToNearestEnemy = Math.atan2(nearestEnemy.y - hero.y, nearestEnemy.x - hero.x);
var bullet = new Bullet();
bullet.x = hero.x;
bullet.y = hero.y;
bullet.move = function () {
this.x += Math.cos(angleToNearestEnemy) * this.speed;
this.y += Math.sin(angleToNearestEnemy) * this.speed;
};
bullets.push(bullet);
game.addChild(bullet);
}
// Game tick event
LK.on('tick', function () {
// Move the hero towards the touch position
if (game.touchPosition) {
hero.x += (game.touchPosition.x - hero.x) * 0.1;
hero.y += (game.touchPosition.y - hero.y) * 0.1;
}
// Move bullets and check for collisions with enemies
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].move();
// Check for bullet-enemy collisions
for (var j = enemies.length - 1; j >= 0; j--) {
if (bullets[i] && bullets[i].intersects(enemies[j])) {
// Destroy enemy and update score
score += 1; // Increment score
scoreDisplay.updateScore(score); // Update score display
spawnRate = Math.max(30, spawnRate - 5); // Decrease spawn rate by 5 ticks to a minimum of 30 ticks
enemies[j].destroy();
enemies.splice(j, 1);
// Destroy bullet
bullets[i].destroy();
bullets.splice(i, 1);
break; // Break out of the enemies loop since the bullet is destroyed
}
}
// Remove bullets that are off-screen
if (bullets[i] && bullets[i].y < 0) {
bullets[i].destroy();
bullets.splice(i, 1);
}
}
// Move enemies
for (var j = enemies.length - 1; j >= 0; j--) {
enemies[j].move();
if (enemies[j].intersects(hero)) {
hero.lives -= 1; // Decrease hero's lives by one
hero.updateLives(); // Update the lives display
LK.effects.flashScreen(0xff0000, 500); // Flash screen red for half a second
if (hero.lives <= 0) {
LK.showGameOver(); // If no lives left, show game over
return;
}
enemies[j].destroy(); // Destroy the enemy that collided with the hero
enemies.splice(j, 1);
}
}
// Spawn enemies only if the previous wave has been cleared
if (LK.ticks % spawnRate === 0 && enemies.length === 0) {
spawnEnemy();
}
// Fire bullets
if (LK.ticks % firingRate === 0) {
fireBullet();
}
}); // Track touch position
var touchPosition = null;
game.on('move', function (obj) {
var event = obj.event;
touchPosition = event.getLocalPosition(game);
game.touchPosition = touchPosition;
}); ===================================================================
--- original.js
+++ change.js
@@ -95,9 +95,9 @@
var score = 0; // Global score variable
// Function to spawn enemies
function spawnEnemy() {
- var enemiesToSpawn = enemiesPerWave + waveCount;
+ var enemiesToSpawn = enemiesPerWave + waveCount + 1;
for (var i = 0; i < enemiesToSpawn; i++) {
var angle = Math.random() * Math.PI * 2; // Random angle
var radius = 1200; // Spawn circle radius
var enemy = new Enemy();
hero with a gun, shoots forward, top view, topdown. Single Game Texture. In-Game asset. 2d.TopDown. Blank background. High contrast. No shadows.
metal ball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A fireball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
heart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
zombie kamikaze, vertical top view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
opponent for the game, zombie kamikaze, vertical top view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.