Sha256: fbca8fae80d8f4b1bf9541bf4ad7a08831fce458eec8e78ec3047618ed84c565

Contents?: true

Size: 800 Bytes

Versions: 5

Compression:

Stored size: 800 Bytes

Contents

define_actor :collidable_debugger do
  has_behaviors :collider_container
end

define_behavior :collider_container do
  setup do
    raise "collider required" unless actor.do_or_do_not(:collider)
    actor.collider.when :remove do
      actor.remove
    end
  end
end

define_actor_view :collidable_debugger_view do

  setup do
    @color = actor.do_or_do_not(:color) || Color::WHITE
  end

  draw do |target,x_off,y_off,z|
    collider = actor.collider
    if collider.shape_type == :circle
      target.draw_circle x_off+collider.center_x, y_off+collider.center_y, collider.radius, @color, z
    else
      collider.cw_world_lines.each do |line|
        f = line.first
        l = line.last
        target.draw_line x_off+f[0],y_off+f[1],x_off+l[0],y_off+l[1], @color, z
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gamebox-0.5.5 lib/gamebox/actors/collidable_debugger.rb
gamebox-0.5.4 lib/gamebox/actors/collidable_debugger.rb
gamebox-0.5.2 lib/gamebox/actors/collidable_debugger.rb
gamebox-0.5.1 lib/gamebox/actors/collidable_debugger.rb
gamebox-0.5.0 lib/gamebox/actors/collidable_debugger.rb