DemoCode
Escape The Matrix Game demo

Escape The Matrix is a 3D first-person, Matrix-themed escape room game built with React and Three.js.

You explore five interconnected rooms, find three colored keys to unlock doors, grab a gun from the glass case in the hub, and fight your way past agents in the Exit Hall to reach the way out. There are Easter eggs hidden around, including a floating spoon, red and blue pills, a white rabbit, a phone booth and black cats.

How it works

The game is one large React component, MatrixGame in src/App.jsx, that sets up the Three.js scene, runs the game loop and draws the HUD. Level data such as rooms, walls, doors, keys and agent spawns lives in constants.js, and the pure helpers in logic.js handle room lookup, joystick clamping and collision against walls, closed doors and furniture. Both have unit tests, including consistency checks on the level data.

The agents avoid obstacles as they come for you. Matrix Time is bullet-time: pressing the button slows the simulation to 20% speed for seven seconds, followed by a ten-second cooldown. The time scale eases in and out rather than snapping, and the code-rain textures slow down with it. Sprinting widens the field of view, damage shows a vignette, and hits pulse the crosshair marker.

Sound effects are synthesized with Web Audio rather than loaded from files, and Matrix Time has its own pad and arpeggio. On desktop, losing pointer lock really pauses the game and silences audio. Dynamic resolution scaling steps the render resolution down under sustained load. Overlay screens use a canvas code-rain background, and speech bubbles carry quotes from the characters.

Controls

  • W A S D or the arrow keys: move.
  • Mouse: look around.
  • Click: shoot, once the gun is equipped.
  • Shift: sprint.
  • Space: Matrix Time.
  • Esc: pause. The options menu covers sensitivity, brightness, enemy speed, field of view, invert-Y and sound.
  • On mobile, touch the left side of the screen for a floating joystick, drag elsewhere to look, and use the Fire, Sprint and Matrix Time buttons.

Built with

React 18, Three.js and Vite, with Vitest for tests and ESLint and Prettier for code quality. The source is on GitHub.