Commit Graph

122 Commits

Author SHA1 Message Date
86483497e9 Add an install target 2025-11-06 14:18:18 -06:00
3f6a4ae532 Set charset & viewport meta tags 2025-11-06 13:24:11 -06:00
7a5148dc74 Update the README with new web build variant info 2025-11-06 12:19:26 -06:00
8d4b033922 Add the tarball-standalone recipe(s)
Some checks failed
check / stable / fmt (push) Successful in 21s
check / beta / clippy (push) Failing after 54s
check / stable / clippy (push) Failing after 49s
check / semver (push) Failing after 5m25s
check / nightly / doc (push) Successful in 2m22s
check / ubuntu / stable / features (push) Successful in 2m32s
check / ubuntu / 1.79.0 (push) Failing after 26s
I forgot to put this in when I added the phony target. Oops.
2025-11-06 10:46:13 -06:00
0c915b025e HTML-installing targets remove the other one
This is actually a build configuration task, but I don't have a tool to
do that (no `./configure.sh` to run!).

To work around this, I'll just have each of the html-installing targets
install their own and remove the other. That way back-to-back builds
don't accidentally contaminate each other. The WASM and JS files are
identical, so they don't need this treatment.
2025-11-06 10:22:44 -06:00
15a1d5c6de New build variants: "standalone" and "bundle-able"
The `web-standalone` target does what the old `web` target did: Produce
the WASM, JS, and an index.html so the output can be served up directly.

The new `web` target renames the "index.html" to "boids.html" so it can
be used as a submodule/subpage in a larger website build.
2025-11-06 10:20:30 -06:00
e7e5337f22 Place Makefile 'configurables' up top
Variables that a package consumer might want to adjust should be placed
at the top of the file so they are immediately visible. Any constants
shall live below those (just the SRC folder, really).
2025-11-06 09:54:30 -06:00
e65deec5ea Rename the Makefile, add usage note at the top
I had named it makefile_web" in an effort to communicate to the user
that the Make-based build path is only for web builds. It's annoying to
type all that out, though, and it doesn't seem like other projects
follow this convention. I'll just put a usage note at the top. It's not
like the Makefile can be mis-used to make a non-web version. There is no
footgun here.
2025-11-06 09:43:11 -06:00
29d0b644ec Remove fly.toml from repo
Some checks failed
check / stable / fmt (push) Successful in 51s
check / beta / clippy (push) Failing after 1m18s
check / stable / clippy (push) Failing after 1m0s
check / semver (push) Failing after 5m49s
check / nightly / doc (push) Successful in 2m20s
check / ubuntu / stable / features (push) Successful in 2m26s
check / ubuntu / 1.79.0 (push) Failing after 28s
As a general rule, this probably shouldn't be in the main repo. I've
also deleted the Fly app, so it doesn't need to exist anywhere.
2025-11-04 14:03:55 -06:00
57e9779241 Release v0.4.0
Some checks failed
check / stable / fmt (push) Successful in 20s
check / beta / clippy (push) Failing after 47s
check / stable / clippy (push) Failing after 47s
check / semver (push) Failing after 5m39s
check / nightly / doc (push) Successful in 2m21s
check / ubuntu / stable / features (push) Successful in 2m27s
check / ubuntu / 1.79.0 (push) Failing after 31s
New version brings a new webpage, readme, and license file.
v0.4.0
2025-10-30 11:11:22 -05:00
cc47f9271f Add a license file (AGPLv3)
If I'm actually presenting this online (and I am), I should probably
have a real license attached to it. The AGPL seems good to me. I can't
imagine anyone would seriously have conflict concerns for a Boids
implementation.

The webpage now presents this information, as does the Cargo.toml
manifest.
2025-10-30 11:11:04 -05:00
6edfc934d2 Add a README to the project
It's about time I had a proper README for this thing.
2025-10-30 10:34:30 -05:00
18ab509554 Fix: automatic var to use *all* deps, not first
The tarball target depends on all the dependencies, but the automatic
variable `$<` means "the first dependency". It should be "all deps", or
`$^`.
2025-10-30 09:04:56 -05:00
615bf79f30 First draft of page structure, basic styling
I'll revise the text at some point, and the styling is *extremely*
basic, but it's a start.
2025-10-29 16:33:11 -05:00
71c095088c Fix: WASM target needs to depend on Cargo.* files
The binary output depends on the configuration input, so maybe tell
`make` about all of the inputs...
2025-10-29 11:35:55 -05:00
7482130ac2 Don't have Bevy resize to full-screen
Now that I have a custom canvas, Bevy should adopt that as it's render
target rather than further modifying it.
2025-10-28 16:23:17 -05:00
e16c0e2e32 Add and use a custom canvas element on the page
Tell bevy to find the canvas with ID "#boids-canvas" instead of creating
it's own.
2025-10-28 16:12:09 -05:00
eca864ec8e Use vars to hold target & profile in makefile_web
I might sometimes build different profiles, so this gives me somewhere
to change them. It *does not work* for debug builds because of how cargo
works. So that sucks.

