/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('tankZombie', {
anchorX: 0.5,
anchorY: 0.5
});
bossGraphics.scaleX = 2.0; // Much bigger than regular zombies
bossGraphics.scaleY = 2.0;
bossGraphics.tint = 0xFF0000; // Red tint to distinguish from regular tanks
self.speed = 1.5; // Slower but more menacing
self.health = 300; // Much more health
self.maxHealth = self.health;
self.damage = 75; // Much more damage
self.isBoss = true;
self.armor = 10; // Boss has armor reducing incoming damage
self.moveDirection = 1; // For side-to-side movement
self.moveTimer = 0;
self.update = function () {
// Boss moves side to side while advancing
self.moveTimer++;
if (self.moveTimer >= 60) {
// Change direction every second
self.moveDirection *= -1;
self.moveTimer = 0;
}
// Side to side movement
self.x += self.moveDirection * 3;
// Keep boss on screen
if (self.x < 200) {
self.x = 200;
self.moveDirection = 1;
} else if (self.x > 1848) {
self.x = 1848;
self.moveDirection = -1;
}
// Move downward from the front
self.y += self.speed + roadSpeed;
// Remove if off screen
if (self.y > 2732 + 50) {
self.destroy();
for (var i = bosses.length - 1; i >= 0; i--) {
if (bosses[i] === self) {
bosses.splice(i, 1);
break;
}
}
}
// Check collision with car
if (self.intersects(car)) {
car.takeDamage(self.damage);
self.destroy();
for (var i = bosses.length - 1; i >= 0; i--) {
if (bosses[i] === self) {
bosses.splice(i, 1);
break;
}
}
}
};
self.takeDamage = function (damage) {
// Boss armor reduces damage
var actualDamage = Math.max(1, damage - self.armor);
self.health -= actualDamage;
LK.effects.flashObject(self, 0xFFFF00, 200); // Yellow flash for boss
if (self.health <= 0) {
LK.setScore(LK.getScore() + 100); // Big bonus points for killing boss
// Boss death explosion effect
LK.effects.flashScreen(0xFFFF00, 800);
self.destroy();
for (var i = bosses.length - 1; i >= 0; i--) {
if (bosses[i] === self) {
bosses.splice(i, 1);
break;
}
}
}
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.damage = car.damage;
self.update = function () {
self.y -= self.speed;
// Remove if off screen
if (self.y < -50) {
self.destroy();
for (var i = bullets.length - 1; i >= 0; i--) {
if (bullets[i] === self) {
bullets.splice(i, 1);
break;
}
}
}
// Check collision with zombies
for (var i = zombies.length - 1; i >= 0; i--) {
var zombie = zombies[i];
if (self.intersects(zombie)) {
zombie.takeDamage(self.damage);
self.destroy();
for (var j = bullets.length - 1; j >= 0; j--) {
if (bullets[j] === self) {
bullets.splice(j, 1);
break;
}
}
break;
}
}
// Check collision with bosses separately
for (var i = bosses.length - 1; i >= 0; i--) {
var boss = bosses[i];
if (self.intersects(boss)) {
boss.takeDamage(self.damage);
self.destroy();
for (var j = bullets.length - 1; j >= 0; j--) {
if (bullets[j] === self) {
bullets.splice(j, 1);
break;
}
}
break;
}
}
};
return self;
});
var Car = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('car', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.maxHealth = 100;
self.health = self.maxHealth;
self.armor = 0;
self.damage = 20;
self.fireRate = 30;
self.fireTimer = 0;
self.moveSpeed = 12;
self.update = function () {
if (self.fireTimer > 0) {
self.fireTimer--;
}
// Auto-fire bullets
if (self.fireTimer <= 0) {
self.fireBullet();
self.fireTimer = self.fireRate;
}
};
self.fireBullet = function () {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y - 100;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
};
self.takeDamage = function (damage) {
var actualDamage = Math.max(1, damage - self.armor);
self.health -= actualDamage;
LK.effects.flashObject(self, 0xff0000, 300);
LK.getSound('hit').play();
if (self.health <= 0) {
LK.showGameOver();
}
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('debris', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += roadSpeed;
// Remove if off screen
if (self.y > 2732 + 50) {
self.destroy();
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i] === self) {
obstacles.splice(i, 1);
break;
}
}
}
// Check collision with car
if (self.intersects(car)) {
car.takeDamage(15);
self.destroy();
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i] === self) {
obstacles.splice(i, 1);
break;
}
}
}
};
return self;
});
var Pickup = Container.expand(function (type) {
var self = Container.call(this);
self.pickupType = type || 'scrap';
var assetName = 'scrapMetal';
if (self.pickupType === 'armor') {
assetName = 'armorPlate';
} else if (self.pickupType === 'weapon') {
assetName = 'weaponPart';
}
var pickupGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += roadSpeed;
// Remove if off screen
if (self.y > 2732 + 50) {
self.destroy();
for (var i = pickups.length - 1; i >= 0; i--) {
if (pickups[i] === self) {
pickups.splice(i, 1);
break;
}
}
}
// Check collision with car
if (self.intersects(car)) {
self.collect();
}
};
self.collect = function () {
LK.getSound('collect').play();
if (self.pickupType === 'scrap') {
scrapCount++;
car.speed += 0.1;
// Heal the car when collecting scrap
car.health = Math.min(car.maxHealth, car.health + 15);
// Increase damage when collecting scrap
car.damage += 2;
} else if (self.pickupType === 'armor') {
armorCount++;
car.armor += 2;
} else if (self.pickupType === 'weapon') {
weaponCount++;
car.damage += 3;
car.fireRate = Math.max(10, car.fireRate - 1);
}
updateUpgradeDisplay();
self.destroy();
for (var i = pickups.length - 1; i >= 0; i--) {
if (pickups[i] === self) {
pickups.splice(i, 1);
break;
}
}
};
return self;
});
var Zombie = Container.expand(function (type) {
var self = Container.call(this);
self.zombieType = type || 'normal';
var assetName = 'zombie';
if (self.zombieType === 'fast') {
assetName = 'fastZombie';
self.speed = 6;
self.health = 15;
self.damage = 15;
} else if (self.zombieType === 'tank') {
assetName = 'tankZombie';
self.speed = 3;
self.health = 50;
self.damage = 30;
} else {
self.speed = 4;
self.health = 20;
self.damage = 20;
}
var zombieGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.maxHealth = self.health;
self.update = function () {
// Move downward from the front
self.y += self.speed + roadSpeed;
// Remove if off screen
if (self.y > 2732 + 50) {
self.destroy();
for (var i = zombies.length - 1; i >= 0; i--) {
if (zombies[i] === self) {
zombies.splice(i, 1);
break;
}
}
}
// Check collision with car
if (self.intersects(car)) {
car.takeDamage(self.damage);
self.destroy();
for (var i = zombies.length - 1; i >= 0; i--) {
if (zombies[i] === self) {
zombies.splice(i, 1);
break;
}
}
}
};
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff0000, 200);
if (self.health <= 0) {
LK.setScore(LK.getScore() + 10);
self.destroy();
for (var i = zombies.length - 1; i >= 0; i--) {
if (zombies[i] === self) {
zombies.splice(i, 1);
break;
}
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a5a1a
});
/****
* Game Code
****/
// Game variables
var car;
var zombies = [];
var bosses = []; // Separate array for boss zombies
var bullets = [];
var pickups = [];
var obstacles = [];
var roadSegments = [];
var roadLines = [];
var roadSpeed = 8;
var spawnTimer = 0;
var pickupTimer = 0;
var obstacleTimer = 0;
var difficultyTimer = 0;
var scrapCount = 0;
var armorCount = 0;
var weaponCount = 0;
var dragActive = false;
var lastBossScore = 0;
// Create road background
for (var i = 0; i < 10; i++) {
var roadSegment = LK.getAsset('road', {
anchorX: 0.5,
anchorY: 0
});
roadSegment.x = 1024;
roadSegment.y = i * 400 - 400;
roadSegments.push(roadSegment);
game.addChild(roadSegment);
}
// Create road lines
for (var i = 0; i < 30; i++) {
var roadLine = LK.getAsset('roadLine', {
anchorX: 0.5,
anchorY: 0
});
roadLine.x = 1024;
roadLine.y = i * 150 - 300;
roadLines.push(roadLine);
game.addChild(roadLine);
}
// Create car
car = game.addChild(new Car());
car.x = 1024;
car.y = 2200;
// UI Elements
var healthBar = new Text2('Health: 100', {
size: 60,
fill: 0xFF4444
});
healthBar.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthBar);
healthBar.x = 120;
healthBar.y = 20;
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var upgradeText = new Text2('Scrap:0 Armor:0 Weapons:0', {
size: 50,
fill: 0x00FF00
});
upgradeText.anchor.set(1, 0);
LK.gui.topRight.addChild(upgradeText);
upgradeText.x = -20;
upgradeText.y = 20;
function updateUpgradeDisplay() {
upgradeText.setText('Scrap:' + scrapCount + ' Armor:' + armorCount + ' Weapons:' + weaponCount);
}
function spawnZombie() {
var zombieType = 'normal';
var rand = Math.random();
if (LK.ticks > 1800) {
// After 30 seconds
if (rand < 0.2) zombieType = 'fast';else if (rand < 0.35) zombieType = 'tank';
}
var zombie = new Zombie(zombieType);
zombie.x = Math.random() * 1800 + 124;
zombie.y = -50;
zombies.push(zombie);
game.addChild(zombie);
}
function spawnPickup() {
var pickupTypes = ['scrap', 'armor', 'weapon'];
var pickupType = pickupTypes[Math.floor(Math.random() * pickupTypes.length)];
var pickup = new Pickup(pickupType);
pickup.x = Math.random() * 1800 + 124;
pickup.y = -50;
pickups.push(pickup);
game.addChild(pickup);
}
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = Math.random() * 1800 + 124;
obstacle.y = -50;
obstacles.push(obstacle);
game.addChild(obstacle);
}
function spawnBoss() {
var boss = new Boss();
boss.x = 1024; // Center of screen
boss.y = -100;
bosses.push(boss); // Add to separate bosses array
game.addChild(boss);
LK.effects.flashScreen(0xFF0000, 500); // Red screen flash when boss spawns
}
// Touch controls
game.down = function (x, y, obj) {
dragActive = true;
};
game.move = function (x, y, obj) {
if (dragActive) {
car.x = Math.max(124, Math.min(1924, x));
}
};
game.up = function (x, y, obj) {
dragActive = false;
};
game.update = function () {
// Update road movement
for (var i = 0; i < roadSegments.length; i++) {
roadSegments[i].y += roadSpeed;
if (roadSegments[i].y > 2732) {
roadSegments[i].y -= 4000;
}
}
for (var i = 0; i < roadLines.length; i++) {
roadLines[i].y += roadSpeed;
if (roadLines[i].y > 2732) {
roadLines[i].y -= 4500;
}
}
// Spawn zombies
spawnTimer++;
var spawnRate = Math.max(30, 120 - Math.floor(LK.ticks / 600) * 10);
if (spawnTimer >= spawnRate) {
spawnZombie();
spawnTimer = 0;
}
// Spawn pickups
pickupTimer++;
if (pickupTimer >= 180) {
spawnPickup();
pickupTimer = 0;
}
// Spawn obstacles
obstacleTimer++;
if (obstacleTimer >= 240) {
spawnObstacle();
obstacleTimer = 0;
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer >= 600) {
// Every 10 seconds
roadSpeed += 0.2;
difficultyTimer = 0;
}
// Update score based on survival time
if (LK.ticks % 60 === 0) {
LK.setScore(LK.getScore() + 1);
}
// Spawn boss every 100 points
var currentScore = LK.getScore();
if (currentScore >= lastBossScore + 100 && currentScore > 0) {
spawnBoss();
lastBossScore = Math.floor(currentScore / 100) * 100;
}
// Update UI
healthBar.setText('Health: ' + Math.max(0, car.health));
scoreText.setText('Score: ' + LK.getScore());
};
// Start background music
LK.playMusic('bgmusic'); /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('tankZombie', {
anchorX: 0.5,
anchorY: 0.5
});
bossGraphics.scaleX = 2.0; // Much bigger than regular zombies
bossGraphics.scaleY = 2.0;
bossGraphics.tint = 0xFF0000; // Red tint to distinguish from regular tanks
self.speed = 1.5; // Slower but more menacing
self.health = 300; // Much more health
self.maxHealth = self.health;
self.damage = 75; // Much more damage
self.isBoss = true;
self.armor = 10; // Boss has armor reducing incoming damage
self.moveDirection = 1; // For side-to-side movement
self.moveTimer = 0;
self.update = function () {
// Boss moves side to side while advancing
self.moveTimer++;
if (self.moveTimer >= 60) {
// Change direction every second
self.moveDirection *= -1;
self.moveTimer = 0;
}
// Side to side movement
self.x += self.moveDirection * 3;
// Keep boss on screen
if (self.x < 200) {
self.x = 200;
self.moveDirection = 1;
} else if (self.x > 1848) {
self.x = 1848;
self.moveDirection = -1;
}
// Move downward from the front
self.y += self.speed + roadSpeed;
// Remove if off screen
if (self.y > 2732 + 50) {
self.destroy();
for (var i = bosses.length - 1; i >= 0; i--) {
if (bosses[i] === self) {
bosses.splice(i, 1);
break;
}
}
}
// Check collision with car
if (self.intersects(car)) {
car.takeDamage(self.damage);
self.destroy();
for (var i = bosses.length - 1; i >= 0; i--) {
if (bosses[i] === self) {
bosses.splice(i, 1);
break;
}
}
}
};
self.takeDamage = function (damage) {
// Boss armor reduces damage
var actualDamage = Math.max(1, damage - self.armor);
self.health -= actualDamage;
LK.effects.flashObject(self, 0xFFFF00, 200); // Yellow flash for boss
if (self.health <= 0) {
LK.setScore(LK.getScore() + 100); // Big bonus points for killing boss
// Boss death explosion effect
LK.effects.flashScreen(0xFFFF00, 800);
self.destroy();
for (var i = bosses.length - 1; i >= 0; i--) {
if (bosses[i] === self) {
bosses.splice(i, 1);
break;
}
}
}
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.damage = car.damage;
self.update = function () {
self.y -= self.speed;
// Remove if off screen
if (self.y < -50) {
self.destroy();
for (var i = bullets.length - 1; i >= 0; i--) {
if (bullets[i] === self) {
bullets.splice(i, 1);
break;
}
}
}
// Check collision with zombies
for (var i = zombies.length - 1; i >= 0; i--) {
var zombie = zombies[i];
if (self.intersects(zombie)) {
zombie.takeDamage(self.damage);
self.destroy();
for (var j = bullets.length - 1; j >= 0; j--) {
if (bullets[j] === self) {
bullets.splice(j, 1);
break;
}
}
break;
}
}
// Check collision with bosses separately
for (var i = bosses.length - 1; i >= 0; i--) {
var boss = bosses[i];
if (self.intersects(boss)) {
boss.takeDamage(self.damage);
self.destroy();
for (var j = bullets.length - 1; j >= 0; j--) {
if (bullets[j] === self) {
bullets.splice(j, 1);
break;
}
}
break;
}
}
};
return self;
});
var Car = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('car', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.maxHealth = 100;
self.health = self.maxHealth;
self.armor = 0;
self.damage = 20;
self.fireRate = 30;
self.fireTimer = 0;
self.moveSpeed = 12;
self.update = function () {
if (self.fireTimer > 0) {
self.fireTimer--;
}
// Auto-fire bullets
if (self.fireTimer <= 0) {
self.fireBullet();
self.fireTimer = self.fireRate;
}
};
self.fireBullet = function () {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y - 100;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
};
self.takeDamage = function (damage) {
var actualDamage = Math.max(1, damage - self.armor);
self.health -= actualDamage;
LK.effects.flashObject(self, 0xff0000, 300);
LK.getSound('hit').play();
if (self.health <= 0) {
LK.showGameOver();
}
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('debris', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += roadSpeed;
// Remove if off screen
if (self.y > 2732 + 50) {
self.destroy();
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i] === self) {
obstacles.splice(i, 1);
break;
}
}
}
// Check collision with car
if (self.intersects(car)) {
car.takeDamage(15);
self.destroy();
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i] === self) {
obstacles.splice(i, 1);
break;
}
}
}
};
return self;
});
var Pickup = Container.expand(function (type) {
var self = Container.call(this);
self.pickupType = type || 'scrap';
var assetName = 'scrapMetal';
if (self.pickupType === 'armor') {
assetName = 'armorPlate';
} else if (self.pickupType === 'weapon') {
assetName = 'weaponPart';
}
var pickupGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += roadSpeed;
// Remove if off screen
if (self.y > 2732 + 50) {
self.destroy();
for (var i = pickups.length - 1; i >= 0; i--) {
if (pickups[i] === self) {
pickups.splice(i, 1);
break;
}
}
}
// Check collision with car
if (self.intersects(car)) {
self.collect();
}
};
self.collect = function () {
LK.getSound('collect').play();
if (self.pickupType === 'scrap') {
scrapCount++;
car.speed += 0.1;
// Heal the car when collecting scrap
car.health = Math.min(car.maxHealth, car.health + 15);
// Increase damage when collecting scrap
car.damage += 2;
} else if (self.pickupType === 'armor') {
armorCount++;
car.armor += 2;
} else if (self.pickupType === 'weapon') {
weaponCount++;
car.damage += 3;
car.fireRate = Math.max(10, car.fireRate - 1);
}
updateUpgradeDisplay();
self.destroy();
for (var i = pickups.length - 1; i >= 0; i--) {
if (pickups[i] === self) {
pickups.splice(i, 1);
break;
}
}
};
return self;
});
var Zombie = Container.expand(function (type) {
var self = Container.call(this);
self.zombieType = type || 'normal';
var assetName = 'zombie';
if (self.zombieType === 'fast') {
assetName = 'fastZombie';
self.speed = 6;
self.health = 15;
self.damage = 15;
} else if (self.zombieType === 'tank') {
assetName = 'tankZombie';
self.speed = 3;
self.health = 50;
self.damage = 30;
} else {
self.speed = 4;
self.health = 20;
self.damage = 20;
}
var zombieGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.maxHealth = self.health;
self.update = function () {
// Move downward from the front
self.y += self.speed + roadSpeed;
// Remove if off screen
if (self.y > 2732 + 50) {
self.destroy();
for (var i = zombies.length - 1; i >= 0; i--) {
if (zombies[i] === self) {
zombies.splice(i, 1);
break;
}
}
}
// Check collision with car
if (self.intersects(car)) {
car.takeDamage(self.damage);
self.destroy();
for (var i = zombies.length - 1; i >= 0; i--) {
if (zombies[i] === self) {
zombies.splice(i, 1);
break;
}
}
}
};
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff0000, 200);
if (self.health <= 0) {
LK.setScore(LK.getScore() + 10);
self.destroy();
for (var i = zombies.length - 1; i >= 0; i--) {
if (zombies[i] === self) {
zombies.splice(i, 1);
break;
}
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a5a1a
});
/****
* Game Code
****/
// Game variables
var car;
var zombies = [];
var bosses = []; // Separate array for boss zombies
var bullets = [];
var pickups = [];
var obstacles = [];
var roadSegments = [];
var roadLines = [];
var roadSpeed = 8;
var spawnTimer = 0;
var pickupTimer = 0;
var obstacleTimer = 0;
var difficultyTimer = 0;
var scrapCount = 0;
var armorCount = 0;
var weaponCount = 0;
var dragActive = false;
var lastBossScore = 0;
// Create road background
for (var i = 0; i < 10; i++) {
var roadSegment = LK.getAsset('road', {
anchorX: 0.5,
anchorY: 0
});
roadSegment.x = 1024;
roadSegment.y = i * 400 - 400;
roadSegments.push(roadSegment);
game.addChild(roadSegment);
}
// Create road lines
for (var i = 0; i < 30; i++) {
var roadLine = LK.getAsset('roadLine', {
anchorX: 0.5,
anchorY: 0
});
roadLine.x = 1024;
roadLine.y = i * 150 - 300;
roadLines.push(roadLine);
game.addChild(roadLine);
}
// Create car
car = game.addChild(new Car());
car.x = 1024;
car.y = 2200;
// UI Elements
var healthBar = new Text2('Health: 100', {
size: 60,
fill: 0xFF4444
});
healthBar.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthBar);
healthBar.x = 120;
healthBar.y = 20;
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var upgradeText = new Text2('Scrap:0 Armor:0 Weapons:0', {
size: 50,
fill: 0x00FF00
});
upgradeText.anchor.set(1, 0);
LK.gui.topRight.addChild(upgradeText);
upgradeText.x = -20;
upgradeText.y = 20;
function updateUpgradeDisplay() {
upgradeText.setText('Scrap:' + scrapCount + ' Armor:' + armorCount + ' Weapons:' + weaponCount);
}
function spawnZombie() {
var zombieType = 'normal';
var rand = Math.random();
if (LK.ticks > 1800) {
// After 30 seconds
if (rand < 0.2) zombieType = 'fast';else if (rand < 0.35) zombieType = 'tank';
}
var zombie = new Zombie(zombieType);
zombie.x = Math.random() * 1800 + 124;
zombie.y = -50;
zombies.push(zombie);
game.addChild(zombie);
}
function spawnPickup() {
var pickupTypes = ['scrap', 'armor', 'weapon'];
var pickupType = pickupTypes[Math.floor(Math.random() * pickupTypes.length)];
var pickup = new Pickup(pickupType);
pickup.x = Math.random() * 1800 + 124;
pickup.y = -50;
pickups.push(pickup);
game.addChild(pickup);
}
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = Math.random() * 1800 + 124;
obstacle.y = -50;
obstacles.push(obstacle);
game.addChild(obstacle);
}
function spawnBoss() {
var boss = new Boss();
boss.x = 1024; // Center of screen
boss.y = -100;
bosses.push(boss); // Add to separate bosses array
game.addChild(boss);
LK.effects.flashScreen(0xFF0000, 500); // Red screen flash when boss spawns
}
// Touch controls
game.down = function (x, y, obj) {
dragActive = true;
};
game.move = function (x, y, obj) {
if (dragActive) {
car.x = Math.max(124, Math.min(1924, x));
}
};
game.up = function (x, y, obj) {
dragActive = false;
};
game.update = function () {
// Update road movement
for (var i = 0; i < roadSegments.length; i++) {
roadSegments[i].y += roadSpeed;
if (roadSegments[i].y > 2732) {
roadSegments[i].y -= 4000;
}
}
for (var i = 0; i < roadLines.length; i++) {
roadLines[i].y += roadSpeed;
if (roadLines[i].y > 2732) {
roadLines[i].y -= 4500;
}
}
// Spawn zombies
spawnTimer++;
var spawnRate = Math.max(30, 120 - Math.floor(LK.ticks / 600) * 10);
if (spawnTimer >= spawnRate) {
spawnZombie();
spawnTimer = 0;
}
// Spawn pickups
pickupTimer++;
if (pickupTimer >= 180) {
spawnPickup();
pickupTimer = 0;
}
// Spawn obstacles
obstacleTimer++;
if (obstacleTimer >= 240) {
spawnObstacle();
obstacleTimer = 0;
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer >= 600) {
// Every 10 seconds
roadSpeed += 0.2;
difficultyTimer = 0;
}
// Update score based on survival time
if (LK.ticks % 60 === 0) {
LK.setScore(LK.getScore() + 1);
}
// Spawn boss every 100 points
var currentScore = LK.getScore();
if (currentScore >= lastBossScore + 100 && currentScore > 0) {
spawnBoss();
lastBossScore = Math.floor(currentScore / 100) * 100;
}
// Update UI
healthBar.setText('Health: ' + Math.max(0, car.health));
scoreText.setText('Score: ' + LK.getScore());
};
// Start background music
LK.playMusic('bgmusic');
ZOMBIE. In-Game asset. 2d. High contrast. No shadows
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Zombie Highway Survivor" and with the description "Drive through zombie-filled highways, collect upgrades, and customize your car to survive as long as possible in this intense top-down survival game.". No text on banner!
MACHINE ZOMBIE. In-Game asset. 2d. High contrast. No shadows
BARIR EXPLOSIVO. In-Game asset. 2d. High contrast. No shadows
CHATARRA. In-Game asset. 2d. High contrast. No shadows
AK47. In-Game asset. 2d. High contrast. No shadows
LLAVE INGLESA. In-Game asset. 2d. High contrast. No shadows
RAYA BLANCA DESPINTADA. In-Game asset. 2d. High contrast. No shadows. RAYA BLANCA DESPINTADA
balas. In-Game asset. 2d. High contrast. No shadows