User prompt
Добавь тоблицу лидеров
User prompt
Добавь буст в виде скорости
User prompt
Зделай так чтобы есле зомби дошлт до низа то игра закончится
User prompt
Добавить смерть персонажа
User prompt
Убрать физику
User prompt
Добавить фон
User prompt
Добивить физику
User prompt
Добавить счёт убийств
Initial prompt
Зомби
/****
* 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 () {
// Player update logic
};
});
// 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 () {
// Zombie update logic
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
// 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) {
zombies[i].destroy();
zombies.splice(i, 1);
}
}
// 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);
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();
}; /****
* 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 () {
// Player update logic
};
});
// 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 () {
// Zombie update logic
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
// 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) {
zombies[i].destroy();
zombies.splice(i, 1);
}
}
// 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);
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();
};
Город зомби апокалипсиса. 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.