I can't think of a reason anyone would seriously want to change the
target, but I've made that a variable, too. WASM64 exists, but I can't
get a read on it's availability across browsers. The benefit seems to be
accessing >4GB of memory, which is not important for this project. Other
targets are for "desktop" platforms and so shouldn't be using the
makefile.
2025-10-28 16:10:28 -05:00
0358935bf6 Group the WASM & JS targets so they're built once
https://www.gnu.org/software/make/manual/html_node/Multiple-Targets.html

The previous recipe told Make that each file could be produced by
running wasm-bindgen. The more correct expression is that *both* files
will be produced at the same time.

Now Make knows to only invoke the command one time to get both files if
either is out of date. Previously, multi-job builds (`-j2`) could build
the files twice -- one invocation for each out-of-date file.
2025-10-28 15:04:45 -05:00
7408f056f6 Fix: use correct name suffix for the WASM file
Maybe I should have spent more time manually running each of the steps.
Eh, whatever. Bug found and fixed.
2025-10-28 15:00:28 -05:00
370fe85d6c Make wasm binary target depend on source files
Now Make will know to rebuild the WASM binary if the source code
changes... because I forgot to do that, too. :v
2025-10-28 14:59:47 -05:00
943483503c Turn output folder into an order-only prerequisite
This makes the output folder "required to exist" and not "required to be
more recent."

The folder's timestamp is updated when files are written into it. The
files inside depend on the folder existing. The result is that the WASM
and JS files are considered very slightly older than the folder that
contains them. The result is that the folder is up-to-date but it's
contents are not, thus re-building them and *again* updating the folder
timestamp. The makefile was stuck constantly rebuilding things that are
actually up-to-date.
2025-10-28 12:46:37 -05:00
3c0cf85da5 Drop extra suffix in wasm-bindgen output name
Oops, it's not supposed to have a file suffix! It's a bit annoying that
it still produces both a WASM and JS file, just not the right ones (and
no _bg.wasm at all). Especially without any warning that it is doing
something different than normal. Oh well.
2025-10-28 12:42:44 -05:00
39925b0c4e Rename WASM & JS output to match HTML
The index.html file calls for a "boids.js", so I need the Makefile to
produce one. I could change it, but that's off-topic for now so I won't.
2025-10-28 12:42:39 -05:00
4eb4fefeb2 Add a Makefile to make web builds more ergonomic
Call with `make -f makefile_web` to produce a web root for serving. Use
target "boids_web_root.tar" to bundle the files into a tarball. For...
publishing... or something.

The `wasm-server-runner` program seems to supply it's own index.html and
is doing *something* regarding MIME types -- hosting a dev build of the
Boids program results in the browser complaining about "" (empty string)
being an invalid MIME type.

I want my own index.html during testing, and I can't figure out why the
MIME type info is wrong. I've decided to automate the web-root build
process and serve it up with whatever webserver I have on hand.
2025-10-28 12:22:26 -05:00
57a4d0924d Fix: Missing destination in Docker copy instr.
Some checks failed
check / stable / fmt (push) Successful in 45s
check / beta / clippy (push) Failing after 51s
check / stable / clippy (push) Failing after 47s
check / semver (push) Failing after 5m38s
check / nightly / doc (push) Successful in 2m12s
check / ubuntu / stable / features (push) Successful in 2m21s
check / ubuntu / 1.79.0 (push) Failing after 27s
I don't really know how I did that, or how I got a build up on Fly.io
without committing the fix. Well, anyway... it's done now.
2025-10-03 13:01:47 -05:00
0c8d39d483 Fix casing in Dockerfile
Some checks failed
check / stable / fmt (push) Successful in 22s
check / beta / clippy (push) Failing after 56s
check / stable / clippy (push) Failing after 48s
check / semver (push) Failing after 5m45s
check / nightly / doc (push) Successful in 2m18s
check / ubuntu / stable / features (push) Successful in 2m25s
check / ubuntu / 1.79.0 (push) Failing after 27s
2025-09-27 10:27:27 -05:00
6009dae6d8 Mark crate version 0.3.0, upadate lockfile 2025-09-27 10:26:02 -05:00
085b855ef7 Disable the minimal-version pins 2025-09-27 10:25:47 -05:00
d808bda765 Use busybox:musl to save a couple more MB
Yay for tiny Linux userspaces.
2025-09-04 09:29:07 -05:00
6b7692cf78 Build using the locked dependency versions
I want to at least have the smell of reproducible builds, so I'll make
the image build using the lockfile. Otherwise the build-time dependency
information gets lost.
2025-09-04 09:29:03 -05:00
0ad31b30df Check-in the fly.toml config file 2025-09-04 09:17:21 -05:00
5e4b7f04b7 Dockerfile for WASM build's webserver 2025-09-04 09:07:31 -05:00
01c50e4bb6 Add an index.html file, taken from Bevy Cheatbook
https://bevy-cheatbook.github.io/platforms/wasm/webpage.html

