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 () {
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
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
// Initialize kill count
var killCount = 0;
// 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);
}
// 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();
}; ===================================================================
--- original.js
+++ change.js
@@ -99,8 +99,16 @@
if (zombies[i].y > 2732) {
zombies[i].destroy();
zombies.splice(i, 1);
}
+ // 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();
Город зомби апокалипсиса. 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.