blob: 20fd2e60737be028ab8c05865a99963bc30ae77f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
FF::Sys.new('Seperation', priority: 50) do
FF::Cmp::Boids.each do |boid_update|
newvec = [0.0,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 < $config.seperation_distance
newvec[0] -= boid_check.x - boid_update.x
newvec[1] -= boid_check.y - boid_update.y
end
end
boid_update.cx += newvec[0] / $config.seperation
boid_update.cy += newvec[1] / $config.seperation
end
end
=begin
FF::Sys.new('Seperation', priority: 50) do
FF::Cmp::Fish[0].entities.each do |ent_update|
boid_update = ent_update.components[FF::Cmp::Boids].first
newvec = [0.0,0.0]
FF::Cmp::Fish[0].entities.each do |ent_check|
boid_check = ent_update.components[FF::Cmp::Boids].first
next if boid_check == boid_update
if Math.sqrt(((-boid_check.x + boid_update.x)**2) + ((-boid_check.y + boid_update.y)**2)).abs < $config.seperation_distance
newvec[0] -= boid_check.x - boid_update.x
newvec[1] -= boid_check.y - boid_update.y
end
end
boid_update.cx += newvec[0] / $config.seperation
boid_update.cy += newvec[1] / $config.seperation
end
end
=end
|