/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ArmedZombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('armedZombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4.0; // Faster than regular zombies
self.health = 3; // Takes 3 hits to kill
self.lastPlayerDistance = Infinity;
self.update = function () {
// Calculate direction to player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize direction and apply speed
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Check for near miss (was far, now close)
if (self.lastPlayerDistance > 150 && distance <= 150) {
LK.setScore(LK.getScore() + 15); // More points for armed zombies
LK.getSound('nearMiss').play();
updateScoreDisplay();
}
self.lastPlayerDistance = distance;
};
return self;
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.rotation = 0;
self.update = function () {
self.y += self.speed;
};
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 = 12;
self.directionX = 0;
self.directionY = 0;
self.update = function () {
self.x += self.directionX * self.speed;
self.y += self.directionY * self.speed;
};
return self;
});
var SuperZombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('superZombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5.5; // Fastest zombie
self.health = 5; // Takes 5 hits to kill
self.lastPlayerDistance = Infinity;
self.update = function () {
// Calculate direction to player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize direction and apply speed
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Check for near miss (was far, now close)
if (self.lastPlayerDistance > 150 && distance <= 150) {
LK.setScore(LK.getScore() + 20); // More points for super zombies
LK.getSound('nearMiss').play();
updateScoreDisplay();
}
self.lastPlayerDistance = distance;
};
return self;
});
var Zombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('zombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2.5;
self.lastPlayerDistance = Infinity;
self.update = function () {
// Calculate direction to player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize direction and apply speed
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Check for near miss (was far, now close)
if (self.lastPlayerDistance > 150 && distance <= 150) {
LK.setScore(LK.getScore() + 10);
LK.getSound('nearMiss').play();
updateScoreDisplay();
}
self.lastPlayerDistance = distance;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F2F2F
});
/****
* Game Code
****/
var player;
var zombies = [];
var armedZombies = [];
var superZombies = [];
var bullets = [];
var bombs = [];
var lastBombSpawn = 0;
var bombSpawnRate = 2000; // milliseconds between bomb spawns
var dragNode = null;
var gameStartTicks = 0;
var lastZombieSpawn = 0;
var zombieSpawnRate = 1200; // milliseconds - reduced for more zombies
var difficultyTimer = 0;
var lastShootTime = 0;
var shootCooldown = 300; // milliseconds between shots
var lastScoreBonus = 0; // Track last tick bonus was given
// Create score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create survival time display
var timeTxt = new Text2('Time: 0s', {
size: 60,
fill: 0xFFFFFF
});
timeTxt.anchor.set(0, 0);
timeTxt.x = 120;
timeTxt.y = 120;
LK.gui.topLeft.addChild(timeTxt);
// Create grass background covering entire map
var grassTileSize = 100;
var tilesX = Math.ceil(2048 / grassTileSize);
var tilesY = Math.ceil(2732 / grassTileSize);
for (var x = 0; x < tilesX; x++) {
for (var y = 0; y < tilesY; y++) {
var grassTile = LK.getAsset('grass', {
anchorX: 0,
anchorY: 0
});
grassTile.x = x * grassTileSize;
grassTile.y = y * grassTileSize;
game.addChild(grassTile);
}
}
// Create player
player = game.addChild(new Container());
var playerGraphics = player.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Position player at center
player.x = 2048 / 2;
player.y = 2732 / 2;
function updateScoreDisplay() {
scoreTxt.setText('Score: ' + LK.getScore());
}
function shootAtNearestZombie() {
if (zombies.length === 0 && armedZombies.length === 0 && superZombies.length === 0) return;
var nearestZombie = null;
var nearestDistance = Infinity;
var zombieType = 'regular';
// Find nearest regular zombie
for (var i = 0; i < zombies.length; i++) {
var dx = zombies[i].x - player.x;
var dy = zombies[i].y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearestDistance = distance;
nearestZombie = zombies[i];
zombieType = 'regular';
}
}
// Find nearest armed zombie
for (var i = 0; i < armedZombies.length; i++) {
var dx = armedZombies[i].x - player.x;
var dy = armedZombies[i].y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearestDistance = distance;
nearestZombie = armedZombies[i];
zombieType = 'armed';
}
}
// Find nearest super zombie
for (var i = 0; i < superZombies.length; i++) {
var dx = superZombies[i].x - player.x;
var dy = superZombies[i].y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearestDistance = distance;
nearestZombie = superZombies[i];
zombieType = 'super';
}
}
if (nearestZombie) {
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
bullet.targetType = zombieType;
// Calculate direction to nearest zombie
var dx = nearestZombie.x - player.x;
var dy = nearestZombie.y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
bullet.directionX = dx / distance;
bullet.directionY = dy / distance;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
}
function spawnZombie() {
var zombie = new Zombie();
// Spawn zombie at random edge of screen
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
zombie.x = Math.random() * 2048;
zombie.y = -50;
break;
case 1:
// Right
zombie.x = 2048 + 50;
zombie.y = Math.random() * 2732;
break;
case 2:
// Bottom
zombie.x = Math.random() * 2048;
zombie.y = 2732 + 50;
break;
case 3:
// Left
zombie.x = -50;
zombie.y = Math.random() * 2732;
break;
}
zombies.push(zombie);
game.addChild(zombie);
}
function spawnArmedZombie() {
var armedZombie = new ArmedZombie();
// Spawn armed zombie at random edge of screen
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
armedZombie.x = Math.random() * 2048;
armedZombie.y = -50;
break;
case 1:
// Right
armedZombie.x = 2048 + 50;
armedZombie.y = Math.random() * 2732;
break;
case 2:
// Bottom
armedZombie.x = Math.random() * 2048;
armedZombie.y = 2732 + 50;
break;
case 3:
// Left
armedZombie.x = -50;
armedZombie.y = Math.random() * 2732;
break;
}
armedZombies.push(armedZombie);
game.addChild(armedZombie);
}
function handleMove(x, y, obj) {
// Make character follow mouse/touch position with smoothing for slower movement
var targetX = Math.max(40, Math.min(2048 - 40, x));
var targetY = Math.max(40, Math.min(2732 - 40, y));
// Apply smoothing factor to slow down character movement
var smoothingFactor = 0.05; // Lower value = slower movement
player.x += (targetX - player.x) * smoothingFactor;
player.y += (targetY - player.y) * smoothingFactor;
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Character automatically follows mouse, no need to set dragNode
handleMove(x, y, obj);
// Manual shooting when tapping
var currentTime = Date.now();
if (currentTime - lastShootTime > shootCooldown && (zombies.length > 0 || armedZombies.length > 0 || superZombies.length > 0)) {
shootAtNearestZombie();
lastShootTime = currentTime;
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
game.update = function () {
var currentTime = Date.now();
// Initialize game start ticks on first update
if (gameStartTicks === 0) {
gameStartTicks = LK.ticks;
}
// Calculate survival time using game ticks (60 FPS)
var survivalTime = Math.floor((LK.ticks - gameStartTicks) / 60);
// Update survival time display
timeTxt.setText('Time: ' + survivalTime + 's');
// Give 20 points every 20 seconds (1200 ticks at 60 FPS)
if (LK.ticks - lastScoreBonus >= 1200) {
// 20 seconds in ticks
LK.setScore(LK.getScore() + 20);
updateScoreDisplay();
lastScoreBonus = LK.ticks;
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer % 1800 == 0) {
// Every 30 seconds (1800 frames)
zombieSpawnRate = Math.max(300, zombieSpawnRate - 150);
// Increase zombie speed
for (var i = 0; i < zombies.length; i++) {
zombies[i].speed += 0.5;
}
// Increase armed zombie speed
for (var i = 0; i < armedZombies.length; i++) {
armedZombies[i].speed += 0.5;
}
// Increase super zombie speed
for (var i = 0; i < superZombies.length; i++) {
superZombies[i].speed += 0.5;
}
}
// Spawn zombies
if (currentTime - lastZombieSpawn > zombieSpawnRate) {
if (LK.getScore() >= 500 && Math.random() < 0.3) {
// 30% chance to spawn super zombie after score 500
spawnSuperZombie();
} else if (LK.getScore() >= 250 && Math.random() < 0.6) {
// 60% chance to spawn armed zombie after score 250
spawnArmedZombie();
} else {
spawnZombie();
}
lastZombieSpawn = currentTime;
}
// Check collisions and update zombies
for (var i = zombies.length - 1; i >= 0; i--) {
var zombie = zombies[i];
// Check if zombie caught player
if (zombie.intersects(player)) {
LK.getSound('zombieHit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove zombies that are too far off screen
var distanceFromCenter = Math.sqrt(Math.pow(zombie.x - 1024, 2) + Math.pow(zombie.y - 1366, 2));
if (distanceFromCenter > 3000) {
zombie.destroy();
zombies.splice(i, 1);
}
}
// Check collisions and update armed zombies
for (var i = armedZombies.length - 1; i >= 0; i--) {
var armedZombie = armedZombies[i];
// Check if armed zombie caught player
if (armedZombie.intersects(player)) {
LK.getSound('zombieHit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove armed zombies that are too far off screen
var distanceFromCenter = Math.sqrt(Math.pow(armedZombie.x - 1024, 2) + Math.pow(armedZombie.y - 1366, 2));
if (distanceFromCenter > 3000) {
armedZombie.destroy();
armedZombies.splice(i, 1);
}
}
// Check collisions and update super zombies
for (var i = superZombies.length - 1; i >= 0; i--) {
var superZombie = superZombies[i];
// Check if super zombie caught player
if (superZombie.intersects(player)) {
LK.getSound('zombieHit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove super zombies that are too far off screen
var distanceFromCenter = Math.sqrt(Math.pow(superZombie.x - 1024, 2) + Math.pow(superZombie.y - 1366, 2));
if (distanceFromCenter > 3000) {
superZombie.destroy();
superZombies.splice(i, 1);
}
}
// Update bullets and check collisions
for (var j = bullets.length - 1; j >= 0; j--) {
var bullet = bullets[j];
// Check if bullet hit any zombie
var bulletHit = false;
for (var k = zombies.length - 1; k >= 0; k--) {
var zombie = zombies[k];
if (bullet.intersects(zombie)) {
// Zombie killed
LK.setScore(LK.getScore() + 5);
updateScoreDisplay();
zombie.destroy();
zombies.splice(k, 1);
bullet.destroy();
bullets.splice(j, 1);
bulletHit = true;
break;
}
}
// Check if bullet hit any armed zombie
if (!bulletHit) {
for (var k = armedZombies.length - 1; k >= 0; k--) {
var armedZombie = armedZombies[k];
if (bullet.intersects(armedZombie)) {
// Reduce armed zombie health
armedZombie.health--;
if (armedZombie.health <= 0) {
// Armed zombie killed
LK.setScore(LK.getScore() + 10);
updateScoreDisplay();
armedZombie.destroy();
armedZombies.splice(k, 1);
} else {
// Flash red to show damage
LK.effects.flashObject(armedZombie, 0xff0000, 200);
}
bullet.destroy();
bullets.splice(j, 1);
bulletHit = true;
break;
}
}
}
// Check if bullet hit any super zombie
if (!bulletHit) {
for (var k = superZombies.length - 1; k >= 0; k--) {
var superZombie = superZombies[k];
if (bullet.intersects(superZombie)) {
// Reduce super zombie health
superZombie.health--;
if (superZombie.health <= 0) {
// Super zombie killed
LK.setScore(LK.getScore() + 15);
updateScoreDisplay();
superZombie.destroy();
superZombies.splice(k, 1);
} else {
// Flash red to show damage
LK.effects.flashObject(superZombie, 0xff0000, 200);
}
bullet.destroy();
bullets.splice(j, 1);
bulletHit = true;
break;
}
}
}
// Remove bullet if it went off screen
if (!bulletHit && (bullet.x < -100 || bullet.x > 2148 || bullet.y < -100 || bullet.y > 2832)) {
bullet.destroy();
bullets.splice(j, 1);
}
}
// Spawn bombs when score reaches 150
if (LK.getScore() >= 150 && currentTime - lastBombSpawn > bombSpawnRate) {
var bomb = new Bomb();
bomb.x = Math.random() * 1800 + 124; // Random X within screen bounds
bomb.y = -100; // Start above screen
bombs.push(bomb);
game.addChild(bomb);
lastBombSpawn = currentTime;
}
// Update bombs and check collisions
for (var b = bombs.length - 1; b >= 0; b--) {
var bomb = bombs[b];
// Check if bomb hit player
if (bomb.intersects(player)) {
LK.getSound('bombExplosion').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove bomb if it went off screen
if (bomb.y > 2832) {
bomb.destroy();
bombs.splice(b, 1);
}
}
// Play background music
LK.playMusic('telifsiz');
// Spawn initial zombie
if (LK.ticks == 120) {
// 2 seconds after game start
spawnZombie();
lastZombieSpawn = currentTime;
}
};
function spawnSuperZombie() {
var superZombie = new SuperZombie();
// Spawn super zombie at random edge of screen
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
superZombie.x = Math.random() * 2048;
superZombie.y = -50;
break;
case 1:
// Right
superZombie.x = 2048 + 50;
superZombie.y = Math.random() * 2732;
break;
case 2:
// Bottom
superZombie.x = Math.random() * 2048;
superZombie.y = 2732 + 50;
break;
case 3:
// Left
superZombie.x = -50;
superZombie.y = Math.random() * 2732;
break;
}
superZombies.push(superZombie);
game.addChild(superZombie);
} /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ArmedZombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('armedZombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4.0; // Faster than regular zombies
self.health = 3; // Takes 3 hits to kill
self.lastPlayerDistance = Infinity;
self.update = function () {
// Calculate direction to player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize direction and apply speed
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Check for near miss (was far, now close)
if (self.lastPlayerDistance > 150 && distance <= 150) {
LK.setScore(LK.getScore() + 15); // More points for armed zombies
LK.getSound('nearMiss').play();
updateScoreDisplay();
}
self.lastPlayerDistance = distance;
};
return self;
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.rotation = 0;
self.update = function () {
self.y += self.speed;
};
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 = 12;
self.directionX = 0;
self.directionY = 0;
self.update = function () {
self.x += self.directionX * self.speed;
self.y += self.directionY * self.speed;
};
return self;
});
var SuperZombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('superZombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5.5; // Fastest zombie
self.health = 5; // Takes 5 hits to kill
self.lastPlayerDistance = Infinity;
self.update = function () {
// Calculate direction to player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize direction and apply speed
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Check for near miss (was far, now close)
if (self.lastPlayerDistance > 150 && distance <= 150) {
LK.setScore(LK.getScore() + 20); // More points for super zombies
LK.getSound('nearMiss').play();
updateScoreDisplay();
}
self.lastPlayerDistance = distance;
};
return self;
});
var Zombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('zombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2.5;
self.lastPlayerDistance = Infinity;
self.update = function () {
// Calculate direction to player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize direction and apply speed
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Check for near miss (was far, now close)
if (self.lastPlayerDistance > 150 && distance <= 150) {
LK.setScore(LK.getScore() + 10);
LK.getSound('nearMiss').play();
updateScoreDisplay();
}
self.lastPlayerDistance = distance;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F2F2F
});
/****
* Game Code
****/
var player;
var zombies = [];
var armedZombies = [];
var superZombies = [];
var bullets = [];
var bombs = [];
var lastBombSpawn = 0;
var bombSpawnRate = 2000; // milliseconds between bomb spawns
var dragNode = null;
var gameStartTicks = 0;
var lastZombieSpawn = 0;
var zombieSpawnRate = 1200; // milliseconds - reduced for more zombies
var difficultyTimer = 0;
var lastShootTime = 0;
var shootCooldown = 300; // milliseconds between shots
var lastScoreBonus = 0; // Track last tick bonus was given
// Create score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create survival time display
var timeTxt = new Text2('Time: 0s', {
size: 60,
fill: 0xFFFFFF
});
timeTxt.anchor.set(0, 0);
timeTxt.x = 120;
timeTxt.y = 120;
LK.gui.topLeft.addChild(timeTxt);
// Create grass background covering entire map
var grassTileSize = 100;
var tilesX = Math.ceil(2048 / grassTileSize);
var tilesY = Math.ceil(2732 / grassTileSize);
for (var x = 0; x < tilesX; x++) {
for (var y = 0; y < tilesY; y++) {
var grassTile = LK.getAsset('grass', {
anchorX: 0,
anchorY: 0
});
grassTile.x = x * grassTileSize;
grassTile.y = y * grassTileSize;
game.addChild(grassTile);
}
}
// Create player
player = game.addChild(new Container());
var playerGraphics = player.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Position player at center
player.x = 2048 / 2;
player.y = 2732 / 2;
function updateScoreDisplay() {
scoreTxt.setText('Score: ' + LK.getScore());
}
function shootAtNearestZombie() {
if (zombies.length === 0 && armedZombies.length === 0 && superZombies.length === 0) return;
var nearestZombie = null;
var nearestDistance = Infinity;
var zombieType = 'regular';
// Find nearest regular zombie
for (var i = 0; i < zombies.length; i++) {
var dx = zombies[i].x - player.x;
var dy = zombies[i].y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearestDistance = distance;
nearestZombie = zombies[i];
zombieType = 'regular';
}
}
// Find nearest armed zombie
for (var i = 0; i < armedZombies.length; i++) {
var dx = armedZombies[i].x - player.x;
var dy = armedZombies[i].y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearestDistance = distance;
nearestZombie = armedZombies[i];
zombieType = 'armed';
}
}
// Find nearest super zombie
for (var i = 0; i < superZombies.length; i++) {
var dx = superZombies[i].x - player.x;
var dy = superZombies[i].y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < nearestDistance) {
nearestDistance = distance;
nearestZombie = superZombies[i];
zombieType = 'super';
}
}
if (nearestZombie) {
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
bullet.targetType = zombieType;
// Calculate direction to nearest zombie
var dx = nearestZombie.x - player.x;
var dy = nearestZombie.y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
bullet.directionX = dx / distance;
bullet.directionY = dy / distance;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
}
function spawnZombie() {
var zombie = new Zombie();
// Spawn zombie at random edge of screen
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
zombie.x = Math.random() * 2048;
zombie.y = -50;
break;
case 1:
// Right
zombie.x = 2048 + 50;
zombie.y = Math.random() * 2732;
break;
case 2:
// Bottom
zombie.x = Math.random() * 2048;
zombie.y = 2732 + 50;
break;
case 3:
// Left
zombie.x = -50;
zombie.y = Math.random() * 2732;
break;
}
zombies.push(zombie);
game.addChild(zombie);
}
function spawnArmedZombie() {
var armedZombie = new ArmedZombie();
// Spawn armed zombie at random edge of screen
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
armedZombie.x = Math.random() * 2048;
armedZombie.y = -50;
break;
case 1:
// Right
armedZombie.x = 2048 + 50;
armedZombie.y = Math.random() * 2732;
break;
case 2:
// Bottom
armedZombie.x = Math.random() * 2048;
armedZombie.y = 2732 + 50;
break;
case 3:
// Left
armedZombie.x = -50;
armedZombie.y = Math.random() * 2732;
break;
}
armedZombies.push(armedZombie);
game.addChild(armedZombie);
}
function handleMove(x, y, obj) {
// Make character follow mouse/touch position with smoothing for slower movement
var targetX = Math.max(40, Math.min(2048 - 40, x));
var targetY = Math.max(40, Math.min(2732 - 40, y));
// Apply smoothing factor to slow down character movement
var smoothingFactor = 0.05; // Lower value = slower movement
player.x += (targetX - player.x) * smoothingFactor;
player.y += (targetY - player.y) * smoothingFactor;
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Character automatically follows mouse, no need to set dragNode
handleMove(x, y, obj);
// Manual shooting when tapping
var currentTime = Date.now();
if (currentTime - lastShootTime > shootCooldown && (zombies.length > 0 || armedZombies.length > 0 || superZombies.length > 0)) {
shootAtNearestZombie();
lastShootTime = currentTime;
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
game.update = function () {
var currentTime = Date.now();
// Initialize game start ticks on first update
if (gameStartTicks === 0) {
gameStartTicks = LK.ticks;
}
// Calculate survival time using game ticks (60 FPS)
var survivalTime = Math.floor((LK.ticks - gameStartTicks) / 60);
// Update survival time display
timeTxt.setText('Time: ' + survivalTime + 's');
// Give 20 points every 20 seconds (1200 ticks at 60 FPS)
if (LK.ticks - lastScoreBonus >= 1200) {
// 20 seconds in ticks
LK.setScore(LK.getScore() + 20);
updateScoreDisplay();
lastScoreBonus = LK.ticks;
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer % 1800 == 0) {
// Every 30 seconds (1800 frames)
zombieSpawnRate = Math.max(300, zombieSpawnRate - 150);
// Increase zombie speed
for (var i = 0; i < zombies.length; i++) {
zombies[i].speed += 0.5;
}
// Increase armed zombie speed
for (var i = 0; i < armedZombies.length; i++) {
armedZombies[i].speed += 0.5;
}
// Increase super zombie speed
for (var i = 0; i < superZombies.length; i++) {
superZombies[i].speed += 0.5;
}
}
// Spawn zombies
if (currentTime - lastZombieSpawn > zombieSpawnRate) {
if (LK.getScore() >= 500 && Math.random() < 0.3) {
// 30% chance to spawn super zombie after score 500
spawnSuperZombie();
} else if (LK.getScore() >= 250 && Math.random() < 0.6) {
// 60% chance to spawn armed zombie after score 250
spawnArmedZombie();
} else {
spawnZombie();
}
lastZombieSpawn = currentTime;
}
// Check collisions and update zombies
for (var i = zombies.length - 1; i >= 0; i--) {
var zombie = zombies[i];
// Check if zombie caught player
if (zombie.intersects(player)) {
LK.getSound('zombieHit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove zombies that are too far off screen
var distanceFromCenter = Math.sqrt(Math.pow(zombie.x - 1024, 2) + Math.pow(zombie.y - 1366, 2));
if (distanceFromCenter > 3000) {
zombie.destroy();
zombies.splice(i, 1);
}
}
// Check collisions and update armed zombies
for (var i = armedZombies.length - 1; i >= 0; i--) {
var armedZombie = armedZombies[i];
// Check if armed zombie caught player
if (armedZombie.intersects(player)) {
LK.getSound('zombieHit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove armed zombies that are too far off screen
var distanceFromCenter = Math.sqrt(Math.pow(armedZombie.x - 1024, 2) + Math.pow(armedZombie.y - 1366, 2));
if (distanceFromCenter > 3000) {
armedZombie.destroy();
armedZombies.splice(i, 1);
}
}
// Check collisions and update super zombies
for (var i = superZombies.length - 1; i >= 0; i--) {
var superZombie = superZombies[i];
// Check if super zombie caught player
if (superZombie.intersects(player)) {
LK.getSound('zombieHit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove super zombies that are too far off screen
var distanceFromCenter = Math.sqrt(Math.pow(superZombie.x - 1024, 2) + Math.pow(superZombie.y - 1366, 2));
if (distanceFromCenter > 3000) {
superZombie.destroy();
superZombies.splice(i, 1);
}
}
// Update bullets and check collisions
for (var j = bullets.length - 1; j >= 0; j--) {
var bullet = bullets[j];
// Check if bullet hit any zombie
var bulletHit = false;
for (var k = zombies.length - 1; k >= 0; k--) {
var zombie = zombies[k];
if (bullet.intersects(zombie)) {
// Zombie killed
LK.setScore(LK.getScore() + 5);
updateScoreDisplay();
zombie.destroy();
zombies.splice(k, 1);
bullet.destroy();
bullets.splice(j, 1);
bulletHit = true;
break;
}
}
// Check if bullet hit any armed zombie
if (!bulletHit) {
for (var k = armedZombies.length - 1; k >= 0; k--) {
var armedZombie = armedZombies[k];
if (bullet.intersects(armedZombie)) {
// Reduce armed zombie health
armedZombie.health--;
if (armedZombie.health <= 0) {
// Armed zombie killed
LK.setScore(LK.getScore() + 10);
updateScoreDisplay();
armedZombie.destroy();
armedZombies.splice(k, 1);
} else {
// Flash red to show damage
LK.effects.flashObject(armedZombie, 0xff0000, 200);
}
bullet.destroy();
bullets.splice(j, 1);
bulletHit = true;
break;
}
}
}
// Check if bullet hit any super zombie
if (!bulletHit) {
for (var k = superZombies.length - 1; k >= 0; k--) {
var superZombie = superZombies[k];
if (bullet.intersects(superZombie)) {
// Reduce super zombie health
superZombie.health--;
if (superZombie.health <= 0) {
// Super zombie killed
LK.setScore(LK.getScore() + 15);
updateScoreDisplay();
superZombie.destroy();
superZombies.splice(k, 1);
} else {
// Flash red to show damage
LK.effects.flashObject(superZombie, 0xff0000, 200);
}
bullet.destroy();
bullets.splice(j, 1);
bulletHit = true;
break;
}
}
}
// Remove bullet if it went off screen
if (!bulletHit && (bullet.x < -100 || bullet.x > 2148 || bullet.y < -100 || bullet.y > 2832)) {
bullet.destroy();
bullets.splice(j, 1);
}
}
// Spawn bombs when score reaches 150
if (LK.getScore() >= 150 && currentTime - lastBombSpawn > bombSpawnRate) {
var bomb = new Bomb();
bomb.x = Math.random() * 1800 + 124; // Random X within screen bounds
bomb.y = -100; // Start above screen
bombs.push(bomb);
game.addChild(bomb);
lastBombSpawn = currentTime;
}
// Update bombs and check collisions
for (var b = bombs.length - 1; b >= 0; b--) {
var bomb = bombs[b];
// Check if bomb hit player
if (bomb.intersects(player)) {
LK.getSound('bombExplosion').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Remove bomb if it went off screen
if (bomb.y > 2832) {
bomb.destroy();
bombs.splice(b, 1);
}
}
// Play background music
LK.playMusic('telifsiz');
// Spawn initial zombie
if (LK.ticks == 120) {
// 2 seconds after game start
spawnZombie();
lastZombieSpawn = currentTime;
}
};
function spawnSuperZombie() {
var superZombie = new SuperZombie();
// Spawn super zombie at random edge of screen
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
superZombie.x = Math.random() * 2048;
superZombie.y = -50;
break;
case 1:
// Right
superZombie.x = 2048 + 50;
superZombie.y = Math.random() * 2732;
break;
case 2:
// Bottom
superZombie.x = Math.random() * 2048;
superZombie.y = 2732 + 50;
break;
case 3:
// Left
superZombie.x = -50;
superZombie.y = Math.random() * 2732;
break;
}
superZombies.push(superZombie);
game.addChild(superZombie);
}
bir adam elinde silah olsun ve asker gibi giyinsin. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
bu bir mermi . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
bu bir zombi ağızında salyalar olsun ve üstü başı dağınık olsun kirli olsun ve boydan olsun . In-Game asset. 2d. High contrast. No shadows
bana büyük bir zombi yap ama yine ağızında salyalar olsun dağınık olsun ve güçlü dursun. In-Game asset. 2d. High contrast. No shadows
bana füze çiz ucu aşağı baksın. In-Game asset. 2d. High contrast. No shadows