User prompt
Let zombies return wherever we go
User prompt
Let's move the gun to wherever our mouse cursor is.
User prompt
Let the gun turn to wherever we shoot
User prompt
Tank zombies 30 bullets, normal zombies 5 bullets, fast zombies die in 5 bullets
User prompt
we have just rifle adn we can shoot
User prompt
more big
User prompt
make more bigger zombies
User prompt
Let's have guns and be able to shoot
Code edit (1 edits merged)
Please save this source code
User prompt
Mall Escape: Zombie Survival
User prompt
We are trying to escape from zombies, we are in a mall, zombies are dropping weapons and bullets with a low probability and we have a knife, they are trying to take items such as armor, helmets, bags from the stores, so that health-replenishing and speed-giving items can be found in the stores.
Initial prompt
Please continue polishing my design document.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bullet = Container.expand(function (startX, startY, targetX, targetY, damage) {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.damage = damage;
self.speed = 8;
// Calculate direction
var dx = targetX - startX;
var dy = targetY - startY;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
self.dirX = dx / distance;
self.dirY = dy / distance;
} else {
self.dirX = 1;
self.dirY = 0;
}
// Set rotation to match direction
bulletGraphics.rotation = Math.atan2(dy, dx);
self.update = function () {
self.x += self.dirX * self.speed;
self.y += self.dirY * self.speed;
};
return self;
});
var Item = Container.expand(function (itemType) {
var self = Container.call(this);
var itemGraphics = self.attachAsset(itemType, {
anchorX: 0.5,
anchorY: 0.5
});
self.type = itemType;
self.collected = false;
self.collect = function () {
if (self.collected) return false;
var success = false;
switch (self.type) {
case 'helmet':
case 'armor':
case 'backpack':
player.equipArmor(self.type);
success = true;
break;
case 'healthPack':
player.heal(50);
success = true;
break;
case 'food':
player.heal(25);
success = true;
break;
case 'energyDrink':
player.speed = player.baseSpeed + 1;
// Speed boost timer
LK.setTimeout(function () {
player.speed = player.baseSpeed;
}, 10000);
success = true;
break;
case 'rifle':
player.equipWeapon(self.type);
success = true;
break;
case 'ammo':
// For now, just give points
LK.setScore(LK.getScore() + 5);
success = true;
break;
}
if (success) {
self.collected = true;
LK.getSound('pickup').play();
return true;
}
return false;
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Player stats
self.maxHealth = 100;
self.health = self.maxHealth;
self.speed = 3;
self.baseSpeed = 3;
self.weapon = 'knife';
self.weaponDamage = 25;
self.attackCooldown = 0;
self.shootCooldown = 0;
self.isRangedWeapon = false;
self.armor = 0;
self.inventorySize = 3;
self.inventory = [];
// Equipment visuals
self.weaponSprite = null;
self.helmetSprite = null;
self.armorSprite = null;
self.backpackSprite = null;
self.equipWeapon = function (weaponType) {
if (self.weaponSprite) {
self.removeChild(self.weaponSprite);
}
self.weapon = weaponType;
self.weaponSprite = self.attachAsset(weaponType, {
anchorX: 0.5,
anchorY: 0.5,
x: 35,
y: 0
});
switch (weaponType) {
case 'rifle':
self.weaponDamage = 60;
self.isRangedWeapon = true;
break;
}
};
self.equipArmor = function (armorType) {
if (armorType === 'helmet' && !self.helmetSprite) {
self.helmetSprite = self.attachAsset('helmet', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -35
});
self.armor += 20;
} else if (armorType === 'armor' && !self.armorSprite) {
self.armorSprite = self.attachAsset('armor', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 10
});
self.armor += 30;
} else if (armorType === 'backpack' && !self.backpackSprite) {
self.backpackSprite = self.attachAsset('backpack', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 40
});
self.inventorySize += 3;
}
};
self.takeDamage = function (damage) {
var actualDamage = Math.max(1, damage - self.armor);
self.health -= actualDamage;
LK.effects.flashObject(self, 0xff0000, 200);
if (self.health <= 0) {
LK.showGameOver();
}
};
self.heal = function (amount) {
self.health = Math.min(self.maxHealth, self.health + amount);
};
self.update = function () {
if (self.attackCooldown > 0) {
self.attackCooldown--;
}
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
};
// Start with rifle
self.equipWeapon('rifle');
return self;
});
var Store = Container.expand(function (storeType) {
var self = Container.call(this);
var storeGraphics = self.attachAsset('store', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = storeType;
self.items = [];
self.looted = false;
// Generate items based on store type
var itemTypes = [];
switch (storeType) {
case 'armor':
itemTypes = ['helmet', 'armor'];
break;
case 'sporting':
itemTypes = ['backpack', 'energyDrink'];
break;
case 'food':
itemTypes = ['food', 'healthPack'];
break;
case 'electronics':
itemTypes = ['ammo', 'energyDrink'];
break;
}
// Create 2-3 items per store
var numItems = 2 + Math.floor(Math.random() * 2);
for (var i = 0; i < numItems; i++) {
var itemType = itemTypes[Math.floor(Math.random() * itemTypes.length)];
var item = new Item(itemType);
item.x = self.x + (Math.random() - 0.5) * 80;
item.y = self.y + (Math.random() - 0.5) * 60;
self.items.push(item);
game.addChild(item);
}
return self;
});
var Zombie = Container.expand(function (type) {
var self = Container.call(this);
var zombieType = type || 'zombie';
var zombieGraphics = self.attachAsset(zombieType, {
anchorX: 0.5,
anchorY: 0.5
});
// Zombie stats based on type
switch (zombieType) {
case 'zombie':
self.health = 300; // 5 bullets (60 damage per bullet)
self.speed = 1;
self.damage = 15;
self.points = 10;
break;
case 'fastZombie':
self.health = 300; // 5 bullets (60 damage per bullet)
self.speed = 2.5;
self.damage = 12;
self.points = 15;
break;
case 'tankZombie':
self.health = 1800; // 30 bullets (60 damage per bullet)
self.speed = 0.7;
self.damage = 25;
self.points = 25;
break;
}
self.maxHealth = self.health;
self.type = zombieType;
self.attackCooldown = 0;
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xff0000, 150);
if (self.health <= 0) {
return true; // Dead
}
return false;
};
self.update = function () {
if (self.attackCooldown > 0) {
self.attackCooldown--;
}
// Move towards player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Attack player if close enough - adjusted for much bigger zombies
var attackRange = zombieType === 'tankZombie' ? 110 : zombieType === 'zombie' ? 90 : 80;
if (distance < attackRange && self.attackCooldown <= 0) {
player.takeDamage(self.damage);
self.attackCooldown = 60; // 1 second at 60fps
LK.getSound('hit').play();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c2c2c
});
/****
* Game Code
****/
// Sounds
// Mall elements
// Items
// Zombies
// Player and weapons
// Game variables
var player;
var zombies = [];
var bullets = [];
var items = [];
var stores = [];
var walls = [];
var zombieSpawnTimer = 0;
var zombieSpawnRate = 180; // 3 seconds at 60fps
var difficultyTimer = 0;
var gameTime = 0;
// UI Elements
var healthText = new Text2('Health: 100', {
size: 40,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthText);
healthText.x = 120; // Avoid menu icon
var scoreText = new Text2('Score: 0', {
size: 40,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var weaponText = new Text2('Weapon: Knife', {
size: 35,
fill: 0xFFFF00
});
weaponText.anchor.set(1, 0);
LK.gui.topRight.addChild(weaponText);
// Create player
player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
// Create mall layout
function createMallLayout() {
// Create walls around the perimeter
for (var x = 0; x < 2048; x += 100) {
var topWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
}));
topWall.x = x + 50;
topWall.y = 50;
walls.push(topWall);
var bottomWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
}));
bottomWall.x = x + 50;
bottomWall.y = 2682;
walls.push(bottomWall);
}
for (var y = 100; y < 2632; y += 100) {
var leftWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
}));
leftWall.x = 50;
leftWall.y = y + 50;
walls.push(leftWall);
var rightWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
}));
rightWall.x = 1998;
rightWall.y = y + 50;
walls.push(rightWall);
}
// Create stores
var storeTypes = ['armor', 'sporting', 'food', 'electronics'];
var storePositions = [{
x: 300,
y: 400
}, {
x: 700,
y: 400
}, {
x: 1100,
y: 400
}, {
x: 1500,
y: 400
}, {
x: 300,
y: 800
}, {
x: 700,
y: 800
}, {
x: 1100,
y: 800
}, {
x: 1500,
y: 800
}, {
x: 300,
y: 1200
}, {
x: 700,
y: 1200
}, {
x: 1100,
y: 1200
}, {
x: 1500,
y: 1200
}];
for (var i = 0; i < storePositions.length; i++) {
var storeType = storeTypes[i % storeTypes.length];
var store = game.addChild(new Store(storeType));
store.x = storePositions[i].x;
store.y = storePositions[i].y;
stores.push(store);
}
}
function spawnZombie() {
var zombieTypes = ['zombie', 'zombie', 'zombie', 'fastZombie', 'tankZombie'];
var zombieType = zombieTypes[Math.floor(Math.random() * zombieTypes.length)];
// Make tank zombies rarer early on
if (zombieType === 'tankZombie' && gameTime < 1800) {
zombieType = 'zombie';
}
var zombie = game.addChild(new Zombie(zombieType));
// Spawn at random edge
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// Top
zombie.x = Math.random() * 1948 + 100;
zombie.y = 150;
break;
case 1:
// Right
zombie.x = 1898;
zombie.y = Math.random() * 2432 + 150;
break;
case 2:
// Bottom
zombie.x = Math.random() * 1948 + 100;
zombie.y = 2582;
break;
case 3:
// Left
zombie.x = 150;
zombie.y = Math.random() * 2432 + 150;
break;
}
zombies.push(zombie);
}
function checkCollisions() {
// Player vs items
for (var i = items.length - 1; i >= 0; i--) {
var item = items[i];
if (player.intersects(item) && item.collect()) {
item.destroy();
items.splice(i, 1);
}
}
// Player vs store items
for (var s = 0; s < stores.length; s++) {
var store = stores[s];
for (var i = store.items.length - 1; i >= 0; i--) {
var item = store.items[i];
if (player.intersects(item) && item.collect()) {
item.destroy();
store.items.splice(i, 1);
}
}
}
// Bullet vs zombie collisions
for (var b = bullets.length - 1; b >= 0; b--) {
var bullet = bullets[b];
var bulletHit = false;
// Check if bullet is out of bounds
if (bullet.x < 0 || bullet.x > 2048 || bullet.y < 0 || bullet.y > 2732) {
bullet.destroy();
bullets.splice(b, 1);
continue;
}
// Check bullet vs zombies
for (var z = zombies.length - 1; z >= 0; z--) {
var zombie = zombies[z];
if (bullet.intersects(zombie)) {
if (zombie.takeDamage(bullet.damage)) {
// Zombie died
LK.setScore(LK.getScore() + zombie.points);
LK.getSound('zombieHit').play();
// Random drop chance
if (Math.random() < 0.12) {
var dropTypes = ['rifle', 'ammo', 'healthPack'];
var dropType = dropTypes[Math.floor(Math.random() * dropTypes.length)];
var drop = new Item(dropType);
drop.x = zombie.x;
drop.y = zombie.y;
items.push(drop);
game.addChild(drop);
}
zombie.destroy();
zombies.splice(z, 1);
}
bullet.destroy();
bullets.splice(b, 1);
bulletHit = true;
break;
}
}
if (bulletHit) continue;
}
// Player melee attacks zombies (only for knife)
if (!player.isRangedWeapon && player.attackCooldown <= 0) {
for (var z = zombies.length - 1; z >= 0; z--) {
var zombie = zombies[z];
var distance = Math.sqrt((player.x - zombie.x) * (player.x - zombie.x) + (player.y - zombie.y) * (player.y - zombie.y));
var meleeRange = zombie.type === 'tankZombie' ? 120 : zombie.type === 'zombie' ? 100 : 90;
if (distance < meleeRange) {
if (zombie.takeDamage(player.weaponDamage)) {
// Zombie died
LK.setScore(LK.getScore() + zombie.points);
LK.getSound('zombieHit').play();
// Random drop chance
if (Math.random() < 0.12) {
var dropTypes = ['rifle', 'ammo', 'healthPack'];
var dropType = dropTypes[Math.floor(Math.random() * dropTypes.length)];
var drop = new Item(dropType);
drop.x = zombie.x;
drop.y = zombie.y;
items.push(drop);
game.addChild(drop);
}
zombie.destroy();
zombies.splice(z, 1);
}
player.attackCooldown = 30; // Half second
break;
}
}
}
}
function updateUI() {
healthText.setText('Health: ' + Math.max(0, Math.floor(player.health)));
scoreText.setText('Score: ' + LK.getScore());
weaponText.setText('Weapon: ' + player.weapon.charAt(0).toUpperCase() + player.weapon.slice(1));
}
// Input handling
var targetX = player.x;
var targetY = player.y;
var isPressed = false;
function tryShoot(x, y) {
if (player.isRangedWeapon && player.shootCooldown <= 0) {
var bullet = new Bullet(player.x, player.y, x, y, player.weaponDamage);
bullet.x = player.x;
bullet.y = player.y;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
// Set cooldown based on weapon type
switch (player.weapon) {
case 'rifle':
player.shootCooldown = 15; // 0.25 seconds
break;
}
}
}
game.down = function (x, y, obj) {
targetX = x;
targetY = y;
isPressed = true;
tryShoot(x, y);
};
game.move = function (x, y, obj) {
targetX = x;
targetY = y;
// Rotate weapon to follow cursor
if (player.weaponSprite) {
var dx = x - player.x;
var dy = y - player.y;
player.weaponSprite.rotation = Math.atan2(dy, dx);
}
if (isPressed) {
tryShoot(x, y);
}
};
game.up = function (x, y, obj) {
isPressed = false;
};
// Initialize mall
createMallLayout();
game.update = function () {
gameTime++;
// Move player towards target
var dx = targetX - player.x;
var dy = targetY - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
player.x += dx / distance * player.speed;
player.y += dy / distance * player.speed;
}
// Keep player in bounds
player.x = Math.max(100, Math.min(1948, player.x));
player.y = Math.max(150, Math.min(2582, player.y));
// Spawn zombies
zombieSpawnTimer++;
if (zombieSpawnTimer >= zombieSpawnRate) {
spawnZombie();
zombieSpawnTimer = 0;
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer >= 1800) {
// Every 30 seconds
zombieSpawnRate = Math.max(60, zombieSpawnRate - 10);
difficultyTimer = 0;
}
// Update game objects
player.update();
for (var z = 0; z < zombies.length; z++) {
zombies[z].update();
}
for (var b = 0; b < bullets.length; b++) {
bullets[b].update();
}
// Check collisions
checkCollisions();
// Update UI
updateUI();
}; ===================================================================
--- original.js
+++ change.js
military knife. In-Game asset. 2d. High contrast. No shadows. miltary knife
bullet. In-Game asset. 2d. High contrast. No shadows
ak 47 . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
soldier without weopen. In-Game asset. 2d. High contrast. No shadows
healty pack middle white plus. In-Game asset. 2d. High contrast. No shadows
bulletproof armor. In-Game asset. 2d. High contrast. No shadows
redbull energy drink. In-Game asset. 2d. High contrast. No shadows
ammo box but gray. In-Game asset. 2d. High contrast. No shadows
sandwich. In-Game asset. 2d. High contrast. No shadows
brown backpack. In-Game asset. 2d. High contrast. No shadows
glock 18. In-Game asset. 2d. High contrast. No shadows
kebab. In-Game asset. 2d. High contrast. No shadows
m249. In-Game asset. 2d. High contrast. No shadows
gray cement. In-Game asset. 2d. High contrast. No shadows
biker helmet. In-Game asset. 2d. High contrast. No shadows
helmet look like soo good bullet proff. In-Game asset. 2d. High contrast. No shadows