Production source: boids.js
JS1K#3 entry on shim: Standard Full-screen (css to fill window with canvas)
JS1K#3 source: boids_shim.js
JS1K#3 debug: Full source shim
Original source: boids-orig.js
File sizes in bytes: sizes.txt
What is JSBoids?
- Space: Add boid
Boids, also known as birds, fly around with free will.
- Enter: Add obstacle
Obstacle is something boids try to avoid running into.
- B+/C-: Ground height, pixels
Boids perch in the ground. If obstacle hits the ground, it gets stuck. That's a good way to clean up obstacles.
- D+/E-: Maximum speed, pixels / 50ms
Maximum speed of boids.
- F+/G-: Minimum distance between boids, pixels
"Private" zone of boids.
- H+/I-: Flockingness, bigger = flock less
Tendency not to flock. The smaller the value, the tighter the flocks.
- J+/K-: Mouse attraction, bigger = attract less
How little mouse attracts the boids. Tiny number, and the cursor is veery interesting.
- L+/M-: Obstacle size, radius in pixels
Size of obstacles on the field. Obstacles also have additional "bad aura" around them, making boids turn away before actually colliding with the obstacle. Bigger the size, bigger the aura.
- N+/O-: Perching time, value x 50ms
Time spent on the ground resting.
- P+/Q-: Boid line-of-sight, pixels
How far boids see. Boids try to flock with other boids, and avoid obstacles they see. Decrease below the minimum distance between boids, and boids stop flocking.
- Boids form flocks based on line-of-sight.
- Boids can form multiple flocks and join other flocks freely. Flocks can be split with obstacles.
- Flocks follow mouse cursor.
- Boids keep distance to peer boids.
- Boids avoid collision with obstacles.
- Boids have adjustable maximum speed.
- Boids rest in the ground, if there's space. After resting, boids jump back to fly.
- Obstacles can have different sizes.
- Mouse & keyboard handler.
- Value viewer.