Class: SpaceInvaders::BulletCollection
- Inherits:
-
Object
- Object
- SpaceInvaders::BulletCollection
- Extended by:
- Forwardable
- Defined in:
- lib/space_invaders/bullets/bullet_collection.rb
Instance Attribute Summary collapse
-
#bullets ⇒ Object
readonly
Returns the value of attribute bullets.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize ⇒ BulletCollection
constructor
A new instance of BulletCollection.
- #update ⇒ Object
Constructor Details
#initialize ⇒ BulletCollection
Returns a new instance of BulletCollection.
8 9 10 |
# File 'lib/space_invaders/bullets/bullet_collection.rb', line 8 def initialize @bullets = [] end |
Instance Attribute Details
#bullets ⇒ Object (readonly)
Returns the value of attribute bullets.
6 7 8 |
# File 'lib/space_invaders/bullets/bullet_collection.rb', line 6 def bullets @bullets end |
Instance Method Details
#draw ⇒ Object
17 18 19 |
# File 'lib/space_invaders/bullets/bullet_collection.rb', line 17 def draw @bullets.each {|bullet| bullet.draw } end |
#update ⇒ Object
12 13 14 15 |
# File 'lib/space_invaders/bullets/bullet_collection.rb', line 12 def update @bullets.delete_if {|bullet| bullet.out_of_screen} @bullets.each { |bullet| bullet.update } end |