1a83062c 2026-05-17 Pavel Safronov | 1 | # Herd ๐ |
| 2 | |
| 3 | A browser game about herding sheep. Tap the field to move your border collie and guide the flock into the pen before time runs out. |
| 4 | |
5a542e96 2026-10-27 Pavel Safronov | 5 | **[Play it โ](https://apps.fuzzyworld.net/herd/)** |
1a83062c 2026-05-17 Pavel Safronov | 6 | |
| 7 | --- |
| 8 | |
| 9 | ## How to Play |
| 10 | |
| 11 | - **Tap / click** anywhere on the field to send the dog to that spot. |
| 12 | - The dog scares nearby sheep โ use this to push the flock toward the pen. |
| 13 | - Get enough sheep inside the pen to win the level. |
| 14 | - If the timer runs out before the flock is penned, you lose. |
| 15 | |
| 16 | Sheep flock together naturally, so a little pressure in the right direction goes a long way. Chasing them head-on scatters the herd โ work from the sides and behind. |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ## Tech Stack |
| 21 | |
| 22 | | Tool | Role | |
| 23 | | --- | --- | |
| 24 | | TypeScript | Language | |
| 25 | | Vite | Dev server & bundler | |
| 26 | | HTML5 Canvas | Rendering | |
| 27 | | npm | Package management | |
| 28 | | GitLab Pages | Hosting | |
| 29 | |
| 30 | No game engine โ physics, flocking AI, and rendering are all hand-rolled. |
| 31 | |
| 32 | --- |
| 33 | |
| 34 | ## Development |
| 35 | |
| 36 | ### Prerequisites |
| 37 | |
| 38 | - Node.js 20+ |
| 39 | - npm 10+ |
| 40 | |
| 41 | ### Setup |
| 42 | |
| 43 | ```bash |
5a542e96 2026-10-27 Pavel Safronov | 44 | git clone https://code.fuzzyworld.net/herd.git |
1a83062c 2026-05-17 Pavel Safronov | 45 | cd herd |
| 46 | npm install |
| 47 | ``` |
| 48 | |
| 49 | ### Run locally |
| 50 | |
| 51 | ```bash |
| 52 | npm run dev |
| 53 | ``` |
| 54 | |
| 55 | Opens at `http://localhost:5173`. |
| 56 | |
| 57 | ### Build |
| 58 | |
| 59 | ```bash |
| 60 | npm run build # outputs to dist/ |
| 61 | npm run preview # serve the production build locally |
| 62 | ``` |
| 63 | |
| 64 | --- |
| 65 | |
| 66 | ## Deployment |
| 67 | |
| 68 | Pushes to `main` automatically deploy to GitLab Pages via `.gitlab-ci.yml`. The live URL is `https://<namespace>.gitlab.io/herd`. |
| 69 | |
| 70 | --- |
| 71 | |
| 72 | ## Project Structure |
| 73 | |
| 74 | ```text |
| 75 | src/ |
| 76 | โโโ main.ts # entry point |
| 77 | โโโ math/Vec2.ts # immutable 2D vector math |
| 78 | โโโ game/ # loop, canvas setup, game state machine |
| 79 | โโโ entities/ # Sheep, Dog, Pen |
| 80 | โโโ ai/Boids.ts # flocking forces (separation, alignment, cohesion, flee) |
| 81 | โโโ input/ # pointer event โ world coordinate mapping |
| 82 | โโโ levels/ # level configs (sheep count, pen size, time limit) |
| 83 | ``` |
| 84 | |
| 85 | The sheep use a [boids](https://www.red3d.com/cwr/boids/) flocking algorithm extended with a flee force triggered by the dog's proximity. |
| 86 | |
| 87 | --- |
| 88 | |
| 89 | ## Credits |
| 90 | |
| 91 | Grass / field icon (favicon + logo) by [Icongeek26](https://www.flaticon.com/authors/icongeek26) from the [Flaticon outline collection](https://www.flaticon.com/authors/icongeek26/outline?author_id=296&type=standard). |
| 92 | |
| 93 | --- |
| 94 | |
| 95 | ## License |
| 96 | |
| 97 | MIT |