summaryrefslogtreecommitdiffhomepage
path: root/app/systems
diff options
context:
space:
mode:
authorarngo <[email protected]>2021-12-17 23:40:59 -0500
committerarngo <[email protected]>2021-12-17 23:40:59 -0500
commita402265fc290cbadf51b3d72925657f1f5cb84e4 (patch)
tree5cc2bda9cecaa1c69ed2edbdbcd03561ea5768fb /app/systems
parent9cb11bdcac69471a3962397b75c3fdbb374d3962 (diff)
downloadSteelWings-a402265fc290cbadf51b3d72925657f1f5cb84e4.tar.gz
SteelWings-a402265fc290cbadf51b3d72925657f1f5cb84e4.zip
center sprite on boid position
Diffstat (limited to 'app/systems')
-rw-r--r--app/systems/debug/debug_render_vector_arrow.rb18
-rw-r--r--app/systems/update_boid_sprite.rb5
2 files changed, 11 insertions, 12 deletions
diff --git a/app/systems/debug/debug_render_vector_arrow.rb b/app/systems/debug/debug_render_vector_arrow.rb
index ce00ef8..ebd7080 100644
--- a/app/systems/debug/debug_render_vector_arrow.rb
+++ b/app/systems/debug/debug_render_vector_arrow.rb
@@ -1,21 +1,19 @@
FF::Sys.new('DebugRenderVectorArrow', priority: 100) do
FF::Cmp::DebugVectorArrow[0].entities.each do |entity|
boid = entity.components[FF::Cmp::Boid][0]
- ox = boid.x + entity.components[FF::Cmp::Sprite][0].props.w / 2
- oy = boid.y + entity.components[FF::Cmp::Sprite][0].props.h / 2
length = FF::Cmp::DebugVectorArrow[0].length
#puts "vx: #{boid.vx}"
#puts "cx: #{boid.cx}"
- vxtip = ox + (boid.vx * length)
- vytip = oy + (boid.vy * length)
+ vxtip = boid.x + (boid.vx * length)
+ vytip = boid.y + (boid.vy * length)
# Velocity
- $gtk.args.outputs.lines << [ox, oy, vxtip, vytip, 0, 255, 255, 255]
- $gtk.args.outputs.lines << [ox+1, oy, vxtip+1, vytip, 0, 255, 255, 255]
- $gtk.args.outputs.lines << [ox-1, oy, vxtip-1, vytip, 0, 255, 255, 255]
- $gtk.args.outputs.lines << [ox, oy+1, vxtip, vytip+1, 0, 255, 255, 255]
- $gtk.args.outputs.lines << [ox, oy-1, vxtip, vytip-1, 0, 255, 255, 255]
- #$gtk.args.outputs.lines << [ox, oy, ox + (boid.cx * length * 10), oy + (boid.cy * length), 0, 255, 0, 255]
+ $gtk.args.outputs.lines << [boid.x, boid.y, vxtip, vytip, 0, 255, 255, 255]
+ $gtk.args.outputs.lines << [boid.x+1, boid.y, vxtip+1, vytip, 0, 255, 255, 255]
+ $gtk.args.outputs.lines << [boid.x-1, boid.y, vxtip-1, vytip, 0, 255, 255, 255]
+ $gtk.args.outputs.lines << [boid.x, boid.y+1, vxtip, vytip+1, 0, 255, 255, 255]
+ $gtk.args.outputs.lines << [boid.x, boid.y-1, vxtip, vytip-1, 0, 255, 255, 255]
+ #$gtk.args.outputs.lines << [boid.x, boid.y, boid.x + (boid.cx * length * 10), boid.y + (boid.cy * length), 0, 255, 0, 255]
# Change in Velocity
$gtk.args.outputs.lines << [vxtip, vytip, vxtip + (boid.cx * length * 10), vytip + (boid.cy * length * 10), 255, 0, 255, 255]
diff --git a/app/systems/update_boid_sprite.rb b/app/systems/update_boid_sprite.rb
index 8afaf56..3a4f25e 100644
--- a/app/systems/update_boid_sprite.rb
+++ b/app/systems/update_boid_sprite.rb
@@ -1,8 +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
+ sprite = boid.entities[0].components[FF::Cmp::Sprite][0]
+ sprite.props[:x] = boid.x - sprite.props[:w] / 2
+ sprite.props[:y] = boid.y - sprite.props[:h] / 2
end
end
)