rboids icon indicating copy to clipboard operation
rboids copied to clipboard

For a few boids more - boids in Rust (Part 2)

Open utterances-bot opened this issue 5 years ago • 6 comments

For a few boids more - boids in Rust (Part 2)

Let's have some fun with procedural graphics generation. We'll give life to a flock of birds by implementing the classic boids algorithm in Rust.

https://blog.bitsacm.in/for-a-few-boids-more/

utterances-bot avatar Jun 14 '20 14:06 utterances-bot

It would be good to utilize some rust functions rather than plain loops, like find.

pickfire avatar Jun 14 '20 14:06 pickfire

Thanks for pointing it out. I cannot change the blog without breaking stuff, but I've made an improvement to the latest version in d589d5f.

twitu avatar Jun 21 '20 17:06 twitu

Nice, that looks better. By the way, you could close this issue.

pickfire avatar Jun 22 '20 12:06 pickfire

Actually this issue acts like the comment section for the post, so it shouldn't be closed.

twitu avatar Jun 22 '20 16:06 twitu

I've been following along and copy-pasting code.. I think after the add_objects_to_scene, I've no idea where what goes where and when.

Also, I'd love it if the code snippets where without scrolling and wide enough to show the entirety of the code?

Great post by the way.

CGMossa avatar Jul 06 '20 15:07 CGMossa

This might be confusing because of closely related names. Objects are meshes (with geometries) that are rendered on screen, while obstacles are "things" that are given to the physics engine to detect collisions. Both have the same shape so that the physics engine's calculations are consistent with what is happening on screen. The add_objects_to_scene registers objects in the game window, and create_obstacles simply creates obstacle and returns a reference to them. You should call both inside the main function, anywhere before the render scene loop.

All changes after that i.e. the ray casting stuff happens in the boid.rs file. Don't fret too much over this though, just download the version of the code tagged as stage_5 and continue from there. Seeing the code written together, rather than in bits and pieces will make it much easier to understand.

Sorry about having to side scroll the code snippets. I'll see if there's a way to make the font smaller but don't bank on it.

twitu avatar Jul 06 '20 15:07 twitu