blob: dad82f6c84d638539ccebaeae7eb30cb3e88c3a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
FF::Scn::BoidCalculations.add(FF::Sys.new('Seperation', priority: 50) do
FF::Cmp::Boids.each do |boid_update|
newvec = [0,0]
FF::Cmp::Boids.each do |boid_check|
next if boid_check == boid_update
if Math.sqrt(((-boid_check.x + boid_update.x)**2) + ((-boid_check.y + boid_update.y)**2)).abs < 200
puts 'repelling'
newvec[0] -= boid_check.x - boid_update.x
newvec[1] -= boid_check.y - boid_update.y
end
end
boid_update.cx += newvec[0] / 100.0
boid_update.cy += newvec[1] / 100.0
end
puts 'end of frame'
end)
|