Commit Graph

128 Commits

Author SHA1 Message Date
8fb11fe800 Make cohesion() affect the acceleration 2024-07-10 14:38:41 -05:00
eb6d4b2e32 Further rewrite of cohesion to match separation 2024-07-10 14:35:46 -05:00
95cdd90485 Fix over-application of cohesion forces
The cohesion function was erroneously applying forces to boids that
shouldn't be experiencing them. It shouldn't be iterating over all
boids-with-velocity and adding speed. It should be applying that force
only to the one boid that the loop is examining at that iteration.

I also cleaned up the signature to have just one query struct. I had it
split as two because I was getting issues with mutability. The fix was
to make the query mutable, and then keep the Transforms as immutable
references. This way I can reach through and update the Velocity alone.
2024-07-10 14:03:38 -05:00
a0323af081 Fix: Put the cohesion function back in 2024-07-10 10:59:18 -05:00
13cacb558e Fix: force direction & magnitude for separation
The clumping was because the function was moving the boids together,
not apart. The chaotic movement was the result of the large coefficient
on the force.
2024-07-10 10:53:12 -05:00
368d6c9201 Boids clumping (try for separation function)
I've updated the position integration function to account for
acceleration. I need to change it once more to represent force, instead.
The idea is that the steering functions can all do their thing and apply
a force to the boid. Then, all mobs have their acceleration (forces)
integrated up through velocity and into their new position.

This version produces clumps of fast moving boids. Boids out on their
own will slowly come to a stop. I'm not sure why either of these is the
case.
2024-07-10 10:34:16 -05:00
38c1d779c1 Just use a for loop in the cohesion function
I was trying to work out a way to run the loop using iterators, but
that doesn't really matter. I had an empty loop to consume the results,
which means I just have a for loop anyway.
2024-07-10 08:47:30 -05:00
3293706328 Iterate over all boids instead of only the player
I understand what Daniel was talking about when they referred to the
movement being very rigid.

https://github.com/danieldidiobalsamo/boids/blob/master/src/boids_plugin.rs#L289

Their implementation has a different main loop than mine so that the
acceleration can be delayed by one frame. This way things can choose
their movements without being able to observe the ones that have already
completed theirs for the current frame. I haven't done that, and things
are weird.

I'm going to try to resolve this by moving down into an acceleration
value. Apply a force, integrate at the beginning or end of the frame.
2024-07-09 17:02:14 -05:00
5d41cd57d3 Fix cohesion force vector
Found it! The force was going the wrong way.
2024-07-09 16:42:19 -05:00
4cf591f937 Cohesion function... sorta. Cohesion *no* function
I got the cohesion function to act on the Boids, but there's something
wrong with the math. I already had to dance around the accidental
introduction of NaN's into the system.
2024-07-09 16:37:46 -05:00
3a680a4ea2 Added bevy_spatial for boid interactions
I'm finally starting on the actual Boids flocking algorithm parts.
I don't want to iterate over all the things, and Bevy doesn't seem to
have fast collision testing yet, so I've reached for bevy_spatial to
track my Boids.
2024-07-09 11:56:52 -05:00
ecbfea04be Apply cargo check fixes 2024-07-09 10:43:20 -05:00
84fa15bd77 cargo-fmt 2024-07-08 16:53:02 -05:00
ed33b8e615 New Cargo.toml config & updated lock file
It's just the (Windows portion of the) recommendations the Bevy getting-
started guide contains.
2024-07-08 16:46:37 -05:00
8f52ad3954 Border avoidance system 2024-07-08 16:10:31 -05:00
7224199a94 Delete unused entity spawn, add player color const 2024-07-08 15:18:18 -05:00
20d12bb056 Slightly better signature for keyboard handler 2024-07-08 14:20:54 -05:00
2e5c34da3d Basic player character steering
This is basically useless as an actual feature, but it was helpful to
demonstrate that I'm beginning to understand how to do this stuff.
2024-07-08 14:18:50 -05:00
38a252c59c Add keyboard event handler. "Q" to quit program 2024-07-08 14:00:07 -05:00
188b571be8 Starting the Boids impl. Dot explosion
The Boids entities are spawned and given a velocity that takes them
away from each other. Now to do the actual Bird-oids algorithm so that
they flock.
2024-07-08 13:32:54 -05:00
ce2da247a4 GH Actions have prompts in non-interactive mode 2024-07-05 16:30:59 -05:00
71e27cc3fd Adjust workflow to install ALSA 2024-07-05 16:26:39 -05:00
491014be0a Format all cargo source files. 2024-07-05 16:19:32 -05:00
2349538199 Check-in a check.yml workflow: jonhoo/rust-ci-conf 2024-07-05 16:10:31 -05:00
593f3edd10 Breakout game as plugin 2024-07-05 15:49:47 -05:00
d90e70e084 Extract games into own modules as Bevy Plugins 2024-07-05 15:37:52 -05:00
e636813b48 Breakout game, from Bevy examples
I ignored the use of sound because I don't want to download sound files.
I'm not certain that the `steppings` module is required, but I don't
really know what it does, either.
2024-07-05 14:55:30 -05:00
3b9114d4b2 Followed getting-started guide 2024-07-05 08:45:34 -05:00