/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.directionX = 0;
self.directionY = 0;
self.isDestroyed = false;
self.update = function () {
if (self.isDestroyed) return;
self.x += self.directionX * self.speed;
self.y += self.directionY * self.speed;
// Remove if off screen
if (self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782) {
self.isDestroyed = true;
self.shouldRemove = true;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Add weapon visual
var weapon = self.attachAsset('gun', {
anchorX: 0.5,
anchorY: 1,
scaleX: 1,
scaleY: 1,
y: -25
});
self.aimAtPoint = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var angle = Math.atan2(dy, dx) - Math.PI / 2;
weapon.rotation = angle;
};
return self;
});
var Zombie = Container.expand(function () {
var self = Container.call(this);
// Choose random zombie type
var zombieTypes = ['zombie1', 'zombie2', 'zombie3', 'zombie4'];
var zombieType = zombieTypes[Math.floor(Math.random() * zombieTypes.length)];
var zombieGraphics = self.attachAsset(zombieType, {
anchorX: 0.5,
anchorY: 0.5
});
// Varying speeds based on zombie type
var speedVariations = [1.5, 1.2, 1.8, 1.1];
var typeIndex = zombieTypes.indexOf(zombieType);
self.speed = speedVariations[typeIndex] + (Math.random() * 0.4 - 0.2); // Add small random variation
self.targetX = 1024;
self.targetY = 1366;
self.isDestroyed = false;
self.update = function () {
if (self.isDestroyed) return;
// Move toward center
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F4F4F
});
/****
* Game Code
****/
// Create bright blue sky
var sky = game.addChild(LK.getAsset('sky', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
tint: 0x87CEEB
}));
// Add sun
var sun = game.addChild(LK.getAsset('leaves', {
anchorX: 0.5,
anchorY: 0.5,
x: 1700,
y: 250,
scaleX: 1.5,
scaleY: 1.5,
tint: 0xFFD700
}));
// Add ground layer
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 1366,
tint: 0x8B4513
}));
// Add grass layer
var grass = game.addChild(LK.getAsset('grass', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 1166,
tint: 0x228B22
}));
// Add forest trees
var treePositions = [150, 350, 550, 750, 950, 1150, 1350, 1550, 1750, 1950];
for (var t = 0; t < treePositions.length; t++) {
var treeX = treePositions[t];
var treeHeight = 180 + Math.random() * 80;
var tree = game.addChild(LK.getAsset('tree', {
anchorX: 0.5,
anchorY: 1,
x: treeX,
y: 1366,
scaleX: 1.2 + Math.random() * 0.8,
scaleY: treeHeight / 200,
tint: 0x8B4513
}));
// Add green leaves to trees
var leaves = game.addChild(LK.getAsset('leaves', {
anchorX: 0.5,
anchorY: 0.5,
x: treeX,
y: 1366 - treeHeight + 60,
scaleX: 1.3 + Math.random() * 0.5,
scaleY: 1.3 + Math.random() * 0.5,
tint: 0x228B22
}));
}
// Game variables
var zombies = [];
var bullets = [];
var player;
var scoreTxt;
var highScoreTxt;
var bulletCountTxt;
var bulletCount = 3; // Start with 3 bullets
var highScore = storage.highScore || 0;
var zombieSpawnRate = 120; // Spawn every 2 seconds initially
var zombieSpeed = 1.5;
var lastZombieSpawn = 0;
var lastShot = 0;
var shootCooldown = 15; // 15 frames between shots (4 shots per second)
var lastSpeedIncrease = 0;
var speedIncreaseInterval = 60; // 1 second at 60fps
// Create player at center
player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
// Create score display
scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
// Create high score display
highScoreTxt = new Text2('Best Point: ' + highScore, {
size: 60,
fill: 0xFFD700
});
highScoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(highScoreTxt);
highScoreTxt.x = -120;
highScoreTxt.y = 50;
// Create bullet count display
bulletCountTxt = new Text2('Bullets: ' + bulletCount, {
size: 60,
fill: 0xFFFFFF
});
bulletCountTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(bulletCountTxt);
bulletCountTxt.x = 120;
bulletCountTxt.y = 50;
// Shooting function
function shootBullet(targetX, targetY) {
if (LK.ticks - lastShot < shootCooldown) return;
if (bulletCount <= 0) return; // Can't shoot if no bullets left
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
// Calculate direction
var dx = targetX - player.x;
var dy = targetY - 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('gunShot').play();
lastShot = LK.ticks;
bulletCount--; // Decrease bullet count
bulletCountTxt.setText('Bullets: ' + bulletCount); // Update display
}
// Touch/click controls
game.down = function (x, y, obj) {
player.aimAtPoint(x, y);
shootBullet(x, y);
};
function spawnZombie() {
var zombie = new Zombie();
// Spawn only from bottom of the map
zombie.x = Math.random() * 2048;
zombie.y = 2772;
zombie.speed = zombieSpeed;
zombies.push(zombie);
game.addChild(zombie);
LK.getSound('zombieSpawn').play();
}
function checkBulletCollisions() {
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.isDestroyed) continue;
for (var j = 0; j < zombies.length; j++) {
var zombie = zombies[j];
if (zombie.isDestroyed) continue;
var dx = bullet.x - zombie.x;
var dy = bullet.y - zombie.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 75) {
// Hit zombie
bullet.isDestroyed = true;
bullet.shouldRemove = true;
zombie.isDestroyed = true;
LK.getSound('zombieHit').play();
// Add random coin reward between 52-56
var coinReward = Math.floor(Math.random() * 5) + 52; // Random between 52-56
LK.setScore(LK.getScore() + coinReward);
scoreTxt.setText(LK.getScore());
// Add 1 bullet reward
bulletCount += 1;
bulletCountTxt.setText('Bullets: ' + bulletCount);
// Update high score if current score is higher
if (LK.getScore() > highScore) {
highScore = LK.getScore();
storage.highScore = highScore;
highScoreTxt.setText('Best Point: ' + highScore);
}
// Create explosion effect
var explosion = game.addChild(LK.getAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5,
x: zombie.x,
y: zombie.y,
scaleX: 0.1,
scaleY: 0.1
}));
// Animate explosion
tween(explosion, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
explosion.destroy();
}
});
// Mark zombie for removal
for (var k = 0; k < zombies.length; k++) {
if (zombies[k] === zombie) {
zombies[k].shouldRemove = true;
break;
}
}
break;
}
}
}
}
function checkGameOver() {
for (var i = 0; i < zombies.length; i++) {
var zombie = zombies[i];
if (zombie.isDestroyed) continue;
var dx = zombie.x - player.x;
var dy = zombie.y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 50) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
}
game.update = function () {
// Increase zombie speed every 1 second and spawn more zombies
if (LK.ticks - lastSpeedIncrease > speedIncreaseInterval) {
zombieSpeed += 0.1; // Increase speed by 0.1
// Decrease spawn rate to spawn zombies more frequently (lower value = more frequent spawning)
if (zombieSpawnRate > 30) {
// Don't go below 30 frames (0.5 seconds)
zombieSpawnRate -= 5; // Spawn zombies 5 frames sooner each time
}
// Update existing zombies' speed
for (var i = 0; i < zombies.length; i++) {
if (!zombies[i].isDestroyed) {
zombies[i].speed = zombieSpeed + (Math.random() * 0.4 - 0.2);
}
}
lastSpeedIncrease = LK.ticks;
}
// Spawn zombies
if (LK.ticks - lastZombieSpawn > zombieSpawnRate) {
spawnZombie();
lastZombieSpawn = LK.ticks;
}
// Clean up destroyed bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.shouldRemove) {
bullet.destroy();
bullets.splice(i, 1);
}
}
// Clean up destroyed zombies
for (var i = zombies.length - 1; i >= 0; i--) {
var zombie = zombies[i];
if (zombie.shouldRemove) {
zombie.destroy();
zombies.splice(i, 1);
}
}
// Check bullet collisions
checkBulletCollisions();
// Check for game over
checkGameOver();
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.directionX = 0;
self.directionY = 0;
self.isDestroyed = false;
self.update = function () {
if (self.isDestroyed) return;
self.x += self.directionX * self.speed;
self.y += self.directionY * self.speed;
// Remove if off screen
if (self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782) {
self.isDestroyed = true;
self.shouldRemove = true;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Add weapon visual
var weapon = self.attachAsset('gun', {
anchorX: 0.5,
anchorY: 1,
scaleX: 1,
scaleY: 1,
y: -25
});
self.aimAtPoint = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var angle = Math.atan2(dy, dx) - Math.PI / 2;
weapon.rotation = angle;
};
return self;
});
var Zombie = Container.expand(function () {
var self = Container.call(this);
// Choose random zombie type
var zombieTypes = ['zombie1', 'zombie2', 'zombie3', 'zombie4'];
var zombieType = zombieTypes[Math.floor(Math.random() * zombieTypes.length)];
var zombieGraphics = self.attachAsset(zombieType, {
anchorX: 0.5,
anchorY: 0.5
});
// Varying speeds based on zombie type
var speedVariations = [1.5, 1.2, 1.8, 1.1];
var typeIndex = zombieTypes.indexOf(zombieType);
self.speed = speedVariations[typeIndex] + (Math.random() * 0.4 - 0.2); // Add small random variation
self.targetX = 1024;
self.targetY = 1366;
self.isDestroyed = false;
self.update = function () {
if (self.isDestroyed) return;
// Move toward center
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F4F4F
});
/****
* Game Code
****/
// Create bright blue sky
var sky = game.addChild(LK.getAsset('sky', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
tint: 0x87CEEB
}));
// Add sun
var sun = game.addChild(LK.getAsset('leaves', {
anchorX: 0.5,
anchorY: 0.5,
x: 1700,
y: 250,
scaleX: 1.5,
scaleY: 1.5,
tint: 0xFFD700
}));
// Add ground layer
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 1366,
tint: 0x8B4513
}));
// Add grass layer
var grass = game.addChild(LK.getAsset('grass', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 1166,
tint: 0x228B22
}));
// Add forest trees
var treePositions = [150, 350, 550, 750, 950, 1150, 1350, 1550, 1750, 1950];
for (var t = 0; t < treePositions.length; t++) {
var treeX = treePositions[t];
var treeHeight = 180 + Math.random() * 80;
var tree = game.addChild(LK.getAsset('tree', {
anchorX: 0.5,
anchorY: 1,
x: treeX,
y: 1366,
scaleX: 1.2 + Math.random() * 0.8,
scaleY: treeHeight / 200,
tint: 0x8B4513
}));
// Add green leaves to trees
var leaves = game.addChild(LK.getAsset('leaves', {
anchorX: 0.5,
anchorY: 0.5,
x: treeX,
y: 1366 - treeHeight + 60,
scaleX: 1.3 + Math.random() * 0.5,
scaleY: 1.3 + Math.random() * 0.5,
tint: 0x228B22
}));
}
// Game variables
var zombies = [];
var bullets = [];
var player;
var scoreTxt;
var highScoreTxt;
var bulletCountTxt;
var bulletCount = 3; // Start with 3 bullets
var highScore = storage.highScore || 0;
var zombieSpawnRate = 120; // Spawn every 2 seconds initially
var zombieSpeed = 1.5;
var lastZombieSpawn = 0;
var lastShot = 0;
var shootCooldown = 15; // 15 frames between shots (4 shots per second)
var lastSpeedIncrease = 0;
var speedIncreaseInterval = 60; // 1 second at 60fps
// Create player at center
player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
// Create score display
scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
// Create high score display
highScoreTxt = new Text2('Best Point: ' + highScore, {
size: 60,
fill: 0xFFD700
});
highScoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(highScoreTxt);
highScoreTxt.x = -120;
highScoreTxt.y = 50;
// Create bullet count display
bulletCountTxt = new Text2('Bullets: ' + bulletCount, {
size: 60,
fill: 0xFFFFFF
});
bulletCountTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(bulletCountTxt);
bulletCountTxt.x = 120;
bulletCountTxt.y = 50;
// Shooting function
function shootBullet(targetX, targetY) {
if (LK.ticks - lastShot < shootCooldown) return;
if (bulletCount <= 0) return; // Can't shoot if no bullets left
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
// Calculate direction
var dx = targetX - player.x;
var dy = targetY - 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('gunShot').play();
lastShot = LK.ticks;
bulletCount--; // Decrease bullet count
bulletCountTxt.setText('Bullets: ' + bulletCount); // Update display
}
// Touch/click controls
game.down = function (x, y, obj) {
player.aimAtPoint(x, y);
shootBullet(x, y);
};
function spawnZombie() {
var zombie = new Zombie();
// Spawn only from bottom of the map
zombie.x = Math.random() * 2048;
zombie.y = 2772;
zombie.speed = zombieSpeed;
zombies.push(zombie);
game.addChild(zombie);
LK.getSound('zombieSpawn').play();
}
function checkBulletCollisions() {
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.isDestroyed) continue;
for (var j = 0; j < zombies.length; j++) {
var zombie = zombies[j];
if (zombie.isDestroyed) continue;
var dx = bullet.x - zombie.x;
var dy = bullet.y - zombie.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 75) {
// Hit zombie
bullet.isDestroyed = true;
bullet.shouldRemove = true;
zombie.isDestroyed = true;
LK.getSound('zombieHit').play();
// Add random coin reward between 52-56
var coinReward = Math.floor(Math.random() * 5) + 52; // Random between 52-56
LK.setScore(LK.getScore() + coinReward);
scoreTxt.setText(LK.getScore());
// Add 1 bullet reward
bulletCount += 1;
bulletCountTxt.setText('Bullets: ' + bulletCount);
// Update high score if current score is higher
if (LK.getScore() > highScore) {
highScore = LK.getScore();
storage.highScore = highScore;
highScoreTxt.setText('Best Point: ' + highScore);
}
// Create explosion effect
var explosion = game.addChild(LK.getAsset('explosion', {
anchorX: 0.5,
anchorY: 0.5,
x: zombie.x,
y: zombie.y,
scaleX: 0.1,
scaleY: 0.1
}));
// Animate explosion
tween(explosion, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
explosion.destroy();
}
});
// Mark zombie for removal
for (var k = 0; k < zombies.length; k++) {
if (zombies[k] === zombie) {
zombies[k].shouldRemove = true;
break;
}
}
break;
}
}
}
}
function checkGameOver() {
for (var i = 0; i < zombies.length; i++) {
var zombie = zombies[i];
if (zombie.isDestroyed) continue;
var dx = zombie.x - player.x;
var dy = zombie.y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 50) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
}
game.update = function () {
// Increase zombie speed every 1 second and spawn more zombies
if (LK.ticks - lastSpeedIncrease > speedIncreaseInterval) {
zombieSpeed += 0.1; // Increase speed by 0.1
// Decrease spawn rate to spawn zombies more frequently (lower value = more frequent spawning)
if (zombieSpawnRate > 30) {
// Don't go below 30 frames (0.5 seconds)
zombieSpawnRate -= 5; // Spawn zombies 5 frames sooner each time
}
// Update existing zombies' speed
for (var i = 0; i < zombies.length; i++) {
if (!zombies[i].isDestroyed) {
zombies[i].speed = zombieSpeed + (Math.random() * 0.4 - 0.2);
}
}
lastSpeedIncrease = LK.ticks;
}
// Spawn zombies
if (LK.ticks - lastZombieSpawn > zombieSpawnRate) {
spawnZombie();
lastZombieSpawn = LK.ticks;
}
// Clean up destroyed bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.shouldRemove) {
bullet.destroy();
bullets.splice(i, 1);
}
}
// Clean up destroyed zombies
for (var i = zombies.length - 1; i >= 0; i--) {
var zombie = zombies[i];
if (zombie.shouldRemove) {
zombie.destroy();
zombies.splice(i, 1);
}
}
// Check bullet collisions
checkBulletCollisions();
// Check for game over
checkGameOver();
};
9mm mermi . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
glock29 . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
zombi . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
zombi . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
zombi. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Bir adet bandanası olsun ve yüzünde savaş çizikleri olsun