Method: Core::Particle#draw

Defined in:
lib/particles.rb

#draw(xoff = 0, yoff = 0) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/particles.rb', line 64

def draw(xoff=0, yoff=0)
  color = @color
  if @age < @fade_in
    a = 125 + ((((@age - @fade_in) * 255) / @lifetime))
    a *= 2
  elsif @age >= @lifetime - @fade_out
    a = ((@lifetime - @age) * 255 / @age).to_i
  else
    a = 255
  end
  if a > 255
    a = 255
  elsif a < 0
    a = 0
  end
  color.alpha = a.to_i;
  @img.draw_rot(@x+xoff, @y+yoff, Core::PARTICLE_Z, @angle, 0.5, 0.5, 1, 1, color, @mode)
end