/**** * 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 (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); } } }; 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; // Score Display using Image var scoreImage = LK.getAsset('score', { anchorX: 0.5, anchorY: 0.5 }); scoreImage.x = scoreImage.width; // Move the score image more to the right scoreImage.y = 100; game.addChild(scoreImage); // Score Text var scoreText = new Text2(score, { size: 100, fill: 0xFFFFFF, align: 'left' }); scoreText.anchor.set(0, 0.5); scoreText.x = scoreImage.x + scoreImage.width + 10; // Positioned next to the score image scoreText.y = scoreImage.y; game.addChild(scoreText); // Zombies Killed Display using Image var zombiesKilledImage = LK.getAsset('zombietext', { anchorX: 0.5, anchorY: 0.5 }); zombiesKilledImage.x = scoreText.x + scoreText.width / 2; // Align with score text zombiesKilledImage.y = scoreText.y + scoreText.height + 20; // Position below the score text game.addChild(zombiesKilledImage); // Zombies Killed Text var zombiesKilledText = new Text2('0', { size: 100, fill: 0xFFD700, align: 'left' }); zombiesKilledText.anchor.set(0, 0.5); zombiesKilledText.x = zombiesKilledImage.x + zombiesKilledImage.width / 2 + 10; // Positioned next to the zombie text image zombiesKilledText.y = zombiesKilledImage.y; game.addChild(zombiesKilledText); // Power-Up Bar var powerUpBar = null; /**** * 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; scoreText.setText(score); WaveSystem.zombieKilled(); zombiesKilledText.setText('Zombies Killed: ' + WaveSystem.zombiesKilled); 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\nThanks for playing!', { size: 100, fill: 0xFF0000, align: 'center' }); gameOverText.anchor.set(0.5, 0.5); gameOverText.x = 2048 / 2; gameOverText.y = 2732 / 2 - 100; gameOverText.alpha = 0; game.addChild(gameOverText); LK.effects.fadeIn(gameOverText, 1000); // 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; restartButton.alpha = 0; game.addChild(restartButton); LK.effects.fadeIn(restartButton, 1000); // 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); // Restart the game WaveSystem.startNextWave(); }); }; // Start the first wave when the game begins WaveSystem.startNextWave();
/****
* 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 (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);
}
}
};
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;
// Score Display using Image
var scoreImage = LK.getAsset('score', {
anchorX: 0.5,
anchorY: 0.5
});
scoreImage.x = scoreImage.width; // Move the score image more to the right
scoreImage.y = 100;
game.addChild(scoreImage);
// Score Text
var scoreText = new Text2(score, {
size: 100,
fill: 0xFFFFFF,
align: 'left'
});
scoreText.anchor.set(0, 0.5);
scoreText.x = scoreImage.x + scoreImage.width + 10; // Positioned next to the score image
scoreText.y = scoreImage.y;
game.addChild(scoreText);
// Zombies Killed Display using Image
var zombiesKilledImage = LK.getAsset('zombietext', {
anchorX: 0.5,
anchorY: 0.5
});
zombiesKilledImage.x = scoreText.x + scoreText.width / 2; // Align with score text
zombiesKilledImage.y = scoreText.y + scoreText.height + 20; // Position below the score text
game.addChild(zombiesKilledImage);
// Zombies Killed Text
var zombiesKilledText = new Text2('0', {
size: 100,
fill: 0xFFD700,
align: 'left'
});
zombiesKilledText.anchor.set(0, 0.5);
zombiesKilledText.x = zombiesKilledImage.x + zombiesKilledImage.width / 2 + 10; // Positioned next to the zombie text image
zombiesKilledText.y = zombiesKilledImage.y;
game.addChild(zombiesKilledText);
// Power-Up Bar
var powerUpBar = null;
/****
* 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;
scoreText.setText(score);
WaveSystem.zombieKilled();
zombiesKilledText.setText('Zombies Killed: ' + WaveSystem.zombiesKilled);
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\nThanks for playing!', {
size: 100,
fill: 0xFF0000,
align: 'center'
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = 2048 / 2;
gameOverText.y = 2732 / 2 - 100;
gameOverText.alpha = 0;
game.addChild(gameOverText);
LK.effects.fadeIn(gameOverText, 1000);
// 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;
restartButton.alpha = 0;
game.addChild(restartButton);
LK.effects.fadeIn(restartButton, 1000);
// 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);
// Restart the game
WaveSystem.startNextWave();
});
};
// Start the first wave when the game begins
WaveSystem.startNextWave();
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