Module: SpaceInvaders::Collideable
Instance Method Summary collapse
Instance Method Details
#collides_with?(bullets) ⇒ Boolean
3 4 5 6 7 8 9 10 11 |
# File 'lib/space_invaders/behaviors/collideable.rb', line 3 def collides_with?(bullets) bullets.each do |bullet| if got_hit_by? bullet bullet.delete return true end end return false end |
#got_hit_by?(bullet) ⇒ Boolean
13 14 15 16 |
# File 'lib/space_invaders/behaviors/collideable.rb', line 13 def got_hit_by?(bullet) bullet.x_position.between?(x_position, x_position + width) and bullet.y_position.between?(y_position, y_position + height) end |