Code edit (4 edits merged)
Please save this source code
User prompt
send to slightly up
User prompt
send to slightly down
Code edit (1 edits merged)
Please save this source code
User prompt
increase size
User prompt
send to slightly down
User prompt
same size as score txt
User prompt
not bottom add to left
User prompt
change position to opposite side of score txt
User prompt
increase size of killed Zombie same as Score txt
User prompt
killed zombie text is not shown solve problem pls
User prompt
Add another thing like a text written in it at the left bottom (Killed Zombie =)
Code edit (2 edits merged)
Please save this source code
User prompt
hange score text position slightly left
User prompt
change score text position slightly left
User prompt
change score text position slightly left
User prompt
when powerup is gained by player then full fill the health of player
Code edit (1 edits merged)
Please save this source code
User prompt
images are not shown only boxes are shown
User prompt
image assests are not working
Code edit (1 edits merged)
Please save this source code
User prompt
improve wave massega design
User prompt
Please fix the bug: 'setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 171
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: this.spawnWaveZombies is not a function' in or related to this line: 'this.spawnWaveZombies(zombieComposition);' Line Number: 175
/**** * Classes ****/ /**** * Base Container Class ****/ var BaseContainer = Container.expand(function () { var self = Container.call(this); self.health = 1; self.takeDamage = function (amount) { self.health -= amount; return self.health <= 0; }; return self; }); /**** * Player Class ****/ var Player = BaseContainer.expand(function () { var self = BaseContainer.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.health = 100; self.update = function () {}; return self; }); /**** * Bullet Class ****/ var Bullet = BaseContainer.expand(function () { var self = BaseContainer.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 15; self.damage = 1; self.update = function () { self.x += self.speed; }; return self; }); var BaseZombie = BaseContainer.expand(function () { var self = BaseContainer.call(this); self.speed = 2; self.update = function () { var dx = player.x - self.x; var dy = player.y - self.y; var magnitude = Math.sqrt(dx * dx + dy * dy); if (magnitude > 0) { dx /= magnitude; dy /= magnitude; self.x += dx * self.speed; self.y += dy * self.speed; } }; return self; }); var WeakZombie = BaseZombie.expand(function () { var self = BaseZombie.call(this); var zombieGraphics = self.attachAsset('weakZombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.health = 1; self.damage = 10; return self; }); var ToughZombie = BaseZombie.expand(function () { var self = BaseZombie.call(this); var zombieGraphics = self.attachAsset('toughZombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1.5; self.health = 3; self.damage = 20; return self; }); /**** * Wave System ****/ var FastZombie = BaseZombie.expand(function () { var self = BaseZombie.call(this); var zombieGraphics = self.attachAsset('fastZombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.health = 1; self.damage = 15; return self; }); /**** * Initialize Game ****/ /**** * Game Initialization ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ /**** * Wave System ****/ /***** * Zombie Shooter Game * Full Implementation with Improved Wave System *****/ // Background var WaveSystem = { currentWave: 0, zombiesRemaining: 0, zombiesKilled: 0, waveCooldown: 300, // Initial delay between waves (5 seconds at 60 FPS) zombieTypes: [{ type: WeakZombie, baseCount: 3 }, { type: FastZombie, baseCount: 2 }, { type: ToughZombie, baseCount: 1 }], startNextWave: function startNextWave() { this.currentWave++; this.zombiesKilled = 0; // Calculate zombie counts for each type var zombieComposition = this.calculateZombieComposition(); this.zombiesRemaining = zombieComposition.total; // Create a background for the wave announcement text var waveTextBackground = LK.getAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 5, scaleY: 5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(waveTextBackground); // Create detailed wave announcement text with improved design var waveText = new Text2('Wave ' + this.currentWave + '\n' + 'Incoming Zombies:\n' + 'Weak: ' + zombieComposition.weakCount + '\n' + 'Fast: ' + zombieComposition.fastCount + '\n' + 'Tough: ' + zombieComposition.toughCount, { size: 100, fill: 0xFFFFFF, align: 'center' }); waveText.anchor.set(0.5, 0.5); waveText.x = 2048 / 2; waveText.y = 2732 / 2; game.addChild(waveText); // Play wave start sound LK.getSound('waveStart').play(); // Remove text after 2 seconds LK.setTimeout(function () { game.removeChild(waveText); }, 2000); // Spawn zombies for this wave this.spawnWaveZombies(zombieComposition); }, calculateZombieComposition: function calculateZombieComposition() { // Base zombie counts increase with wave number var weakBase = this.zombieTypes[0].baseCount + Math.floor(this.currentWave / 2); var fastBase = this.zombieTypes[1].baseCount + Math.floor(this.currentWave / 3); var toughBase = this.zombieTypes[2].baseCount + Math.floor(this.currentWave / 4); var composition = { weakCount: weakBase, fastCount: fastBase, toughCount: toughBase }; composition.total = composition.weakCount + composition.fastCount + composition.toughCount; return composition; }, spawnWaveZombies: function spawnWaveZombies(zombieComposition) { // Spawn weak zombies for (var i = 0; i < zombieComposition.weakCount; i++) { this.spawnZombie(WeakZombie); } // Spawn fast zombies for (var j = 0; j < zombieComposition.fastCount; j++) { this.spawnZombie(FastZombie); } // Spawn tough zombies for (var k = 0; k < zombieComposition.toughCount; k++) { this.spawnZombie(ToughZombie); } }, spawnZombie: function spawnZombie(ZombieClass) { var zombie = new ZombieClass(); zombie.x = 2048; // Start from right side of screen zombie.y = Math.random() * 2732; zombies.push(zombie); game.addChild(zombie); }, zombieKilled: function zombieKilled() { this.zombiesRemaining--; this.zombiesKilled++; // Update score text to show zombies killed if (scoreTxt) { scoreTxt.setText('Score: ' + score + ' | Zombies Killed: ' + this.zombiesKilled); } } }; var background = game.attachAsset('background', { anchorX: 0, anchorY: 0 }); // Initialize player var player = game.addChild(new Player()); player.x = 150; player.y = 2732 / 2; // Initialize health bar var healthBarBorder = LK.getAsset('healthBarBorder', { anchorX: 0.5, anchorY: 0.5 }); healthBarBorder.x = 2048 - healthBarBorder.width / 2 - 50; healthBarBorder.y = 2732 - 50; game.addChild(healthBarBorder); var healthBar = LK.getAsset('healthBar', { anchorX: 0, anchorY: 0.5 }); healthBar.x = healthBarBorder.x - healthBarBorder.width / 2; healthBar.y = healthBarBorder.y; game.addChild(healthBar); // Initialize score var score = 0; var scoreTxt = new Text2('Score: 0 | Zombies Killed: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.x = 2048 / 2; scoreTxt.y = 50; // Bullet and zombie tracking var bullets = []; var zombies = []; /**** * Game Mechanics ****/ // Shooting bullets function shootBullet() { var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; bullets.push(bullet); game.addChild(bullet); LK.getSound('shoot').play(); } /**** * Game Update Loop ****/ game.update = function () { player.update(); // Update health bar width and position if (player.health > 0) { healthBar.width = player.health * 10; } else { healthBar.width = 0; LK.showGameOver(); } // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].update(); if (bullets[i].x > 2048) { bullets[i].destroy(); bullets.splice(i, 1); } } // Update zombies for (var j = zombies.length - 1; j >= 0; j--) { zombies[j].update(); // Zombie-player collision if (zombies[j].intersects(player)) { player.takeDamage(zombies[j].damage); zombies[j].destroy(); zombies.splice(j, 1); LK.getSound('zombieHit').play(); } } // Bullet-zombie collisions for (var k = bullets.length - 1; k >= 0; k--) { for (var l = zombies.length - 1; l >= 0; l--) { if (bullets[k].intersects(zombies[l])) { // Zombie takes damage from bullet if (zombies[l].takeDamage(bullets[k].damage)) { score += 10; WaveSystem.zombieKilled(); // Track killed zombies zombies[l].destroy(); zombies.splice(l, 1); LK.getSound('zombieKill').play(); } bullets[k].destroy(); bullets.splice(k, 1); break; } } } // Wave system management if (LK.ticks % WaveSystem.waveCooldown === 0) { // If no zombies exist, start a new wave if (zombies.length === 0) { WaveSystem.startNextWave(); } } }; /**** * Game Controls ****/ game.down = function (x, y, obj) { shootBullet(); }; game.move = function (x, y, obj) { player.x = x; player.y = y; }; // Start the first wave when the game begins WaveSystem.startNextWave();
===================================================================
--- original.js
+++ change.js
@@ -138,12 +138,22 @@
this.zombiesKilled = 0;
// Calculate zombie counts for each type
var zombieComposition = this.calculateZombieComposition();
this.zombiesRemaining = zombieComposition.total;
- // Create detailed wave announcement text
+ // Create a background for the wave announcement text
+ var waveTextBackground = LK.getAsset('centerCircle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 5,
+ scaleY: 5,
+ x: 2048 / 2,
+ y: 2732 / 2
+ });
+ game.addChild(waveTextBackground);
+ // Create detailed wave announcement text with improved design
var waveText = new Text2('Wave ' + this.currentWave + '\n' + 'Incoming Zombies:\n' + 'Weak: ' + zombieComposition.weakCount + '\n' + 'Fast: ' + zombieComposition.fastCount + '\n' + 'Tough: ' + zombieComposition.toughCount, {
- size: 70,
- fill: 0xFF0000,
+ size: 100,
+ fill: 0xFFFFFF,
align: 'center'
});
waveText.anchor.set(0.5, 0.5);
waveText.x = 2048 / 2;
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