diff options
| author | realtradam <[email protected]> | 2021-08-09 09:15:38 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2021-08-09 09:15:38 -0400 |
| commit | 501ec02e894865836f2960b0bbc16b3448e3707f (patch) | |
| tree | ad2c1124e5ab5807dea1b11002cc5bf2df1226d9 /lib/rules/bounds.rb | |
| parent | 4e909c6b44794b76ef3a98c032ea90204b673f85 (diff) | |
| download | ruboids-501ec02e894865836f2960b0bbc16b3448e3707f.tar.gz ruboids-501ec02e894865836f2960b0bbc16b3448e3707f.zip | |
ruboids!
Diffstat (limited to 'lib/rules/bounds.rb')
| -rw-r--r-- | lib/rules/bounds.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/rules/bounds.rb b/lib/rules/bounds.rb new file mode 100644 index 0000000..5045d60 --- /dev/null +++ b/lib/rules/bounds.rb @@ -0,0 +1,15 @@ +FF::Sys.new('Bounds', priority: 50) do + FF::Cmp::Boids.each do |boid| + if boid.x > $config.xmax + boid.cx -= $config.bounds_strength + elsif boid.x < $config.xmin + boid.cx += $config.bounds_strength + end + + if boid.y > $config.ymax + boid.cy -= $config.bounds_strength + elsif boid.y < $config.ymin + boid.cy += $config.bounds_strength + end + end +end |
