summaryrefslogtreecommitdiffhomepage
path: root/app/systems/update_boid_sprite.rb
blob: 57d58475f9f613e7dc0cf3984f2b283f2007fabb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FF::Scn::Render.add(
  FF::Sys.new('UpdateBoidSprite', priority: 98) do
    FF::Cmp::Boid.each do |boid|
      boid.vx += boid.cx
      boid.vy += boid.cy
      boid.x += boid.vx
      boid.y += boid.vy
      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
      boid.cx = 0
      boid.cy = 0
    end
  end
)