Class: Ashton::ParticleEmitter
- Inherits:
-
Object
- Object
- Ashton::ParticleEmitter
- Defined in:
- lib/ashton/particle_emitter.rb
Constant Summary collapse
- DEFAULT_MAX_PARTICLES =
1000
- DEFAULT_COLOR =
Gosu::Color::WHITE
- RANGED_ATTRIBUTES =
[ :angular_velocity, :center_x, :center_y, :fade, :friction, :interval, :offset, :scale, :speed, :time_to_live, :zoom ]
Instance Method Summary collapse
-
#color ⇒ Object
Gosu::Color.
-
#color=(value) ⇒ Object
[Gosu::Color, Integer, Array<Float>].
- #draw ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(x, y, z, options = {}) ⇒ ParticleEmitter
constructor
A new instance of ParticleEmitter.
- #update(delta) ⇒ Object
Constructor Details
#initialize(x, y, z, options = {}) ⇒ ParticleEmitter
Returns a new instance of ParticleEmitter.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ashton/particle_emitter.rb', line 13 def initialize(x, y, z, = {}) # I'm MUCH too lazy to implement a huge options hash manager in C, especially on a constructor. max_particles = [:max_particles] || DEFAULT_MAX_PARTICLES initialize_ x, y, z, max_particles self.shader = [:shader] self.image = [:image] || $window.pixel self.gravity = [:gravity] || 0.0 self.color = [:color] || DEFAULT_COLOR self.angular_velocity = [:angular_velocity] || 0.0 self.center_x = [:center_x] || 0.5 self.center_y = [:center_y] || 0.5 self.fade = [:fade] || 0.0 self.friction = [:friction] || 0.0 self.interval = [:interval] || Float::INFINITY self.offset = [:offset] || 0.0 self.scale = [:scale] || 1.0 self.speed = [:speed] || 0.0 self.time_to_live = [:time_to_live] || Float::INFINITY self.zoom = [:zoom] || 0.0 end |
Instance Method Details
#color ⇒ Object
Gosu::Color
38 39 40 |
# File 'lib/ashton/particle_emitter.rb', line 38 def color Gosu::Color.new color_argb end |
#color=(value) ⇒ Object
- Gosu::Color, Integer, Array<Float>
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ashton/particle_emitter.rb', line 43 def color=(value) case value when Integer self.color_argb = value when Gosu::Color self.color_argb = value.to_i when Array self.color_argb = Gosu::Color.from_opengl value else raise TypeError, "Expected argb integer, rgba opengl float array or Gosu::Color" end value end |
#draw ⇒ Object
|
# File 'lib/ashton/particle_emitter.rb', line 82
|
#empty? ⇒ Boolean
3 |
# File 'lib/ashton/particle_emitter.rb', line 3 def empty?; count == 0 end |
#update(delta) ⇒ Object
|
# File 'lib/ashton/particle_emitter.rb', line 84
|