summaryrefslogtreecommitdiffhomepage
path: root/lib/rules/bounds.rb
blob: 8524e0274a3a2eef17e08cfabdee4f153c61852c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

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