lib/explosion.rb in missile-command-ruby-0.0.7 vs lib/explosion.rb in missile-command-ruby-0.0.8
- old
+ new
@@ -1,35 +1,35 @@
class Explosion < Actor
- use InterpolationSystem
+ use_systems :interpolation
collides_as :explosion
def initialize(opts={})
super
set_image('explosion.png', opts)
- @initial_radius = 10.0
- @end_radius = 100.0
- @explosion_time = 3.0
- @fade_after = 0.5
+ @initial_radius = opts[:initial_radius] || 10.0
+ @final_radius = opts[:final_radius] || 100.0
+ @duration = opts[:duration] || 3.0
+ @fade_after = opts[:fade_after] || 2.5
- interpolate_alpha(:init => 255, :end => 0, :duration => @explosion_time - @fade_after, :start_in => @fade_after)
+ interpolate_alpha(:init => 255, :end => 0, :duration => @duration - @fade_after, :start_in => @fade_after)
interpolate_saturation(:init => 0.0, :end => 1.0, :duration => 0.1, :loop => true)
# Don't know why gosu changes my hue when only transforming
# saturation so we keep it fixed, or give it a little space for
# change
interpolate_hue(:init => @color.hue-50, :end => @color.hue+50, :loop => true, :duration => 0.5)
self.radius = @initial_radius
# Expand or shrink the explosion
- interpolate(self, :radius, :init => @initial_radius, :end => @end_radius, :duration => @explosion_time)
+ interpolate_my( :radius, :init => @initial_radius, :end => @final_radius, :duration => @duration )
- @z = 7
+ @z = ZOrder::Explosion
@elapsed_time = 0.0
end
def update
# Note to self: It's important to call super!
super
- if @elapsed_time > @explosion_time
+ if @elapsed_time > @duration
die
end
@elapsed_time += dt
end