diff options
| author | realtradam <[email protected]> | 2021-12-17 01:29:19 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2021-12-17 01:29:19 -0500 |
| commit | c85f6533efb50981ef8cf59e840a1f8b58b4deef (patch) | |
| tree | 99dd36898baa41b9832072fbab72ce50539cd7c9 /app/systems/rules/bounds.rb | |
| parent | 8c918c1fadebfb076cafcb347b8aac0e8ac28882 (diff) | |
| download | SteelWings-c85f6533efb50981ef8cf59e840a1f8b58b4deef.tar.gz SteelWings-c85f6533efb50981ef8cf59e840a1f8b58b4deef.zip | |
added boid bounds rule
Diffstat (limited to 'app/systems/rules/bounds.rb')
| -rw-r--r-- | app/systems/rules/bounds.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/systems/rules/bounds.rb b/app/systems/rules/bounds.rb new file mode 100644 index 0000000..602f19c --- /dev/null +++ b/app/systems/rules/bounds.rb @@ -0,0 +1,20 @@ +FF::Scn::BoidRules.add( + FF::Sys.new('BoidBounds') do + FF::Cmp::BoidBounds.each do |boid_bounds| + boid = boid_bounds.entities[0].components[FF::Cmp::Boid][0] + + if boid.x > boid_bounds.xmax + boid.cx -= boid_bounds.strength + elsif boid.x < boid_bounds.xmin + boid.cx += boid_bounds.strength + end + + if boid.y > boid_bounds.ymax + boid.cy -= boid_bounds.strength + elsif boid.y < boid_bounds.ymin + boid.cy += boid_bounds.strength + end + end + end +) + |
