User prompt
change zombie text image position below of score text
User prompt
now change the positon of zombie text image and send this below of Score text
User prompt
now add zombie text image below of Score image
User prompt
more right
User prompt
half of score image go to out of screen pls solve
Code edit (2 edits merged)
Please save this source code
User prompt
now change the position of Score image to left and also score
User prompt
now replace the Zombie Killed text to zombie text image
Code edit (1 edits merged)
Please save this source code
User prompt
after the score image the score should show
User prompt
add a score text image insted of score text
User prompt
this is very small increase size and make majesti
User prompt
now add score: and Zombie killed: in Game in best place
User prompt
improve game over screen
User prompt
remove all zombie killed and Score display fuctionality
Code edit (1 edits merged)
Please save this source code
User prompt
sore and zombie killed also
User prompt
improve texts deign so that they look best
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'LK.pauseGame is not a function' in or related to this line: 'LK.pauseGame(); // Pause the game to prevent background activity until the game starts' Line Number: 568
User prompt
Please fix the bug: 'game.pause is not a function' in or related to this line: 'game.pause(); // Pause the game to prevent background activity until the game starts' Line Number: 568
User prompt
not working
User prompt
not working
User prompt
not working in background game is show and main menu is not shown correctly
/****
* Classes
****/
/****
* Base Container Class
****/
var BaseContainer = Container.expand(function () {
var self = Container.call(this);
self.health = 1;
self.maxHealth = 1;
self.takeDamage = function (amount) {
self.health -= amount;
return self.health <= 0;
};
self.heal = function (amount) {
self.health = Math.min(self.health + amount, self.maxHealth);
};
return self;
});
/****
* Power-Up Class
****/
var PowerUp = BaseContainer.expand(function () {
var self = BaseContainer.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = ['speedBoost', 'damageBoost', 'healthBoost'][Math.floor(Math.random() * 3)];
self.speed = -5;
self.update = function () {
self.x += self.speed;
};
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.maxHealth = 100;
self.powerUpDuration = 0;
self.powerUpType = null;
self.bulletDamageMultiplier = 1;
self.activatePowerUp = function (type) {
self.powerUpType = type;
self.powerUpDuration = 300; // 5 seconds at 60 FPS
switch (type) {
case 'speedBoost':
self.speed *= 2;
break;
case 'damageBoost':
self.bulletDamageMultiplier = 2;
break;
case 'healthBoost':
self.health = self.maxHealth; // Fully restore health
break;
}
};
self.updatePowerUp = function () {
if (self.powerUpDuration > 0) {
self.powerUpDuration--;
if (self.powerUpDuration <= 0) {
// Reset power-up effects
self.speed = 10;
self.bulletDamageMultiplier = 1;
self.powerUpType = null;
}
}
};
self.update = function () {
self.updatePowerUp();
};
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;
});
/****
* Zombie Base Class
****/
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;
});
/****
* Specific Zombie Types
****/
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;
});
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
****/
/****
* Wave System
****/
/****
* Game Initialization
****/
var game = new LK.Game({
backgroundColor: 0x2C3E50
});
/****
* Game Code
****/
// Background
/*****
* Zombie Shooter Game
* Full Implementation with Enhanced Features
*****/
// Image Assets
// Sound Assets
/****
* Wave System
****/
// Image Assets
var WaveSystem = {
currentWave: 0,
zombiesRemaining: 0,
zombiesKilled: 0,
waveCooldown: 300,
powerUpSpawnChance: 0.4,
zombieTypes: [{
type: WeakZombie,
baseCount: 3
}, {
type: FastZombie,
baseCount: 2
}, {
type: ToughZombie,
baseCount: 1
}],
startNextWave: function startNextWave() {
this.currentWave++;
this.zombiesKilled = 0;
var zombieComposition = this.calculateZombieComposition();
this.zombiesRemaining = zombieComposition.total;
var waveText = new Text2('WAVE ' + this.currentWave + '\n' + '⚔️ Zombie Invasion ⚔️\n' + '🧟 Weak: ' + zombieComposition.weakCount + '\n' + '⚡ Fast: ' + zombieComposition.fastCount + '\n' + '💪 Tough: ' + zombieComposition.toughCount, {
size: 70,
fill: 0xFF0000,
align: 'center'
});
waveText.anchor.set(0.5, 0.5);
waveText.x = 2048 / 2;
waveText.y = 2732 / 2;
game.addChild(waveText);
LK.getSound('waveStart').play();
this.currentWaveText = waveText; // Store reference to wave text
this.spawnWaveZombies(zombieComposition);
if (Math.random() < this.powerUpSpawnChance) {
this.spawnPowerUp();
}
},
calculateZombieComposition: function calculateZombieComposition() {
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) {
for (var i = 0; i < zombieComposition.weakCount; i++) {
this.spawnZombie(WeakZombie);
}
for (var j = 0; j < zombieComposition.fastCount; j++) {
this.spawnZombie(FastZombie);
}
for (var k = 0; k < zombieComposition.toughCount; k++) {
this.spawnZombie(ToughZombie);
}
},
spawnZombie: function spawnZombie(ZombieClass) {
var zombie = new ZombieClass();
zombie.x = 2048;
zombie.y = Math.random() * 2732;
zombies.push(zombie);
game.addChild(zombie);
},
spawnPowerUp: function spawnPowerUp() {
var powerUp = new PowerUp();
powerUp.x = 2048;
powerUp.y = Math.random() * 2732;
powerUps.push(powerUp);
game.addChild(powerUp);
},
zombieKilled: function zombieKilled() {
this.zombiesRemaining--;
this.zombiesKilled++;
if (scoreTxt) {
scoreTxt.setText('Score: ' + score + ' | Zombies Killed: ' + this.zombiesKilled);
}
if (this.zombiesRemaining === 0) {
var waveCompleteText = new Text2('Wave ' + this.currentWave + ' Completed!', {
size: 100,
fill: 0x00FF00,
align: 'center'
});
waveCompleteText.anchor.set(0.5, 0.5);
waveCompleteText.x = 2048 / 2;
waveCompleteText.y = 2732 / 2;
game.addChild(waveCompleteText);
if (this.currentWaveText) {
game.removeChild(this.currentWaveText); // Remove wave text
this.currentWaveText = null;
}
LK.setTimeout(function () {
game.removeChild(waveCompleteText);
}, 4000);
}
if (killedZombieText) {
killedZombieText.setText('Zombies Killed: ' + this.zombiesKilled);
}
}
};
var background = game.attachAsset('background', {
anchorX: 0,
anchorY: 0
});
// Player
var player = game.addChild(new Player());
player.x = 150;
player.y = 2732 / 2;
// 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);
// Tracking Arrays
var bullets = [];
var zombies = [];
var powerUps = [];
// 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 - 150;
scoreTxt.y = 50;
// Power-Up Bar
var powerUpBar = null;
// Add text 'Killed Zombie =)' at the bottom left of the screen
var killedZombieText = new Text2('Zombies Killed: ' + WaveSystem.zombiesKilled, {
size: 130,
fill: 0xFFFFFF
});
killedZombieText.anchor.set(0, 0);
killedZombieText.x = 30;
killedZombieText.y = 90;
game.addChild(killedZombieText);
/****
* Game Mechanics
****/
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();
// Health Bar Update
if (player.health > 0) {
healthBar.width = player.health * 10;
} else {
healthBar.width = 0;
LK.showGameOver();
}
// Power-Up Bar Update
if (player.powerUpType) {
if (!powerUpBar) {
powerUpBar = LK.getAsset('powerUpBar', {
anchorX: 0,
anchorY: 0.5
});
powerUpBar.x = healthBarBorder.x - healthBarBorder.width / 2;
powerUpBar.y = healthBarBorder.y + 50;
game.addChild(powerUpBar);
}
powerUpBar.width = player.powerUpDuration / 300 * 500;
} else if (powerUpBar) {
game.removeChild(powerUpBar);
powerUpBar = null;
}
// Bullets Update
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].update();
if (bullets[i].x > 2048) {
bullets[i].destroy();
bullets.splice(i, 1);
}
}
// Zombies Update
for (var j = zombies.length - 1; j >= 0; j--) {
zombies[j].update();
if (zombies[j].intersects(player)) {
player.takeDamage(zombies[j].damage);
zombies[j].destroy();
zombies.splice(j, 1);
LK.getSound('zombieHit').play();
}
}
// Power-Ups Update
for (var p = powerUps.length - 1; p >= 0; p--) {
powerUps[p].update();
// Power-up collection
if (powerUps[p].intersects(player)) {
player.activatePowerUp(powerUps[p].type);
LK.getSound('powerUp').play();
powerUps[p].destroy();
powerUps.splice(p, 1);
}
// Remove power-ups that go off-screen
if (powerUps[p] && powerUps[p].x < -100) {
powerUps[p].destroy();
powerUps.splice(p, 1);
}
}
// 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])) {
// Calculate damage with potential power-up multiplier
var damage = bullets[k].damage * (player.bulletDamageMultiplier || 1);
if (zombies[l].takeDamage(damage)) {
score += 10;
WaveSystem.zombieKilled();
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 (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;
};
// Game Over Handler (if not already defined)
LK.showGameOver = function () {
// Create game over screen
var gameOverText = new Text2('GAME OVER\nScore: ' + score, {
size: 100,
fill: 0xFF0000,
align: 'center'
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = 2048 / 2;
gameOverText.y = 2732 / 2;
game.addChild(gameOverText);
// Add restart button
var restartButton = new Text2('RESTART', {
size: 50,
fill: 0xFFFFFF,
align: 'center'
});
restartButton.anchor.set(0.5, 0.5);
restartButton.x = 2048 / 2;
restartButton.y = 2732 / 2 + 200;
game.addChild(restartButton);
// Restart functionality
restartButton.interactive = true;
restartButton.on('mousedown', function () {
// Reset game state
score = 0;
zombies = [];
bullets = [];
powerUps = [];
// Reset player
player.health = 100;
player.powerUpType = null;
player.powerUpDuration = 0;
player.bulletDamageMultiplier = 1;
// Reset wave system
WaveSystem.currentWave = 0;
// Remove game over elements
game.removeChild(gameOverText);
game.removeChild(restartButton);
// Main Menu
var mainMenu = new Container();
var playGameText = new Text2('Play Game', {
size: 100,
fill: 0xFFFFFF,
align: 'center'
});
playGameText.anchor.set(0.5, 0.5);
playGameText.x = 2048 / 2;
playGameText.y = 2732 / 2 - 100;
mainMenu.addChild(playGameText);
var highScoreText = new Text2('High Score', {
size: 100,
fill: 0xFFFFFF,
align: 'center'
});
highScoreText.anchor.set(0.5, 0.5);
highScoreText.x = 2048 / 2;
highScoreText.y = 2732 / 2 + 100;
mainMenu.addChild(highScoreText);
game.addChild(mainMenu);
// Play Game functionality
playGameText.interactive = true;
playGameText.on('mousedown', function () {
game.removeChild(mainMenu);
WaveSystem.startNextWave();
});
// High Score functionality
highScoreText.interactive = true;
highScoreText.on('mousedown', function () {
var highScore = LK.getHighScore(); // Assuming LK.getHighScore() returns the high score
var highScoreDisplay = new Text2('High Score: ' + highScore, {
size: 100,
fill: 0xFFFFFF,
align: 'center'
});
highScoreDisplay.anchor.set(0.5, 0.5);
highScoreDisplay.x = 2048 / 2;
highScoreDisplay.y = 2732 / 2;
game.addChild(highScoreDisplay);
LK.setTimeout(function () {
game.removeChild(highScoreDisplay);
}, 3000);
});
});
};
// Main Menu
var mainMenu = new Container();
var playGameText = new Text2('Play Game', {
size: 100,
fill: 0xFFFFFF,
align: 'center'
});
playGameText.anchor.set(0.5, 0.5);
playGameText.x = 2048 / 2;
playGameText.y = 2732 / 2 - 100;
mainMenu.addChild(playGameText);
var highScoreText = new Text2('High Score', {
size: 100,
fill: 0xFFFFFF,
align: 'center'
});
highScoreText.anchor.set(0.5, 0.5);
highScoreText.x = 2048 / 2;
highScoreText.y = 2732 / 2 + 100;
mainMenu.addChild(highScoreText);
game.addChild(mainMenu);
// Ensure main menu is displayed at game start
game.addChild(mainMenu);
// Play Game functionality
playGameText.interactive = true;
playGameText.on('mousedown', function () {
game.removeChild(mainMenu);
WaveSystem.startNextWave();
});
// High Score functionality
highScoreText.interactive = true;
highScoreText.on('mousedown', function () {
var highScore = LK.getHighScore(); // Assuming LK.getHighScore() returns the high score
var highScoreDisplay = new Text2('High Score: ' + highScore, {
size: 100,
fill: 0xFFFFFF,
align: 'center'
});
highScoreDisplay.anchor.set(0.5, 0.5);
highScoreDisplay.x = 2048 / 2;
highScoreDisplay.y = 2732 / 2;
game.addChild(highScoreDisplay);
LK.setTimeout(function () {
game.removeChild(highScoreDisplay);
}, 3000);
});
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