diff options
| author | realtradam <[email protected]> | 2021-12-17 00:46:33 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2021-12-17 00:46:33 -0500 |
| commit | 8c918c1fadebfb076cafcb347b8aac0e8ac28882 (patch) | |
| tree | 6a8771451ae2d9509a7931a48162a3138efc6818 | |
| parent | d48fd199777cc17cf89d1e50d59852ad373de5b5 (diff) | |
| download | SteelWings-8c918c1fadebfb076cafcb347b8aac0e8ac28882.tar.gz SteelWings-8c918c1fadebfb076cafcb347b8aac0e8ac28882.zip | |
Added Boid and Sprite component and systems
| -rw-r--r-- | app/components/boid.rb | 4 | ||||
| -rw-r--r-- | app/main.rb | 2 | ||||
| -rw-r--r-- | app/systems/update_boid_sprite.rb | 9 | ||||
| -rw-r--r-- | app/tick.rb | 2 |
4 files changed, 16 insertions, 1 deletions
diff --git a/app/components/boid.rb b/app/components/boid.rb new file mode 100644 index 0000000..99701df --- /dev/null +++ b/app/components/boid.rb @@ -0,0 +1,4 @@ +FF::Cmp.new('Boid', + x: 0, y: 0, + vx: 0, vy: 0, + cx: 0, cy: 0) diff --git a/app/main.rb b/app/main.rb index 8491866..972a496 100644 --- a/app/main.rb +++ b/app/main.rb @@ -3,7 +3,9 @@ require 'app/felflame.rb' require 'app/scenes/scenes.rb' require 'app/components/sprite.rb' +require 'app/components/boid.rb' require 'app/systems/render.rb' +require 'app/systems/update_boid_sprite.rb' require 'app/tick.rb' diff --git a/app/systems/update_boid_sprite.rb b/app/systems/update_boid_sprite.rb new file mode 100644 index 0000000..d600fa6 --- /dev/null +++ b/app/systems/update_boid_sprite.rb @@ -0,0 +1,9 @@ +FF::Scn::Render.add( + FF::Sys.new('UpdateBoidSprite', priority: 98) do + FF::Cmp::Boid.each do |boid| + boid.entities[0].components[FF::Cmp::Sprite][0].props[:x] = boid.x + boid.entities[0].components[FF::Cmp::Sprite][0].props[:y] = boid.y + # based on direction of the vector, needs to update the rotation of sprite too + end + end +) diff --git a/app/tick.rb b/app/tick.rb index 7bb1cf4..a528a22 100644 --- a/app/tick.rb +++ b/app/tick.rb @@ -1,4 +1,4 @@ -FF::Ent.new(FF::Cmp::Sprite.new) +FF::Ent.new(FF::Cmp::Sprite.new, FF::Cmp::Boid.new) def tick args FelFlame::Stage.call end |