I need a page to give the user, which loads some JS, which loads the
WASM file. The JS and WASM are both generated by the wasm-bindgen tool.
2025-09-03 17:04:43 -05:00
60417d6956 Make the WASM build profile even smaller 2025-09-03 16:15:48 -05:00
2d568455d8 Use whole browser window
Taken from
https://johanhelsing.studio/posts/extreme-bevy
2025-09-03 16:14:38 -05:00
df86f05876 Mark v0.2.0, update lockfile v0.2.0 2025-09-03 14:46:25 -05:00
68d6de9a83 Add a WASM build configuration
The config.toml lets me run `cargo run --target wasm32-unknown-unknown`
and host a dev server.

I've adjusted the Cargo.toml to use the kdtree_rayon feature by default,
but disable the Rayon feature for WASM builds (because it doesn't work).
2025-09-03 14:41:53 -05:00
ccd8a12b79 Autoformat 2025-09-03 14:27:28 -05:00
f2a71e712a Put the boid separation range back to 1/4 not 1/8
With the 1.0 radius boids (instead of whatever `Circle::default()`
uses), a separation activation of 1/4 the range looks more visually
appealing (imo).
2025-09-03 14:25:16 -05:00
dca8bcdaa7 Add speed_controller to maintain system energy
The starting velocities going outwards in a circle means that the sum of
energy in the system is 0. As the boids come back together, they will
slow down to fall into a lattice. This is interesting, but not the
flocking behavior Boids are supposed to have.

I've replaced the `space_brakes` function with this new speed controller
to keep boids moving between two speeds. Anything too slow will speed up
along it's current vector, and anything too fast will slow down.
2025-09-03 14:20:17 -05:00
e6e56506f8 Fix: alignment should align to vel, not impulse
I need to apply an impulse to match the velocities, but the previous
version was trying to match the forces.
2025-09-03 14:11:18 -05:00
bc0630b4ae Fix: off-by-one error in alignment averaging
The "length" is actually the `enumerate()` index, which is one less than
the item count. The previous version was not using the average, and may
have been deviding by 0 for boids with exactly one neighbor.
2025-09-03 14:09:40 -05:00
76a6b4f999 New cohesion rule function 2025-09-03 14:07:50 -05:00
451311126d New separation rule function 2025-09-03 14:07:34 -05:00
7b380196a5 Filter-map the entities to avoid self-alignment
The boids shouldn't try to align with themselves. That doesn't really
make any sense.
2025-09-03 12:23:53 -05:00
8b61d38636 Make keyboard control forces, not velocities
The keyboard input should apply a force, not modify the velocity. Right
now, there is no Mass component, but in the future there might be. I've
just fixed a broken physics integrator made by bad assumptions, too, so
I'm goig to do this for consistency if nothing else.
2025-09-03 12:23:53 -05:00
b3cf47e684 Remove BoidBundle, use required-components instead 2025-09-03 12:23:53 -05:00
69403bc6ca Fix the physics integrator
The velocity component never got updated. Instead, the system was only
calculating the current frame's deltaV. That instantaneous dV and any
velocity that *did* get assigned (bundle insertion, keyboard control)
would be added to the position.

Now forces are integrated into velocity, and velocity is integrated into
position. You know... like a real integration function.
2025-09-03 12:23:53 -05:00
a6240c844a Make another new alignment system 2025-09-03 12:23:53 -05:00