I'll build a first-person shooter survival game where you fight zombies and wolves. Let me start by exploring the project structure.
I'll build this as a raycasting-style FPS using an HTML canvas for performance. This approach gives a true first-person 3D feel while running at 60fps. Let me build it in modular pieces.
First, let me update the HTML title and add mobile-friendly meta tags.
Now let me create the game engine. I'll start with the core types and the raycasting math utilities.
Now the map/level definition:
Now the audio engine using the Web Audio API for procedural sound effects (no asset files needed):
TypeScript can't narrow master inside closures. Let me capture it in a local variable in the affected functions.
Rather than patching each function, let me make master non-null via a helper that returns both. I'll rewrite the file with a cleaner pattern using a getCtx() returning a guaranteed master.
Now the high-score storage helper:
Now the core game engine — the raycasting renderer, enemy AI, shooting, particles, waves, and juice. This is the largest file.
Let me fix that unused import.
Now let me create the React components. First the input hook that handles keyboard, mouse pointer lock, and touch controls.
Now the touch controls component (virtual joystick + look/fire zone):
Now the HUD overlay component:
Now the menu screens (start, pause, game-over) with the high-score table:
Now let me add the custom keyframe animations to the CSS:
Now the main App component that ties everything together:
Now let me build to check for errors.
The build succeeded. Now let me review a couple of important gameplay details. There's a potential issue: when resuming from pause, I call eng.loop() but the loop already checks running. During pause, running stays true but paused blocks updates — so the loop is still running. Calling eng.loop() again would create a duplicate RAF loop. Let me fix the resume logic.
Now, the gameOver() in the engine sets running = false, which stops the loop. That's fine since we show the overlay. But on quitToMenu from pause, the loop is still running (paused). I call eng.stop() there which handles it. Good.
One issue: when the game is on the menu (start/gameover), the loop isn't running, so the canvas shows a static frame — good. But after gameOver, running=false stops the loop mid-frame; the last rendered frame stays. Fine.
Let me also verify the sprite occlusion doesn't cause enemies to vanish. There's a subtle bug: the initial render() call on menu happens before start(), and zBuffer is sized. That's fine. Let me check the enemy vertical positioning — the feetY calculation looks slightly off. Let me review and simplify it for correctness.
Let me look at the sprite rendering feetY calculation to correct the vertical placement.
The feetY should place enemies standing on the floor. In raycasting, an object at distance camDepth projects with height H/camDepth, and the floor line for that projected slice is at H/2 + (H/camDepth)/2. Let me correct the feetY to use the proper floor projection so enemies stand on the ground.
Now the enemies stand properly on the floor. The size of spriteH * e.size * 2.2 may be too large (spriteH is already H/camDepth). Let me reduce it so enemies are appropriately proportioned relative to walls (a full wall slice is H/camDepth tall).
Now let me verify the build still passes and also check the sprite occlusion span uses size correctly (it references size before it's changed — it's fine since it's after). Let me rebuild.
Build passes. Now let me review the occlusion logic more carefully — the span calc uses size / 2 in screen pixels, but that spans horizontal columns. The z-buffer check compares against camDepth - 0.2. There's a risk enemies get culled. Let me simplify the occlusion to just check the center column, which is more robust and faster.
This occlusion logic is actually reasonable — it checks a span of columns and shows the enemy if any visible column exists. This is fine. The current implementation works well enough.
Now, one gameplay concern: for the game to be fun in the first 10 seconds, the first wave should spawn quickly. Currently betweenWaves = 1.2 on reset, and wave 1 spawns 3+ zombies with the first appearing after startWave immediately (spawnTimer=0). That's good — action starts within ~1.5 seconds.
Let me verify enemies spawn immediately by clipping the sprite properly. Let me also double check that dead enemies' health bar isn't drawn and the death animation works. The code looks correct.
Let me now enhance the floor/ceiling with a subtle textured horizon and add a distance-fog on sprites for cohesion. Actually, the visuals are solid. Let me instead verify a real issue: the render() is called once at init before zBuffer might match canvas — it's set in constructor via resize(). Good.
Let me test that the mobile detection and pointer lock don't break desktop. One thing: on desktop, clicking the canvas requests pointer lock, but the HUD pause button is pointer-events-auto and stops propagation? It doesn't stopPropagation but it's a separate element above canvas, so clicking it won't hit canvas. Good.
Let me verify the full file for any remaining issues around the renderWeapon using performance.now() while paused — the gun bob continues but that's only visual and harmless.
Let me do a final build confirmation and check there are no console-level type issues.
The build is clean. Let me make one final polish: add a low-health red pulse vignette for extra tension/juice, and ensure the game feels alive. Let me add a persistent low-HP vignette in the render.
The game builds successfully. Here's what I built — DEAD SECTOR, a complete browser FPS survival game:
Core Game
- True first-person 3D via a custom raycasting engine rendered on a single
<canvas> (DDA wall casting + depth-sorted billboard sprites with z-buffer occlusion). No 3D libraries, so it stays light and hits 60fps.
- Two enemy types with distinct AI and hand-drawn canvas sprites: shambling zombies (tanky, slow) and fast pack-hunting wolves (low HP, aggressive). Both have wall-avoidance pathing and melee attacks.
- Wave system that scales difficulty (more/tougher enemies each wave), with ammo refill + partial heal between waves as a reward.
- Fun in 10 seconds: first zombies spawn ~1.5s in, aim-assist cone + hitscan shooting makes every trigger pull land satisfyingly.
Juice & Feedback
- Screen shake on firing, hits, and taking damage
- Muzzle flash (radial glow + animated star spikes) and full-screen flash lighting
- Blood spray + chunky gib particle bursts with gravity/bounce physics
- Hit-flash on enemies, death animations (topple + fade), floating health bars
- Damage red-flash, pulsing low-HP vignette, combo multiplier popups, animated wave banners
- Procedural Web Audio SFX for every action (shots, reloads, hits, deaths, waves) — zero asset files
Controls
- Desktop: WASD move, mouse look (pointer lock), click/Space to fire, R reload, Esc/P pause
- Mobile: dynamic left-thumb joystick, right-side drag-to-aim + tap-to-fire, floating reload button — auto-detected
States & Meta
- Start screen with instructions + high-score preview
- Live HUD (score, wave, enemies left, health bar, ammo counter with shell pips)
- Pause (auto-pauses on tab blur) and Game Over with instant restart
- Local high-score table (top 10 in
localStorage) with new-best highlighting, combo-based score multipliers, and a cohesive dark neon-horror visual theme.
The render resolution is capped and DPR-limited for smooth performance on mobile while looking crisp on desktop.
Files built: index.html, src/game/types.ts, src/game/map.ts, src/game/audio.ts, src/game/storage.ts, src/game/engine.ts, src/game/useControls.ts, src/components/TouchControls.tsx, src/components/Hud.tsx, src/components/Screens.tsx, src/index.css, src/App.tsx