User prompt
Develop a 2D top-down zombie survival maze game for PC. 🎮 Core Concept: The player controls a mysterious survivor with a bird’s head, trapped in a dark, maze-like facility filled with zombies. The objective is to eliminate as many zombies as possible and escape the labyrinth alive. Players earn points only by killing zombies — survival time does not increase score. 📌 Key Features: Top-down camera for full map awareness Maze-based level: tight corridors, dead ends, hidden paths Unlimited bullets, but player must manage space and avoid being cornered Zombies spawn continuously and become stronger over time A hidden escape exit allows players to end the game by escaping Skor sadece zombileri öldürdükçe artar (Score increases only by killing zombies) 🕹️ Controls (PC only): Move: W / A / S / D Aim: Mouse Cursor Shoot: Left Mouse Button 🧾 UI and Screens: Main Menu: Start Game, How to Play, Exit How to Play screen: Clear explanation of controls and objectives Game Over screen: Display total zombies killed (score) Minimalist HUD showing Kill Count, Health, and optional Map 🎨 Art Style: Stylized pixel-art or simple cartoon visuals Atmospheric lighting in maze corridors Placeholder sprites acceptable in prototype 🔧 Development Notes: Modular structure for adding enemy types, power-ups, or new maze levels Designed only for PC, with keyboard + mouse control Game ends either on death or successful escape
User prompt
Design a 2D top-down zombie survival maze game for PC only. 🎮 Core Concept: The player controls a mysterious survivor with a bird’s head, trapped in an abandoned labyrinth filled with undead threats. The objective is to navigate the maze, eliminate zombies, and ultimately escape through a hidden exit. There is no ammo limit — survival depends on reflexes, positioning, and map knowledge. 📌 Features: Top-down camera with clear visibility of the maze environment Labyrinth-style map: narrow corridors, blocked paths, multiple routes Waves of zombies increase in difficulty over time The player must find the correct path to escape while surviving constant pressure Escape zone is hidden and may change position in each round (optional) No ammo limit, but limited health — getting surrounded is fatal 🕹️ Controls (PC only): Move: W / A / S / D Shoot: Left Mouse Button Aim: Mouse Cursor 🧾 UI Elements: Main Menu with Start Game, How to Play, Exit "How to Play" screen explaining controls and objective Game Over screen showing time survived and zombies eliminated Clean, minimalist interface, designed for PC experience 🎨 Style: Simple pixel-art or cartoon aesthetic Dark and atmospheric color palette Placeholder assets allowed for initial build 💡 Expansion Potential: Dynamic lighting in the maze Power-ups and keys to unlock shortcut doors Multiple character types (future update) Global leaderboard for fastest escapes / most kills This game should be optimized for PC with keyboard + mouse controls only. Mobile support is not required.
User prompt
Create a 2D top-down zombie survival game with the following features: The main character has a bird’s head and can move freely. The map is designed as a maze (labyrinth) filled with paths, dead ends, and multiple routes. The player must survive as long as possible and optionally escape the maze to win. The character can shoot without ammo limits (infinite bullets). Zombies spawn randomly and chase the player with increasing difficulty. The camera uses a top-down view to show the entire environment from above. UI and Features: Include an English Main Menu with: Start Game, How to Play, Exit Add a "How to Play" screen explaining the controls and the escape objective Game Over screen showing survival time and option to restart Use placeholder sprites for character, zombies, and maze environment Art style: simple cartoon or pixel-art The game should work on both mobile and PC, with on-screen buttons for mobile Make the structure modular and beginner-friendly, allowing future expansion (more enemies, new weapons, timed escape, etc.).
User prompt
Create a 2D top-down zombie survival game with the following features: The main character has a bird’s head and can move freely. The map is designed as a maze (labyrinth) filled with paths, dead ends, and multiple routes. The player must survive as long as possible and optionally escape the maze to win. The character can shoot without ammo limits (infinite bullets). Zombies spawn randomly and chase the player with increasing difficulty. The camera uses a top-down view to show the entire environment from above. UI and Features: Include an English Main Menu with: Start Game, How to Play, Exit Add a "How to Play" screen explaining the controls and the escape objective Game Over screen showing survival time and option to restart Use placeholder sprites for character, zombies, and maze environment Art style: simple cartoon or pixel-art The game should work on both mobile and PC, with on-screen buttons for mobile Make the structure modular and beginner-friendly, allowing future expansion (more enemies, new weapons, timed escape, etc.)
User prompt
Create a 2D side-scrolling zombie survival game where the main character has a bird’s head. The character can move freely and shoot without ammo limits. Include a "How to Play" UI screen that clearly explains the controls and gameplay mechanics.
User prompt
Create a 2D side-scrolling zombie survival game where the character can move freely and shoot without ammo limits. Include a "How to Play" UI screen that clearly explains the controls and gameplay mechanics.
Code edit (1 edits merged)
Please save this source code
User prompt
Zombie Survival Rush
Initial prompt
Create a 2D side-scrolling zombie survival game that works on both mobile devices and PC. The player must survive as long as possible against endless waves of zombies. The game should include a scoring system based on survival time and zombie kills. Features: English user interface Main Menu with: Start Game, How to Play, High Scores, Exit “How to Play” screen explaining controls: PC: Move (A/D), Jump (Space), Shoot (Left Click), Change Weapon (1/2/3) Mobile: On-screen buttons for move, jump, shoot, and switch weapon Increasing difficulty with time (zombies become stronger and faster) Game Over screen showing score and a "Try Again" button Health and weapon pickups Responsive UI that works on both PC and mobile screen sizes Use placeholder sprites for player, zombies, and background Simple, cartoon or pixel-art style Beginner-friendly and modular structure for future expansion
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.damage = 25;
self.directionX = 0;
self.directionY = 0;
self.update = function () {
self.x += self.speed * self.directionX;
self.y += self.speed * self.directionY;
};
return self;
});
var HealthPack = Container.expand(function () {
var self = Container.call(this);
var healthGraphics = self.attachAsset('healthPack', {
anchorX: 0.5,
anchorY: 0.5
});
self.healAmount = 30;
self.update = function () {
// Simple floating animation
self.y += Math.sin(LK.ticks * 0.1) * 0.5;
// Check pickup
if (self.intersects(player)) {
player.heal(self.healAmount);
LK.getSound('pickup').play();
self.collected = true;
}
};
return self;
});
var HowToPlay = Container.expand(function () {
var self = Container.call(this);
// Create background overlay
var background = LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732,
alpha: 0.9
});
self.addChild(background);
// Title
var titleText = new Text2('HOW TO PLAY', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 200;
self.addChild(titleText);
// Controls section
var controlsTitle = new Text2('CONTROLS', {
size: 80,
fill: 0xFFFF00
});
controlsTitle.anchor.set(0.5, 0);
controlsTitle.x = 1024;
controlsTitle.y = 400;
self.addChild(controlsTitle);
// PC controls
var pcText = new Text2('PC CONTROLS:', {
size: 60,
fill: 0x00FF00
});
pcText.anchor.set(0, 0);
pcText.x = 200;
pcText.y = 520;
self.addChild(pcText);
var pcControls = new Text2('• W/A/S/D - Move Up/Left/Down/Right\n• Mouse - Aim direction\n• Left Click - Shoot\n• Navigate the maze to find the exit', {
size: 45,
fill: 0xFFFFFF
});
pcControls.anchor.set(0, 0);
pcControls.x = 200;
pcControls.y = 600;
self.addChild(pcControls);
// Gameplay section
var gameplayTitle = new Text2('GAMEPLAY', {
size: 80,
fill: 0xFFFF00
});
gameplayTitle.anchor.set(0.5, 0);
gameplayTitle.x = 1024;
gameplayTitle.y = 950;
self.addChild(gameplayTitle);
var gameplayText = new Text2('• Navigate through a maze labyrinth\n• Collect health packs (red circles)\n• Collect weapon upgrades (blue boxes)\n• Zombies spawn and chase you\n• Escape through the green exit to win', {
size: 45,
fill: 0xFFFFFF
});
gameplayText.anchor.set(0, 0);
gameplayText.x = 200;
gameplayText.y = 1050;
self.addChild(gameplayText);
// Objectives
var objectiveTitle = new Text2('OBJECTIVES', {
size: 80,
fill: 0xFFFF00
});
objectiveTitle.anchor.set(0.5, 0);
objectiveTitle.x = 1024;
objectiveTitle.y = 1400;
self.addChild(objectiveTitle);
var objectiveText = new Text2('• Find your way through the maze\n• Avoid or kill zombies\n• Reach the green exit to escape\n• Use walls for protection and strategy', {
size: 45,
fill: 0xFFFFFF
});
objectiveText.anchor.set(0, 0);
objectiveText.x = 200;
objectiveText.y = 1500;
self.addChild(objectiveText);
// Close button
var closeButton = LK.getAsset('player', {
width: 200,
height: 100,
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8
});
closeButton.x = 1024;
closeButton.y = 1900;
self.addChild(closeButton);
var closeText = new Text2('TAP TO START', {
size: 60,
fill: 0x000000
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 1024;
closeText.y = 1900;
self.addChild(closeText);
closeButton.down = function () {
self.visible = false;
gameStarted = true;
};
background.down = function () {
self.visible = false;
gameStarted = true;
};
return self;
});
var MazeExit = Container.expand(function () {
var self = Container.call(this);
var exitGraphics = self.attachAsset('exit', {
anchorX: 0,
anchorY: 0
});
self.update = function () {
// Pulsing effect for exit
exitGraphics.alpha = 0.7 + Math.sin(LK.ticks * 0.1) * 0.3;
// Check if player reached exit
if (self.intersects(player)) {
LK.showYouWin();
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Add bird head
var birdHead = self.attachAsset('playerHead', {
anchorX: 0.5,
anchorY: 0.5
});
birdHead.x = 0;
birdHead.y = -8; // Position head above body
// Add bird beak
var birdBeak = self.attachAsset('playerBeak', {
anchorX: 0,
anchorY: 0.5
});
birdBeak.x = 15; // Position to right of head
birdBeak.y = -8; // Same height as head
self.health = 100;
self.maxHealth = 100;
self.speed = 4;
self.weapon = 1;
self.maxWeapon = 3;
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
self.health = 0;
gameOver = true;
}
// Flash red when taking damage
LK.effects.flashObject(self, 0xFF0000, 500);
};
self.heal = function (amount) {
self.health = Math.min(self.maxHealth, self.health + amount);
};
self.upgradeWeapon = function () {
if (self.weapon < self.maxWeapon) {
self.weapon++;
}
};
self.checkWallCollision = function (newX, newY) {
// Check collision with maze walls
for (var i = 0; i < walls.length; i++) {
var wall = walls[i];
if (newX < wall.x + 80 && newX + 40 > wall.x && newY < wall.y + 80 && newY + 40 > wall.y) {
return true;
}
}
return false;
};
self.update = function () {
// No gravity or ground collision in top-down view
};
return self;
});
var Wall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('wall', {
anchorX: 0,
anchorY: 0
});
return self;
});
var WeaponPickup = Container.expand(function () {
var self = Container.call(this);
var weaponGraphics = self.attachAsset('weaponPickup', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Simple floating animation
self.y += Math.sin(LK.ticks * 0.1) * 0.5;
// Check pickup
if (self.intersects(player)) {
player.upgradeWeapon();
LK.getSound('pickup').play();
self.collected = true;
}
};
return self;
});
var Zombie = Container.expand(function () {
var self = Container.call(this);
var zombieGraphics = self.attachAsset('zombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 50;
self.speed = 1.5;
self.damage = 20;
self.lastAttackTime = 0;
self.moveTimer = 0;
self.targetX = 0;
self.targetY = 0;
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xFFFFFF, 200);
if (self.health <= 0) {
return true; // Zombie is dead
}
return false;
};
self.checkWallCollision = function (newX, newY) {
// Check collision with maze walls
for (var i = 0; i < walls.length; i++) {
var wall = walls[i];
if (newX < wall.x + 80 && newX + 35 > wall.x && newY < wall.y + 80 && newY + 35 > wall.y) {
return true;
}
}
return false;
};
self.update = function () {
// Simple AI: move towards player if path is clear
var deltaX = player.x - self.x;
var deltaY = player.y - self.y;
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
if (distance > 0) {
var moveX = deltaX / distance * self.speed;
var moveY = deltaY / distance * self.speed;
var newX = self.x + moveX;
var newY = self.y + moveY;
// Only move if not hitting walls
if (!self.checkWallCollision(newX, self.y)) {
self.x = newX;
}
if (!self.checkWallCollision(self.x, newY)) {
self.y = newY;
}
}
// Check collision with player
if (self.intersects(player)) {
var currentTime = LK.ticks;
if (currentTime - self.lastAttackTime > 60) {
// Attack every second
player.takeDamage(self.damage);
self.lastAttackTime = currentTime;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2d4a2d
});
/****
* Game Code
****/
// Game variables
var player;
var zombies = [];
var bullets = [];
var healthPacks = [];
var weaponPickups = [];
var walls = [];
var mazeExit;
var gameOver = false;
var gameStarted = false;
var score = 0;
var zombieSpawnTimer = 0;
var pickupSpawnTimer = 0;
var howToPlayScreen;
// Movement controls
var moveUp = false;
var moveDown = false;
var moveLeft = false;
var moveRight = false;
var shooting = false;
var shootTimer = 0;
var shootTargetX = 0;
var shootTargetY = 0;
// Create maze layout (simplified maze pattern)
var mazePattern = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
// Build maze walls
for (var row = 0; row < mazePattern.length; row++) {
for (var col = 0; col < mazePattern[row].length; col++) {
var cellX = col * 80;
var cellY = row * 80;
if (mazePattern[row][col] === 1) {
// Wall
var wall = game.addChild(new Wall());
wall.x = cellX;
wall.y = cellY;
walls.push(wall);
} else if (mazePattern[row][col] === 2) {
// Exit
mazeExit = game.addChild(new MazeExit());
mazeExit.x = cellX;
mazeExit.y = cellY;
}
}
}
// Create player
player = game.addChild(new Player());
player.x = 120; // Start position in maze
player.y = 120;
// UI Elements positioned for PC
var scoreText = new Text2('Score: 0', {
size: 50,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
scoreText.x = 20;
scoreText.y = 120;
LK.gui.topLeft.addChild(scoreText);
var healthText = new Text2('Health: 100', {
size: 50,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
healthText.x = 20;
healthText.y = 180;
LK.gui.topLeft.addChild(healthText);
var weaponText = new Text2('Weapon: 1', {
size: 50,
fill: 0x00BFFF
});
weaponText.anchor.set(0, 0);
weaponText.x = 20;
weaponText.y = 240;
LK.gui.topLeft.addChild(weaponText);
var objectiveText = new Text2('Find the Exit!', {
size: 60,
fill: 0x00FF00
});
objectiveText.anchor.set(0.5, 0);
objectiveText.x = 1024;
objectiveText.y = 30;
LK.gui.top.addChild(objectiveText);
var controlHint = new Text2('WASD to move, Mouse to aim & shoot', {
size: 40,
fill: 0xCCCCCC
});
controlHint.anchor.set(1, 0);
controlHint.x = 2028;
controlHint.y = 120;
LK.gui.topRight.addChild(controlHint);
// Keyboard event listeners for PC controls
LK.on('keydown', function (key) {
if (key === 'w' || key === 'W') moveUp = true;
if (key === 's' || key === 'S') moveDown = true;
if (key === 'a' || key === 'A') moveLeft = true;
if (key === 'd' || key === 'D') moveRight = true;
});
LK.on('keyup', function (key) {
if (key === 'w' || key === 'W') moveUp = false;
if (key === 's' || key === 'S') moveDown = false;
if (key === 'a' || key === 'A') moveLeft = false;
if (key === 'd' || key === 'D') moveRight = false;
});
// Create How to Play screen
howToPlayScreen = game.addChild(new HowToPlay());
howToPlayScreen.visible = true;
// Game event handlers for mouse shooting
game.down = function (x, y, obj) {
// Convert screen coordinates to game coordinates
var gamePos = game.toLocal({
x: x,
y: y
});
shootTargetX = gamePos.x;
shootTargetY = gamePos.y;
shooting = true;
};
game.up = function (x, y, obj) {
shooting = false;
};
// Track mouse position for aiming
game.move = function (x, y, obj) {
var gamePos = game.toLocal({
x: x,
y: y
});
shootTargetX = gamePos.x;
shootTargetY = gamePos.y;
};
// Spawn functions
function spawnZombie() {
var zombie = new Zombie();
// Find a random open space in the maze
var spawnAttempts = 0;
do {
zombie.x = Math.random() * 1920 + 80;
zombie.y = Math.random() * 1520 + 80;
spawnAttempts++;
} while (zombie.checkWallCollision(zombie.x, zombie.y) && spawnAttempts < 50);
zombies.push(zombie);
game.addChild(zombie);
}
function spawnHealthPack() {
var healthPack = new HealthPack();
// Find a random open space in the maze
var spawnAttempts = 0;
do {
healthPack.x = Math.random() * 1920 + 80;
healthPack.y = Math.random() * 1520 + 80;
spawnAttempts++;
} while (spawnAttempts < 50 && isPositionBlocked(healthPack.x, healthPack.y));
healthPacks.push(healthPack);
game.addChild(healthPack);
}
function spawnWeaponPickup() {
var weaponPickup = new WeaponPickup();
// Find a random open space in the maze
var spawnAttempts = 0;
do {
weaponPickup.x = Math.random() * 1920 + 80;
weaponPickup.y = Math.random() * 1520 + 80;
spawnAttempts++;
} while (spawnAttempts < 50 && isPositionBlocked(weaponPickup.x, weaponPickup.y));
weaponPickups.push(weaponPickup);
game.addChild(weaponPickup);
}
function isPositionBlocked(x, y) {
// Check if position overlaps with walls
for (var i = 0; i < walls.length; i++) {
var wall = walls[i];
if (x < wall.x + 80 && x + 25 > wall.x && y < wall.y + 80 && y + 25 > wall.y) {
return true;
}
}
return false;
}
function shootBullet() {
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
bullet.damage = 25 * player.weapon; // More damage with better weapons
// Calculate direction toward shoot target
var deltaX = shootTargetX - player.x;
var deltaY = shootTargetY - player.y;
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
if (distance > 0) {
bullet.directionX = deltaX / distance;
bullet.directionY = deltaY / distance;
} else {
bullet.directionX = 1; // Default right
bullet.directionY = 0;
}
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
// Main game update
game.update = function () {
if (!gameStarted) {
return; // Don't start game until player dismisses how to play screen
}
if (gameOver) {
LK.showGameOver();
return;
}
// Update score based on survival time
score += 1;
LK.setScore(score);
// Handle player movement with wall collision
var newX = player.x;
var newY = player.y;
if (moveLeft) {
newX = player.x - player.speed;
}
if (moveRight) {
newX = player.x + player.speed;
}
if (moveUp) {
newY = player.y - player.speed;
}
if (moveDown) {
newY = player.y + player.speed;
}
// Check wall collisions and move if valid
if (!player.checkWallCollision(newX, player.y)) {
player.x = newX;
}
if (!player.checkWallCollision(player.x, newY)) {
player.y = newY;
}
// Handle shooting
if (shooting && LK.ticks - shootTimer > 30 / player.weapon) {
// Faster shooting with better weapons
shootBullet();
shootTimer = LK.ticks;
}
// Spawn zombies
zombieSpawnTimer++;
var spawnRate = Math.max(180, 120); // Spawn every 3-2 seconds
if (zombieSpawnTimer >= spawnRate) {
spawnZombie();
zombieSpawnTimer = 0;
}
// Spawn pickups occasionally
pickupSpawnTimer++;
if (pickupSpawnTimer >= 900) {
// Every 15 seconds
if (Math.random() < 0.7) {
spawnHealthPack();
} else {
spawnWeaponPickup();
}
pickupSpawnTimer = 0;
}
// Update bullets and check collisions
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Check if bullet is off screen or hits walls
if (bullet.x < 0 || bullet.x > 2000 || bullet.y < 0 || bullet.y > 1600) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check wall collision
var bulletHitWall = false;
for (var w = 0; w < walls.length; w++) {
var wall = walls[w];
if (bullet.x < wall.x + 80 && bullet.x + 12 > wall.x && bullet.y < wall.y + 80 && bullet.y + 12 > wall.y) {
bulletHitWall = true;
break;
}
}
if (bulletHitWall) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet-zombie collisions
var hit = false;
for (var j = zombies.length - 1; j >= 0; j--) {
var zombie = zombies[j];
if (bullet.intersects(zombie)) {
if (zombie.takeDamage(bullet.damage)) {
// Zombie died
score += 50;
LK.getSound('zombieHit').play();
zombie.destroy();
zombies.splice(j, 1);
}
bullet.destroy();
bullets.splice(i, 1);
hit = true;
break;
}
}
}
// Update health packs
for (var i = healthPacks.length - 1; i >= 0; i--) {
var healthPack = healthPacks[i];
if (healthPack.collected) {
healthPack.destroy();
healthPacks.splice(i, 1);
}
}
// Update weapon pickups
for (var i = weaponPickups.length - 1; i >= 0; i--) {
var weaponPickup = weaponPickups[i];
if (weaponPickup.collected) {
weaponPickup.destroy();
weaponPickups.splice(i, 1);
}
}
// Update UI
scoreText.setText('Score: ' + score);
healthText.setText('Health: ' + player.health);
weaponText.setText('Weapon: ' + player.weapon);
// Exit reached condition handled by MazeExit class
}; ===================================================================
--- original.js
+++ change.js
@@ -71,25 +71,25 @@
controlsTitle.anchor.set(0.5, 0);
controlsTitle.x = 1024;
controlsTitle.y = 400;
self.addChild(controlsTitle);
- // Mobile controls
- var mobileText = new Text2('MOBILE:', {
+ // PC controls
+ var pcText = new Text2('PC CONTROLS:', {
size: 60,
fill: 0x00FF00
});
- mobileText.anchor.set(0, 0);
- mobileText.x = 200;
- mobileText.y = 520;
- self.addChild(mobileText);
- var mobileControls = new Text2('• Touch direction buttons to move\n• Touch anywhere to shoot toward that direction\n• Move freely in all directions', {
+ pcText.anchor.set(0, 0);
+ pcText.x = 200;
+ pcText.y = 520;
+ self.addChild(pcText);
+ var pcControls = new Text2('• W/A/S/D - Move Up/Left/Down/Right\n• Mouse - Aim direction\n• Left Click - Shoot\n• Navigate the maze to find the exit', {
size: 45,
fill: 0xFFFFFF
});
- mobileControls.anchor.set(0, 0);
- mobileControls.x = 200;
- mobileControls.y = 600;
- self.addChild(mobileControls);
+ pcControls.anchor.set(0, 0);
+ pcControls.x = 200;
+ pcControls.y = 600;
+ self.addChild(pcControls);
// Gameplay section
var gameplayTitle = new Text2('GAMEPLAY', {
size: 80,
fill: 0xFFFF00
@@ -370,112 +370,88 @@
// Create player
player = game.addChild(new Player());
player.x = 120; // Start position in maze
player.y = 120;
-// UI Elements
+// UI Elements positioned for PC
var scoreText = new Text2('Score: 0', {
- size: 60,
+ size: 50,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
-scoreText.x = 150;
-scoreText.y = 50;
+scoreText.x = 20;
+scoreText.y = 120;
LK.gui.topLeft.addChild(scoreText);
var healthText = new Text2('Health: 100', {
- size: 60,
+ size: 50,
fill: 0xFF0000
});
healthText.anchor.set(0, 0);
-healthText.x = 150;
-healthText.y = 120;
+healthText.x = 20;
+healthText.y = 180;
LK.gui.topLeft.addChild(healthText);
-var objectiveText = new Text2('Find the Exit!', {
+var weaponText = new Text2('Weapon: 1', {
size: 50,
+ fill: 0x00BFFF
+});
+weaponText.anchor.set(0, 0);
+weaponText.x = 20;
+weaponText.y = 240;
+LK.gui.topLeft.addChild(weaponText);
+var objectiveText = new Text2('Find the Exit!', {
+ size: 60,
fill: 0x00FF00
});
-objectiveText.anchor.set(1, 0);
-objectiveText.x = 1948;
-objectiveText.y = 50;
-LK.gui.topRight.addChild(objectiveText);
-// Control buttons for mobile
-var upButton = LK.getAsset('player', {
- width: 80,
- height: 80,
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0.4
+objectiveText.anchor.set(0.5, 0);
+objectiveText.x = 1024;
+objectiveText.y = 30;
+LK.gui.top.addChild(objectiveText);
+var controlHint = new Text2('WASD to move, Mouse to aim & shoot', {
+ size: 40,
+ fill: 0xCCCCCC
});
-upButton.x = 150;
-upButton.y = 2500;
-LK.gui.addChild(upButton);
-var downButton = LK.getAsset('player', {
- width: 80,
- height: 80,
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0.4
+controlHint.anchor.set(1, 0);
+controlHint.x = 2028;
+controlHint.y = 120;
+LK.gui.topRight.addChild(controlHint);
+// Keyboard event listeners for PC controls
+LK.on('keydown', function (key) {
+ if (key === 'w' || key === 'W') moveUp = true;
+ if (key === 's' || key === 'S') moveDown = true;
+ if (key === 'a' || key === 'A') moveLeft = true;
+ if (key === 'd' || key === 'D') moveRight = true;
});
-downButton.x = 150;
-downButton.y = 2650;
-LK.gui.addChild(downButton);
-var leftButton = LK.getAsset('player', {
- width: 80,
- height: 80,
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0.4
+LK.on('keyup', function (key) {
+ if (key === 'w' || key === 'W') moveUp = false;
+ if (key === 's' || key === 'S') moveDown = false;
+ if (key === 'a' || key === 'A') moveLeft = false;
+ if (key === 'd' || key === 'D') moveRight = false;
});
-leftButton.x = 75;
-leftButton.y = 2575;
-LK.gui.addChild(leftButton);
-var rightButton = LK.getAsset('player', {
- width: 80,
- height: 80,
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0.4
-});
-rightButton.x = 225;
-rightButton.y = 2575;
-LK.gui.addChild(rightButton);
-// Button event handlers
-upButton.down = function () {
- moveUp = true;
-};
-upButton.up = function () {
- moveUp = false;
-};
-downButton.down = function () {
- moveDown = true;
-};
-downButton.up = function () {
- moveDown = false;
-};
-leftButton.down = function () {
- moveLeft = true;
-};
-leftButton.up = function () {
- moveLeft = false;
-};
-rightButton.down = function () {
- moveRight = true;
-};
-rightButton.up = function () {
- moveRight = false;
-};
// Create How to Play screen
howToPlayScreen = game.addChild(new HowToPlay());
howToPlayScreen.visible = true;
-// Game event handlers
+// Game event handlers for mouse shooting
game.down = function (x, y, obj) {
- // Set shoot target position
- shootTargetX = x;
- shootTargetY = y;
+ // Convert screen coordinates to game coordinates
+ var gamePos = game.toLocal({
+ x: x,
+ y: y
+ });
+ shootTargetX = gamePos.x;
+ shootTargetY = gamePos.y;
shooting = true;
};
game.up = function (x, y, obj) {
shooting = false;
};
+// Track mouse position for aiming
+game.move = function (x, y, obj) {
+ var gamePos = game.toLocal({
+ x: x,
+ y: y
+ });
+ shootTargetX = gamePos.x;
+ shootTargetY = gamePos.y;
+};
// Spawn functions
function spawnZombie() {
var zombie = new Zombie();
// Find a random open space in the maze
@@ -660,6 +636,7 @@
}
// Update UI
scoreText.setText('Score: ' + score);
healthText.setText('Health: ' + player.health);
+ weaponText.setText('Weapon: ' + player.weapon);
// Exit reached condition handled by MazeExit class
};
\ No newline at end of file
Human. In-Game asset. 2d. High contrast. No shadows
Zombie. In-Game asset. 2d. High contrast. No shadows
Health. In-Game asset. 2d. High contrast. No shadows
Weapon. In-Game asset. 2d. High contrast. No shadows
Exit. In-Game asset. 2d. High contrast. No shadows
Maze exit. In-Game asset. 2d. High contrast. No shadows
Bullet. In-Game asset. 2d. High contrast. No shadows
Player Health. In-Game asset. 2d. High contrast. No shadows