diff options
| author | realtradam <[email protected]> | 2021-08-09 14:28:43 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2021-08-09 14:28:43 -0400 |
| commit | f80fd9ea0e340db6286feb014e437c9ca0c93dd0 (patch) | |
| tree | 46446d902eb7f523f1542105162e46ea00b032f8 /lib/rules/limit.rb | |
| parent | c1eb3f4c18404d4921adc3d38dfa7438a47f4aa0 (diff) | |
| download | ruboids-f80fd9ea0e340db6286feb014e437c9ca0c93dd0.tar.gz ruboids-f80fd9ea0e340db6286feb014e437c9ca0c93dd0.zip | |
.
Diffstat (limited to 'lib/rules/limit.rb')
| -rw-r--r-- | lib/rules/limit.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/rules/limit.rb b/lib/rules/limit.rb index dba9f96..b2a8f32 100644 --- a/lib/rules/limit.rb +++ b/lib/rules/limit.rb @@ -3,10 +3,16 @@ FF::Sys.new('Limit') do unless $config.limit < 0 FF::Cmp::Boids.each do |boid| + if boid.entities[0].components[FF::Cmp::Piranha].nil? + multi = 1.0 + else + multi = 0.3 + end + absolute_velocity = Math.sqrt((boid.vx**2) + (boid.vy**2)) if absolute_velocity > $config.limit - boid.vx = (boid.vx / absolute_velocity) * $config.limit - boid.vy = (boid.vy / absolute_velocity) * $config.limit + boid.vx = (boid.vx / absolute_velocity) * $config.limit * multi + boid.vy = (boid.vy / absolute_velocity) * $config.limit * multi end end end |
