/**** * Classes ****/ // Define a class for bullets 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.update = function () { self.y -= self.speed; }; }); // Assets will be automatically created and loaded by the LK engine based on their usage in the code. // Define a class for the player character var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.y += self.speed; }; }); // Define a class for zombies var Zombie = Container.expand(function () { var self = Container.call(this); var zombieGraphics = self.attachAsset('zombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.update = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Add background image var background = LK.getAsset('backgroundImage', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(background); // Create and display the kill count text var killCountText = new Text2('Kills: 0', { size: 100, fill: "#ffffff" }); killCountText.anchor.set(0.5, 0); LK.gui.top.addChild(killCountText); // Initialize player with speed boost var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 200; var speedBoostActive = false; var speedBoostDuration = 5000; // 5 seconds var speedBoostCooldown = 10000; // 10 seconds var lastSpeedBoostTime = 0; // Function to activate speed boost function activateSpeedBoost() { if (!speedBoostActive && LK.ticks - lastSpeedBoostTime > speedBoostCooldown) { speedBoostActive = true; player.speed *= 2; // Double the player's speed lastSpeedBoostTime = LK.ticks; LK.setTimeout(function () { player.speed /= 2; // Reset the player's speed speedBoostActive = false; }, speedBoostDuration); } } // Initialize kill count var killCount = 0; // Initialize leaderboard var leaderboard = new Text2('Leaderboard:\n1. Player1 - 100\n2. Player2 - 80\n3. Player3 - 60', { size: 80, fill: "#ffffff" }); leaderboard.anchor.set(0.5, 0); LK.gui.topRight.addChild(leaderboard); // Initialize arrays for zombies and bullets var zombies = []; var bullets = []; // Function to spawn a zombie function spawnZombie() { var zombie = new Zombie(); zombie.x = Math.random() * 2048; zombie.y = -50; zombies.push(zombie); game.addChild(zombie); } // Function to handle shooting function shootBullet() { var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; bullets.push(bullet); game.addChild(bullet); } // Game update logic game.update = function () { // Update player player.update(); // Update zombies for (var i = zombies.length - 1; i >= 0; i--) { zombies[i].update(); if (zombies[i].y > 2732) { // Flash screen red for 1 second to indicate game over LK.effects.flashScreen(0xff0000, 1000); // Show game over screen LK.showGameOver(); return; // Exit update loop } // Check for collision between player and zombies if (player.intersects(zombies[i])) { // Flash screen red for 1 second to indicate player death LK.effects.flashScreen(0xff0000, 1000); // Show game over screen LK.showGameOver(); return; // Exit update loop } } // Update bullets for (var j = bullets.length - 1; j >= 0; j--) { bullets[j].update(); if (bullets[j].y < 0) { bullets[j].destroy(); bullets.splice(j, 1); } } // Check for collisions between bullets and zombies for (var k = bullets.length - 1; k >= 0; k--) { for (var l = zombies.length - 1; l >= 0; l--) { if (bullets[k].intersects(zombies[l])) { bullets[k].destroy(); zombies[l].destroy(); bullets.splice(k, 1); zombies.splice(l, 1); killCount++; killCountText.setText('Kills: ' + killCount); break; } } } // Spawn zombies periodically if (LK.ticks % 60 === 0) { spawnZombie(); } }; // Handle player movement game.move = function (x, y, obj) { player.x = x; player.y = y; }; // Handle shooting game.down = function (x, y, obj) { shootBullet(); activateSpeedBoost(); };
/****
* Classes
****/
// Define a class for bullets
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.update = function () {
self.y -= self.speed;
};
});
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// Define a class for the player character
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
self.y += self.speed;
};
});
// Define a class for zombies
var Zombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('zombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.update = function () {
self.y += self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Add background image
var background = LK.getAsset('backgroundImage', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
game.addChild(background);
// Create and display the kill count text
var killCountText = new Text2('Kills: 0', {
size: 100,
fill: "#ffffff"
});
killCountText.anchor.set(0.5, 0);
LK.gui.top.addChild(killCountText);
// Initialize player with speed boost
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
var speedBoostActive = false;
var speedBoostDuration = 5000; // 5 seconds
var speedBoostCooldown = 10000; // 10 seconds
var lastSpeedBoostTime = 0;
// Function to activate speed boost
function activateSpeedBoost() {
if (!speedBoostActive && LK.ticks - lastSpeedBoostTime > speedBoostCooldown) {
speedBoostActive = true;
player.speed *= 2; // Double the player's speed
lastSpeedBoostTime = LK.ticks;
LK.setTimeout(function () {
player.speed /= 2; // Reset the player's speed
speedBoostActive = false;
}, speedBoostDuration);
}
}
// Initialize kill count
var killCount = 0;
// Initialize leaderboard
var leaderboard = new Text2('Leaderboard:\n1. Player1 - 100\n2. Player2 - 80\n3. Player3 - 60', {
size: 80,
fill: "#ffffff"
});
leaderboard.anchor.set(0.5, 0);
LK.gui.topRight.addChild(leaderboard);
// Initialize arrays for zombies and bullets
var zombies = [];
var bullets = [];
// Function to spawn a zombie
function spawnZombie() {
var zombie = new Zombie();
zombie.x = Math.random() * 2048;
zombie.y = -50;
zombies.push(zombie);
game.addChild(zombie);
}
// Function to handle shooting
function shootBullet() {
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
bullets.push(bullet);
game.addChild(bullet);
}
// Game update logic
game.update = function () {
// Update player
player.update();
// Update zombies
for (var i = zombies.length - 1; i >= 0; i--) {
zombies[i].update();
if (zombies[i].y > 2732) {
// Flash screen red for 1 second to indicate game over
LK.effects.flashScreen(0xff0000, 1000);
// Show game over screen
LK.showGameOver();
return; // Exit update loop
}
// Check for collision between player and zombies
if (player.intersects(zombies[i])) {
// Flash screen red for 1 second to indicate player death
LK.effects.flashScreen(0xff0000, 1000);
// Show game over screen
LK.showGameOver();
return; // Exit update loop
}
}
// Update bullets
for (var j = bullets.length - 1; j >= 0; j--) {
bullets[j].update();
if (bullets[j].y < 0) {
bullets[j].destroy();
bullets.splice(j, 1);
}
}
// Check for collisions between bullets and zombies
for (var k = bullets.length - 1; k >= 0; k--) {
for (var l = zombies.length - 1; l >= 0; l--) {
if (bullets[k].intersects(zombies[l])) {
bullets[k].destroy();
zombies[l].destroy();
bullets.splice(k, 1);
zombies.splice(l, 1);
killCount++;
killCountText.setText('Kills: ' + killCount);
break;
}
}
}
// Spawn zombies periodically
if (LK.ticks % 60 === 0) {
spawnZombie();
}
};
// Handle player movement
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
};
// Handle shooting
game.down = function (x, y, obj) {
shootBullet();
activateSpeedBoost();
};
Город зомби апокалипсиса. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Пуля. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Игрок в стиле зомби апокалипсиса. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.