CodePen | GitHub Pages | Source
This started months ago. I needed something to get my head out of work, and instead of fidgeting aimlessly I decided to code, with zero plan and no aim whatsoever. I built a pig just for fun, liked how it came out, and kept adding animals until I had a herd of 20 species.
The scene went dark and eerie. Then I added sound, though only for a few animals. Making synthesized sound feel organic is really hard, and I wasn’t willing to half-do the rest.
It turned into a cool place that’s nice to just be in. Heavy, quiet dread. Wolf howls and crows from the dark. Sometimes the herd spooks and turns toward the sound, the nearest animals first, the rest following in a wave. Sometimes a bird takes off. Sometimes a whole pond of ducks bursts into the air. Animals roam and graze freely.
I packed a lot into this one:
- 20 species built from primitives in code: rigs, gaits, grazing, blinking, and little catch-steps so idle animals don’t skate. No models or authored animations. About a third of the file is the species classes, which all follow the same pattern, so it’s less code than it looks.
- All audio synthesized live in WebAudio: calls, footsteps, wind and insects. No samples. I built voices for all 20 species and kept the five I could live with; the rest stay silent rather than sound fake.
- The ground is just two triangles, and the shader paints the rest. Grass, dirt and gravel are all noise, and where they meet, each one’s own texture roughens the edge so it doesn’t look like a drawn line. Detail fades out with distance so nothing shimmers, and the shader skips the work once it can’t be seen. Dirt and gravel get a bit of bumpy relief almost for free.
- The lakes are flat ground too. The shader makes them read as water (dark looking straight down, reflecting the sky at low angles), adds a damp shore, and runs two ripple layers across each other so the glints blink on and off instead of sliding. The animals see the same lakes, so ducks go looking for water and everyone else walks around it.
- Patches of moonlight drift across the field. They aren’t objects in the sky, just a tweak to how everything is lit, so they brighten the actual grass, bales and animals as they pass over.
- Shadows are flattened copies of the animals drawn straight onto the ground, cut at the waterline so swimmers only cast from what’s above water. I had so much fun with this one; I hadn’t done shadows quite this way before, and I love how good they look for almost no cost. The catch: it only works because the ground is flat and nothing else receives shadows.
- For collisions, every animal is a pill shape on the ground (small round ones are circles). A grid finds who’s close, and overlaps get pushed apart a few times a frame. A little sideways nudge stops two animals walking head-on from getting stuck nose to nose, and the animal you’re driving can’t clip through small ones even at a sprint.
- Moths and night birds aren’t stored anywhere. The GPU works out where each one is from its spot in the world and the time, so each swarm is a single draw call.
- The world never ends. Bales and scarecrows aren’t stored either; each is worked out from its spot on the map, so it’s still there when you come back. Animals that fall behind get moved ahead of you, but only where the fog is fully opaque, so you never see it happen. It feels like the fields go on forever and hold billions of animals.
- Birds plan the whole flight at take-off: they pick their landing spot, hold it, and work out a path over anything in the way.
- The whole herd draws in a few draw calls, and nothing gets allocated per frame. There’s a HUD with CPU and GPU timings if you like numbers.
Mouse, keyboard and touch are all supported. Everything is documented in the help menu (the question mark, top right).
If you don’t want to wait for the dark to do something, open the sound panel (K, or the sliders icon). It started as my own testing tool and worked so well I kept it: play any voice near or far, mute animals one by one, trigger the owl, crow or wolf, spook the herd, or make a bird take off.
There’s no gameplay as such. The controller is solid, though: you can fly, drive any animal, and orbit the camera around whatever you’re following.
I haven’t figured out what the game is yet. I’ve sketched a dozen or so directions on paper and none of them stuck. If you can see a game hiding in here, I’d genuinely like to hear it. And if you want to take it somewhere yourself, I’d love to see what you come up with.
Hope you enjoy it.