Skip to content

Repository files navigation

Surviva.io

Multiplayer browser game based on Conway's Game of Life. Players are movable cells in a running GoL simulation and must follow survival rules.

Core Mechanics

  • GoL runs permanently in the background (NPC cells spawn/die following classic rules)
  • Players are "living cells with legs" - they can move freely on the grid
  • Every 5 seconds: Tick - GoL rules are applied
  • Players with 2-3 neighbors (players or NPC cells) survive
  • Players with 0-1 or 4+ neighbors die
  • Dead players get a score (moves made) and can rejoin
  • New cells spawn according to GoL rules (3 neighbors) as static NPCs

Gameplay Details

  • Movement: Grid-based, one cell at a time. Hold WASD/arrows for continuous movement. Move cooldown 150ms.
  • Collisions: Only one player per cell allowed. Movement to occupied cells is blocked.
  • Spawning: Random free cell within visible area. Players spawn at start of next generation.
  • Countdown: Prominent visual countdown (5, 4, 3, 2, 1, TICK) before each tick.

Tech Stack

  • Vite + React + TypeScript + SWC
  • Three.js via @react-three/fiber + @react-three/drei
  • Yjs + y-webrtc for P2P state sync
  • Zustand for local state
  • Biome for linting/formatting

Architecture

  • Yjs synchronizes: meta (seed, startedAt), grid (living cells), players (position, color, score)
  • GoL tick based on timestamp (all clients tick synchronously via Math.floor((Date.now() - startedAt) / tickInterval))
  • Grid: sparse Map (only store living cells)
  • Initial grid: procedurally generated from seed when first player joins

Rendering

  • OrthographicCamera, top-down view
  • InstancedMesh for cells (performance)
  • Players as separate meshes with color

MVP Scope

  • 100x100 grid
  • 2-20 players
  • Keyboard movement (WASD/arrows)
  • Visual countdown before each tick
  • Score display
  • Share link for room

About

🦠 Multiplayer survival game in Conway's Game of Life - move your cell, survive the rules, beat your friends

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages