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);
};
});
// 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 () {
// Simple movement towards the center of the screen
var dx = 1024 - self.x;
var dy = 1366 - 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 = 5;
self.move = function () {
self.y -= self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize hero and lives display
var hero = game.addChild(new Hero());
var livesDisplay = game.addChild(new LivesDisplay());
// 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 = [];
// Function to spawn enemies
function spawnEnemy() {
var angle = Math.random() * Math.PI * 2; // Random angle
var radius = 1200; // Spawn circle radius
var enemy = new Enemy();
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
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
if (LK.ticks % 120 === 0) {
spawnEnemy();
}
// Fire bullets
if (LK.ticks % 30 === 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
@@ -1,7 +1,20 @@
/****
* 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);
+ };
+});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5);
@@ -42,11 +55,17 @@
/****
* Game Code
****/
-// Initialize hero
+// Initialize hero and lives display
var hero = game.addChild(new Hero());
+var livesDisplay = game.addChild(new LivesDisplay());
+// 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 = [];
@@ -117,8 +136,9 @@
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;
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.