Skip to content

bigdestiny2/hiveworm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HiveWorm

A perpetual peer-to-peer life-sim. You're a worm in a 2D meadow. Eat dots to grow. Crash into another worm and you die. One move per worm every five seconds.

No backend. No accounts. No servers. Players gossip moves directly over Hyperswarm. The game state is just an append-only log of signed moves; everyone runs the same deterministic world simulation.

pear run pear://d1xbkcpcbi1xa8dexp49rsendra5r67w3qh5a9k8t44oemm4k16y

(Pinned on the HiveRelay network for 24/7 availability — the game is reachable even when no individual player is online.)

What it is

  • Pear app — Bare main process plus a Chromium renderer via pear-electron
  • Multiplayer over Hyperswarm — peers discover each other through the DHT, gossip moves on a drive-derived topic, exchange Ed25519-signed entries
  • Detects PearBrowser Desktop — when running inside PearBrowser v0.3+, uses window.pear.swarm.v1 directly. Outside PearBrowser, it falls back to single-player local mode
  • Saturday-morning-cartoon aesthetic — pastels, sun with a smile, gentle synth pad

Architecture

┌──────────────────────────────────────────┐
│  Chromium renderer (ui/)                 │
│  - canvas2d game loop                    │
│  - signed move entries                   │
│  - identity.js (ed25519 keypair)         │
└──────────────┬───────────────────────────┘
               │ pear-bridge pipe
               │ { kind: 'join'|'leave'|'broadcast'|'send', ... }
               │ { kind: 'peer'|'message'|'peer-leave', ... }
               ▼
┌──────────────────────────────────────────┐
│  Bare main (index.js)                    │
│  - Hyperswarm (lazy)                     │
│  - peer connection multiplexer           │
│  - drive-derived topic                   │
└──────────────────────────────────────────┘

Hyperswarm is lazy-loaded so any native-module surprise crash happens after the window opens — the game stays playable in local mode rather than failing at boot.

What's in the bundle

index.html          page shell, viewport, mount point
index.js            Bare entrypoint — pear-electron runtime + lazy swarm
ui/
  game.js           wires identity + network + world + renderer
  network.js        peer gossip
  identity.js       ed25519 keygen + localStorage + backup/import
  schema.js         canonical signing helpers
  worm.js           client Worm: rendering + interpolation + color
  world.js          tracks worms + food, applies entries, deterministic seeding
  renderer.js       Canvas2D draw routines
  input.js          keyboard + touch + cooldown gate
  audio.js          synthesized SFX over WebAudio
  config.js         biome key + tuning constants
  style.css         saturated 90s-cartoon aesthetic
landing/            static landing page (for direct hyper:// browsing)

No build step. Pure ES modules. The only runtime download is @noble/ed25519.

Running it locally

Inside Pear runtime (multiplayer)

npm i -g pear
pear
pear run pear://d1xbkcpcbi1xa8dexp49rsendra5r67w3qh5a9k8t44oemm4k16y

Open it on two different machines (or two windows on the same machine) and they'll find each other through the DHT.

Single-player (any browser)

cd ui
python3 -m http.server 8080
# open http://localhost:8080

The game detects no window.pear.swarm.v1 and falls back to local-only mode.

Building from source

git clone https://github.com/bigdestiny2/hiveworm
cd hiveworm
npm install
pear run -d .              # dev mode, live-reload

Stage and release your own fork

pear stage default .
pear release default .

Credits

Built on:

License: Apache-2.0

About

HiveWorm — perpetual P2P life-sim. Pear app, peer gossip over Hyperswarm via window.pear.swarm.v1. No backend.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors