User prompt
zombie is comming from define location add random location
User prompt
"Create a wave system for a zombie shooter game that increases the difficulty over time by spawning more zombies in each wave. The system should: Start with a small number of zombies (e.g., 20 zombies in the first wave). Gradually increase the zombie count by 5 or 6 with each subsequent wave (e.g., 25 zombies in the second wave, 30 zombies in the third wave, etc.). Introduce variations in zombie types, such as faster zombies or stronger zombies, as the waves progress. Include a delay between waves that can decrease slightly as the game progresses, increasing the challenge. Display a message on screen announcing the start of each new wave and the number of zombies to defeat.
User prompt
add background image
User prompt
add zombie kill sound
Code edit (1 edits merged)
Please save this source code
User prompt
Health bar is going from left to right, do the opposite.
User prompt
heath bar is decreasing from left to right not right t o left
User prompt
The entire health bar has gone into the left bottom, a small part of it is not visible.
User prompt
rest of health bar is not shown solve
User prompt
set location of health bar to left bottom
User prompt
set health bar location to center bottom
User prompt
Game over before health bar runs out solve pls
User prompt
before health bar is empty then game is automatically over solve
User prompt
health is decreasing from left pls change to right solve
User prompt
health color to red
User prompt
health is not shown only black colour is shown
User prompt
health is not shown
User prompt
fill black rectangle to health
User prompt
health bar health is not fill full when game is started solve pls
User prompt
health bar improve this
Code edit (1 edits merged)
Please save this source code
User prompt
increase health bar length and change to red
User prompt
change size of health bar to rectangular
User prompt
add health bar to right bottom of game and rectangulra
User prompt
health bar is not working
===================================================================
--- original.js
+++ change.js
@@ -34,8 +34,9 @@
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
+ self.health = 1; // Default health
self.update = function () {
var dx = player.x - self.x;
var dy = player.y - self.y;
var magnitude = Math.sqrt(dx * dx + dy * dy);
@@ -43,8 +44,14 @@
dy /= magnitude;
self.x += dx * self.speed;
self.y += dy * self.speed;
};
+ self.takeDamage = function (amount) {
+ self.health -= amount;
+ if (self.health <= 0) {
+ self.destroy();
+ }
+ };
});
/****
* Initialize Game
@@ -55,8 +62,21 @@
/****
* Game Code
****/
+// Wave system variables
+var currentWave = 1;
+var zombiesPerWave = 20;
+var waveDelay = 3000; // 3 seconds
+var waveTimer = 0;
+var waveMessage = new Text2('', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+waveMessage.anchor.set(0.5, 0);
+LK.gui.top.addChild(waveMessage);
+waveMessage.x = 2048 / 2;
+waveMessage.y = 150;
var background = game.attachAsset('background', {
anchorX: 0,
anchorY: 0
});
@@ -97,8 +117,14 @@
function spawnZombie() {
var zombie = new Zombie();
zombie.x = 2048;
zombie.y = Math.random() * 2732;
+ // Introduce variations in zombie types
+ if (currentWave > 3 && Math.random() < 0.3) {
+ zombie.speed = 4; // Faster zombie
+ } else if (currentWave > 5 && Math.random() < 0.2) {
+ zombie.health = 2; // Stronger zombie
+ }
zombies.push(zombie);
game.addChild(zombie);
}
// Shooting bullets
@@ -144,19 +170,35 @@
if (bullets[k].intersects(zombies[l])) {
score += 10;
scoreTxt.setText('Score: ' + score);
bullets[k].destroy();
- zombies[l].destroy();
+ zombies[l].takeDamage(1);
+ bullets[k].destroy();
bullets.splice(k, 1);
- zombies.splice(l, 1);
- LK.getSound('zombieKill').play();
+ if (zombies[l].health <= 0) {
+ zombies.splice(l, 1);
+ LK.getSound('zombieKill').play();
+ }
break;
}
}
}
- // Spawn zombies every 60 ticks
- if (LK.ticks % 60 === 0) {
- spawnZombie();
+ // Handle wave system
+ if (zombies.length === 0 && waveTimer <= 0) {
+ // Start new wave
+ waveMessage.setText('Wave ' + currentWave + ': ' + zombiesPerWave + ' Zombies');
+ waveTimer = waveDelay;
+ for (var n = 0; n < zombiesPerWave; n++) {
+ spawnZombie();
+ }
+ currentWave++;
+ zombiesPerWave += 5; // Increase zombies per wave
+ waveDelay = Math.max(1000, waveDelay - 200); // Decrease delay, minimum 1 second
+ } else if (waveTimer > 0) {
+ waveTimer -= 1000 / 60; // Decrease timer by 1/60th of a second
+ if (waveTimer <= 0) {
+ waveMessage.setText('');
+ }
}
};
// Player controls
game.down = function (x, y, obj) {
make player like this style
make full legs of this player
bullet. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
more dangorous
make horror
red heart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
rename text to -- Zombie Killed