Class: ExplosionParticle
- Inherits:
-
Chingu::GameObject
- Object
- Chingu::GameObject
- ExplosionParticle
- Includes:
- GamespacePersistence
- Defined in:
- lib/prkwars/explosionparticle.rb
Overview
Class used for holding behaviour of particles during explosions of various entitites.
Instance Method Summary collapse
-
#initialize(gamespace, options = {}) ⇒ ExplosionParticle
constructor
A new instance of ExplosionParticle.
- #update ⇒ Object
Methods included from GamespacePersistence
Constructor Details
#initialize(gamespace, options = {}) ⇒ ExplosionParticle
Returns a new instance of ExplosionParticle.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/prkwars/explosionparticle.rb', line 12 def initialize(gamespace, = {}) super() @gamespace = gamespace @fade_rate = -3 @mode = :default @image = Image['media/myparticle.png'] @velocity_x = rand(-7..7) @velocity_y = rand(-7..7) @angle = Math.atan2(@velocity_x, @velocity_y) / Math::PI * 180 + 90 end |
Instance Method Details
#update ⇒ Object
24 25 26 27 |
# File 'lib/prkwars/explosionparticle.rb', line 24 def update velocity_correct! unless bounding_box.collide_rect?(@gamespace.bounding_box) destroy! if color.alpha.zero? end |