Sha256: 3f923a337517bb1884e1f7d4db7fb052b48c46079f07874c31f1fbff276e3285

Contents?: true

Size: 408 Bytes

Versions: 8

Compression:

Stored size: 408 Bytes

Contents

define_behavior :projectile do

  requires :director
  requires_behaviors :positioned
  setup do
    actor.has_attributes vel_x: 0,
                         vel_y: 0

    director.when :update do |time, secs|
      actor.x += (actor.vel_x * secs)
      actor.y += (actor.vel_y * secs)
    end

    reacts_with :remove
  end

  helpers do
    def remove
      director.unsubscribe_all self
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gamebox-0.5.5 lib/gamebox/behaviors/projectile.rb
gamebox-0.5.4 lib/gamebox/behaviors/projectile.rb
gamebox-0.5.2 lib/gamebox/behaviors/projectile.rb
gamebox-0.5.1 lib/gamebox/behaviors/projectile.rb
gamebox-0.5.0 lib/gamebox/behaviors/projectile.rb
gamebox-0.4.1 lib/gamebox/behaviors/projectile.rb
gamebox-0.4.0 lib/gamebox/behaviors/projectile.rb
gamebox-0.4.0.rc11 lib/gamebox/behaviors/projectile.rb