diff options
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 |
