From 8c918c1fadebfb076cafcb347b8aac0e8ac28882 Mon Sep 17 00:00:00 2001 From: realtradam Date: Fri, 17 Dec 2021 00:46:33 -0500 Subject: Added Boid and Sprite component and systems --- app/components/boid.rb | 4 ++++ app/main.rb | 2 ++ app/systems/update_boid_sprite.rb | 9 +++++++++ app/tick.rb | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 app/components/boid.rb create mode 100644 app/systems/update_boid_sprite.rb 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 -- cgit v1.2.3