User prompt
- When you press W: It goes in the +Y direction (up) - When you press S: It goes in the -Y direction (down) - When you press A: It goes in the -X direction (left) - When you press D: It goes in the +X direction (right)
User prompt
- When you press W: It goes in the +Y direction (up) - When you press S: It goes in the -Y direction (down) - When you press A: It goes in the -X direction (left) - When you press D: It goes in the +X direction (right)
User prompt
- When you press W: It goes in the +Y direction (up) - When you press S: It goes in the -Y direction (down) - When you press A: It goes in the -X direction (left) - When you press D: It goes in the +X direction (right)
User prompt
yes it is
User prompt
Now, in the game, after killing 15 normal and 3 fast zombies in the first section, let's move on and the screen will say "section over" and armored vehicles will come and take us to another section.
User prompt
May food give us 20 lives
User prompt
Make the number of normal zombies we need to kill 20
User prompt
zombies should do less damage except tank zombies
User prompt
Increase item drop rate
User prompt
Energy drinks increase our speed by 25 percent and our fire rate by 15 percent
User prompt
Let's say there are 5 levels in the game, we need to kill 30 normal, 5 fast and 1 tank zombies to pass the first level, and after each level is finished, we are rescued by an armored vehicle and taken to the next level.
User prompt
healtpack full our healt
User prompt
Armor gives us 50 extra health and this bar appears white
User prompt
Increase the chance of item drops from zombies
User prompt
make zombies liddle
User prompt
Let's go to where our cursor is looking
User prompt
Follow-up? Bigger.
User prompt
remove stores
User prompt
Change your movement keys to wasd
User prompt
w to go up a to go right s to go back d to go right
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addEventListener')' in or related to this line: 'document.addEventListener('keydown', function (e) {' Line Number: 654
User prompt
Let the control keys be w a s d
User prompt
zombies should be slower
User prompt
Let's have a gun magazine, let's say there are 90 bullets in total, let's say there are 30 bullets in each magazine.
User prompt
Let zombies return wherever we go
/**** * 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(player.maxHealth); success = true; break; case 'food': player.heal(20); success = true; break; case 'energyDrink': player.speed = player.baseSpeed * 1.25; // Speed boost timer LK.setTimeout(function () { player.speed = player.baseSpeed; }, 10000); player.shootCooldown = Math.max(1, player.shootCooldown * 0.85); // Fire rate boost timer LK.setTimeout(function () { player.shootCooldown = Math.max(1, player.shootCooldown / 0.85); }, 10000); success = true; break; case 'rifle': player.equipWeapon(self.type); success = true; break; case 'ammo': totalBullets += 30; // Add one magazine worth of bullets 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 += 50; // Increase armor by 50 } 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 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, scaleX: 0.5, // Reduce width by 50% scaleY: 0.5 // Reduce height by 50% }); // Zombie stats based on type switch (zombieType) { case 'zombie': self.health = 300; // 5 bullets (60 damage per bullet) self.speed = 0.5; self.damage = 10; // Reduced damage self.points = 10; break; case 'fastZombie': self.health = 300; // 5 bullets (60 damage per bullet) self.speed = 1.5; self.damage = 8; // Reduced damage self.points = 15; break; case 'tankZombie': self.health = 1800; // 30 bullets (60 damage per bullet) self.speed = 0.4; 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--; } // Always aggressively pursue player position var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { // Increase pursuit speed based on distance - zombies move faster when player is farther var pursuitMultiplier = Math.min(2, distance / 200); var actualSpeed = self.speed * (1 + pursuitMultiplier); self.x += dx / distance * actualSpeed; self.y += dy / distance * actualSpeed; } // 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 ****/ // Game variables // Player and weapons // Zombies // Items // Mall elements // Sounds var player; var zombies = []; var bullets = []; var items = []; var walls = []; var zombieSpawnTimer = 0; var zombieSpawnRate = 180; // 3 seconds at 60fps var difficultyTimer = 0; var gameTime = 0; // Level progression variables var currentLevel = 1; var maxLevels = 5; var normalZombiesKilled = 0; var fastZombiesKilled = 0; var tankZombiesKilled = 0; var normalZombiesToKill = 20; var fastZombiesToKill = 5; var tankZombiesToKill = 1; // Magazine system var totalBullets = 90; var bulletsPerMagazine = 30; var currentMagazineBullets = bulletsPerMagazine; var isReloading = false; var reloadTimer = 0; var reloadTime = 120; // 2 seconds at 60fps // UI Elements var healthText = new Text2('Health: 100', { size: 40, fill: 0xFFFFFF // Change health text color to white }); 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); var ammoText = new Text2('Ammo: 30/90', { size: 35, fill: 0x00FFFF }); ammoText.anchor.set(1, 0); ammoText.y = 50; LK.gui.topRight.addChild(ammoText); // 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); } } 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); } } // 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.50) { 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); } // Track zombie kills for level progression switch (zombie.type) { case 'zombie': normalZombiesKilled++; break; case 'fastZombie': fastZombiesKilled++; break; case 'tankZombie': tankZombiesKilled++; break; } 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.50) { 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)) + ' + Armor: ' + player.armor); scoreText.setText('Score: ' + LK.getScore()); weaponText.setText('Weapon: ' + player.weapon.charAt(0).toUpperCase() + player.weapon.slice(1)); if (isReloading) { ammoText.setText('Reloading... ' + Math.ceil(reloadTimer / 60) + 's'); } else { ammoText.setText('Ammo: ' + currentMagazineBullets + '/' + totalBullets); } } // Input handling var targetX = player.x; var targetY = player.y; var isPressed = false; var keys = { w: false, a: false, s: false, d: false }; function tryShoot(x, y) { if (player.isRangedWeapon && player.shootCooldown <= 0 && currentMagazineBullets > 0 && !isReloading) { 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(); currentMagazineBullets--; // Set cooldown based on weapon type switch (player.weapon) { case 'rifle': player.shootCooldown = 15; // 0.25 seconds break; } } } function tryReload() { if (isReloading || currentMagazineBullets >= bulletsPerMagazine || totalBullets <= 0) { return; } var bulletsNeeded = bulletsPerMagazine - currentMagazineBullets; var bulletsToReload = Math.min(bulletsNeeded, totalBullets); if (bulletsToReload > 0) { isReloading = true; reloadTimer = reloadTime; } } game.down = function (x, y, obj) { targetX = x; targetY = y; isPressed = true; // Simulate WASD based on touch position relative to player var dx = x - player.x; var dy = y - player.y; var threshold = 50; // Reset all keys first keys.w = false; keys.a = false; keys.s = false; keys.d = false; // Set movement keys based on touch direction if (Math.abs(dx) > threshold || Math.abs(dy) > threshold) { if (Math.abs(dx) > Math.abs(dy)) { // Horizontal movement - X axis controls A/D if (dx > 0) keys.d = true; // D goes right (+X direction) else keys.a = true; // A goes left (-X direction) } else { // Vertical movement - Y axis controls W/S if (dy > 0) keys.s = true; // S goes down (+Y direction) else keys.w = true; // W goes up (+Y direction) } } 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; // Stop all movement when touch is released keys.w = false; keys.a = false; keys.s = false; keys.d = false; }; // Note: LK engine sandbox doesn't support document API // WASD movement will be handled through touch/mouse simulation // Touch controls for mobile compatibility var touchStartX = 0; var touchStartY = 0; var isTouching = false; // Initialize mall createMallLayout(); game.update = function () { gameTime++; // Move player based on WASD keys var moveX = 0; var moveY = 0; if (keys.w) moveY += player.speed; // W goes in +Y direction (down) if (keys.s) moveY -= player.speed; // S goes in -Y direction (up) if (keys.a) moveX -= player.speed; // A goes in -X direction (left) if (keys.d) moveX += player.speed; // D goes in +X direction (right) player.x += moveX; player.y += moveY; // 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; } // Handle reload system if (isReloading) { reloadTimer--; if (reloadTimer <= 0) { var bulletsNeeded = bulletsPerMagazine - currentMagazineBullets; var bulletsToReload = Math.min(bulletsNeeded, totalBullets); currentMagazineBullets += bulletsToReload; totalBullets -= bulletsToReload; isReloading = false; } } else if (currentMagazineBullets <= 0 && totalBullets > 0) { // Auto reload when magazine is empty tryReload(); } // Check level completion if (normalZombiesKilled >= 15 && fastZombiesKilled >= 3) { // Display 'section over' message var sectionOverText = new Text2('Section Over', { size: 100, fill: 0xFFFFFF }); sectionOverText.anchor.set(0.5, 0.5); sectionOverText.x = 1024; sectionOverText.y = 1366; game.addChild(sectionOverText); // Simulate transition to next section LK.setTimeout(function () { sectionOverText.destroy(); // Simulate rescue by armored vehicle player.x = 1024; player.y = 1366; // Reset zombie kill counts for next section normalZombiesKilled = 0; fastZombiesKilled = 0; tankZombiesKilled = 0; }, 2000); } // 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
@@ -551,10 +551,10 @@
if (dx > 0) keys.d = true; // D goes right (+X direction)
else keys.a = true; // A goes left (-X direction)
} else {
// Vertical movement - Y axis controls W/S
- if (dy > 0) keys.w = true; // W goes down (+Y direction)
- else keys.s = true; // S goes up (-Y direction)
+ if (dy > 0) keys.s = true; // S goes down (+Y direction)
+ else keys.w = true; // W goes up (+Y direction)
}
}
tryShoot(x, y);
};
@@ -592,9 +592,9 @@
// Move player based on WASD keys
var moveX = 0;
var moveY = 0;
if (keys.w) moveY += player.speed; // W goes in +Y direction (down)
- if (keys.s) moveY -= player.speed; // S goes in -Y direction (up)
+ if (keys.s) moveY -= player.speed; // S goes in -Y direction (up)
if (keys.a) moveX -= player.speed; // A goes in -X direction (left)
if (keys.d) moveX += player.speed; // D goes in +X direction (right)
player.x += moveX;
player.y += moveY;
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