summaryrefslogtreecommitdiffhomepage
path: root/lib/rules/seperation.rb
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-08-10 00:24:10 -0400
committerrealtradam <[email protected]>2021-08-10 00:24:10 -0400
commitfef549030394f1662fcef86afa853b5238ec88d2 (patch)
tree3924722a98f585d90dd6f0bf0bdfa452d3560559 /lib/rules/seperation.rb
parentb22858807ffe83a35a956272c401aec17dadb759 (diff)
downloadruboids-fef549030394f1662fcef86afa853b5238ec88d2.tar.gz
ruboids-fef549030394f1662fcef86afa853b5238ec88d2.zip
rubocop autofixes
Diffstat (limited to 'lib/rules/seperation.rb')
-rw-r--r--lib/rules/seperation.rb50
1 files changed, 26 insertions, 24 deletions
diff --git a/lib/rules/seperation.rb b/lib/rules/seperation.rb
index 65493e8..ad5f0fd 100644
--- a/lib/rules/seperation.rb
+++ b/lib/rules/seperation.rb
@@ -1,12 +1,15 @@
+# frozen_string_literal: true
+
FF::Sys.new('Seperation', priority: 50) do
FF::Cmp::Fish[0].entities.each do |ent|
boid_update = ent.components[FF::Cmp::Boids].first
- newvec = [0.0,0.0]
+ 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
+ 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
@@ -14,13 +17,14 @@ FF::Sys.new('Seperation', priority: 50) do
end
FF::Cmp::Piranha[0].entities.each do |ent|
boid_update = ent.components[FF::Cmp::Boids].first
- newvec = [0.0,0.0]
+ newvec = [0.0, 0.0]
FF::Cmp::Piranha[0].entities.each do |ent2|
boid_check = ent2.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
+ 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 / 10)
@@ -28,21 +32,19 @@ FF::Sys.new('Seperation', priority: 50) do
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
+# 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