Build a mobile first-person zombie survival game in Three.js

This prompt helps you write code and automations faster: "Build a mobile first-person zombie survival game in Three.js". Copy the ready-to-paste prompt, fill in the bracketed details for your situation, and run it in your AI tool for a high-quality first draft you can refine in minutes.

The prompt

# Role
You are a senior WebGL/Three.js game developer who specializes in performant mobile browser games and procedural content generation.

# Before you begin
Ask me for the specifics that matter most, then wait for my answers: (1) [GAME TITLE] and any theme or style notes, (2) [TARGET DEVICES] (for example mid-range Android and recent iPhones) and whether I prefer portrait or landscape, (3) [MYSTERY BOX PRICE and STARTING POINTS] if I have preferences, (4) [HOSTING PLAN] (single HTML file to open locally, or a small project to deploy). If I don't answer, make reasonable assumptions and list them clearly at the top of your reply.

# Task
Build a complete, playable Call of Duty Zombies-style survival game set inside a medium-sized mansion at night. It must be first-person, designed for mobile touch controls, and built entirely with Three.js. No external assets of any kind: no image files, textures, models, fonts, or audio files. Everything (textures, geometry, sounds) must be generated procedurally in code.

# Technical requirements
- Use one specific, stable, well-established Three.js release, pinned by exact version via an import map or versioned CDN URL (or npm if I choose a project setup). State the exact version at the top and add a comment explaining why. Use only APIs that exist in that version. Do not use deprecated or removed APIs, and do not use floating tags like "latest".
- Deliver as a single self-contained index.html unless I ask for a project setup.
- Generate all textures with canvas (wood planks, wallpaper, stone, rugs, parquet floors, paintings, bookshelves, etc.) and all sounds with the Web Audio API (gunshots, footsteps, zombie groans, hammering wood, thunder, rain, box jingle, cash register).
- Optimize for mobile: cap pixel ratio (around 2 max), keep the number of real-time point lights low (use a handful of real lights near the player plus emissive glow sprites for the other candles), limit shadow casters, reuse geometries and materials, pool zombies, bullets, and particles, and keep a stable frame rate. Include a simple quality toggle.

# Game design requirements
1. Perspective and controls (touch only): left-side virtual joystick for movement, right-side drag area for looking, on-screen buttons for fire, reload, interact (buy, repair, open box), and weapon switch. Include a subtle crosshair, haptic feedback via vibration where supported, and prevent page scroll, zoom, and text selection. Add an optional desktop fallback (WASD and mouse) for testing.
2. Mansion: medium-sized with believable layout and connected rooms, for example foyer with grand staircase, dining room, kitchen, library, study, hallway, and a lounge. Add realistic interior detailing built from primitives: baseboards, crown molding, door frames, wall paneling, chandeliers, fireplaces, bookshelves with books, tables, chairs, sofas, rugs, paintings, curtains, and clutter. Use simple collision (AABB or circle-vs-box) so the player and zombies cannot walk through walls and furniture.
3. Barricades: several windows around the mansion, each with a set of wooden planks (for example 5). Zombies gather outside a window, tear off planks one at a time, then climb in. The player holds the interact button near a window to rebuild planks one by one, earning points per plank. Animate planks being removed and replaced, with sound.
4. Mystery boxes: at least one box placed in the mansion that the player can pay points for to receive a random weapon from a defined list (for example pistol, SMG, shotgun, assault rifle, LMG, plus one rare wonder weapon). Include a spinning weapon animation with a short reveal, a time window to accept the weapon, and a chance to be swapped. Build each weapon model procedurally with distinct stats (damage, fire rate, magazine, reserve ammo, reload time, recoil) and a visible first-person viewmodel with fire and reload animations and muzzle flash.
5. Zombies: lifelike humanoid models built procedurally from articulated parts (head, torso, upper and lower limbs, tattered clothing, wounds, glowing eyes), with skeletal-style animation done in code: shambling walk, run, attack, climbing through windows, crawling, hit reactions, and death. Add slight per-zombie variation (size, skin and clothing color, gait). Zombies must path to windows first, then to the player, using a simple waypoint or navigation grid system.
6. Wave system (5 waves to win): wave 1 has a small number of slow walkers. Variety and difficulty increase each wave: add runners, crawlers, armored or heavy brutes, and a boss-type zombie in wave 5. Define the zombie count, health, speed, and damage per wave in a clearly labeled config object at the top of the code. Show a wave intro banner and an end-of-wave break. Survive wave 5 to see a victory screen. Show a game-over screen when the player dies, with a restart button.
7. Economy and HUD: points for hits, kills, and repairs; health with a damage vignette and regeneration after a delay; ammo and reserve count; current wave; points; interaction prompts (for example "Hold to repair" or "Tap to open Mystery Box: [PRICE]").
8. Atmosphere: set at night with a moonlit, bluish ambient scene. Candles with flickering flames and warm light are placed throughout the mansion, and there must be enough light overall that no area is ever pitch black (use a low hemisphere or ambient light as a floor). A thunderstorm rages outside: animated rain, periodic lightning flashes that briefly light the interior through the windows, distant and close thunder timed to the flashes, wind sound, and fog. Add dust motes or light shafts if performance allows.

