Sha256: 5e3ca73bf1d83af9bdb602556e3f92f68190c1fae91055c07d244d7cb4568613
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
require 'actor' require 'publisher' require 'actor_view' class CurtainView < ActorView def draw(target,x_off,y_off) target.draw_box_s [0,0],[1024,800], [0,0,0,@actor.height] end end class Curtain < Actor extend Publisher can_fire :curtain_up, :curtain_down has_behavior :updatable, :layered => {:layer => 99_999} attr_accessor :height FULL_CURTAIN = 255 NO_CURTAIN = 0 def setup @duration_in_ms = @opts[:duration] @duration_in_ms ||= 1000 case @opts[:dir] when :up @height = FULL_CURTAIN @dir = -1 when :down @height = NO_CURTAIN @dir = 1 end end # Update curtain height 0-255 (alpha) def update(time) perc_change = time.to_f/@duration_in_ms amount = FULL_CURTAIN * perc_change * @dir @height += amount.floor if @height < 0 @height = 0 if alive? fire :curtain_up remove_self end elsif @height > 255 @height = 255 if alive? fire :curtain_down remove_self end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gamebox-0.1.1 | lib/gamebox/actors/curtain.rb |
gamebox-0.1.0 | lib/gamebox/actors/curtain.rb |
gamebox-0.0.9 | lib/gamebox/actors/curtain.rb |
gamebox-0.0.8 | lib/gamebox/actors/curtain.rb |