Sha256: a042612d38024ce6ca8ca7ea0c6e7876e627c3a7552dfc23dbb0623401bbc6d8
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
class Explosion < Actor use InterpolationSystem 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 interpolate_alpha(:init => 255, :end => 0, :duration => @explosion_time - @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) @z = 7 @elapsed_time = 0.0 end def update # Note to self: It's important to call super! super if @elapsed_time > @explosion_time die end @elapsed_time += dt end def collision_radius @collision_radius end def radius=(radius) @collision_radius = radius @factor_x = 2*radius/@image.width @factor_y = 2*radius/@image.height end def to_s ["@elapsed_time #{format('%.2f', @elapsed_time)}", "@color.alpha #{@color.alpha}", "@color.hue #{format('%.2f', @color.hue)}", "@color.saturation #{format('%.2f', @color.saturation)}", "@color.value #{format('%.2f', @color.value)}"] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
missile-command-ruby-0.0.7 | lib/explosion.rb |
missile-command-ruby-0.0.6 | lib/explosion.rb |