diff options
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 |
