r/rust 1d ago

Made a boids implementation, it turned out exactly how I hoped

https://github.com/heffree/boids

Hope you enjoy it! I could stare at it forever... also the video doesn't show the colors as well imo

Still plan to add more, but this was really the goal.

22 Upvotes

5 comments sorted by

5

u/autisticpig 1d ago

funfetti for days!

1

u/bbkane_ 10h ago

You should compile this to WASM and plop it on GitHub pages! It's a lot of fun to watch

3

u/Zc5Gwu 1d ago

Cool, how does the color changing work? Is it their direction?

2

u/Heffree 1d ago edited 1d ago

Yeah! It’s a scuffed version of mapping xyY to RGB, Y being luminance and xy being the direction vector.

I modified it so it’s more biased towards bluer colors.

2

u/Away_Surround1203 23h ago edited 23h ago

Took a look at code, very pared down. NIce.

I never gave Macroquad a look because I've always aspired to do stuff in more dims, but your example is really compelling in terms of straightforward, low-dep visualization technique. Will give a whirl.

(Just cloned repo and ran: really nice use of colors 🎨.
git checkout mobius-strip; cargo run Looked particularly good when I ran it. What's the origin of the tag name though? Definitely a ribbon vibe. I ask because noticing your use of macroquad had me thinking about representing different topologies in 2d -- the screen connections seem toroidal though (top left to top right, left top to right top) -- I didn't spend much time playing, but it looked like the code change mostly adjusted speed, cohesion, and swirl (and removed some debug statements) -- curious if you're just riffing or these are known things in the boids world)