Class: ExplosionParticle

Inherits:
Chingu::GameObject
  • Object
show all
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

Methods included from GamespacePersistence

#correct_coords, #in_bounds

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, options = {})
  super(options)

  @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

#updateObject



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