# Process (think step by step before coding)
First, write a short plan covering: file and code architecture (scene setup, input, mansion builder, lighting, zombie system, weapons, wave manager, HUD, audio), the mansion floor plan with room dimensions, the zombie AI approach, and the mobile performance budget. Then write the code.

# Output format
1. **Assumptions and version**: a bullet list, including the exact Three.js version.
2. **Plan**: concise, as described above.
3. **Code**: the complete, runnable code in a single code block. No pseudo-code, no "add the rest here" placeholders, no TODOs for core features. If the length limit forces a split, stop at a clean section boundary, say "CONTINUE" at the end, and resume exactly where you left off when I reply.
4. **How to run and test**: 3-5 short steps.
5. **Tuning guide**: a list of the config values I can change to adjust difficulty, performance, lighting brightness, and weapon balance.

# Constraints
- Do not use external files, URLs for images, models, or sounds, or any third-party libraries besides Three.js.
- Keep code well organized with clear section comments and named constants.
- Gore should be stylized and moderate (it's a zombie game), with no real-world violence or references.
- If any requirement conflicts with mobile performance, favor a smooth frame rate and tell me what you simplified.
- Be creative: add a few polish touches of your own (for example flickering lights that react to lightning, blood splatter on walls, a dramatic wave transition), but do not remove any required feature.
Share: X LinkedIn

How to use it

  1. 1Open your AI coding assistant of choice (Claude is a strong option for long code generation) and start a new chat. Paste the whole prompt and send it.
  2. 2Answer the AI's opening questions (game title, target phones, box price, hosting plan). If you skip them, it will state its assumptions at the top, which you can correct in a follow-up.
  3. 3Copy the code into a file named index.html. If the AI says CONTINUE because of length limits, reply 'continue' and append the next part exactly where the previous one stopped.
  4. 4Test on your phone: serve the file over a local server or deploy it to a free host like Netlify or Vercel, then open the link on your device. Opening the file directly may block some browser features.
  5. 5Iterate in small steps: report one issue at a time (for example 'zombies get stuck on the stairs' or 'frame rate drops in the library') and ask for only the changed code sections.
  6. 6Use the tuning guide at the end of the response to adjust difficulty, lighting, and weapon balance before recording or sharing your game.

Recommended tools

Related prompts

Frequently asked

What does the "Build a mobile first-person zombie survival game in Three.js" prompt do?

This prompt helps you write code and automations faster: "Build a mobile first-person zombie survival game in Three.js". Copy the ready-to-paste prompt, fill in the bracketed details for your situation, and run it in your AI tool for a high-quality first draft you can refine in minutes.

Which AI tool is this prompt for?

It works in any AI assistant. Paste it into ChatGPT, Claude, Gemini, or your tool of choice and adjust the formatting if needed.

How do I use this prompt?

Copy the prompt, replace any bracketed placeholders with your own details, and paste it into your AI assistant. Then follow the setup steps on this page to refine the output.

Want a prompt tailored to your exact task?

Remix this in the builder →