Sha256: f7e7c86bc5d499c488f8ccab185bc4cd89f3a4783713c01b801d452d45896e67
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
require_relative 'general_object.rb' class SmallExplosion < GeneralObject attr_reader :x, :y, :living_time TIME_TO_LIVE = 50 def initialize(scale, screen_width, screen_height, x = nil, y = nil, image = nil, options = {}) @scale = scale if options[:third_scale] @scale = @scale / 3 end @smoke_scale = @scale * 1.2 @smoke = Gosu::Image.new("#{MEDIA_DIRECTORY}/smoke.png") @image = image#Gosu::Image.new("#{MEDIA_DIRECTORY}/starfighterv4.png", :tileable => true) @x = x || 0 @y = y || 0 @time_alive = 0 if @image @image_width = @image.width * @scale @image_height = @image.height * @scale @image_size = @image_width * @image_height / 2 @image_radius = (@image_width + @image_height) / 4 else @image_width = @smoke.width * @scale @image_height = @smoke.height * @scale @image_size = @image_width * @image_height / 2 @image_radius = (@image_width + @image_height) / 4 end @current_speed = (SCROLLING_SPEED - 1) * @scale @screen_width = screen_width @screen_height = screen_height @off_screen = screen_height + screen_height @time_to_live = options[:ttl] || TIME_TO_LIVE end def draw spin_down = 0 if @time_alive > 0 spin_down = (@time_alive * @time_alive) / 5 end if spin_down > (@time_alive * 10) spin_down = @time_alive * 10 end @smoke.draw_rot(@x, @y, ZOrder::SmallExplosions, (360 - spin_down), 0.5, 0.5, @smoke_scale, @smoke_scale) @image.draw_rot(@x, @y, ZOrder::SmallExplosions, (360 - spin_down), 0.5, 0.5, @scale, @scale) if @image end def update mouse_x = nil, mouse_y = nil, player = nil # Remove even if hasn't gone offscreen if @time_alive <= @time_to_live @time_alive += 1 @y += @current_speed super(mouse_x, mouse_y) else false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
line-em-up-0.4.0 | line-em-up/models/small_explosion.rb |