User prompt
health bar health is not fill full when game is started solve pls
User prompt
health bar improve this
Code edit (1 edits merged)
Please save this source code
User prompt
increase health bar length and change to red
User prompt
change size of health bar to rectangular
User prompt
add health bar to right bottom of game and rectangulra
User prompt
health bar is not working
User prompt
change background to best background
User prompt
scoor is not seen solve pls
User prompt
user is not able to move player up and down
User prompt
zombie is not comming to player and is moving to up and down solve problem
User prompt
change this game to horizontal
User prompt
zombie is not comming to player
Initial prompt
Zombie Shooter
/**** * Classes ****/ // Bullet class 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; }; }); //<Write imports for supported plugins here> // Player class 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.health = 100; self.update = function () { // Update player position based on input }; self.takeDamage = function (amount) { self.health -= amount; if (self.health <= 0) { LK.showGameOver(); } }; }); // Zombie class 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 () { // Move towards player }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize player // Initialize assets used in this game. var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 150; // Initialize health bar var healthBar = LK.getAsset('healthBar', { anchorX: 0.5, anchorY: 0.5 }); healthBar.x = 2048 / 2; healthBar.y = 50; game.addChild(healthBar); // Initialize score var score = 0; var scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Arrays to keep track of bullets and zombies var bullets = []; var zombies = []; // Function to spawn zombies function spawnZombie() { var zombie = new Zombie(); zombie.x = Math.random() * 2048; zombie.y = 0; 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); LK.getSound('shoot').play(); } // Game update loop game.update = function () { // Update player player.update(); // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].update(); if (bullets[i].y < 0) { bullets[i].destroy(); bullets.splice(i, 1); } } // Update zombies for (var j = zombies.length - 1; j >= 0; j--) { zombies[j].update(); if (zombies[j].intersects(player)) { player.takeDamage(10); zombies[j].destroy(); zombies.splice(j, 1); LK.getSound('zombieHit').play(); } } // Check for bullet-zombie collisions for (var k = bullets.length - 1; k >= 0; k--) { for (var l = zombies.length - 1; l >= 0; l--) { if (bullets[k].intersects(zombies[l])) { score += 10; scoreTxt.setText('Score: ' + score); bullets[k].destroy(); zombies[l].destroy(); bullets.splice(k, 1); zombies.splice(l, 1); break; } } } // Spawn zombies periodically if (LK.ticks % 60 === 0) { spawnZombie(); } }; // Event listeners for player controls game.down = function (x, y, obj) { shootBullet(); }; game.move = function (x, y, obj) { player.x = x; player.y = y; };
/****
* Classes
****/
// Bullet class
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;
};
});
//<Write imports for supported plugins here>
// Player class
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.health = 100;
self.update = function () {
// Update player position based on input
};
self.takeDamage = function (amount) {
self.health -= amount;
if (self.health <= 0) {
LK.showGameOver();
}
};
});
// Zombie class
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 () {
// Move towards player
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize player
// Initialize assets used in this game.
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 150;
// Initialize health bar
var healthBar = LK.getAsset('healthBar', {
anchorX: 0.5,
anchorY: 0.5
});
healthBar.x = 2048 / 2;
healthBar.y = 50;
game.addChild(healthBar);
// Initialize score
var score = 0;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Arrays to keep track of bullets and zombies
var bullets = [];
var zombies = [];
// Function to spawn zombies
function spawnZombie() {
var zombie = new Zombie();
zombie.x = Math.random() * 2048;
zombie.y = 0;
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);
LK.getSound('shoot').play();
}
// Game update loop
game.update = function () {
// Update player
player.update();
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].update();
if (bullets[i].y < 0) {
bullets[i].destroy();
bullets.splice(i, 1);
}
}
// Update zombies
for (var j = zombies.length - 1; j >= 0; j--) {
zombies[j].update();
if (zombies[j].intersects(player)) {
player.takeDamage(10);
zombies[j].destroy();
zombies.splice(j, 1);
LK.getSound('zombieHit').play();
}
}
// Check for bullet-zombie collisions
for (var k = bullets.length - 1; k >= 0; k--) {
for (var l = zombies.length - 1; l >= 0; l--) {
if (bullets[k].intersects(zombies[l])) {
score += 10;
scoreTxt.setText('Score: ' + score);
bullets[k].destroy();
zombies[l].destroy();
bullets.splice(k, 1);
zombies.splice(l, 1);
break;
}
}
}
// Spawn zombies periodically
if (LK.ticks % 60 === 0) {
spawnZombie();
}
};
// Event listeners for player controls
game.down = function (x, y, obj) {
shootBullet();
};
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
};
make player like this style
make full legs of this player
bullet. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
more dangorous
make horror
red heart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
rename text to -- Zombie Killed