Class: Bullet
- Inherits:
-
GameObject
- Object
- GameObject
- Bullet
- Defined in:
- lib/entities/bullet.rb
Instance Attribute Summary collapse
-
#fired_at ⇒ Object
Returns the value of attribute fired_at.
-
#source ⇒ Object
Returns the value of attribute source.
-
#speed ⇒ Object
Returns the value of attribute speed.
-
#target_x ⇒ Object
Returns the value of attribute target_x.
-
#target_y ⇒ Object
Returns the value of attribute target_y.
Attributes inherited from GameObject
#components, #location, #x, #y
Instance Method Summary collapse
- #box ⇒ Object
- #explode ⇒ Object
- #fire(source, speed) ⇒ Object
-
#initialize(object_pool, source_x, source_y, target_x, target_y) ⇒ Bullet
constructor
A new instance of Bullet.
Methods inherited from GameObject
#collide, #draw, #effect?, #mark_for_removal, #move, #on_collision, #removable?, #update
Constructor Details
#initialize(object_pool, source_x, source_y, target_x, target_y) ⇒ Bullet
Returns a new instance of Bullet.
4 5 6 7 8 9 10 |
# File 'lib/entities/bullet.rb', line 4 def initialize(object_pool, source_x, source_y, target_x, target_y) super(object_pool, source_x, source_y) @target_x, @target_y = target_x, target_y BulletPhysics.new(self, object_pool) BulletGraphics.new(self) BulletSounds.play(self, object_pool.camera) end |
Instance Attribute Details
#fired_at ⇒ Object
Returns the value of attribute fired_at.
2 3 4 |
# File 'lib/entities/bullet.rb', line 2 def fired_at @fired_at end |
#source ⇒ Object
Returns the value of attribute source.
2 3 4 |
# File 'lib/entities/bullet.rb', line 2 def source @source end |
#speed ⇒ Object
Returns the value of attribute speed.
2 3 4 |
# File 'lib/entities/bullet.rb', line 2 def speed @speed end |
#target_x ⇒ Object
Returns the value of attribute target_x.
2 3 4 |
# File 'lib/entities/bullet.rb', line 2 def target_x @target_x end |
#target_y ⇒ Object
Returns the value of attribute target_y.
2 3 4 |
# File 'lib/entities/bullet.rb', line 2 def target_y @target_y end |
Instance Method Details
#box ⇒ Object
12 13 14 |
# File 'lib/entities/bullet.rb', line 12 def box [@x, @y] end |
#explode ⇒ Object
16 17 18 19 |
# File 'lib/entities/bullet.rb', line 16 def explode Explosion.new(object_pool, @x, @y, @source) mark_for_removal end |
#fire(source, speed) ⇒ Object
21 22 23 24 25 |
# File 'lib/entities/bullet.rb', line 21 def fire(source, speed) @source = source @speed = speed @fired_at = Gosu.milliseconds end |